rb-document-form-constructor 0.2.0 → 0.2.4

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.
@@ -98,10 +98,13 @@
98
98
  }
99
99
  }
100
100
 
101
- .rb-form-column:not(.rb-single-column) {
101
+ .rb-form-column {
102
102
  padding: 10px;
103
- margin: 0 10px;
104
103
  border: 2px dashed $rb-doc-template-constructor-form-column-border-color;
105
104
  }
105
+
106
+ .rb-form-column:not(.rb-single-column) {
107
+ margin: 0 10px;
108
+ }
106
109
  }
107
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rb-document-form-constructor",
3
- "version": "0.2.0",
3
+ "version": "0.2.4",
4
4
  "description": "",
5
5
  "main": "dist/rb-document-form-constructor.ssr.js",
6
6
  "browser": "dist/rb-document-form-constructor.esm.js",
@@ -24,6 +24,7 @@
24
24
  "bootstrap-vue": "^2.15.0",
25
25
  "debounce": "^1.2.1",
26
26
  "jquery": "^3.6.0",
27
+ "notevil": "^1.3.3",
27
28
  "sass": "^1.32.0",
28
29
  "sass-loader": "^10.1.0",
29
30
  "uuid": "^8.3.2",
@@ -47,6 +47,7 @@
47
47
  if (rule.event === eventName && rule.script) {
48
48
  let ruleContext = UtFormConstructor.getRuleContext();
49
49
  ruleContext.form = this;
50
+ ruleContext.doc = this.doc;
50
51
  ruleContext.event = event;
51
52
  ruleContext.eventName = eventName;
52
53
  UtFormConstructor.runRule(ruleContext, rule.script);
@@ -20,7 +20,7 @@
20
20
  <b-form-select @input="onRuleSelected($event)">
21
21
  <b-form-select-option v-for="r in rulePresets" :key="r.name"
22
22
  :value="r.name">
23
- {{r.name}}
23
+ {{r.labelRu}} ({{r.name}})
24
24
  </b-form-select-option>
25
25
  </b-form-select>
26
26
  </b-form-group>
@@ -80,14 +80,14 @@
80
80
  size="sm" class="mx-1">
81
81
  <b-dropdown-item v-for="f in fields" :key="f.name"
82
82
  v-if="fields" @click="addSetVariableToScript(f)">
83
- {{f.name}}
83
+ {{f.labelRu}} ({{f.name}})
84
84
  </b-dropdown-item>
85
85
  </b-dropdown>
86
86
  <b-dropdown text="Вызвать функцию инпута" variant="outline-secondary"
87
87
  size="sm" class="mx-1">
88
88
  <b-dropdown-item v-for="f in fields" :key="f.name"
89
89
  v-if="fields" @click="addCallInputFunction(f)">
90
- {{f.name}}
90
+ {{f.labelRu}} ({{f.name}})
91
91
  </b-dropdown-item>
92
92
  </b-dropdown>
93
93
  </b-button-toolbar>
@@ -95,6 +95,7 @@
95
95
  :state="state.script"
96
96
  :invalid-feedback="state.script_feedback"
97
97
  rows="8"
98
+ ref="scriptInput"
98
99
  ></b-form-textarea>
99
100
  </div>
100
101
  </b-form-group>
@@ -219,18 +220,23 @@
219
220
  this.innerRule = null;
220
221
  },
221
222
  addVariableToScript(varName) {
222
- let r = this.innerRule;
223
- r.script = r.script ? r.script + varName : varName;
223
+ let caretPosition = this.$refs.scriptInput.selectionStart;
224
+ this.insertTextToScript(varName, caretPosition);
224
225
  },
225
226
  addSetVariableToScript(field) {
226
- let r = this.innerRule;
227
- let setVariableScript = `doc['${field.name}'] = Значение;`;
228
- r.script = r.script? r.script + setVariableScript: setVariableScript;
227
+ let caretPosition = this.$refs.scriptInput.selectionStart;
228
+ this.insertTextToScript(`doc['${field.name}'] = Значение;`, caretPosition);
229
229
  },
230
230
  addCallInputFunction(field) {
231
- let r = this.innerRule;
232
- let setVariableScript = `form.$refs['${field.name}'][0].Название функции();`;
233
- r.script = r.script? r.script + setVariableScript: setVariableScript;
231
+ let caretPosition = this.$refs.scriptInput.selectionStart;
232
+ this.insertTextToScript(`form.$refs['${field.name}'][0].Название функции();`, caretPosition);
233
+ },
234
+ insertTextToScript(text, position) {
235
+ position = position != null? position: this.script.length;
236
+ this.innerRule.script = this.innerRule.script != null? this.innerRule.script: '';
237
+ let scriptSplit = this.innerRule.script.split('');
238
+ scriptSplit.splice(position, 0, text);
239
+ this.innerRule.script = scriptSplit.join('');
234
240
  },
235
241
  onRuleSelected(ruleName) {
236
242
  let rule = this.rulePresets.find(rule => rule.name === ruleName);