codelation_ui 1.0.1 → 1.0.57

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/codelation_ui/_base_resources/app.js +54 -5
  3. data/app/assets/javascripts/codelation_ui/base.js +1 -0
  4. data/app/assets/javascripts/codelation_ui/extended/checkmark.js +31 -0
  5. data/app/assets/javascripts/codelation_ui/extended/code.js +64 -0
  6. data/app/assets/javascripts/codelation_ui/extended/fail.js +31 -0
  7. data/app/assets/javascripts/codelation_ui/extended/radial_progress_bar.js +267 -0
  8. data/app/assets/javascripts/codelation_ui/extended/slider.js +636 -639
  9. data/app/assets/javascripts/codelation_ui/extended/spinner.js +103 -0
  10. data/app/assets/javascripts/codelation_ui/forms/components/input.js +417 -388
  11. data/app/assets/javascripts/codelation_ui/forms/interfaces/form.js +35 -30
  12. data/app/assets/javascripts/codelation_ui/std.js +3 -1
  13. data/app/assets/javascripts/codelation_ui/std/components/info.js +22 -0
  14. data/app/assets/javascripts/codelation_ui/std/components/transition.js +26 -0
  15. data/app/assets/javascripts/codelation_ui/std/computed_interfaces/mockAPI.js +17 -0
  16. data/app/assets/javascripts/codelation_ui/std/interfaces/array.js +28 -0
  17. data/app/assets/javascripts/codelation_ui/std/interfaces/content_formatters.js +37 -10
  18. data/app/assets/javascripts/codelation_ui/std/interfaces/date.js +8 -0
  19. data/app/assets/javascripts/codelation_ui/std/interfaces/number.js +20 -0
  20. data/app/assets/javascripts/codelation_ui/std/interfaces/rest_api.js +104 -0
  21. data/app/assets/javascripts/codelation_ui/std/interfaces/string.js +29 -0
  22. data/app/assets/javascripts/codelation_ui/vue.js +25 -8
  23. data/app/assets/javascripts/codelation_ui/vue_pages.js +35 -10
  24. data/app/assets/stylesheets/codelation_ui.scss +1 -3
  25. data/app/assets/stylesheets/codelation_ui/_base_resources/_turbolinks.scss +11 -0
  26. data/app/assets/stylesheets/codelation_ui/_base_resources/mixins/button.scss +185 -33
  27. data/app/assets/stylesheets/codelation_ui/base.scss +3 -0
  28. data/app/assets/stylesheets/codelation_ui/colors.scss +2 -0
  29. data/app/assets/stylesheets/codelation_ui/extended/checkmark.scss +53 -0
  30. data/app/assets/stylesheets/codelation_ui/extended/code.scss +153 -0
  31. data/app/assets/stylesheets/codelation_ui/extended/fail.scss +50 -0
  32. data/app/assets/stylesheets/codelation_ui/extended/radial_progress_bar.scss +70 -0
  33. data/app/assets/stylesheets/codelation_ui/extended/slider.scss +2 -2
  34. data/app/assets/stylesheets/codelation_ui/extended/spinner.scss +100 -0
  35. data/app/assets/stylesheets/codelation_ui/std.scss +1 -1
  36. data/app/assets/stylesheets/codelation_ui/std/info.scss +51 -0
  37. data/app/assets/stylesheets/codelation_ui/vue_transitions.scss +94 -0
  38. data/app/helpers/action_view/helpers/url_helper.rb +22 -0
  39. data/lib/generators/ui/component/USAGE +22 -0
  40. data/lib/generators/ui/component/component_generator.rb +41 -0
  41. data/lib/generators/ui/component/templates/javascript.js.erb +20 -0
  42. data/lib/generators/ui/component/templates/page_javascript.js.erb +20 -0
  43. data/lib/generators/ui/component/templates/page_stylesheet.scss.erb +3 -0
  44. data/lib/generators/ui/component/templates/stylesheet.scss.erb +3 -0
  45. data/lib/generators/ui/component/templates/template.html.erb +5 -0
  46. data/lib/generators/ui/mixin/USAGE +8 -0
  47. data/lib/generators/ui/mixin/mixin_generator.rb +11 -0
  48. data/lib/generators/ui/mixin/templates/javascript.js.erb +8 -0
  49. data/lib/generators/ui/pages/USAGE +23 -0
  50. data/lib/generators/ui/pages/pages_generator.rb +48 -0
  51. data/lib/generators/ui/pages/templates/controller.rb +2 -0
  52. data/lib/generators/ui/pages/templates/javascript.js.erb +22 -0
  53. data/lib/generators/ui/pages/templates/stylesheet.scss.erb +3 -0
  54. data/lib/generators/ui/pages/templates/template.html.erb +3 -0
  55. data/vendor/assets/javascripts/highlight.pack.js +2 -0
  56. data/vendor/assets/javascripts/pluralize.js +1 -0
  57. data/vendor/assets/javascripts/vue.js +4 -10232
  58. metadata +107 -11
  59. data/app/assets/javascripts/codelation_ui/std/index.js +0 -2
@@ -2,57 +2,62 @@
2
2
  "use strict";
3
3
 
4
4
  // Exposes method validateForm(success, fail)
5
-
5
+ App.vue.config.form = {
6
+ disableValidation: false
7
+ }
8
+
6
9
  App.vue.interfaces.form = {
7
10
  data: function() {
8
11
  return {
9
- _formValidationWatch: true,
10
- _formValidationInputs: 0,
11
- _formValidationResponded: 0,
12
- _formValidationValid: true,
13
- _formValidationValidAction: null,
14
- _formValidationInvalidAction: null,
15
- _formValidationErrorMessage: null,
16
- _formValidationDeveloperMode: false
12
+ form: {
13
+ formValidationWatch: true,
14
+ formValidationInputs: 0,
15
+ formValidationResponded: 0,
16
+ formValidationValid: true,
17
+ formValidationValidAction: null,
18
+ formValidationInvalidAction: null,
19
+ formValidationErrorMessage: null,
20
+ formValidationDeveloperMode: false,
21
+ }
17
22
  }
18
23
  },
19
24
  ready: function() {
20
- if (App.vue.config.disableVueFormValidations == true) {
21
- this._formValidationDeveloperMode = true;
25
+ if (App.vue.config.form.disableValidation == true) {
26
+ this.form.formValidationDeveloperMode = true;
22
27
  console.error("VUE FORMS DEVELOPER MODE: Validations will not fail the form");
23
28
  }
24
29
  },
25
30
  methods: {
26
31
  _formValidationRespondToForm: function() {
27
- if (this._formValidationWatch && this._formValidationResponded === this._formValidationInputs) {
28
- if (this._formValidationValid && typeof this._formValidationValidAction === 'function') {
29
- this._formValidationValidAction();
30
- }else if (!this._formValidationValid && typeof this._formValidationInvalidAction === 'function') {
31
- this._formValidationInvalidAction();
32
+ if (this.form.formValidationWatch && this.form.formValidationResponded === this.form.formValidationInputs) {
33
+ if (this.form.formValidationValid && typeof this.form.formValidationValidAction === 'function') {
34
+ this.form.formValidationValidAction();
35
+ }else if (!this.form.formValidationValid && typeof this.form.formValidationInvalidAction === 'function') {
36
+ this.form.formValidationInvalidAction();
32
37
  }
33
38
  }
34
39
  },
35
40
  _formValidationValidateCallback: function(valid) {
36
- this._formValidationResponded++;
37
- if (this._formValidationValid) {
38
- this._formValidationValid = valid;
41
+ this.form.formValidationResponded++;
42
+ if (this.form.formValidationValid) {
43
+ this.form.formValidationValid = valid;
39
44
  }
40
45
  this._formValidationRespondToForm();
41
46
  },
42
47
  validateForm: function(successCB, failCB) {
43
- if (this._formValidationDeveloperMode === true) {
48
+ if (this.form.formValidationDeveloperMode === true) {
44
49
  successCB();
45
50
  return;
46
51
  }
47
- this._formValidationWatch = false;
48
- this._formValidationErrorMessage = null;
49
- this._formValidationResponded = 0;
50
- this._formValidationValid = true;
51
- this._formValidationValidAction = successCB || null;
52
- this._formValidationInvalidAction = failCB || null;
53
- this._formValidationWatch = true;
52
+ this.form.formValidationWatch = false;
53
+ this.form.formValidationErrorMessage = null;
54
+ this.form.formValidationResponded = 0;
55
+ this.form.formValidationValid = true;
56
+ this.form.formValidationValidAction = successCB || null;
57
+ this.form.formValidationInvalidAction = failCB || null;
58
+ this.form.formValidationWatch = true;
54
59
 
55
- if (this._formValidationInputs < 1) {
60
+ if (this.form.formValidationInputs < 1) {
56
61
  this._formValidationRespondToForm();
57
62
  }else{
58
63
  this.$broadcast('_form-validation-validate-inputs', this._formValidationValidateCallback);
@@ -61,10 +66,10 @@
61
66
  },
62
67
  events: {
63
68
  '_form-validation-inputs-check-in': function() {
64
- this._formValidationInputs++;
69
+ this.form.formValidationInputs++;
65
70
  },
66
71
  '_form-validation-inputs-check-out': function() {
67
- this._formValidationInputs--;
72
+ this.form.formValidationInputs--;
68
73
  }
69
74
  }
70
75
  };
@@ -1 +1,3 @@
1
- //= require_tree ./std
1
+ //= require_tree ./std/interfaces
2
+ //= require_tree ./std/computed_interfaces
3
+ //= require_tree ./std/components
@@ -0,0 +1,22 @@
1
+ (function() {
2
+ "use strict";
3
+
4
+ var template = '<div class="vue-info" :style="{\'font-size\': size + \'px\'}">\
5
+ <i class=\"fa fa-question vue-info-hint\"></i>\
6
+ <span class="vue-info-message" :class="[direction]">\
7
+ <slot></slot>\
8
+ </span>\
9
+ </div>';
10
+
11
+ App.vue.components.vueInfo = Vue.extend({
12
+ template: template,
13
+ props: {
14
+ 'size': {
15
+ default: '12'
16
+ },
17
+ 'direction': {
18
+ default: ''
19
+ }
20
+ }
21
+ });
22
+ })();
@@ -0,0 +1,26 @@
1
+ (function() {
2
+ "use strict";
3
+
4
+ var template = '<div v-if="pageTransitionFinished" :transition="transitionName"><slot></slot></div>';
5
+
6
+ App.vue.components.vueTransition = Vue.extend({
7
+ props: {
8
+ transitionName: {
9
+ type: String,
10
+ default: "v-fade-up"
11
+ }
12
+ },
13
+ template: template,
14
+ data: function() {
15
+ return {
16
+ pageTransitionFinished: false
17
+ }
18
+ },
19
+ ready: function() {
20
+ var self = this;
21
+ this.$nextTick(function() {
22
+ self.pageTransitionFinished = true;
23
+ });
24
+ }
25
+ });
26
+ })();
@@ -0,0 +1,17 @@
1
+ App.vue.computedInterfaces.mockAPI = function(data, objectString, queryData) {
2
+ return {
3
+ ready: function() {
4
+ var self = this;
5
+ this.$nextTick(function(){
6
+ self[objectString] = data;
7
+ self.queryData = queryData || {};
8
+ self.ready();
9
+ });
10
+ },
11
+ methods: {
12
+ ready: function() {
13
+
14
+ }
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,28 @@
1
+ (function(){
2
+ "use strict";
3
+
4
+ App.vue.interfaces.array = {
5
+ methods: {
6
+ _uniq: function(arr) {
7
+ if (arr.constructor === Array) {
8
+ var seen = {};
9
+ var out = [];
10
+ var len = arr.length;
11
+ var j = 0;
12
+ for(var i = 0; i < len; i++) {
13
+ var item = arr[i];
14
+ if(seen[item] !== 1) {
15
+ seen[item] = 1;
16
+ out[j++] = item;
17
+ }
18
+ }
19
+ return out;
20
+ }else{
21
+ console.warn("_uniq only supports arrays");
22
+ return -1;
23
+ }
24
+ }
25
+ }
26
+ }
27
+
28
+ })();
@@ -1,26 +1,53 @@
1
1
  (function() {
2
2
  "use strict";
3
+
4
+ // Config options
5
+ App.vue.config.contentFormatters = {
6
+ 'empty': '--',
7
+ 'currency': '0,0[.]00',
8
+ 'percent': '0,0[.]00',
9
+ 'number': '0,0[.]00',
10
+ 'date': 'MM/DD/YYYY',
11
+ };
12
+
3
13
  App.vue.interfaces.contentFormatters = {
4
14
  methods: {
5
- _formatToCurrency: function(value, custom_number_format) {
6
- return numeral(value).format('$' + (custom_number_format || '0,0[.]00'));
15
+ _formatToCurrency: function(value, custom_number_format, nullReturn) {
16
+ if (value === undefined || value === null || isNaN(value)) {
17
+ return nullReturn || App.vue.config.contentFormatters.empty;
18
+ }
19
+ return App.vue.interfaces.number.methods._numeral(value).format('$' + (custom_number_format || App.vue.config.contentFormatters.currency));
7
20
  },
8
- _formatToPercent: function(value, custom_number_format) {
9
- return numeral(value / 100).format((custom_number_format || '0,0[.]00') + '%');
21
+ _formatToPercent: function(value, custom_number_format, nullReturn) {
22
+ if (value === undefined || value === null || isNaN(value)) {
23
+ return nullReturn || App.vue.config.contentFormatters.empty;
24
+ }
25
+ return App.vue.interfaces.number.methods._numeral(value / 100).format((custom_number_format || App.vue.config.contentFormatters.percent) + '%');
10
26
  },
11
- _formatToNumber: function(value, custom_number_format) {
12
- return numeral(value).format(custom_number_format || '0,0[.]00');
27
+ _formatToNumber: function(value, custom_number_format, nullReturn) {
28
+ if (value === undefined || value === null || isNaN(value)) {
29
+ return nullReturn || App.vue.config.contentFormatters.empty;
30
+ }
31
+ return App.vue.interfaces.number.methods._numeral(value).format(custom_number_format || App.vue.config.contentFormatters.number);
13
32
  },
14
- _formatToPhoneNumber: function(value) {
15
- var r = /(?:(\+?(?:(\d{1,2}))\s?)?(\(?(?:(\d{3}))\)?(\s|-|\.)?)((?:(\d{3}))(\s|-|\.)?)((?:(\d{4}))))/i;
33
+ _formatToPhoneNumber: function(value, reg, nullReturn) {
34
+ if (value === undefined || value === null) {
35
+ return nullReturn || App.vue.config.contentFormatters.empty;
36
+ }
37
+ var r = reg || /(?:(\+?(?:(\d{1,2}))\s?)?(\(?(?:(\d{3}))\)?(\s|-|\.)?)((?:(\d{3}))(\s|-|\.)?)((?:(\d{4}))))/i;
16
38
  var match = r.exec(value);
17
39
  if (match !== null && match.length === 11) {
18
40
  var areaCode = match[2] || 1;
19
41
  return '+' + areaCode + ' (' + match[4] + ') ' + match[7] + '-' + match[10];
42
+ }else{
43
+ return nullReturn || App.vue.config.contentFormatters.empty;
20
44
  }
21
45
  },
22
- _formatToDate: function(value) {
23
- return moment(date).format('MM/DD/YYYY');
46
+ _formatToDate: function(value, custom_format, nullReturn) {
47
+ if (value === undefined || value === null || !this._moment(value).isValid()) {
48
+ return nullReturn || App.vue.config.contentFormatters.empty;
49
+ }
50
+ return App.vue.interfaces.date.methods._moment(value).format(custom_format || App.vue.config.contentFormatters.date);
24
51
  }
25
52
  }
26
53
  };
@@ -0,0 +1,8 @@
1
+ (function() {
2
+ App.vue.interfaces.date = {
3
+ methods: {
4
+ // Includes the Momentjs Library
5
+ _moment: moment
6
+ }
7
+ };
8
+ })();
@@ -0,0 +1,20 @@
1
+
2
+ (function(){
3
+ "use strict";
4
+
5
+ App.vue.interfaces.number = {
6
+ methods: {
7
+ _numeral: numeral,
8
+ // checks if the denominator is zero and returns zero
9
+ _safeDivide: function(num, den) {
10
+ if (den === 0) {
11
+ return 0;
12
+ } else {
13
+ // Mult by float ensures that decimals are not stripped like dividing two integers can cause
14
+ return (num * 1.0) / den;
15
+ }
16
+ }
17
+ }
18
+ }
19
+
20
+ })();
@@ -0,0 +1,104 @@
1
+ (function(){
2
+ "use strict";
3
+
4
+ // Config options
5
+ App.vue.config.restApi = {
6
+ 'options': {},
7
+ 'version': null
8
+ };
9
+
10
+ // Alias for old names
11
+ App.vue.config.rest_api = App.vue.config.restApi;
12
+
13
+
14
+
15
+ function url() {
16
+ if (App.vue.config.restApi.version === null) {
17
+ return '/api';
18
+ }else{
19
+ return '/api/v' + App.vue.config.restApi.version;
20
+ }
21
+ }
22
+
23
+ function toPath(model) {
24
+ var pluralModel = App.vue.interfaces.string.methods._pluralize(model);
25
+ var modelPath = App.vue.interfaces.string.methods._dasherize(pluralModel);
26
+ return url() + '/' + modelPath;
27
+ }
28
+
29
+ function queryStringFromOptions(options_arg, defaultOptions_arg) {
30
+ var queries = [];
31
+
32
+ var options = options_arg || {};
33
+ var defaultOptions = defaultOptions_arg || {};
34
+
35
+ // Add options to default options (overwrites any default)
36
+ Object.keys(options).forEach(function(key) {
37
+ defaultOptions[key] = options[key];
38
+ });
39
+
40
+ Object.keys(defaultOptions).forEach(function(key) {
41
+ queries.push(App.vue.interfaces.string.methods._underscore(key) + "=" + defaultOptions[key]);
42
+ });
43
+
44
+ if (queries.length > 0) {
45
+ return '?'+queries.join('&');
46
+ } else {
47
+ return '';
48
+ }
49
+ }
50
+
51
+ App.vue.interfaces.restApi = {
52
+ methods: {
53
+ _sendRequest: function(url, method, data) {
54
+ return $.ajax({
55
+ url: url,
56
+ type: method || 'GET',
57
+ data: data || {}
58
+ });
59
+ },
60
+ _restfulGet: function(model, id, options) {
61
+ if (App.vue.interfaces.contentValidators.methods._valueIsEmpty(id)) {
62
+ return App.vue.interfaces.restApi.methods._restfulGetAll(model, options);
63
+ }else{
64
+ var url = toPath(model);
65
+ var path = url + '/' + id;
66
+ }
67
+ var requestUrl = path + queryStringFromOptions(options, App.vue.config.restApi.options);
68
+ return App.vue.interfaces.restApi.methods._sendRequest(requestUrl, 'GET');
69
+ },
70
+ _restfulGetAll: function(model, options) {
71
+ var requestUrl = toPath(model) + queryStringFromOptions(options, App.vue.config.restApi.options);
72
+ return App.vue.interfaces.restApi.methods._sendRequest(requestUrl, 'GET');
73
+ },
74
+ _restfulCreate: function(model, id, data, options) {
75
+ var url = toPath(model);
76
+ var path = url;
77
+ var requestUrl = path + queryStringFromOptions(options, App.vue.config.restApi.options);
78
+ return App.vue.interfaces.restApi.methods._sendRequest(requestUrl, 'POST', data);
79
+ },
80
+ _restfulUpdate: function(model, id, data, options) {
81
+ var url = toPath(model);
82
+ if (App.vue.interfaces.contentValidators.methods._valueIsEmpty(id)) {
83
+ var path = url + '/';
84
+ }else{
85
+ var path = url + '/' + id;
86
+ }
87
+ var requestUrl = path + queryStringFromOptions(options, App.vue.config.restApi.options);
88
+ return App.vue.interfaces.restApi.methods._sendRequest(requestUrl, 'PATCH', data);
89
+ },
90
+ _restfulDelete: function(model, id, options) {
91
+ var url = toPath(model);
92
+ if (App.vue.interfaces.contentValidators.methods._valueIsEmpty(id)) {
93
+ var path = url + '/';
94
+ }else{
95
+ var path = url + '/' + id;
96
+ }
97
+ var requestUrl = path + queryStringFromOptions(options, App.vue.config.restApi.options);
98
+ return App.vue.interfaces.restApi.methods._sendRequest(requestUrl, 'DELETE');
99
+ }
100
+ }
101
+ }
102
+
103
+ App.vue.interfaces.rest_api = App.vue.interfaces.restApi;
104
+ })();
@@ -0,0 +1,29 @@
1
+ (function(){
2
+ "use strict";
3
+
4
+ App.vue.interfaces.string = {
5
+ methods: {
6
+ // Replaces spaces and reverts capital letters to lowercase with underscore before them.
7
+ _underscore: function(string) {
8
+ return string.replace((/([a-z\d])([A-Z])/g), '$1_$2')
9
+ .toLowerCase()
10
+ .replace((/[ -]/g), '_');
11
+ },
12
+ // Changes the word into the plural form
13
+ _pluralize: pluralize,
14
+ // Replaces spaces and reverts capital letters to lowercase with dash before them.
15
+ _dasherize: function(string) {
16
+ return string.replace((/([a-z\d])([A-Z])/g), '$1_$2')
17
+ .toLowerCase()
18
+ .replace((/[ _]/g), '-');
19
+ },
20
+ // Changes a character after any break in the string to the capital version
21
+ _titleize: function(string) {
22
+ return string.replace((/([a-z\d])([A-Z])/g), '$1_$2').toLowerCase().replace(/(?:^|\s|-|_)\S/g, function(m) {
23
+ return m.toUpperCase();
24
+ }).replace((/[ _-]/g), ' ');
25
+ }
26
+ }
27
+ }
28
+
29
+ })();
@@ -1,13 +1,30 @@
1
1
  //= require vue
2
- //= require ./std
3
2
  //= require_self
4
-
3
+ //= require ./std
5
4
 
6
5
  App.vue = {
7
- interfaces: {},
8
- components: {},
9
- config: {}
6
+ _info: 'Contains object references to all functionality that the UI offers as well as the reference to the root vue component',
7
+ interfaces: {
8
+ _info: 'Used for containing mixins and methods used for vue'
9
+ },
10
+ computedInterfaces: {
11
+ _info: 'Same as interfaces except accepts arguments to alter the mixin before applying it to the component'
12
+ },
13
+ globalComponents: {
14
+ _info: 'Used to define all global components'
15
+ },
16
+ components: {
17
+ _info: 'Used to hold references to various vue components you may use or are not defined globaly'
18
+ },
19
+ config: {
20
+ _info: 'Used to customize the functionality for some interfaces and components',
21
+ main: {
22
+ showInterfaces: true,
23
+ includedInterfaces: []
24
+ }
25
+ },
26
+ root: null,
27
+ extend: {
28
+ _info: 'Used to hold references to per page components and attach to the root component if you did not define one.'
29
+ }
10
30
  }
11
-
12
- console.warn("Loaded Vue Interfaces")
13
- console.warn(App.vue.interfaces);