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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/codelation_ui/_base_resources/app.js +54 -5
- data/app/assets/javascripts/codelation_ui/base.js +1 -0
- data/app/assets/javascripts/codelation_ui/extended/checkmark.js +31 -0
- data/app/assets/javascripts/codelation_ui/extended/code.js +64 -0
- data/app/assets/javascripts/codelation_ui/extended/fail.js +31 -0
- data/app/assets/javascripts/codelation_ui/extended/radial_progress_bar.js +267 -0
- data/app/assets/javascripts/codelation_ui/extended/slider.js +636 -639
- data/app/assets/javascripts/codelation_ui/extended/spinner.js +103 -0
- data/app/assets/javascripts/codelation_ui/forms/components/input.js +417 -388
- data/app/assets/javascripts/codelation_ui/forms/interfaces/form.js +35 -30
- data/app/assets/javascripts/codelation_ui/std.js +3 -1
- data/app/assets/javascripts/codelation_ui/std/components/info.js +22 -0
- data/app/assets/javascripts/codelation_ui/std/components/transition.js +26 -0
- data/app/assets/javascripts/codelation_ui/std/computed_interfaces/mockAPI.js +17 -0
- data/app/assets/javascripts/codelation_ui/std/interfaces/array.js +28 -0
- data/app/assets/javascripts/codelation_ui/std/interfaces/content_formatters.js +37 -10
- data/app/assets/javascripts/codelation_ui/std/interfaces/date.js +8 -0
- data/app/assets/javascripts/codelation_ui/std/interfaces/number.js +20 -0
- data/app/assets/javascripts/codelation_ui/std/interfaces/rest_api.js +104 -0
- data/app/assets/javascripts/codelation_ui/std/interfaces/string.js +29 -0
- data/app/assets/javascripts/codelation_ui/vue.js +25 -8
- data/app/assets/javascripts/codelation_ui/vue_pages.js +35 -10
- data/app/assets/stylesheets/codelation_ui.scss +1 -3
- data/app/assets/stylesheets/codelation_ui/_base_resources/_turbolinks.scss +11 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/mixins/button.scss +185 -33
- data/app/assets/stylesheets/codelation_ui/base.scss +3 -0
- data/app/assets/stylesheets/codelation_ui/colors.scss +2 -0
- data/app/assets/stylesheets/codelation_ui/extended/checkmark.scss +53 -0
- data/app/assets/stylesheets/codelation_ui/extended/code.scss +153 -0
- data/app/assets/stylesheets/codelation_ui/extended/fail.scss +50 -0
- data/app/assets/stylesheets/codelation_ui/extended/radial_progress_bar.scss +70 -0
- data/app/assets/stylesheets/codelation_ui/extended/slider.scss +2 -2
- data/app/assets/stylesheets/codelation_ui/extended/spinner.scss +100 -0
- data/app/assets/stylesheets/codelation_ui/std.scss +1 -1
- data/app/assets/stylesheets/codelation_ui/std/info.scss +51 -0
- data/app/assets/stylesheets/codelation_ui/vue_transitions.scss +94 -0
- data/app/helpers/action_view/helpers/url_helper.rb +22 -0
- data/lib/generators/ui/component/USAGE +22 -0
- data/lib/generators/ui/component/component_generator.rb +41 -0
- data/lib/generators/ui/component/templates/javascript.js.erb +20 -0
- data/lib/generators/ui/component/templates/page_javascript.js.erb +20 -0
- data/lib/generators/ui/component/templates/page_stylesheet.scss.erb +3 -0
- data/lib/generators/ui/component/templates/stylesheet.scss.erb +3 -0
- data/lib/generators/ui/component/templates/template.html.erb +5 -0
- data/lib/generators/ui/mixin/USAGE +8 -0
- data/lib/generators/ui/mixin/mixin_generator.rb +11 -0
- data/lib/generators/ui/mixin/templates/javascript.js.erb +8 -0
- data/lib/generators/ui/pages/USAGE +23 -0
- data/lib/generators/ui/pages/pages_generator.rb +48 -0
- data/lib/generators/ui/pages/templates/controller.rb +2 -0
- data/lib/generators/ui/pages/templates/javascript.js.erb +22 -0
- data/lib/generators/ui/pages/templates/stylesheet.scss.erb +3 -0
- data/lib/generators/ui/pages/templates/template.html.erb +3 -0
- data/vendor/assets/javascripts/highlight.pack.js +2 -0
- data/vendor/assets/javascripts/pluralize.js +1 -0
- data/vendor/assets/javascripts/vue.js +4 -10232
- metadata +107 -11
- data/app/assets/javascripts/codelation_ui/std/index.js +0 -2
@@ -0,0 +1,103 @@
|
|
1
|
+
(function() {
|
2
|
+
"use strict";
|
3
|
+
|
4
|
+
App.vue.components.vueSpinner = Vue.extend({
|
5
|
+
template: ' <div class="vue-spinner" :class="classes" :style="styles">\
|
6
|
+
<svg class="vue-spinner-draw" viewBox="25 25 50 50" v-if="spinning">\
|
7
|
+
<circle class="vue-spinner-path" cx="50" cy="50" r="20" :stroke-width="stroke" :stroke-dasharray="dashProgress">\
|
8
|
+
</svg>\
|
9
|
+
<vue-checkmark v-if="success" :stroke="stroke" :size="size"></vue-checkmark>\
|
10
|
+
<vue-fail v-if="fail" :stroke="stroke" :size="size"></vue-fail>\
|
11
|
+
<span v-if="showMessage" class="vue-spinner-message" transition="v-fade-in-out">\
|
12
|
+
{{ message }}\
|
13
|
+
</span>\
|
14
|
+
</div>',
|
15
|
+
props: {
|
16
|
+
size: {
|
17
|
+
type: Number,
|
18
|
+
default: 50
|
19
|
+
},
|
20
|
+
stroke: {
|
21
|
+
type: Number,
|
22
|
+
default: 3.5
|
23
|
+
},
|
24
|
+
indeterminate: {
|
25
|
+
type: Boolean,
|
26
|
+
default: true
|
27
|
+
},
|
28
|
+
progress: {
|
29
|
+
type: Number,
|
30
|
+
default: null
|
31
|
+
},
|
32
|
+
success: {
|
33
|
+
type: Boolean,
|
34
|
+
default: false
|
35
|
+
},
|
36
|
+
message: {
|
37
|
+
type: String,
|
38
|
+
default: null
|
39
|
+
},
|
40
|
+
fail: {
|
41
|
+
type: Boolean,
|
42
|
+
default: false
|
43
|
+
}
|
44
|
+
},
|
45
|
+
computed: {
|
46
|
+
showMessage: function() {
|
47
|
+
if (this.message === null) {
|
48
|
+
return false;
|
49
|
+
}
|
50
|
+
|
51
|
+
if (this.success) {
|
52
|
+
return true;
|
53
|
+
}
|
54
|
+
|
55
|
+
if (this.fail) {
|
56
|
+
return true;
|
57
|
+
}
|
58
|
+
|
59
|
+
return false;
|
60
|
+
},
|
61
|
+
spinning: function() {
|
62
|
+
if (this.success) {
|
63
|
+
return false;
|
64
|
+
}
|
65
|
+
|
66
|
+
return true;
|
67
|
+
},
|
68
|
+
isIndeterminate: function() {
|
69
|
+
if (this.indeterminate) {
|
70
|
+
return true;
|
71
|
+
} else {
|
72
|
+
if (this.progress === null) {
|
73
|
+
return true;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
return false;
|
78
|
+
},
|
79
|
+
classes: function() {
|
80
|
+
return {
|
81
|
+
'vue-indeterminate': this.isIndeterminate
|
82
|
+
};
|
83
|
+
},
|
84
|
+
styles: function() {
|
85
|
+
var newSize = this.size + 'px';
|
86
|
+
return {
|
87
|
+
width: newSize,
|
88
|
+
height: newSize
|
89
|
+
};
|
90
|
+
},
|
91
|
+
dashProgress: function() {
|
92
|
+
if (this.isIndeterminate) {
|
93
|
+
return false;
|
94
|
+
}
|
95
|
+
var progress = this.progress * 125 / 100;
|
96
|
+
if (progress >= 125) {
|
97
|
+
progress = 130;
|
98
|
+
}
|
99
|
+
return progress + ', 200';
|
100
|
+
}
|
101
|
+
}
|
102
|
+
});
|
103
|
+
})();
|
@@ -69,429 +69,458 @@ Used to remove the icon if the field has one. Only effects Date types right now
|
|
69
69
|
(function() {
|
70
70
|
"use strict";
|
71
71
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
<
|
81
|
-
|
82
|
-
|
83
|
-
<
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
<div v-if="
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
72
|
+
var template = '<div class="vue-input" :class="[message ? \'has-message\' : \'\', disabled ? \'disabled\' : \'\', type]">\
|
73
|
+
<i v-if="inputIcon" v-on:click="activeObject()" class="vue-input-icon fa" :class="[inputIcon]"></i>\
|
74
|
+
<input :disabled="disabled" id="{{ id}}" type="text" name="{{ name }}" v-if="showInputFor(\'number\')" v-on:keyup.up="incrementValue()" v-on:keyup.down="decrementValue()" v-model="inputValue" :placeholder="placeholder" v-el:input>\
|
75
|
+
<input :disabled="disabled" id="{{ id}}" type="text" name="{{ name }}" v-if="showInputFor(\'string\')" v-model="inputValue" :placeholder="placeholder" v-el:input>\
|
76
|
+
<input :disabled="disabled" id="{{ id}}" type="text" name="{{ name }}" v-if="showInputFor(\'date\')" v-on:keyup.up="incrementValue()" v-on:keyup.down="decrementValue()" v-el:input v-model="inputValue" :placeholder="placeholder">\
|
77
|
+
<input :disabled="disabled" id="{{ id}}" type="checkbox" name="{{ name }}" v-if="showInputFor(\'bool\')" v-el:input v-model="inputValue">\
|
78
|
+
<input :disabled="disabled" id="{{ id}}" type="radio" name="{{ name }}" v-if="showInputFor(\'radio\')" v-el:input v-model="inputValue">\
|
79
|
+
<select :disabled="disabled" id="{{ id}}" v-if="showInputFor(\'select\')" v-model="inputValue" name="{{ name }}">\
|
80
|
+
<option v-for="option in optionsForSelect" :value="optionValue(option)">{{ optionLabel(option) }}</option>\
|
81
|
+
</select>\
|
82
|
+
<span v-if="showInputFor(\'toggle\')" class="vue-input-toggle">\
|
83
|
+
<input :disabled="disabled" id="{{ id}}" name="{{ name }}" type="checkbox" v-model="inputValue">\
|
84
|
+
<label for="{{ id}}"></label>\
|
85
|
+
</span>\
|
86
|
+
<div v-if="message" class="vue-input-message-container">\
|
87
|
+
<i class="fa fa-exclamation-triangle"></i><div><h5>{{ message }}</h5><p v-if="inputFormat">Format: {{ inputFormat }}</p></div>\
|
88
|
+
</div>\
|
89
|
+
</div>'
|
90
|
+
|
91
|
+
var inputTypeMap = {
|
92
|
+
'money': 'money',
|
93
|
+
'currency': 'money',
|
94
|
+
'number': 'number',
|
95
|
+
'numeric': 'number',
|
96
|
+
'date': 'date',
|
97
|
+
'calendar': 'date',
|
98
|
+
'percent': 'percent',
|
99
|
+
'bool': 'bool',
|
100
|
+
'check': 'bool',
|
101
|
+
'boolean': 'bool',
|
102
|
+
'toggle': 'toggle',
|
103
|
+
'text': 'text',
|
104
|
+
'email': 'text',
|
105
|
+
'phone': 'text',
|
106
|
+
'option': 'radio',
|
107
|
+
'radio': 'radio',
|
108
|
+
'select': 'select',
|
109
|
+
'list': 'select'
|
110
|
+
}
|
111
|
+
|
112
|
+
var dataTypeMap = {
|
113
|
+
'money': 'number',
|
114
|
+
'currency': 'number',
|
115
|
+
'number': 'number',
|
116
|
+
'integer': 'number',
|
117
|
+
'float': 'number',
|
118
|
+
'numeric': 'number',
|
119
|
+
'date': 'date',
|
120
|
+
'calendar': 'date',
|
121
|
+
'percent': 'number',
|
122
|
+
'bool': 'bool',
|
123
|
+
'check': 'bool',
|
124
|
+
'boolean': 'bool',
|
125
|
+
'toggle': 'toggle',
|
126
|
+
'text': 'string',
|
127
|
+
'radio': 'radio',
|
128
|
+
'select': 'select'
|
129
|
+
}
|
130
|
+
|
131
|
+
var autoNumericDefault = {
|
132
|
+
aSign: '',
|
133
|
+
pSign: 'p'
|
134
|
+
}
|
135
|
+
|
136
|
+
var numericDefaults = {
|
137
|
+
'money': {
|
138
|
+
aSign: '$',
|
139
|
+
mDec: '2',
|
140
|
+
wEmpty: 'empty'
|
141
|
+
},
|
142
|
+
'percent': {
|
143
|
+
aSign: '%',
|
144
|
+
mDec: '0',
|
145
|
+
wEmpty: 'empty'
|
146
|
+
},
|
147
|
+
'number': {
|
148
|
+
wEmpty: 'empty'
|
149
|
+
},
|
150
|
+
'integer': {
|
151
|
+
mDec: '0',
|
152
|
+
wEmpty: 'empty'
|
111
153
|
}
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
'
|
119
|
-
|
120
|
-
'date':'date',
|
121
|
-
'calendar':'date',
|
122
|
-
'percent':'number',
|
123
|
-
'bool':'bool',
|
124
|
-
'check':'bool',
|
125
|
-
'boolean':'bool',
|
126
|
-
'toggle':'toggle',
|
127
|
-
'text':'string',
|
128
|
-
'radio':'radio',
|
129
|
-
'select':'select'
|
130
|
-
}
|
131
|
-
|
132
|
-
var numericDefaults = {
|
133
|
-
'money': {aSign: '$', mDec: '2', wEmpty: 'empty'},
|
134
|
-
'percent': {aSign: '%', pSign: 's', mDec: '0', wEmpty: 'empty'},
|
135
|
-
'number': {wEmpty: 'empty'},
|
136
|
-
'integer': {mDec: '0', wEmpty: 'empty'}
|
137
|
-
}
|
138
|
-
|
139
|
-
Vue.component('vue-input', {
|
140
|
-
mixins: [App.vue.interfaces.formValidation, App.vue.interfaces.contentValidators, App.vue.interfaces.helpers],
|
141
|
-
template: template,
|
142
|
-
props: {
|
143
|
-
'type': {
|
144
|
-
default: 'plain'
|
145
|
-
},
|
146
|
-
'precision': {
|
147
|
-
default: null
|
148
|
-
},
|
149
|
-
'min': {
|
150
|
-
default: null
|
151
|
-
},
|
152
|
-
'max': {
|
153
|
-
default: null
|
154
|
-
},
|
155
|
-
'numberLabel': {
|
156
|
-
default: null
|
157
|
-
},
|
158
|
-
'numberPostLabel': {
|
159
|
-
default: null
|
160
|
-
},
|
161
|
-
'numberPreLabel': {
|
162
|
-
default: null
|
163
|
-
},
|
164
|
-
'restrictMax': {
|
165
|
-
default: true
|
166
|
-
},
|
167
|
-
'restrictMin': {
|
168
|
-
default: true
|
169
|
-
},
|
170
|
-
'placeholder': {
|
171
|
-
default: null
|
172
|
-
},
|
173
|
-
'required': {
|
174
|
-
default: false
|
175
|
-
},
|
176
|
-
'validate': {
|
177
|
-
default: true
|
178
|
-
},
|
179
|
-
'toString': {
|
180
|
-
default: false
|
181
|
-
},
|
182
|
-
'noIcon': {
|
183
|
-
default: false
|
184
|
-
},
|
185
|
-
'value': {
|
186
|
-
twoWay: true
|
187
|
-
},
|
188
|
-
'keyCodes': {
|
189
|
-
default: true
|
190
|
-
},
|
191
|
-
'id': {
|
192
|
-
default: null
|
193
|
-
},
|
194
|
-
'name': {
|
195
|
-
default: null
|
196
|
-
},
|
197
|
-
'optionsForSelect': {
|
198
|
-
default: function() {return [];}
|
199
|
-
},
|
200
|
-
'disabled': {
|
201
|
-
default: false
|
202
|
-
}
|
154
|
+
}
|
155
|
+
|
156
|
+
App.vue.components.vueInput = Vue.extend({
|
157
|
+
mixins: [App.vue.interfaces.formValidation, App.vue.interfaces.contentValidators, App.vue.interfaces.helpers],
|
158
|
+
template: template,
|
159
|
+
props: {
|
160
|
+
'type': {
|
161
|
+
default: 'plain'
|
203
162
|
},
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
163
|
+
'precision': {
|
164
|
+
default: null
|
165
|
+
},
|
166
|
+
'min': {
|
167
|
+
default: null
|
168
|
+
},
|
169
|
+
'max': {
|
170
|
+
default: null
|
171
|
+
},
|
172
|
+
'numberLabel': {
|
173
|
+
default: null
|
174
|
+
},
|
175
|
+
'numberPostLabel': {
|
176
|
+
default: null
|
177
|
+
},
|
178
|
+
'numberPreLabel': {
|
179
|
+
default: null
|
180
|
+
},
|
181
|
+
'restrictMax': {
|
182
|
+
default: true
|
183
|
+
},
|
184
|
+
'restrictMin': {
|
185
|
+
default: true
|
186
|
+
},
|
187
|
+
'placeholder': {
|
188
|
+
default: null
|
189
|
+
},
|
190
|
+
'required': {
|
191
|
+
default: false
|
216
192
|
},
|
217
|
-
|
218
|
-
|
219
|
-
|
193
|
+
'validate': {
|
194
|
+
default: true
|
195
|
+
},
|
196
|
+
'toString': {
|
197
|
+
default: false
|
198
|
+
},
|
199
|
+
'noIcon': {
|
200
|
+
default: false
|
201
|
+
},
|
202
|
+
'value': {
|
203
|
+
twoWay: true
|
204
|
+
},
|
205
|
+
'keyCodes': {
|
206
|
+
default: true
|
207
|
+
},
|
208
|
+
'id': {
|
209
|
+
default: null
|
210
|
+
},
|
211
|
+
'name': {
|
212
|
+
default: null
|
213
|
+
},
|
214
|
+
'optionsForSelect': {
|
215
|
+
default: function() {
|
216
|
+
return [];
|
220
217
|
}
|
218
|
+
},
|
219
|
+
'disabled': {
|
220
|
+
default: false
|
221
|
+
}
|
222
|
+
},
|
223
|
+
data: function() {
|
224
|
+
return {
|
225
|
+
inputValue: null,
|
226
|
+
message: null,
|
227
|
+
inputFormat: null,
|
228
|
+
validating: false,
|
229
|
+
formatting: true,
|
230
|
+
renderHTML: false,
|
231
|
+
obj: null,
|
232
|
+
showInput: false,
|
233
|
+
initialValue: this.value,
|
234
|
+
}
|
235
|
+
},
|
236
|
+
ready: function() {
|
237
|
+
if (this._valueIsEmpty(this.id)) {
|
238
|
+
this.id = this._randomId();
|
239
|
+
}
|
221
240
|
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
this.inputValue = this.value;
|
226
|
-
}else{
|
227
|
-
this.inputValue = moment(this.value).format(this._formatForDate());
|
228
|
-
}
|
229
|
-
}else{
|
241
|
+
// set the initial value
|
242
|
+
if (this.isDate) {
|
243
|
+
if (this._valueIsEmpty(this.value)) {
|
230
244
|
this.inputValue = this.value;
|
245
|
+
} else {
|
246
|
+
this.inputValue = moment(this.value).format(this._formatForDate());
|
231
247
|
}
|
248
|
+
} else {
|
249
|
+
this.inputValue = this.value;
|
250
|
+
}
|
232
251
|
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
252
|
+
this.renderHTML = true;
|
253
|
+
var self = this;
|
254
|
+
this.$nextTick(function() {
|
255
|
+
self.setupNumber();
|
256
|
+
self.setupDate();
|
257
|
+
self.validating = true;
|
258
|
+
$(self.$els.input).on('focus', self.validateContent);
|
259
|
+
});
|
260
|
+
},
|
261
|
+
beforeDestroy: function() {
|
262
|
+
try {
|
263
|
+
$(self.$els.input).off('focus');
|
264
|
+
$(this.$els.input).autoNumeric('destroy');
|
265
|
+
this.obj.destroy();
|
266
|
+
} catch (err) {}
|
267
|
+
},
|
268
|
+
watch: {
|
269
|
+
disabled: function(newValue) {
|
270
|
+
if (newValue) {
|
271
|
+
this.validateContent();
|
272
|
+
}
|
273
|
+
},
|
274
|
+
inputValue: function(newValue) {
|
275
|
+
if (this.toString) {
|
276
|
+
this.value = String(newValue);
|
277
|
+
} else if (this.isDate) {
|
278
|
+
if (this._valueIsEmpty(newValue)) {
|
279
|
+
this.value = null;
|
280
|
+
} else {
|
281
|
+
this.value = new Date(newValue);
|
253
282
|
}
|
254
|
-
}
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
}else if (this.isDate) {
|
259
|
-
if (this._valueIsEmpty(newValue)) {
|
260
|
-
this.value = null;
|
261
|
-
}else{
|
262
|
-
this.value = new Date(newValue);
|
263
|
-
}
|
264
|
-
}else if (this.isNumber){
|
265
|
-
try{
|
266
|
-
this.value = $(this.$els.input).autoNumeric('get');
|
267
|
-
}catch(e){
|
268
|
-
this.value = newValue;
|
269
|
-
}
|
270
|
-
}else{
|
283
|
+
} else if (this.isNumber) {
|
284
|
+
try {
|
285
|
+
this.value = $(this.$els.input).autoNumeric('get');
|
286
|
+
} catch (e) {
|
271
287
|
this.value = newValue;
|
272
288
|
}
|
273
|
-
|
274
|
-
this.
|
289
|
+
} else {
|
290
|
+
this.value = newValue;
|
275
291
|
}
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
292
|
+
this.formatContent();
|
293
|
+
this.validateContent();
|
294
|
+
}
|
295
|
+
},
|
296
|
+
methods: {
|
297
|
+
setupDate: function() {
|
298
|
+
if (this.isDate) {
|
299
|
+
var options = {
|
300
|
+
field: this.$els.input,
|
301
|
+
format: this._formatForDate()
|
302
|
+
};
|
284
303
|
|
285
|
-
|
286
|
-
|
287
|
-
}
|
288
|
-
if (this.hasRestrictedMin) {
|
289
|
-
options['minDate'] = new Date(this.min);
|
290
|
-
}
|
291
|
-
this.obj = new Pikaday(options);
|
304
|
+
if (this.hasRestrictedMax) {
|
305
|
+
options['maxDate'] = new Date(this.max);
|
292
306
|
}
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
baseOptions['aSign'] = this.numberPreLabel;
|
312
|
-
baseOptions['pSign'] = 'p';
|
313
|
-
}
|
314
|
-
|
315
|
-
var self = this;
|
316
|
-
$(this.$els.input).autoNumeric('init', baseOptions).on('keyup', function() {
|
317
|
-
self.value = $(self.$els.input).autoNumeric('get');
|
318
|
-
});
|
319
|
-
$(this.$els.input).autoNumeric('set', this.inputValue);
|
307
|
+
if (this.hasRestrictedMin) {
|
308
|
+
options['minDate'] = new Date(this.min);
|
309
|
+
}
|
310
|
+
this.obj = new Pikaday(options);
|
311
|
+
}
|
312
|
+
},
|
313
|
+
setupNumber: function() {
|
314
|
+
if (this.isNumber) {
|
315
|
+
|
316
|
+
// Set options
|
317
|
+
var baseOptions = JSON.parse(JSON.stringify(autoNumericDefault));
|
318
|
+
var additionals = numericDefaults[this.type] || numericDefaults[this.dataType] || {};
|
319
|
+
Object.keys(additionals).forEach(function(opt) {
|
320
|
+
baseOptions[opt] = additionals[opt];
|
321
|
+
});
|
322
|
+
|
323
|
+
if (this.precision) {
|
324
|
+
baseOptions['mDec'] = this.precision;
|
320
325
|
}
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
326
|
+
if (this.hasRestrictedMax) {
|
327
|
+
baseOptions['vMax'] = this.max;
|
328
|
+
}
|
329
|
+
if (this.hasRestrictedMin) {
|
330
|
+
baseOptions['vMin'] = this.min;
|
325
331
|
}
|
326
332
|
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
if (this.
|
331
|
-
|
332
|
-
|
333
|
-
|
333
|
+
if (this.numberPostLabel || this.numberLabel) {
|
334
|
+
baseOptions['aSign'] = this.numberPostLabel || this.numberLabel;
|
335
|
+
baseOptions['pSign'] = 's';
|
336
|
+
} else if (this.numberPreLabel) {
|
337
|
+
baseOptions['aSign'] = this.numberPreLabel;
|
338
|
+
baseOptions['pSign'] = 'p';
|
339
|
+
}
|
334
340
|
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
341
|
+
var self = this;
|
342
|
+
try {
|
343
|
+
$(this.$els.input).autoNumeric('destroy');
|
344
|
+
} catch (err) {}
|
345
|
+
|
346
|
+
$(this.$els.input).autoNumeric('init', baseOptions).on('keyup', function() {
|
347
|
+
self.value = $(self.$els.input).autoNumeric('get');
|
348
|
+
});
|
349
|
+
$(this.$els.input).autoNumeric('set', this.inputValue);
|
350
|
+
}
|
351
|
+
},
|
352
|
+
showInputFor: function(type) {
|
353
|
+
if (!this.renderHTML) {
|
354
|
+
return false;
|
355
|
+
}
|
356
|
+
|
357
|
+
return this.dataType === type;
|
358
|
+
},
|
359
|
+
incrementValue: function() {
|
360
|
+
if (this.keyCodes) {
|
361
|
+
if (this.isDate) {
|
362
|
+
this.obj.nextMonth();
|
340
363
|
}
|
341
|
-
},
|
342
|
-
decrementValue: function() {
|
343
|
-
if (this.keyCodes) {
|
344
|
-
if (this.isDate) {
|
345
|
-
this.obj.prevMonth();
|
346
|
-
}
|
347
364
|
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
}
|
365
|
+
if (this.isNumber) {
|
366
|
+
if (this.inputValue < this.max) {
|
367
|
+
this.inputValue++;
|
352
368
|
}
|
353
369
|
}
|
354
|
-
}
|
355
|
-
|
370
|
+
}
|
371
|
+
},
|
372
|
+
decrementValue: function() {
|
373
|
+
if (this.keyCodes) {
|
356
374
|
if (this.isDate) {
|
357
|
-
this.obj.
|
375
|
+
this.obj.prevMonth();
|
358
376
|
}
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
this.inputValue = App.vue.interfaces.formatters.methods._formatToPhoneNumber(this.inputValue);
|
377
|
+
|
378
|
+
if (this.isNumber) {
|
379
|
+
if (this.inputValue > this.min) {
|
380
|
+
this.inputValue--;
|
364
381
|
}
|
365
382
|
}
|
366
|
-
}
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
383
|
+
}
|
384
|
+
},
|
385
|
+
activeObject: function() {
|
386
|
+
if (this.isDate) {
|
387
|
+
this.obj.show();
|
388
|
+
}
|
389
|
+
},
|
390
|
+
formatContent: function() {
|
391
|
+
if (this.formatting) {
|
392
|
+
if (this.type === 'phone' && this._valueIsPhone(this.inputValue)) {
|
393
|
+
this.inputValue = App.vue.interfaces.formatters.methods._formatToPhoneNumber(this.inputValue);
|
394
|
+
}
|
395
|
+
}
|
396
|
+
},
|
397
|
+
validateContent: function() {
|
398
|
+
this.message = null;
|
399
|
+
this.inputFormat = null;
|
400
|
+
if (this.validating && !this.disabled) {
|
401
|
+
if (this._valueIsEmpty(this.inputValue)) {
|
402
|
+
if (this.required) {
|
403
|
+
this.message = "This can't be empty";
|
404
|
+
this.inputFormat = this._formatForEmpty();
|
405
|
+
return false;
|
406
|
+
} else {
|
407
|
+
// Empty but not required
|
408
|
+
return true;
|
380
409
|
}
|
410
|
+
}
|
381
411
|
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
}
|
412
|
-
}else{
|
413
|
-
return true;
|
412
|
+
if (this.validate) {
|
413
|
+
if (this.type === 'email') {
|
414
|
+
var res = this._valueIsEmail(this.inputValue);
|
415
|
+
if (!res) {
|
416
|
+
this.message = "Not a valid email address.";
|
417
|
+
this.inputFormat = this._formatForEmail();
|
418
|
+
}
|
419
|
+
return res;
|
420
|
+
} else if (this.type === 'phone') {
|
421
|
+
var res = this._valueIsPhone(this.inputValue);
|
422
|
+
if (!res) {
|
423
|
+
this.message = "Not a valid phone number.";
|
424
|
+
this.inputFormat = this._formatForPhone();
|
425
|
+
}
|
426
|
+
return res;
|
427
|
+
} else if (this.isDate) {
|
428
|
+
var res = this._valueIsDate(this.inputValue);
|
429
|
+
if (!res) {
|
430
|
+
this.message = "Not a valid date.";
|
431
|
+
this.inputFormat = this._formatForDate();
|
432
|
+
}
|
433
|
+
return res;
|
434
|
+
} else if (this.isNumber) {
|
435
|
+
if (this.hasUnrestrictedMax && numeral(this.inputValue).value() > this.max) {
|
436
|
+
this.message = "Number out of range.";
|
437
|
+
this.inputFormat = "less than or equal to " + this.max;
|
438
|
+
} else if (this.hasUnrestrictedMin && numeral(this.inputValue).value() < this.min) {
|
439
|
+
this.message = "Number out of range.";
|
440
|
+
this.inputFormat = "greater than or equal to " + this.min;
|
414
441
|
}
|
442
|
+
} else {
|
443
|
+
return true;
|
415
444
|
}
|
416
445
|
}
|
446
|
+
}
|
447
|
+
return true;
|
448
|
+
},
|
449
|
+
optionValue: function(option) {
|
450
|
+
return option.value || option;
|
451
|
+
},
|
452
|
+
optionLabel: function(option) {
|
453
|
+
return option.label || option;
|
454
|
+
}
|
455
|
+
},
|
456
|
+
computed: {
|
457
|
+
inputType: function() {
|
458
|
+
return inputTypeMap[this.type] || 'text';
|
459
|
+
},
|
460
|
+
dataType: function() {
|
461
|
+
return dataTypeMap[this.inputType] || 'string';
|
462
|
+
},
|
463
|
+
isNumber: function() {
|
464
|
+
if (this.dataType === 'number') {
|
417
465
|
return true;
|
418
|
-
}
|
419
|
-
|
420
|
-
return option.value || option;
|
421
|
-
},
|
422
|
-
optionLabel: function(option) {
|
423
|
-
return option.label || option;
|
466
|
+
} else {
|
467
|
+
return false;
|
424
468
|
}
|
425
469
|
},
|
426
|
-
|
427
|
-
|
428
|
-
return
|
429
|
-
}
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
}else{
|
479
|
-
return false;
|
480
|
-
}
|
481
|
-
},
|
482
|
-
hasUnrestrictedMin: function() {
|
483
|
-
if (this.min !== null && !this.restrictMin) {
|
484
|
-
return true;
|
485
|
-
}else{
|
486
|
-
return false;
|
487
|
-
}
|
488
|
-
},
|
489
|
-
inputIcon: function() {
|
490
|
-
if (this.isDate && !this.init) {
|
491
|
-
return 'fa-calendar';
|
492
|
-
}
|
470
|
+
isDate: function() {
|
471
|
+
if (this.dataType === 'date') {
|
472
|
+
return true;
|
473
|
+
} else {
|
474
|
+
return false;
|
475
|
+
}
|
476
|
+
},
|
477
|
+
isBool: function() {
|
478
|
+
if (this.dataType === 'bool') {
|
479
|
+
return true;
|
480
|
+
} else {
|
481
|
+
return false;
|
482
|
+
}
|
483
|
+
},
|
484
|
+
isString: function() {
|
485
|
+
if (this.dataType === 'string') {
|
486
|
+
return true;
|
487
|
+
} else {
|
488
|
+
return false;
|
489
|
+
}
|
490
|
+
},
|
491
|
+
hasRestrictedMax: function() {
|
492
|
+
if (this.max !== null && this.restrictMax) {
|
493
|
+
return true;
|
494
|
+
} else {
|
495
|
+
return false;
|
496
|
+
}
|
497
|
+
},
|
498
|
+
hasRestrictedMin: function() {
|
499
|
+
if (this.min !== null && this.restrictMin) {
|
500
|
+
return true;
|
501
|
+
} else {
|
502
|
+
return false;
|
503
|
+
}
|
504
|
+
},
|
505
|
+
hasUnrestrictedMax: function() {
|
506
|
+
if (this.max !== null && !this.restrictMax) {
|
507
|
+
return true;
|
508
|
+
} else {
|
509
|
+
return false;
|
510
|
+
}
|
511
|
+
},
|
512
|
+
hasUnrestrictedMin: function() {
|
513
|
+
if (this.min !== null && !this.restrictMin) {
|
514
|
+
return true;
|
515
|
+
} else {
|
516
|
+
return false;
|
517
|
+
}
|
518
|
+
},
|
519
|
+
inputIcon: function() {
|
520
|
+
if (this.isDate && !this.init) {
|
521
|
+
return 'fa-calendar';
|
493
522
|
}
|
494
523
|
}
|
495
|
-
}
|
524
|
+
}
|
496
525
|
});
|
497
526
|
})();
|