rb-document-form-constructor 0.9.14 → 0.9.16

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.
@@ -5,30 +5,31 @@ const UtFormConfig = {
5
5
  if (!formConfig || !formConfig.sections) {
6
6
  return null;
7
7
  }
8
+
8
9
  let found = null;
9
- formConfig.sections.every(r => {
10
+ formConfig.sections.forEach(r => {
11
+ console.info(r);
12
+
10
13
  if (r.columns) {
11
- r.columns.every(c => {
14
+ r.columns.forEach(c => {
12
15
  c.fields.forEach(f => {
16
+ console.info(f.name);
17
+
13
18
  if (f.name === fieldName) {
14
19
  found = f;
15
20
  }
16
21
  });
17
- if (found) {
18
- return false;
19
- }
20
22
  });
21
23
  }
22
- if (found) {
23
- return false;
24
- }
25
24
  });
26
25
  return found;
27
26
  },
27
+
28
28
  findRule(ruleId, formConfig) {
29
29
  if (!formConfig || !formConfig.sections) {
30
30
  return null;
31
31
  }
32
+
32
33
  let found = null;
33
34
  formConfig.sections.every(s => {
34
35
  if (s.columns) {
@@ -41,21 +42,25 @@ const UtFormConfig = {
41
42
  }
42
43
  });
43
44
  }
45
+
44
46
  if (found) {
45
47
  return false;
46
48
  }
47
49
  });
50
+
48
51
  if (found) {
49
52
  return false;
50
53
  }
51
54
  });
52
55
  }
56
+
53
57
  if (found) {
54
58
  return false;
55
59
  }
56
60
  });
57
61
  return found;
58
62
  },
63
+
59
64
  getFields(formConfig) {
60
65
  let fields = [];
61
66
  formConfig.sections.forEach(s => {
@@ -71,6 +76,7 @@ const UtFormConfig = {
71
76
  });
72
77
  return fields;
73
78
  },
79
+
74
80
  parseFacets(formConfig) {
75
81
  let facets = [];
76
82
  formConfig.sections.forEach(section => {
@@ -84,24 +90,31 @@ const UtFormConfig = {
84
90
  });
85
91
  return facets;
86
92
  }
93
+
87
94
  };
88
95
 
89
96
  let __clone = function (data) {
90
97
  return JSON.parse(JSON.stringify(data));
91
98
  };
99
+
92
100
  let __assign = function () {
93
101
  __assign = Object.assign || function __assign(t) {
94
102
  for (let s, i = 1, n = arguments.length; i < n; i++) {
95
103
  s = arguments[i];
104
+
96
105
  for (let p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
97
106
  }
107
+
98
108
  return t;
99
109
  };
110
+
100
111
  return __assign.apply(this, arguments);
101
112
  };
113
+
102
114
  let __mergeInputInMapOfArrays = function (inputs, formConfigInputs) {
103
115
  for (let dataType in formConfigInputs) {
104
116
  let foundInputs = inputs[dataType];
117
+
105
118
  if (foundInputs) {
106
119
  __mergeInputsInArray(foundInputs, formConfigInputs[dataType]);
107
120
  } else {
@@ -109,14 +122,17 @@ let __mergeInputInMapOfArrays = function (inputs, formConfigInputs) {
109
122
  }
110
123
  }
111
124
  };
125
+
112
126
  let __mergeInputsInMap = function (inputs, formConfigInputs) {
113
127
  for (let name in formConfigInputs) {
114
128
  inputs[name] = __assign(inputs[name] ? inputs[name] : {}, formConfigInputs[name] ? formConfigInputs[name] : {});
115
129
  }
116
130
  };
131
+
117
132
  let __mergeInputsInArray = function (inputs, formConfigInputs) {
118
133
  formConfigInputs.forEach(input => {
119
134
  let index = inputs.findIndex(item => item.name === input.name);
135
+
120
136
  if (index >= 0) {
121
137
  inputs[index] = input;
122
138
  } else {
@@ -124,13 +140,16 @@ let __mergeInputsInArray = function (inputs, formConfigInputs) {
124
140
  }
125
141
  });
126
142
  };
143
+
127
144
  let __applyDefaultProps = function (input, field) {
128
145
  for (let propName in input.props) {
129
146
  if (field) {
130
147
  if (field.input.propsData[propName]) {
131
- var _input$propsData, _input$props;
148
+ var _input$propsData, _input$props, _input$props$type;
149
+
132
150
  input.propsData[propName] = field.input.propsData[propName];
133
- if ((_input$propsData = input.propsData) !== null && _input$propsData !== void 0 && _input$propsData.type && (_input$props = input.props) !== null && _input$props !== void 0 && (_input$props = _input$props.type) !== null && _input$props !== void 0 && _input$props.default) {
151
+
152
+ if ((_input$propsData = input.propsData) !== null && _input$propsData !== void 0 && _input$propsData.type && (_input$props = input.props) !== null && _input$props !== void 0 && (_input$props$type = _input$props.type) !== null && _input$props$type !== void 0 && _input$props$type.default) {
134
153
  input.propsData.type = input.props.type.default;
135
154
  }
136
155
  }
@@ -139,6 +158,7 @@ let __applyDefaultProps = function (input, field) {
139
158
  }
140
159
  }
141
160
  };
161
+
142
162
  let __applyRefProps = function (input, refConfig) {
143
163
  if (refConfig !== null && refConfig !== void 0 && refConfig.propsData) {
144
164
  for (let propName in refConfig.propsData) {
@@ -146,11 +166,13 @@ let __applyRefProps = function (input, refConfig) {
146
166
  }
147
167
  }
148
168
  };
169
+
149
170
  let __filterInputsByMultiple = function (inputs, multiple) {
150
171
  return inputs.filter(i => {
151
172
  return i.multiple && multiple || !i.multiple && !multiple;
152
173
  });
153
174
  };
175
+
154
176
  let fcInputs = {
155
177
  string: {
156
178
  text: 'Текст',
@@ -352,40 +374,52 @@ let baseConfig = {
352
374
  };
353
375
  const UtFormConstructor = {
354
376
  config: {},
377
+
355
378
  init(formConfig) {
356
379
  this.config = __clone(baseConfig);
380
+
357
381
  if (formConfig) {
358
382
  if (formConfig.inputs) {
359
383
  __mergeInputsInMap(this.config.inputs, formConfig.inputs);
360
384
  }
385
+
361
386
  if (formConfig.primitiveInputs) {
362
387
  __mergeInputInMapOfArrays(this.config.primitiveInputs, formConfig.primitiveInputs);
363
388
  }
389
+
364
390
  if (formConfig.dictInputs) {
365
391
  __mergeInputsInArray(this.config.dictInputs, formConfig.dictInputs);
366
392
  }
393
+
367
394
  if (formConfig.refInputs) {
368
395
  __mergeInputInMapOfArrays(this.config.refInputs, formConfig.refInputs);
369
396
  }
397
+
370
398
  if (formConfig.refInputConfigs) {
371
399
  this.config.refInputConfigs = formConfig.refInputConfigs;
372
400
  }
401
+
373
402
  if (formConfig.icons) {
374
403
  this.config.icons = __assign(this.config.icons, formConfig.icons);
375
404
  }
405
+
376
406
  if (formConfig.rules) {
377
407
  this.config.rules = formConfig.rules;
378
408
  }
409
+
379
410
  if (formConfig.ruleContext) {
380
411
  this.config.ruleContext = formConfig.ruleContext;
381
412
  }
382
413
  }
383
414
  },
415
+
384
416
  getInputTypes(field) {
385
417
  let inputs = [];
418
+
386
419
  if (!field) {
387
420
  return inputs;
388
421
  }
422
+
389
423
  if (field.dict && !this.config.refInputs[field.ref]) {
390
424
  inputs = __filterInputsByMultiple(this.config.dictInputs, field.multiple);
391
425
  } else if (field.ref) {
@@ -393,76 +427,98 @@ const UtFormConstructor = {
393
427
  } else {
394
428
  inputs = __filterInputsByMultiple(this.config.primitiveInputs[field.type], field.multiple);
395
429
  }
430
+
396
431
  return inputs;
397
432
  },
433
+
398
434
  hasMultipleInputTypes(field) {
399
- let inputs = this.getInputTypes({
400
- ...field,
435
+ let inputs = this.getInputTypes({ ...field,
401
436
  multiple: true
402
437
  });
403
438
  return inputs && inputs.length > 0;
404
439
  },
440
+
405
441
  getDefaultInput(field) {
406
442
  let input = null;
407
443
  let inputs = this.getInputTypes(field);
444
+
408
445
  if (!inputs) {
409
446
  input = this.primitiveInputs[0];
410
447
  }
448
+
411
449
  if (field.ref && this.config.refInputs[field.ref]) {
412
450
  input = __clone(inputs[0]);
451
+
413
452
  __applyDefaultProps(input);
453
+
414
454
  if (this.config.refInputConfigs[field.ref] && this.config.refInputConfigs[field.ref][input.name]) {
415
455
  __applyRefProps(input, this.config.refInputConfigs[field.ref][input.name]);
416
456
  }
417
457
  } else if (field.dict) {
418
458
  input = __clone(inputs[0]);
419
459
  input.props.dict.default = field.ref;
460
+
420
461
  __applyDefaultProps(input);
421
462
  } else {
422
463
  input = __clone(inputs[0]);
464
+
423
465
  __applyDefaultProps(input);
424
466
  }
467
+
425
468
  return input;
426
469
  },
470
+
427
471
  getInputTypeByName(name, field) {
428
472
  let input = __clone(this.config.inputs[name]);
473
+
429
474
  if (field.ref && this.config.refInputs[field.ref]) {
430
475
  __applyDefaultProps(input);
476
+
431
477
  if (this.config.refInputConfigs[field.ref] && this.config.refInputConfigs[field.ref][input.name]) {
432
478
  __applyRefProps(input, this.config.refInputConfigs[field.ref][input.name]);
433
479
  }
434
480
  } else if (field.dict) {
435
481
  input.props.dict.default = field.ref;
436
- __applyDefaultProps(input);
482
+
483
+ __applyDefaultProps(input, field);
437
484
  } else {
438
485
  __applyDefaultProps(input, field);
439
486
  }
487
+
440
488
  input.propsData['ref'] = field.name;
441
489
  return input;
442
490
  },
491
+
443
492
  getAvailableFieldRules(field) {
444
493
  return this.config.rules.filter(rule => {
445
494
  return !rule.fields || rule.fields.length === 0 || rule.fields.indexOf(field.name) >= 0;
446
495
  });
447
496
  },
497
+
448
498
  getRuleContext() {
449
499
  return this.config.ruleContext;
450
500
  },
501
+
451
502
  runRule(context, script) {
452
503
  context = context ? context : {};
453
504
  context['console'] = console;
454
505
  context['Date'] = Date;
455
506
  context['Math'] = Math;
456
507
  let appendScript = '';
508
+
457
509
  for (let v in context) {
458
510
  appendScript = appendScript + `var ${v} = this.${v};\n`;
459
511
  }
512
+
460
513
  appendScript = appendScript ? appendScript + '\n' : '';
514
+
461
515
  let func = function (script) {
462
516
  return eval(script);
463
517
  };
518
+
464
519
  func.call(context, appendScript + script);
465
520
  }
521
+
466
522
  };
467
523
 
468
524
  //
@@ -484,7 +540,6 @@ const UtFormConstructor = {
484
540
  //
485
541
  //
486
542
  //
487
-
488
543
  var script$5 = {
489
544
  name: 'DocTemplateSectionModal',
490
545
  props: {
@@ -498,16 +553,19 @@ var script$5 = {
498
553
  default: () => {}
499
554
  }
500
555
  },
556
+
501
557
  data() {
502
558
  return {
503
559
  id: 'rb-doc-template-section-modal',
504
560
  label: {}
505
561
  };
506
562
  },
563
+
507
564
  computed: {
508
565
  title() {
509
566
  return this.mode === 'ins' ? 'Добавление секции' : 'Редактирование секции';
510
567
  }
568
+
511
569
  },
512
570
  watch: {
513
571
  section() {
@@ -515,23 +573,29 @@ var script$5 = {
515
573
  this.label = this.section;
516
574
  }
517
575
  }
576
+
518
577
  },
519
578
  methods: {
520
579
  onOk() {
521
580
  this.section = this.label;
581
+
522
582
  if (this.onAfterOk) {
523
583
  this.onAfterOk();
524
584
  }
585
+
525
586
  this.$nextTick(() => {
526
587
  this.$bvModal.hide(this.id);
527
588
  });
528
589
  }
590
+
529
591
  },
592
+
530
593
  created() {
531
594
  if (this.section) {
532
595
  this.label = this.section;
533
596
  }
534
597
  }
598
+
535
599
  };
536
600
 
537
601
  function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
@@ -611,12 +675,15 @@ function normalizeComponent(template, style, script, scopeId, isFunctionalTempla
611
675
 
612
676
  /* script */
613
677
  const __vue_script__$5 = script$5;
614
-
615
678
  /* template */
679
+
616
680
  var __vue_render__$5 = function () {
617
681
  var _vm = this;
682
+
618
683
  var _h = _vm.$createElement;
684
+
619
685
  var _c = _vm._self._c || _h;
686
+
620
687
  return _c('b-modal', {
621
688
  attrs: {
622
689
  "id": "rb-doc-template-section-modal",
@@ -657,15 +724,19 @@ var __vue_render__$5 = function () {
657
724
  }
658
725
  })], 1)], 1)], 1)], 1)], 1);
659
726
  };
660
- var __vue_staticRenderFns__$5 = [];
661
727
 
728
+ var __vue_staticRenderFns__$5 = [];
662
729
  /* style */
730
+
663
731
  const __vue_inject_styles__$5 = undefined;
664
732
  /* scoped */
733
+
665
734
  const __vue_scope_id__$5 = undefined;
666
735
  /* module identifier */
736
+
667
737
  const __vue_module_identifier__$5 = undefined;
668
738
  /* functional template */
739
+
669
740
  const __vue_is_functional_template__$5 = false;
670
741
  /* style inject */
671
742
 
@@ -677,6 +748,7 @@ const __vue_component__$6 = /*#__PURE__*/normalizeComponent({
677
748
  render: __vue_render__$5,
678
749
  staticRenderFns: __vue_staticRenderFns__$5
679
750
  }, __vue_inject_styles__$5, __vue_script__$5, __vue_scope_id__$5, __vue_is_functional_template__$5, __vue_module_identifier__$5, false, undefined, undefined, undefined);
751
+
680
752
  var DocTemplateSectionModal = __vue_component__$6;
681
753
 
682
754
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -6079,6 +6151,7 @@ var script$4 = {
6079
6151
  default: () => []
6080
6152
  }
6081
6153
  },
6154
+
6082
6155
  data() {
6083
6156
  return {
6084
6157
  allFacets: [],
@@ -6086,21 +6159,26 @@ var script$4 = {
6086
6159
  facetSearchStr: null
6087
6160
  };
6088
6161
  },
6162
+
6089
6163
  computed: {
6090
6164
  iconExpandFacet() {
6091
6165
  return UtFormConstructor.config.icons.iconExpandFacet;
6092
6166
  },
6167
+
6093
6168
  iconCollapseFacet() {
6094
6169
  return UtFormConstructor.config.icons.iconCollapseFacet;
6095
6170
  }
6171
+
6096
6172
  },
6097
6173
  watch: {
6098
6174
  facetSearchStr() {
6099
6175
  this.findInFacets(this.facetSearchStr);
6100
6176
  },
6177
+
6101
6178
  facets() {
6102
6179
  this.handleFacetsProp();
6103
6180
  }
6181
+
6104
6182
  },
6105
6183
  methods: {
6106
6184
  onFieldCloned(cloneField) {
@@ -6108,55 +6186,69 @@ var script$4 = {
6108
6186
  field.input = UtFormConstructor.getDefaultInput(field);
6109
6187
  return field;
6110
6188
  },
6189
+
6111
6190
  onFieldMoveEnd(event) {
6112
6191
  this.$emit('fieldMoveEnd', event);
6113
6192
  },
6193
+
6114
6194
  findInFacets(str) {
6115
6195
  str = str.toLowerCase();
6196
+
6116
6197
  if (!str || str.length === 0) {
6117
6198
  this.innerFacets = this.allFacets;
6118
6199
  }
6200
+
6119
6201
  let facets = JSON.parse(JSON.stringify(this.allFacets));
6120
6202
  facets = facets.filter(facet => {
6121
6203
  let facetFound = false;
6122
6204
  facet.fields = facet.fields.filter(field => {
6123
6205
  let fieldFound = field.labelRu.toLowerCase().indexOf(str) >= 0 || field.name.toLowerCase().indexOf(str) >= 0;
6206
+
6124
6207
  if (fieldFound) {
6125
6208
  facetFound = true;
6126
6209
  }
6210
+
6127
6211
  return fieldFound;
6128
6212
  });
6129
6213
  return facetFound;
6130
6214
  });
6131
6215
  this.innerFacets = facets;
6132
6216
  },
6217
+
6133
6218
  handleFacetsProp() {
6134
- let innerFacets = this.facets.map(f => ({
6135
- ...f,
6219
+ let innerFacets = this.facets.map(f => ({ ...f,
6136
6220
  expanded: false
6137
6221
  }));
6222
+
6138
6223
  if (innerFacets) {
6139
6224
  innerFacets.forEach(facet => {
6140
6225
  facet.fields = facet.fields.filter(field => !field.hiddenOnFormConfig);
6141
6226
  });
6142
6227
  }
6228
+
6143
6229
  this.innerFacets = JSON.parse(JSON.stringify(innerFacets));
6144
6230
  this.allFacets = JSON.parse(JSON.stringify(innerFacets));
6145
6231
  }
6232
+
6146
6233
  },
6234
+
6147
6235
  created() {
6148
6236
  this.handleFacetsProp();
6149
6237
  }
6238
+
6150
6239
  };
6151
6240
 
6152
6241
  /* script */
6153
6242
  const __vue_script__$4 = script$4;
6154
-
6155
6243
  /* template */
6244
+
6156
6245
  var __vue_render__$4 = function () {
6157
6246
  var _vm = this;
6247
+
6158
6248
  var _h = _vm.$createElement;
6249
+
6159
6250
  var _c = _vm._self._c || _h;
6251
+
6160
6252
  return _c('div', {
6161
6253
  staticClass: "rb-facets-sidebar"
6162
6254
  }, [_c('div', {
@@ -6235,15 +6327,19 @@ var __vue_render__$4 = function () {
6235
6327
  }), 1)], 1) : _vm._e()], 1) : _vm._e();
6236
6328
  }), 0)], 1);
6237
6329
  };
6238
- var __vue_staticRenderFns__$4 = [];
6239
6330
 
6331
+ var __vue_staticRenderFns__$4 = [];
6240
6332
  /* style */
6333
+
6241
6334
  const __vue_inject_styles__$4 = undefined;
6242
6335
  /* scoped */
6336
+
6243
6337
  const __vue_scope_id__$4 = undefined;
6244
6338
  /* module identifier */
6339
+
6245
6340
  const __vue_module_identifier__$4 = undefined;
6246
6341
  /* functional template */
6342
+
6247
6343
  const __vue_is_functional_template__$4 = false;
6248
6344
  /* style inject */
6249
6345
 
@@ -6255,6 +6351,7 @@ const __vue_component__$5 = /*#__PURE__*/normalizeComponent({
6255
6351
  render: __vue_render__$4,
6256
6352
  staticRenderFns: __vue_staticRenderFns__$4
6257
6353
  }, __vue_inject_styles__$4, __vue_script__$4, __vue_scope_id__$4, __vue_is_functional_template__$4, __vue_module_identifier__$4, false, undefined, undefined, undefined);
6354
+
6258
6355
  var DocTemplateFacetList = __vue_component__$5;
6259
6356
 
6260
6357
  var toString = Object.prototype.toString;
@@ -6276,9 +6373,12 @@ var _typeof = function(object) {
6276
6373
  };
6277
6374
 
6278
6375
  const UtArray = {
6279
- removeDuplicate(array = [], key = 'key') {
6376
+ removeDuplicate() {
6377
+ let array = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
6378
+ let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'key';
6280
6379
  return array.filter((v, i, a) => a.findLastIndex(v2 => (v2 === null || v2 === void 0 ? void 0 : v2[key]) === (v === null || v === void 0 ? void 0 : v[key])) === i);
6281
6380
  }
6381
+
6282
6382
  };
6283
6383
 
6284
6384
  //
@@ -6315,28 +6415,34 @@ var script$3 = {
6315
6415
  default: 'container'
6316
6416
  }
6317
6417
  },
6418
+
6318
6419
  data() {
6319
6420
  return {
6320
6421
  validationState: {}
6321
6422
  };
6322
6423
  },
6424
+
6323
6425
  watch: {
6324
6426
  formConfig() {
6325
6427
  this.validationState = {};
6326
6428
  this.execApplyDefaultValues();
6327
6429
  this.execApplyDefaultValRule();
6328
6430
  }
6431
+
6329
6432
  },
6330
6433
  methods: {
6331
6434
  getResolveValueName(field) {
6332
6435
  if ((field.dict || field.ref) && !field.multiple) {
6333
6436
  return field.name.substring(0, field.name.length - 2);
6334
6437
  }
6438
+
6335
6439
  return field.name;
6336
6440
  },
6441
+
6337
6442
  getResolveValue(field) {
6338
6443
  return this.doc[this.getResolveValueName(field)] ? this.doc[this.getResolveValueName(field)] : null;
6339
6444
  },
6445
+
6340
6446
  getDisplayField(value) {
6341
6447
  if (!value[this.displayField]) {
6342
6448
  return value.labelRu;
@@ -6344,9 +6450,11 @@ var script$3 = {
6344
6450
  return value[this.displayField];
6345
6451
  }
6346
6452
  },
6453
+
6347
6454
  isResolvableField(field) {
6348
6455
  return !!field.ref;
6349
6456
  },
6457
+
6350
6458
  getResolveObject(field) {
6351
6459
  if (this.isResolvableField(field)) {
6352
6460
  let resolveFieldName = this.getResolveFieldName(field);
@@ -6355,14 +6463,19 @@ var script$3 = {
6355
6463
  return null;
6356
6464
  }
6357
6465
  },
6466
+
6358
6467
  getResolveFieldName(field) {
6359
6468
  var _resolveFieldName;
6469
+
6360
6470
  let resolveFieldName = field === null || field === void 0 ? void 0 : field.name;
6471
+
6361
6472
  if ((_resolveFieldName = resolveFieldName) !== null && _resolveFieldName !== void 0 && _resolveFieldName.endsWith('Id')) {
6362
6473
  resolveFieldName = field.name.substring(0, field.name.length - 2);
6363
6474
  }
6475
+
6364
6476
  return resolveFieldName;
6365
6477
  },
6478
+
6366
6479
  onEventFired(eventName, event, field) {
6367
6480
  if (field.rules) {
6368
6481
  field.rules.forEach(rule => {
@@ -6375,6 +6488,7 @@ var script$3 = {
6375
6488
  });
6376
6489
  }
6377
6490
  },
6491
+
6378
6492
  onGlobalEventFired(eventName, event) {
6379
6493
  let fields = UtFormConfig.getFields(this.formConfig);
6380
6494
  fields.forEach(f => {
@@ -6390,6 +6504,7 @@ var script$3 = {
6390
6504
  }
6391
6505
  });
6392
6506
  },
6507
+
6393
6508
  createRuleContext(additionalContext) {
6394
6509
  return Object.assign({
6395
6510
  form: this,
@@ -6397,66 +6512,88 @@ var script$3 = {
6397
6512
  ...additionalContext
6398
6513
  }, UtFormConstructor.getRuleContext());
6399
6514
  },
6515
+
6400
6516
  runRule(rule, context) {
6401
6517
  UtFormConstructor.runRule(this.createRuleContext(context), rule.script);
6402
6518
  },
6519
+
6403
6520
  isValueEmpty(fieldName) {
6404
6521
  var _this$doc$fieldName;
6522
+
6405
6523
  if (this.doc[fieldName] == null) {
6406
6524
  return true;
6407
6525
  }
6526
+
6408
6527
  if (Array.isArray(this.doc[fieldName]) && !((_this$doc$fieldName = this.doc[fieldName]) !== null && _this$doc$fieldName !== void 0 && _this$doc$fieldName.length)) {
6409
6528
  return true;
6410
6529
  }
6530
+
6411
6531
  if (_typeof(this.doc[fieldName] === 'string') && this.doc[fieldName] === '') {
6412
6532
  return true;
6413
6533
  }
6534
+
6414
6535
  return false;
6415
6536
  },
6537
+
6416
6538
  isValueLessThanMax(fieldname, max) {
6417
6539
  if (this.doc[fieldname] && max) {
6418
6540
  var _this$doc$fieldname;
6541
+
6419
6542
  return ((_this$doc$fieldname = this.doc[fieldname]) === null || _this$doc$fieldname === void 0 ? void 0 : _this$doc$fieldname.length) > parseInt(max);
6420
6543
  }
6544
+
6421
6545
  return false;
6422
6546
  },
6547
+
6423
6548
  isValueLessThanMin(fieldname, min) {
6424
6549
  if (this.doc[fieldname] && min) {
6425
6550
  return parseInt(this.doc[fieldname]) < parseInt(min);
6426
6551
  }
6552
+
6427
6553
  return false;
6428
6554
  },
6429
- validate(callback = () => {}) {
6555
+
6556
+ validate() {
6557
+ let callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : () => {};
6430
6558
  this.formConfig.sections.forEach(s => {
6431
6559
  s.columns.forEach(c => {
6432
6560
  c.fields.forEach(f => {
6433
6561
  var _f$input$propsData, _f$input$propsData3;
6562
+
6434
6563
  let feedback = '';
6564
+
6435
6565
  if (f.required && this.isValueEmpty(f.name)) {
6436
6566
  feedback += this.getDisplayField(f);
6437
6567
  }
6568
+
6438
6569
  if (f.type === 'integer' && this.isValueLessThanMin(f.name, f.input.propsData.min)) {
6439
6570
  feedback += f.input.propsData.min;
6440
- }
6441
- // TODO: Костыль так как на бэке нету типа memo
6571
+ } // TODO: Костыль так как на бэке нету типа memo
6572
+
6573
+
6442
6574
  if (f.input.type === 'b-form-textarea' && this.isValueLessThanMax(f.name, (_f$input$propsData = f.input.propsData) === null || _f$input$propsData === void 0 ? void 0 : _f$input$propsData.max)) {
6443
6575
  var _f$input$propsData2;
6576
+
6444
6577
  feedback += `\nМаксимальное значение для этого поля ${(_f$input$propsData2 = f.input.propsData) === null || _f$input$propsData2 === void 0 ? void 0 : _f$input$propsData2.max}`;
6445
6578
  }
6579
+
6446
6580
  if (f.required && (_f$input$propsData3 = f.input.propsData) !== null && _f$input$propsData3 !== void 0 && _f$input$propsData3.isInlineTableInput) {
6447
- var _this$$refs$f$name$0$, _this$$refs, _this$$refs$getIsDirt, _UtArray$removeDuplic;
6448
- const findErrors = (_this$$refs$f$name$0$ = (_this$$refs = this.$refs) === null || _this$$refs === void 0 || (_this$$refs = _this$$refs[f.name]) === null || _this$$refs === void 0 || (_this$$refs = _this$$refs[0]) === null || _this$$refs === void 0 || (_this$$refs$getIsDirt = _this$$refs.getIsDirty) === null || _this$$refs$getIsDirt === void 0 ? void 0 : _this$$refs$getIsDirt.call(_this$$refs)) !== null && _this$$refs$f$name$0$ !== void 0 ? _this$$refs$f$name$0$ : [];
6581
+ var _this$$refs$f$name$0$, _this$$refs, _this$$refs$f$name, _this$$refs$f$name$, _this$$refs$f$name$$g, _UtArray$removeDuplic;
6582
+
6583
+ const findErrors = (_this$$refs$f$name$0$ = (_this$$refs = this.$refs) === null || _this$$refs === void 0 ? void 0 : (_this$$refs$f$name = _this$$refs[f.name]) === null || _this$$refs$f$name === void 0 ? void 0 : (_this$$refs$f$name$ = _this$$refs$f$name[0]) === null || _this$$refs$f$name$ === void 0 ? void 0 : (_this$$refs$f$name$$g = _this$$refs$f$name$.getIsDirty) === null || _this$$refs$f$name$$g === void 0 ? void 0 : _this$$refs$f$name$$g.call(_this$$refs$f$name$)) !== null && _this$$refs$f$name$0$ !== void 0 ? _this$$refs$f$name$0$ : [];
6449
6584
  const errors = (_UtArray$removeDuplic = UtArray.removeDuplicate(findErrors, 'field')) === null || _UtArray$removeDuplic === void 0 ? void 0 : _UtArray$removeDuplic.map(f => f === null || f === void 0 ? void 0 : f.label).join(', ');
6450
6585
  feedback = errors ? this.$t('validate.multiRequired', {
6451
6586
  field: errors
6452
6587
  }) : this.isValueEmpty(f.name) ? this.getDisplayField(f) : '';
6453
6588
  }
6589
+
6454
6590
  if (feedback) {
6455
6591
  Vue.set(this.validationState, f.name, false);
6456
6592
  Vue.set(this.validationState, `${f.name}__feedback`, feedback);
6457
6593
  } else {
6458
6594
  Vue.set(this.validationState, f.name, null);
6459
6595
  }
6596
+
6460
6597
  callback(feedback, this.$refs, f, this.doc);
6461
6598
  this.onEventFired('validate', {
6462
6599
  validationState: this.validationState,
@@ -6465,24 +6602,31 @@ var script$3 = {
6465
6602
  });
6466
6603
  });
6467
6604
  });
6605
+
6468
6606
  for (let fieldName in this.validationState) {
6469
6607
  if (this.validationState[fieldName] === false) {
6470
6608
  return false;
6471
6609
  }
6472
6610
  }
6611
+
6473
6612
  return true;
6474
6613
  },
6614
+
6475
6615
  getColumnSize(section) {
6476
6616
  const MAX_COLUMN_SIZE = 12;
6617
+
6477
6618
  if (!section || !section.columnCount) {
6478
6619
  return MAX_COLUMN_SIZE;
6479
6620
  }
6621
+
6480
6622
  let colSize = Math.floor(MAX_COLUMN_SIZE / section.columnCount);
6481
6623
  return colSize;
6482
6624
  },
6625
+
6483
6626
  isNotUndefinedAndNull(value) {
6484
6627
  return !(value === null || value === undefined);
6485
6628
  },
6629
+
6486
6630
  execApplyDefaultValues() {
6487
6631
  if (this.applyDefaultValues) {
6488
6632
  this.formConfig.sections.forEach(r => {
@@ -6490,11 +6634,13 @@ var script$3 = {
6490
6634
  c.fields.forEach(f => {
6491
6635
  if (this.isNotUndefinedAndNull(f.defaultValue)) {
6492
6636
  let defValue;
6637
+
6493
6638
  if (this.defaultValue && _typeof(f.defaultValue) === 'function') {
6494
6639
  defValue = f.defaultValue();
6495
6640
  } else {
6496
6641
  defValue = f.defaultValue == null ? null : f.defaultValue;
6497
6642
  }
6643
+
6498
6644
  this.$set(this.doc, f.name, f.defaultValue = defValue);
6499
6645
  }
6500
6646
  });
@@ -6502,6 +6648,7 @@ var script$3 = {
6502
6648
  });
6503
6649
  }
6504
6650
  },
6651
+
6505
6652
  execApplyDefaultValRule() {
6506
6653
  this.formConfig.sections.forEach(el => {
6507
6654
  el.columns.forEach(c => {
@@ -6509,6 +6656,7 @@ var script$3 = {
6509
6656
  if (f.rules) {
6510
6657
  if (!f.defaultValue) {
6511
6658
  const rule = f.rules.find(rule => rule.event === 'defaultValue');
6659
+
6512
6660
  if (rule && !this.doc[f.name]) {
6513
6661
  this.$set(this.doc, f.name, f.defaultValue = eval(rule.script));
6514
6662
  }
@@ -6518,27 +6666,34 @@ var script$3 = {
6518
6666
  });
6519
6667
  });
6520
6668
  }
6669
+
6521
6670
  },
6671
+
6522
6672
  mounted() {
6523
6673
  this.execApplyDefaultValues();
6524
6674
  this.execApplyDefaultValRule();
6525
6675
  this.onGlobalEventFired('form-mounted', this);
6526
6676
  },
6677
+
6527
6678
  activated() {
6528
6679
  this.execApplyDefaultValues();
6529
6680
  this.execApplyDefaultValRule();
6530
6681
  this.onGlobalEventFired('form-activated', this);
6531
6682
  }
6683
+
6532
6684
  };
6533
6685
 
6534
6686
  /* script */
6535
6687
  const __vue_script__$3 = script$3;
6536
-
6537
6688
  /* template */
6689
+
6538
6690
  var __vue_render__$3 = function () {
6539
6691
  var _vm = this;
6692
+
6540
6693
  var _h = _vm.$createElement;
6694
+
6541
6695
  var _c = _vm._self._c || _h;
6696
+
6542
6697
  return _vm.formConfig && _vm.formConfig.sections ? _c('b-form', {
6543
6698
  staticClass: "rb-doc-form",
6544
6699
  on: {
@@ -6645,15 +6800,19 @@ var __vue_render__$3 = function () {
6645
6800
  })], 2)], 1);
6646
6801
  }), 0) : _vm._e();
6647
6802
  };
6648
- var __vue_staticRenderFns__$3 = [];
6649
6803
 
6804
+ var __vue_staticRenderFns__$3 = [];
6650
6805
  /* style */
6806
+
6651
6807
  const __vue_inject_styles__$3 = undefined;
6652
6808
  /* scoped */
6809
+
6653
6810
  const __vue_scope_id__$3 = undefined;
6654
6811
  /* module identifier */
6812
+
6655
6813
  const __vue_module_identifier__$3 = undefined;
6656
6814
  /* functional template */
6815
+
6657
6816
  const __vue_is_functional_template__$3 = false;
6658
6817
  /* style inject */
6659
6818
 
@@ -6665,21 +6824,26 @@ const __vue_component__$4 = /*#__PURE__*/normalizeComponent({
6665
6824
  render: __vue_render__$3,
6666
6825
  staticRenderFns: __vue_staticRenderFns__$3
6667
6826
  }, __vue_inject_styles__$3, __vue_script__$3, __vue_scope_id__$3, __vue_is_functional_template__$3, __vue_module_identifier__$3, false, undefined, undefined, undefined);
6827
+
6668
6828
  var DocForm = __vue_component__$4;
6669
6829
 
6670
6830
  const generateRandomString = length => {
6671
6831
  let result = '';
6672
6832
  const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
6673
6833
  const charactersLength = characters.length;
6834
+
6674
6835
  for (let i = 0; i < length; i++) {
6675
6836
  result += characters.charAt(Math.floor(Math.random() * charactersLength));
6676
6837
  }
6838
+
6677
6839
  return result;
6678
6840
  };
6841
+
6679
6842
  const UtRandom = {
6680
6843
  getRandomString(length) {
6681
6844
  return generateRandomString(length);
6682
6845
  }
6846
+
6683
6847
  };
6684
6848
 
6685
6849
  //
@@ -6698,6 +6862,7 @@ var script$2 = {
6698
6862
  },
6699
6863
  onAfterOk: Function
6700
6864
  },
6865
+
6701
6866
  data() {
6702
6867
  return {
6703
6868
  id: 'rb-field-rule-form-modal',
@@ -6706,21 +6871,26 @@ var script$2 = {
6706
6871
  innerRule: null
6707
6872
  };
6708
6873
  },
6874
+
6709
6875
  computed: {
6710
6876
  title() {
6711
6877
  return this.mode === 'ins' ? 'Добавление правила' : 'Редактирование правила';
6712
6878
  },
6879
+
6713
6880
  fields() {
6714
6881
  return UtFormConfig.getFields(this.formConfig);
6715
6882
  },
6883
+
6716
6884
  rulePresets() {
6717
6885
  return UtFormConstructor.getAvailableFieldRules(this.field);
6718
6886
  }
6887
+
6719
6888
  },
6720
6889
  watch: {
6721
6890
  formConfig() {
6722
6891
  this.copyToInnerFormConfig();
6723
6892
  },
6893
+
6724
6894
  rule() {
6725
6895
  if (this.rule) {
6726
6896
  this.innerRule = this.rule;
@@ -6728,6 +6898,7 @@ var script$2 = {
6728
6898
  this.innerRule = this.getDefaultRule();
6729
6899
  }
6730
6900
  }
6901
+
6731
6902
  },
6732
6903
  methods: {
6733
6904
  validateFields(fieldName) {
@@ -6742,14 +6913,18 @@ var script$2 = {
6742
6913
  }
6743
6914
  });
6744
6915
  },
6916
+
6745
6917
  copyToInnerFormConfig() {
6746
6918
  this.innerFormConfig = JSON.parse(JSON.stringify(this.formConfig));
6747
6919
  },
6920
+
6748
6921
  applyRuleToInnerFormConfig() {
6749
6922
  if (this.innerFormConfig) {
6750
6923
  let foundRule = UtFormConfig.findRule(this.innerRule.id, this.innerFormConfig);
6924
+
6751
6925
  if (!foundRule) {
6752
6926
  let foundField = UtFormConfig.findField(this.field.name, this.innerFormConfig);
6927
+
6753
6928
  if (foundField) {
6754
6929
  foundField.rules = foundField.rules ? foundField.rules : [];
6755
6930
  foundField.rules.push(this.rule);
@@ -6759,12 +6934,14 @@ var script$2 = {
6759
6934
  }
6760
6935
  }
6761
6936
  },
6937
+
6762
6938
  onActivateTab(index) {
6763
6939
  if (index > 0) {
6764
6940
  this.copyToInnerFormConfig();
6765
6941
  this.applyRuleToInnerFormConfig();
6766
6942
  }
6767
6943
  },
6944
+
6768
6945
  getDefaultState() {
6769
6946
  return {
6770
6947
  name: null,
@@ -6772,6 +6949,7 @@ var script$2 = {
6772
6949
  script: null
6773
6950
  };
6774
6951
  },
6952
+
6775
6953
  getDefaultRule() {
6776
6954
  return {
6777
6955
  id: UtRandom.getRandomString(10),
@@ -6780,22 +6958,27 @@ var script$2 = {
6780
6958
  script: null
6781
6959
  };
6782
6960
  },
6961
+
6783
6962
  resetModal() {
6784
6963
  this.state = this.getDefaultState();
6785
6964
  this.innerRule = null;
6786
6965
  },
6966
+
6787
6967
  addVariableToScript(varName) {
6788
6968
  let caretPosition = this.$refs.scriptInput.selectionStart;
6789
6969
  this.insertTextToScript(varName, caretPosition);
6790
6970
  },
6971
+
6791
6972
  addSetVariableToScript(field) {
6792
6973
  let caretPosition = this.$refs.scriptInput.selectionStart;
6793
6974
  this.insertTextToScript(`doc['${field.name}'] = Значение;`, caretPosition);
6794
6975
  },
6976
+
6795
6977
  addCallInputFunction(field) {
6796
6978
  let caretPosition = this.$refs.scriptInput.selectionStart;
6797
6979
  this.insertTextToScript(`form.$refs['${field.name}'][0].Название функции();`, caretPosition);
6798
6980
  },
6981
+
6799
6982
  insertTextToScript(text, position) {
6800
6983
  position = position != null ? position : this.script.length;
6801
6984
  this.innerRule.script = this.innerRule.script != null ? this.innerRule.script : '';
@@ -6803,39 +6986,50 @@ var script$2 = {
6803
6986
  scriptSplit.splice(position, 0, text);
6804
6987
  this.innerRule.script = scriptSplit.join('');
6805
6988
  },
6989
+
6806
6990
  onRuleSelected(ruleName) {
6807
6991
  let rule = this.rulePresets.find(rule => rule.name === ruleName);
6992
+
6808
6993
  if (rule) {
6809
6994
  Object.assign(this.innerRule, rule);
6810
6995
  this.innerRule.script = this.innerRule.script.trim();
6811
6996
  }
6812
6997
  },
6998
+
6813
6999
  onOk() {
6814
7000
  this.validateFields();
7001
+
6815
7002
  if (this.state.name && this.state.script) {
6816
7003
  if (this.onAfterOk) {
6817
7004
  this.onAfterOk(this.innerRule);
6818
7005
  }
7006
+
6819
7007
  this.$nextTick(() => {
6820
7008
  this.resetModal();
6821
7009
  this.$bvModal.hide(this.id);
6822
7010
  });
6823
7011
  }
6824
7012
  }
7013
+
6825
7014
  },
7015
+
6826
7016
  created() {
6827
7017
  this.copyToInnerFormConfig();
6828
7018
  }
7019
+
6829
7020
  };
6830
7021
 
6831
7022
  /* script */
6832
7023
  const __vue_script__$2 = script$2;
6833
-
6834
7024
  /* template */
7025
+
6835
7026
  var __vue_render__$2 = function () {
6836
7027
  var _vm = this;
7028
+
6837
7029
  var _h = _vm.$createElement;
7030
+
6838
7031
  var _c = _vm._self._c || _h;
7032
+
6839
7033
  return _c('b-modal', {
6840
7034
  attrs: {
6841
7035
  "id": _vm.id,
@@ -7088,15 +7282,19 @@ var __vue_render__$2 = function () {
7088
7282
  }
7089
7283
  })], 1) : _vm._e()], 1)], 1)], 1);
7090
7284
  };
7091
- var __vue_staticRenderFns__$2 = [];
7092
7285
 
7286
+ var __vue_staticRenderFns__$2 = [];
7093
7287
  /* style */
7288
+
7094
7289
  const __vue_inject_styles__$2 = undefined;
7095
7290
  /* scoped */
7291
+
7096
7292
  const __vue_scope_id__$2 = undefined;
7097
7293
  /* module identifier */
7294
+
7098
7295
  const __vue_module_identifier__$2 = undefined;
7099
7296
  /* functional template */
7297
+
7100
7298
  const __vue_is_functional_template__$2 = false;
7101
7299
  /* style inject */
7102
7300
 
@@ -7108,6 +7306,7 @@ const __vue_component__$3 = /*#__PURE__*/normalizeComponent({
7108
7306
  render: __vue_render__$2,
7109
7307
  staticRenderFns: __vue_staticRenderFns__$2
7110
7308
  }, __vue_inject_styles__$2, __vue_script__$2, __vue_scope_id__$2, __vue_is_functional_template__$2, __vue_module_identifier__$2, false, undefined, undefined, undefined);
7309
+
7111
7310
  var FieldRuleFormModal = __vue_component__$3;
7112
7311
 
7113
7312
  //
@@ -7127,6 +7326,7 @@ var script$1 = {
7127
7326
  },
7128
7327
  formConfig: Object
7129
7328
  },
7329
+
7130
7330
  data() {
7131
7331
  return {
7132
7332
  innerVisible: null,
@@ -7140,61 +7340,78 @@ var script$1 = {
7140
7340
  rulesHash: UtRandom.getRandomString(10)
7141
7341
  };
7142
7342
  },
7343
+
7143
7344
  computed: {
7144
7345
  inputOptions() {
7145
7346
  return this.field ? UtFormConstructor.getInputTypes(this.field) : [];
7146
7347
  },
7348
+
7147
7349
  iconCloseSidebar() {
7148
7350
  return UtFormConstructor.config.icons.iconCloseFieldSidebar;
7149
7351
  },
7352
+
7150
7353
  iconOpenSidebar() {
7151
7354
  return UtFormConstructor.config.icons.iconOpenFieldSidebar;
7152
7355
  },
7356
+
7153
7357
  iconAdd() {
7154
7358
  return UtFormConstructor.config.icons.iconAdd;
7155
7359
  },
7360
+
7156
7361
  rules() {
7157
7362
  return UtFormConstructor.getAvailableFieldRules(this.field);
7158
7363
  },
7364
+
7159
7365
  hasMultipleInputTypes() {
7160
7366
  return UtFormConstructor.hasMultipleInputTypes(this.field);
7161
7367
  },
7368
+
7162
7369
  multiple() {
7163
7370
  return this.field && this.field.multiple;
7164
7371
  }
7372
+
7165
7373
  },
7166
7374
  watch: {
7167
7375
  visible() {
7168
7376
  this.innerVisible = this.visible;
7169
7377
  },
7378
+
7170
7379
  value() {
7171
7380
  this.field = this.value;
7381
+
7172
7382
  if (this.field && this.field.input) {
7173
7383
  this.currentInputName = this.field.input.name;
7174
7384
  }
7175
7385
  },
7386
+
7176
7387
  field: {
7177
7388
  handler() {
7178
7389
  this.$emit('input', this.field);
7179
7390
  this.$emit('change', this.field);
7180
7391
  },
7392
+
7181
7393
  deep: true
7182
7394
  },
7395
+
7183
7396
  currentInputName(val) {
7184
7397
  this.field.input = UtFormConstructor.getInputTypeByName(this.currentInputName, this.field);
7185
7398
  },
7399
+
7186
7400
  multiple() {
7187
7401
  let input = UtFormConstructor.getDefaultInput(this.field);
7402
+
7188
7403
  if (this.field.multiple) {
7189
7404
  this.currentInputName = input.name;
7190
7405
  }
7191
7406
  }
7407
+
7192
7408
  },
7193
7409
  methods: {
7194
7410
  hide() {
7195
7411
  this.innerVisible = false;
7196
7412
  this.$emit('hide');
7197
7413
  },
7414
+
7198
7415
  getPropInputType(prop, propName) {
7199
7416
  if (['string', 'number'].includes(prop.type)) {
7200
7417
  return 'b-form-input';
@@ -7204,6 +7421,7 @@ var script$1 = {
7204
7421
  return 'rb-boolean-single-option-input';
7205
7422
  }
7206
7423
  },
7424
+
7207
7425
  getPropInputPropData(prop, propName) {
7208
7426
  if (prop.type === 'string') {
7209
7427
  return {
@@ -7217,6 +7435,7 @@ var script$1 = {
7217
7435
  return {};
7218
7436
  }
7219
7437
  },
7438
+
7220
7439
  addRule() {
7221
7440
  this.ruleModalCfg = {
7222
7441
  mode: 'ins',
@@ -7226,22 +7445,22 @@ var script$1 = {
7226
7445
  },
7227
7446
  onAfterOk: rule => {
7228
7447
  this.field.rules = this.field.rules ? this.field.rules : [];
7229
- this.field.rules.push({
7230
- ...rule
7448
+ this.field.rules.push({ ...rule
7231
7449
  });
7232
7450
  this.rulesHash = UtRandom.getRandomString(10);
7233
7451
  }
7234
7452
  };
7235
7453
  this.$bvModal.show(this.modalId);
7236
7454
  },
7455
+
7237
7456
  editRule(rule, event) {
7238
7457
  if (event.target.classList && event.target.classList.contains('rb-remove-rule')) {
7239
7458
  return;
7240
7459
  }
7460
+
7241
7461
  this.ruleModalCfg = {
7242
7462
  mode: 'upd',
7243
- rule: {
7244
- ...rule
7463
+ rule: { ...rule
7245
7464
  },
7246
7465
  onAfterOk: modalRule => {
7247
7466
  Object.assign(rule, modalRule);
@@ -7249,33 +7468,43 @@ var script$1 = {
7249
7468
  };
7250
7469
  this.$bvModal.show(this.modalId);
7251
7470
  },
7471
+
7252
7472
  removeRule(rule) {
7253
7473
  let index = this.field.rules.findIndex(r => r.id === rule.id);
7474
+
7254
7475
  if (index >= 0) {
7255
7476
  this.field.rules.splice(index, 1);
7256
7477
  }
7478
+
7257
7479
  this.rulesHash = UtRandom.getRandomString(10);
7258
7480
  }
7481
+
7259
7482
  },
7483
+
7260
7484
  created() {
7261
7485
  if (this.value) {
7262
7486
  this.innerVisible = this.visible;
7263
7487
  this.field = this.value;
7488
+
7264
7489
  if (this.field && this.field.input) {
7265
7490
  this.currentInputName = this.field.input.name;
7266
7491
  }
7267
7492
  }
7268
7493
  }
7494
+
7269
7495
  };
7270
7496
 
7271
7497
  /* script */
7272
7498
  const __vue_script__$1 = script$1;
7273
-
7274
7499
  /* template */
7500
+
7275
7501
  var __vue_render__$1 = function () {
7276
7502
  var _vm = this;
7503
+
7277
7504
  var _h = _vm.$createElement;
7505
+
7278
7506
  var _c = _vm._self._c || _h;
7507
+
7279
7508
  return _c('b-sidebar', {
7280
7509
  staticClass: "rb-doc-template-field-sidebar",
7281
7510
  attrs: {
@@ -7513,15 +7742,19 @@ var __vue_render__$1 = function () {
7513
7742
  }
7514
7743
  })], 1);
7515
7744
  };
7516
- var __vue_staticRenderFns__$1 = [];
7517
7745
 
7746
+ var __vue_staticRenderFns__$1 = [];
7518
7747
  /* style */
7748
+
7519
7749
  const __vue_inject_styles__$1 = undefined;
7520
7750
  /* scoped */
7751
+
7521
7752
  const __vue_scope_id__$1 = undefined;
7522
7753
  /* module identifier */
7754
+
7523
7755
  const __vue_module_identifier__$1 = undefined;
7524
7756
  /* functional template */
7757
+
7525
7758
  const __vue_is_functional_template__$1 = false;
7526
7759
  /* style inject */
7527
7760
 
@@ -7533,6 +7766,7 @@ const __vue_component__$2 = /*#__PURE__*/normalizeComponent({
7533
7766
  render: __vue_render__$1,
7534
7767
  staticRenderFns: __vue_staticRenderFns__$1
7535
7768
  }, __vue_inject_styles__$1, __vue_script__$1, __vue_scope_id__$1, __vue_is_functional_template__$1, __vue_module_identifier__$1, false, undefined, undefined, undefined);
7769
+
7536
7770
  var DocTemplateFieldSidebar = __vue_component__$2;
7537
7771
 
7538
7772
  //
@@ -7558,6 +7792,7 @@ var script = {
7558
7792
  default: () => []
7559
7793
  }
7560
7794
  },
7795
+
7561
7796
  data() {
7562
7797
  return {
7563
7798
  sidebarVisible: false,
@@ -7568,32 +7803,41 @@ var script = {
7568
7803
  id: 'rb-doc-template-section-modal',
7569
7804
  mode: 'ins',
7570
7805
  section: null,
7806
+
7571
7807
  onAfterOk() {}
7808
+
7572
7809
  }
7573
7810
  };
7574
7811
  },
7812
+
7575
7813
  computed: {
7576
7814
  iconAdd() {
7577
7815
  return UtFormConstructor.config.icons.iconAdd;
7578
7816
  },
7817
+
7579
7818
  iconEdit() {
7580
7819
  return UtFormConstructor.config.icons.iconEdit;
7581
7820
  },
7821
+
7582
7822
  iconDelete() {
7583
7823
  return UtFormConstructor.config.icons.iconDelete;
7584
7824
  },
7825
+
7585
7826
  iconDrag() {
7586
7827
  return UtFormConstructor.config.icons.iconDrag;
7587
7828
  }
7829
+
7588
7830
  },
7589
7831
  methods: {
7590
7832
  showProperties(field, event) {
7591
7833
  if (event.target.classList && event.target.classList.contains('rb-remove-field')) {
7592
7834
  return;
7593
7835
  }
7836
+
7594
7837
  this.sidebarVisible = true;
7595
7838
  this.sidebarField = field;
7596
7839
  },
7840
+
7597
7841
  addSection(columnCount) {
7598
7842
  let section = {
7599
7843
  labelRu: null,
@@ -7601,24 +7845,32 @@ var script = {
7601
7845
  };
7602
7846
  this.sectionModalCfg.mode = 'ins';
7603
7847
  this.sectionModalCfg.section = section;
7848
+
7604
7849
  this.sectionModalCfg.onAfterOk = () => {
7605
7850
  section.columns = [];
7851
+
7606
7852
  for (let i = 0; i < columnCount; i++) {
7607
7853
  section.columns.push({
7608
7854
  index: i,
7609
7855
  fields: []
7610
7856
  });
7611
7857
  }
7858
+
7612
7859
  this.formConfig.sections.push(section);
7613
7860
  };
7861
+
7614
7862
  this.$bvModal.show(this.sectionModalCfg.id);
7615
7863
  },
7864
+
7616
7865
  editSection(section) {
7617
7866
  this.sectionModalCfg.mode = 'update';
7618
7867
  this.sectionModalCfg.section = section;
7868
+
7619
7869
  this.sectionModalCfg.onAfterOk = () => {};
7870
+
7620
7871
  this.$bvModal.show(this.sectionModalCfg.id);
7621
7872
  },
7873
+
7622
7874
  removeSection(section, index) {
7623
7875
  this.formConfig.sections.splice(index, 1);
7624
7876
  /*UtModal.showYesNoDialog('Вы действительно хотите удалить секцию?', {
@@ -7642,31 +7894,40 @@ var script = {
7642
7894
  });
7643
7895
  return count > 1;
7644
7896
  },
7897
+
7645
7898
  removeFieldFromColumn(field, column, newIndex) {
7646
7899
  let index = newIndex != null ? newIndex : -1;
7900
+
7647
7901
  if (index < 0) {
7648
7902
  index = column.fields.findIndex(f => field.name === f.name);
7649
7903
  }
7904
+
7650
7905
  if (index >= 0) {
7651
7906
  column.fields.splice(index, 1);
7652
7907
  }
7653
7908
  },
7909
+
7654
7910
  onRemoveField(event, field, column) {
7655
7911
  event.preventDefault();
7656
7912
  this.removeFieldFromColumn(field, column);
7657
7913
  },
7914
+
7658
7915
  onFieldAddedToColumn(event, column, section) {
7659
7916
  this.columnTo = column;
7660
7917
  },
7918
+
7661
7919
  onFieldMoveEnd(event) {
7662
7920
  const {
7663
7921
  newIndex
7664
7922
  } = event;
7665
7923
  let field = event.item._underlying_vm_;
7924
+
7666
7925
  if (!field.hasOwnProperty('defaultValue')) {
7667
7926
  this.$set(field, 'defaultValue', undefined);
7668
7927
  }
7928
+
7669
7929
  let found = this.multipleFieldAreOnFormConfig(field);
7930
+
7670
7931
  if (found) {
7671
7932
  this.removeFieldFromColumn(field, this.columnTo, newIndex);
7672
7933
  this.resetDragVariables();
@@ -7680,30 +7941,36 @@ var script = {
7680
7941
  noCloseOnEsc: true
7681
7942
  });
7682
7943
  }
7944
+
7683
7945
  this.resetDragVariables();
7684
7946
  this.hash = (Math.random() + 1).toString(36).substring(7);
7685
7947
  },
7948
+
7686
7949
  getFieldExtendedPropsData(field) {
7687
- return {
7688
- ...field.input.propsData,
7950
+ return { ...field.input.propsData,
7689
7951
  placeholder: field.tag,
7690
7952
  disabled: true
7691
7953
  };
7692
7954
  },
7955
+
7693
7956
  resetDragVariables() {
7694
7957
  this.columnTo = null;
7695
7958
  }
7959
+
7696
7960
  }
7697
7961
  };
7698
7962
 
7699
7963
  /* script */
7700
7964
  const __vue_script__ = script;
7701
-
7702
7965
  /* template */
7966
+
7703
7967
  var __vue_render__ = function () {
7704
7968
  var _vm = this;
7969
+
7705
7970
  var _h = _vm.$createElement;
7971
+
7706
7972
  var _c = _vm._self._c || _h;
7973
+
7707
7974
  return _c('div', {
7708
7975
  staticClass: "rb-doc-template-constructor d-flex"
7709
7976
  }, [_c('doc-template-facet-list', {
@@ -7943,15 +8210,19 @@ var __vue_render__ = function () {
7943
8210
  }
7944
8211
  })], 1)], 1);
7945
8212
  };
7946
- var __vue_staticRenderFns__ = [];
7947
8213
 
8214
+ var __vue_staticRenderFns__ = [];
7948
8215
  /* style */
8216
+
7949
8217
  const __vue_inject_styles__ = undefined;
7950
8218
  /* scoped */
8219
+
7951
8220
  const __vue_scope_id__ = undefined;
7952
8221
  /* module identifier */
8222
+
7953
8223
  const __vue_module_identifier__ = undefined;
7954
8224
  /* functional template */
8225
+
7955
8226
  const __vue_is_functional_template__ = false;
7956
8227
  /* style inject */
7957
8228
 
@@ -7963,6 +8234,7 @@ const __vue_component__ = /*#__PURE__*/normalizeComponent({
7963
8234
  render: __vue_render__,
7964
8235
  staticRenderFns: __vue_staticRenderFns__
7965
8236
  }, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, undefined, undefined, undefined);
8237
+
7966
8238
  var __vue_component__$1 = __vue_component__;
7967
8239
 
7968
8240
  /* eslint-disable import/prefer-default-export */
@@ -7981,11 +8253,11 @@ var components = /*#__PURE__*/Object.freeze({
7981
8253
 
7982
8254
  // Import vue components
7983
8255
 
7984
- // install function executed by Vue.use()
7985
8256
  const install = function installRbDocumentFormConstructor(Vue) {
7986
- Object.entries(components).forEach(([componentName, component]) => {
8257
+ Object.entries(components).forEach(_ref => {
8258
+ let [componentName, component] = _ref;
7987
8259
  Vue.component(componentName, component);
7988
8260
  });
7989
- };
8261
+ }; // Create module definition for Vue.use()
7990
8262
 
7991
8263
  export { DocForm, __vue_component__$1 as DocTemplateConstructor, DocTemplateFacetList, DocTemplateFieldSidebar, DocTemplateSectionModal, FieldRuleFormModal, UtFormConfig, UtFormConstructor, install as default };