Started xosForm component
diff --git a/views/ngXosLib/xosHelpers/src/services/label_formatter.service.js b/views/ngXosLib/xosHelpers/src/services/label_formatter.service.js
new file mode 100644
index 0000000..1eb2796
--- /dev/null
+++ b/views/ngXosLib/xosHelpers/src/services/label_formatter.service.js
@@ -0,0 +1,38 @@
+(function() {
+ 'use strict';
+
+ /**
+ * @ngdoc service
+ * @name xos.helpers.LabelFormatter
+ * @description This factory define a set of helper function to format label started from an object property
+ **/
+
+ angular
+ .module('xos.helpers')
+ .factory('LabelFormatter', labelFormatter);
+
+ function labelFormatter() {
+
+ const _formatByUnderscore = string => string.split('_').join(' ').trim();
+
+ const _formatByUppercase = string => string.split(/(?=[A-Z])/).map(w => w.toLowerCase()).join(' ');
+
+ const _capitalize = string => string.slice(0, 1).toUpperCase() + string.slice(1);
+
+ const format = (string) => {
+ string = _formatByUnderscore(string);
+ string = _formatByUppercase(string);
+
+ return _capitalize(string).replace(/\s\s+/g, ' ') + ':';
+ };
+
+ return {
+ // test export
+ _formatByUnderscore: _formatByUnderscore,
+ _formatByUppercase: _formatByUppercase,
+ _capitalize: _capitalize,
+ // export to use
+ format: format
+ };
+ }
+})();
diff --git a/views/ngXosLib/xosHelpers/src/services/log.decorator.js b/views/ngXosLib/xosHelpers/src/services/log.decorator.js
new file mode 100644
index 0000000..382f78e
--- /dev/null
+++ b/views/ngXosLib/xosHelpers/src/services/log.decorator.js
@@ -0,0 +1,40 @@
+// TODO write tests for log
+
+angular.module('xos.helpers')
+.config([ '$provide', function( $provide )
+{
+ // Use the `decorator` solution to substitute or attach behaviors to
+ // original service instance; @see angular-mocks for more examples....
+
+ $provide.decorator( '$log', [ '$delegate', function( $delegate )
+ {
+
+ const isLogEnabled = () => {
+ return window.location.href.indexOf('debug=true') >= 0;
+ }
+ // Save the original $log.debug()
+ let debugFn = $delegate.info;
+
+ // create the replacement function
+ const replacement = (fn) => {
+ return function(){
+ if(!isLogEnabled()){
+ console.log('logging is disabled');
+ return;
+ }
+ let args = [].slice.call(arguments);
+ let now = new Date();
+
+ // Prepend timestamp
+ args[0] = `[${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}] ${args[0]}`;
+
+ // Call the original with the output prepended with formatted timestamp
+ fn.apply(null, args)
+ };
+ };
+
+ $delegate.info = replacement(debugFn);
+
+ return $delegate;
+ }]);
+}]);
\ No newline at end of file