rb-document-form-constructor 0.6.0 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5222,6 +5222,7 @@ var UtFormConstructor = {
5222
5222
  runRule: function runRule(context, script) {
5223
5223
  context = context ? context : {};
5224
5224
  context['console'] = console;
5225
+ context['Date'] = new Date();
5225
5226
 
5226
5227
  var func = function func(script) {
5227
5228
  return notevil(script, context);
@@ -11108,6 +11109,7 @@ var script$3 = {
11108
11109
  formConfig: function formConfig() {
11109
11110
  this.validationState = {};
11110
11111
  this.execApplyDefaultValues();
11112
+ this.execApplyDefaultValRule();
11111
11113
  }
11112
11114
  },
11113
11115
  methods: {
@@ -11209,13 +11211,34 @@ var script$3 = {
11209
11211
  });
11210
11212
  });
11211
11213
  }
11214
+ },
11215
+ execApplyDefaultValRule: function execApplyDefaultValRule() {
11216
+ var _this4 = this;
11217
+
11218
+ this.formConfig.sections.forEach(function (el) {
11219
+ el.columns.forEach(function (c) {
11220
+ c.fields.forEach(function (f) {
11221
+ if (f.rules) {
11222
+ var rule = f.rules.find(function (rule) {
11223
+ return rule.event === 'defaultValue';
11224
+ });
11225
+
11226
+ if (rule) {
11227
+ _this4.$set(_this4.doc, f.name, f.defaultValue = eval(rule.script));
11228
+ }
11229
+ }
11230
+ });
11231
+ });
11232
+ });
11212
11233
  }
11213
11234
  },
11214
11235
  mounted: function mounted() {
11215
11236
  this.execApplyDefaultValues();
11237
+ this.execApplyDefaultValRule();
11216
11238
  },
11217
11239
  activated: function activated() {
11218
11240
  this.execApplyDefaultValues();
11241
+ this.execApplyDefaultValRule();
11219
11242
  }
11220
11243
  };/* script */
11221
11244
  var __vue_script__$3 = script$3;
@@ -11279,7 +11302,8 @@ var __vue_render__$3 = function __vue_render__() {
11279
11302
  attrs: {
11280
11303
  "disabled": !_vm.editable || !field.editable,
11281
11304
  "id": field.name,
11282
- "state": _vm.validationState[field.name]
11305
+ "state": _vm.validationState[field.name],
11306
+ "required": field.required
11283
11307
  },
11284
11308
  on: {
11285
11309
  "input": function input($event) {
@@ -11314,7 +11338,7 @@ var __vue_inject_styles__$3 = undefined;
11314
11338
  var __vue_scope_id__$3 = undefined;
11315
11339
  /* module identifier */
11316
11340
 
11317
- var __vue_module_identifier__$3 = "data-v-519938d8";
11341
+ var __vue_module_identifier__$3 = "data-v-65467378";
11318
11342
  /* functional template */
11319
11343
 
11320
11344
  var __vue_is_functional_template__$3 = false;
@@ -11626,7 +11650,11 @@ var __vue_render__$2 = function __vue_render__() {
11626
11650
  attrs: {
11627
11651
  "value": 'validate'
11628
11652
  }
11629
- }, [_vm._v("\n Валидация\n ")])], 1)], 1)], 1), _vm._v(" "), _c('b-col', {
11653
+ }, [_vm._v("\n Валидация\n ")]), _vm._v(" "), _c('b-form-select-option', {
11654
+ attrs: {
11655
+ "value": 'defaultValue'
11656
+ }
11657
+ }, [_vm._v("\n Установить значение по умолчанию\n ")])], 1)], 1)], 1), _vm._v(" "), _c('b-col', {
11630
11658
  attrs: {
11631
11659
  "lg": "12"
11632
11660
  }
@@ -11734,7 +11762,7 @@ var __vue_inject_styles__$2 = undefined;
11734
11762
  var __vue_scope_id__$2 = undefined;
11735
11763
  /* module identifier */
11736
11764
 
11737
- var __vue_module_identifier__$2 = "data-v-397a42e7";
11765
+ var __vue_module_identifier__$2 = "data-v-2b82f62a";
11738
11766
  /* functional template */
11739
11767
 
11740
11768
  var __vue_is_functional_template__$2 = false;
@@ -11991,22 +12019,6 @@ var __vue_render__$1 = function __vue_render__() {
11991
12019
  attrs: {
11992
12020
  "lg": "12"
11993
12021
  }
11994
- }, [_c('b-checkbox', {
11995
- attrs: {
11996
- "size": "lg",
11997
- "disabled": !_vm.hasMultipleInputTypes
11998
- },
11999
- model: {
12000
- value: _vm.field.multiple,
12001
- callback: function callback($$v) {
12002
- _vm.$set(_vm.field, "multiple", $$v);
12003
- },
12004
- expression: "field.multiple"
12005
- }
12006
- }, [_vm._v("\n Множественное\n ")])], 1)], 1), _vm._v(" "), _c('b-form-row', [_c('b-col', {
12007
- attrs: {
12008
- "lg": "12"
12009
- }
12010
12022
  }, [_c('b-checkbox', {
12011
12023
  attrs: {
12012
12024
  "size": "lg"
@@ -12052,7 +12064,7 @@ var __vue_render__$1 = function __vue_render__() {
12052
12064
  staticClass: "rb-form-section"
12053
12065
  }, [_c('div', {
12054
12066
  staticClass: "rb-title"
12055
- }, [_vm._v("\n Настройки ввода\n ")]), _vm._v(" "), _c('b-form-row', [_c('b-col', {
12067
+ }, [_vm._v("\n Настройки ввода\n ")]), _vm._v(" "), _c('b-form-row', [_c('b-col', {
12056
12068
  attrs: {
12057
12069
  "lg": "12"
12058
12070
  }
@@ -12172,7 +12184,7 @@ var __vue_inject_styles__$1 = undefined;
12172
12184
  var __vue_scope_id__$1 = undefined;
12173
12185
  /* module identifier */
12174
12186
 
12175
- var __vue_module_identifier__$1 = "data-v-48140b1d";
12187
+ var __vue_module_identifier__$1 = "data-v-a0db2474";
12176
12188
  /* functional template */
12177
12189
 
12178
12190
  var __vue_is_functional_template__$1 = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rb-document-form-constructor",
3
- "version": "0.6.0",
3
+ "version": "0.6.3",
4
4
  "description": "",
5
5
  "main": "dist/rb-document-form-constructor.ssr.js",
6
6
  "browser": "dist/rb-document-form-constructor.esm.js",
@@ -7,7 +7,7 @@
7
7
  class="rb-form-section">
8
8
  <b-row>
9
9
  <b-col lg="12">
10
- <h4>{{section.labelRu}}</h4>
10
+ <h4>{{ section.labelRu }}</h4>
11
11
  </b-col>
12
12
  <template v-for="column in section.columns">
13
13
  <b-col :key="column.index" :lg="getColumnSize(section)" :sm="12">
@@ -23,14 +23,15 @@
23
23
  :id="field.name"
24
24
  :state="validationState[field.name]"
25
25
  :ref="field.name"
26
+ :required="field.required"
26
27
  @input="onEventFired('input', $event, field)"
27
28
  @change="onEventFired('change', $event, field)"
28
29
  @click="onEventFired('click', $event, field)"
29
30
  v-bind="field.input.propsData"></component>
30
31
  <template #label>
31
- <span :title="field.labelRu">{{field.labelRu}}</span> <span
32
- v-if="showRequiredInLabel && field.required"
33
- class="text-danger">*</span>
32
+ <span :title="field.labelRu">{{ field.labelRu }}</span>
33
+ <span v-if="showRequiredInLabel && field.required"
34
+ class="text-danger">*</span>
34
35
  </template>
35
36
  </b-form-group>
36
37
  </b-col>
@@ -45,133 +46,155 @@
45
46
  </template>
46
47
 
47
48
  <script>
48
- import Vue from 'vue';
49
- import {UtFormConstructor} from "../utils/UtFormConstructor";
50
- import typeOf from 'typeof';
49
+ import Vue from 'vue';
50
+ import {UtFormConstructor} from "../utils/UtFormConstructor";
51
+ import typeOf from 'typeof';
52
+ import safeEval from "notevil";
51
53
 
52
- export default {
53
- name: 'DocForm',
54
- props: {
55
- formConfig: Object,
56
- applyDefaultValues: {type: Boolean, default: true},
57
- doc: {type: Object, default: () => ({})},
58
- refSuffix: {type: String, default: 'Id'},
59
- editable: {type: Boolean, default: true},
60
- showRequiredInLabel: {type: Boolean, default: true},
61
- },
62
- data() {
63
- return {
64
- validationState: {}
54
+ export default {
55
+ name: 'DocForm',
56
+ props: {
57
+ formConfig: Object,
58
+ applyDefaultValues: {type: Boolean, default: true},
59
+ doc: {type: Object, default: () => ({})},
60
+ refSuffix: {type: String, default: 'Id'},
61
+ editable: {type: Boolean, default: true},
62
+ showRequiredInLabel: {type: Boolean, default: true},
63
+ },
64
+ data() {
65
+ return {
66
+ validationState: {}
67
+ }
68
+ },
69
+ watch: {
70
+ formConfig() {
71
+ this.validationState = {};
72
+ this.execApplyDefaultValues();
73
+ this.execApplyDefaultValRule();
74
+ }
75
+ },
76
+ methods: {
77
+ onEventFired(eventName, event, field) {
78
+ if (eventName === 'input' && field.ref && !field.multiple) {
79
+ let dataField = null;
80
+ if (field.name.lastIndexOf(this.refSuffix) >= 0) {
81
+ dataField = field.name.substring(0, field.name.lastIndexOf(this.refSuffix));
82
+ }
83
+
84
+ if (dataField && dataField.length > 0) {
85
+ this.doc[dataField] = null;
86
+ }
65
87
  }
66
- },
67
- watch: {
68
- formConfig() {
69
- this.validationState = {};
70
- this.execApplyDefaultValues();
88
+
89
+ if (field.rules) {
90
+ field.rules.forEach(rule => {
91
+ if (rule.event === eventName && rule.script) {
92
+ let ruleContext = UtFormConstructor.getRuleContext();
93
+ ruleContext.form = this;
94
+ ruleContext.doc = this.doc;
95
+ ruleContext.event = event;
96
+ ruleContext.eventName = eventName;
97
+ UtFormConstructor.runRule(ruleContext, rule.script);
98
+ }
99
+ })
71
100
  }
72
101
  },
73
- methods: {
74
- onEventFired(eventName, event, field) {
75
- if (eventName === 'input' && field.ref && !field.multiple) {
76
- let dataField = null;
77
- if (field.name.lastIndexOf(this.refSuffix) >= 0) {
78
- dataField = field.name.substring(0, field.name.lastIndexOf(this.refSuffix));
79
- }
102
+ isValueEmpty(fieldName) {
103
+ if (this.doc[fieldName] == null) {
104
+ return true;
105
+ }
80
106
 
81
- if (dataField && dataField.length > 0) {
82
- this.doc[dataField] = null;
83
- }
84
- }
107
+ if (typeOf(this.doc[fieldName] === 'string') && this.doc[fieldName] === '') {
108
+ return true;
109
+ }
85
110
 
86
- if (field.rules) {
87
- field.rules.forEach(rule => {
88
- if (rule.event === eventName && rule.script) {
89
- let ruleContext = UtFormConstructor.getRuleContext();
90
- ruleContext.form = this;
91
- ruleContext.doc = this.doc;
92
- ruleContext.event = event;
93
- ruleContext.eventName = eventName;
94
- UtFormConstructor.runRule(ruleContext, rule.script);
111
+ return false;
112
+ },
113
+ validate() {
114
+ this.formConfig.sections.forEach(s => {
115
+ s.columns.forEach(c => {
116
+ c.fields.forEach(f => {
117
+ if (f.required && this.isValueEmpty(f.name)) {
118
+ Vue.set(this.validationState, f.name, false);
119
+ Vue.set(this.validationState, `${f.name}__feedback`,
120
+ `Поле "${f.labelRu} обязательно"`);
121
+ } else {
122
+ Vue.set(this.validationState, f.name, null);
95
123
  }
124
+
125
+ this.onEventFired('validate', {
126
+ validationState: this.validationState,
127
+ doc: this.doc,
128
+ }, f);
96
129
  })
97
- }
98
- },
99
- isValueEmpty(fieldName) {
100
- if (this.doc[fieldName] == null) {
101
- return true;
102
- }
130
+ })
131
+ });
103
132
 
104
- if (typeOf(this.doc[fieldName] === 'string') && this.doc[fieldName] === '') {
105
- return true;
133
+ for (let fieldName in this.validationState) {
134
+ if (this.validationState[fieldName] === false) {
135
+ return false;
106
136
  }
137
+ }
138
+
139
+ return true;
140
+ },
141
+ getColumnSize(section) {
142
+ const MAX_COLUMN_SIZE = 12;
143
+ if (!section || !section.columnCount) {
144
+ return MAX_COLUMN_SIZE;
145
+ }
107
146
 
108
- return false;
109
- },
110
- validate() {
111
- this.formConfig.sections.forEach(s => {
112
- s.columns.forEach(c => {
147
+ let colSize = Math.floor(MAX_COLUMN_SIZE / section.columnCount);
148
+ return colSize;
149
+ },
150
+ execApplyDefaultValues() {
151
+ if (this.applyDefaultValues) {
152
+ this.formConfig.sections.forEach(r => {
153
+ r.columns.forEach(c => {
113
154
  c.fields.forEach(f => {
114
- if (f.required && this.isValueEmpty(f.name)) {
115
- Vue.set(this.validationState, f.name, false);
116
- Vue.set(this.validationState, `${f.name}__feedback`,
117
- `Поле "${f.labelRu} обязательно"`);
155
+ let defValue;
156
+ if (this.defaultValue && typeOf(f.defaultValue) === 'function') {
157
+ defValue = f.defaultValue();
118
158
  } else {
119
- Vue.set(this.validationState, f.name, null);
159
+ defValue = f.defaultValue == null ? null : f.defaultValue;
120
160
  }
121
161
 
122
- this.onEventFired('validate', {
123
- validationState: this.validationState,
124
- doc: this.doc,
125
- }, f);
162
+ this.$set(
163
+ this.doc,
164
+ f.name,
165
+ f.defaultValue = defValue
166
+ );
126
167
  })
127
- })
168
+ });
128
169
  });
129
-
130
- for (let fieldName in this.validationState) {
131
- if (this.validationState[fieldName] === false) {
132
- return false;
133
- }
134
- }
135
-
136
- return true;
137
- },
138
- getColumnSize(section) {
139
- const MAX_COLUMN_SIZE = 12;
140
- if (!section || !section.columnCount) {
141
- return MAX_COLUMN_SIZE;
142
- }
143
-
144
- let colSize = Math.floor(MAX_COLUMN_SIZE / section.columnCount);
145
- return colSize;
146
- },
147
- execApplyDefaultValues() {
148
- if (this.applyDefaultValues) {
149
- this.formConfig.sections.forEach(r => {
150
- r.columns.forEach(c => {
151
- c.fields.forEach(f => {
152
- let defValue;
153
- if (this.defaultValue && typeOf(f.defaultValue) === 'function') {
154
- defValue = f.defaultValue();
155
- } else {
156
- defValue = f.defaultValue == null ? null : f.defaultValue;
157
- }
158
-
170
+ }
171
+ },
172
+ execApplyDefaultValRule() {
173
+ this.formConfig.sections.forEach(el => {
174
+ el.columns.forEach(c => {
175
+ c.fields.forEach(f => {
176
+ if (f.rules) {
177
+ const rule = f.rules.find(rule => rule.event === 'defaultValue')
178
+ if (rule) {
159
179
  this.$set(
160
180
  this.doc,
161
181
  f.name,
162
- f.defaultValue = defValue
182
+ f.defaultValue = eval(rule.script)
163
183
  );
164
- })
165
- });
166
- });
167
- }
168
- }
169
- },
170
- mounted() {
171
- this.execApplyDefaultValues();
172
- },
173
- activated() {
174
- this.execApplyDefaultValues();
184
+ }
185
+ }
186
+ })
187
+ });
188
+ });
175
189
  }
190
+ },
191
+ mounted() {
192
+ this.execApplyDefaultValues();
193
+ this.execApplyDefaultValRule();
194
+ },
195
+ activated() {
196
+ this.execApplyDefaultValues();
197
+ this.execApplyDefaultValRule();
176
198
  }
199
+ }
177
200
  </script>
@@ -38,13 +38,13 @@
38
38
  </b-form-group>
39
39
  </b-col>
40
40
  </b-form-row>
41
- <b-form-row>
42
- <b-col lg="12">
43
- <b-checkbox size="lg" v-model="field.multiple" :disabled="!hasMultipleInputTypes">
44
- Множественное
45
- </b-checkbox>
46
- </b-col>
47
- </b-form-row>
41
+ <!-- <b-form-row>-->
42
+ <!-- <b-col lg="12">-->
43
+ <!-- <b-checkbox size="lg" v-model="field.multiple" :disabled="!hasMultipleInputTypes">-->
44
+ <!-- Множественное-->
45
+ <!-- </b-checkbox>-->
46
+ <!-- </b-col>-->
47
+ <!-- </b-form-row>-->
48
48
  <b-form-row>
49
49
  <b-col lg="12">
50
50
  <b-checkbox size="lg" v-model="field.visible">Отображаемое</b-checkbox>
@@ -56,6 +56,9 @@
56
56
  <b-form-select-option :value="'validate'">
57
57
  Валидация
58
58
  </b-form-select-option>
59
+ <b-form-select-option :value="'defaultValue'">
60
+ Установить значение по умолчанию
61
+ </b-form-select-option>
59
62
  </b-form-select>
60
63
  </b-form-group>
61
64
  </b-col>
@@ -1,75 +0,0 @@
1
- This webfont is generated by https://fontello.com open source project.
2
-
3
-
4
- ================================================================================
5
- Please, note, that you should obey original font licenses, used to make this
6
- webfont pack. Details available in LICENSE.txt file.
7
-
8
- - Usually, it's enough to publish content of LICENSE.txt file somewhere on your
9
- site in "About" section.
10
-
11
- - If your project is open-source, usually, it will be ok to make LICENSE.txt
12
- file publicly available in your repository.
13
-
14
- - Fonts, used in Fontello, don't require a clickable link on your site.
15
- But any kind of additional authors crediting is welcome.
16
- ================================================================================
17
-
18
-
19
- Comments on archive content
20
- ---------------------------
21
-
22
- - /font/* - fonts in different formats
23
-
24
- - /css/* - different kinds of css, for all situations. Should be ok with
25
- twitter bootstrap. Also, you can skip <i> style and assign icon classes
26
- directly to text elements, if you don't mind about IE7.
27
-
28
- - demo.html - demo file, to show your webfont content
29
-
30
- - LICENSE.txt - license info about source fonts, used to build your one.
31
-
32
- - config.json - keeps your settings. You can import it back into fontello
33
- anytime, to continue your work
34
-
35
-
36
- Why so many CSS files ?
37
- -----------------------
38
-
39
- Because we like to fit all your needs :)
40
-
41
- - basic file, <your_font_name>.css - is usually enough, it contains @font-face
42
- and character code definitions
43
-
44
- - *-ie7.css - if you need IE7 support, but still don't wish to put char codes
45
- directly into html
46
-
47
- - *-codes.css and *-ie7-codes.css - if you like to use your own @font-face
48
- rules, but still wish to benefit from css generation. That can be very
49
- convenient for automated asset build systems. When you need to update font -
50
- no need to manually edit files, just override old version with archive
51
- content. See fontello source code for examples.
52
-
53
- - *-embedded.css - basic css file, but with embedded WOFF font, to avoid
54
- CORS issues in Firefox and IE9+, when fonts are hosted on the separate domain.
55
- We strongly recommend to resolve this issue by `Access-Control-Allow-Origin`
56
- server headers. But if you ok with dirty hack - this file is for you. Note,
57
- that data url moved to separate @font-face to avoid problems with <IE9, when
58
- string is too long.
59
-
60
- - animate.css - use it to get ideas about spinner rotation animation.
61
-
62
-
63
- Attention for server setup
64
- --------------------------
65
-
66
- You MUST setup server to reply with proper `mime-types` for font files -
67
- otherwise some browsers will fail to show fonts.
68
-
69
- Usually, `apache` already has necessary settings, but `nginx` and other
70
- webservers should be tuned. Here is list of mime types for our file extensions:
71
-
72
- - `application/vnd.ms-fontobject` - eot
73
- - `application/x-font-woff` - woff
74
- - `application/x-font-ttf` - ttf
75
- - `image/svg+xml` - svg