formiojs-eorion 0.1.15 → 0.1.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.
package/Formio.js CHANGED
@@ -1724,7 +1724,7 @@ Formio.projectUrlSet = false;
1724
1724
  Formio.plugins = [];
1725
1725
  Formio.cache = {};
1726
1726
  Formio.Providers = _providers.default;
1727
- Formio.version = '0.1.15';
1727
+ Formio.version = '0.1.16';
1728
1728
  Formio.pathType = '';
1729
1729
  Formio.events = new _EventEmitter.default();
1730
1730
  Formio.cdn = new _CDN.default();
@@ -162,7 +162,7 @@ var DataSourceComponent = /*#__PURE__*/function (_FieldComponent) {
162
162
  }
163
163
  if (this.component.dataSource !== "file") {
164
164
  setTimeout(function () {
165
- _this.setValue("");
165
+ _this.setValue(null);
166
166
  }, 100);
167
167
  }
168
168
  return _get(_getPrototypeOf(DataSourceComponent.prototype), "attach", this).call(this, element);
@@ -197,104 +197,112 @@ var DataSourceComponent = /*#__PURE__*/function (_FieldComponent) {
197
197
  key: "setValue",
198
198
  value: function setValue(value) {
199
199
  var self = this;
200
- if (self.component['dataSource'] === 'file') {
201
- return true;
202
- }
203
- if (self.component['data-source-url']) {
204
- var url = self.parseTpl(self.component['data-source-url'], {
205
- data: self.rootValue
200
+ if (value) {
201
+ _get(_getPrototypeOf(DataSourceComponent.prototype), "setValue", this).call(this, value, {
202
+ noUpdateEvent: true,
203
+ noValidate: true,
204
+ resetValue: true
206
205
  });
207
- if (url.startsWith('http')) {
208
- url = new URL(url);
209
- } else {
210
- url = new URL(url, window.location.origin);
206
+ } else {
207
+ if (self.component['dataSource'] === 'file') {
208
+ return true;
211
209
  }
212
- var searchParams = new URLSearchParams(url.search);
213
- var params = {};
214
- var headers = {};
215
- self.component.request['headers'].forEach(function (header) {
216
- headers["".concat(header.key)] = self.parseTpl(header.value, {
210
+ if (self.component['data-source-url']) {
211
+ var url = self.parseTpl(self.component['data-source-url'], {
217
212
  data: self.rootValue
218
213
  });
219
- });
220
- // 搜索
221
- if (self.component['dataSource'] === 'url') {} else if (self.component['dataSource'] === 'noco_db') {
222
- if (self.component.data['noco_db_conditions']) {
223
- var where = '';
224
- self.component.data['noco_db_conditions'].forEach(function (item, index) {
225
- if (item.value && item.value.length > 0) {
226
- var conditionVal = self.parseTpl(item.value, {
227
- data: self.rootValue
228
- });
229
- if (index === 0 && item.logical_operator === '~not') {
230
- where += "(".concat(item.name, ",").concat(item.operator, ",").concat(conditionVal, ")");
231
- } else {
232
- where += "".concat(item.logical_operator, "(").concat(item.name, ",").concat(item.operator, ",").concat(conditionVal, ")");
233
- }
234
- }
235
- });
236
- params.where = where;
214
+ if (url.startsWith('http')) {
215
+ url = new URL(url);
216
+ } else {
217
+ url = new URL(url, window.location.origin);
237
218
  }
238
- }
239
- Object.keys(params).forEach(function (key) {
240
- searchParams.set(key, params["".concat(key)]);
241
- });
242
- try {
243
- var lastestReqTime = new Date().getTime();
244
- self.lastestReqTime = lastestReqTime;
245
- var xhr = new XMLHttpRequest();
246
- var reqMethod = self.component.request['method'];
247
- if (reqMethod === 'GET') {
248
- xhr.open('GET', "".concat(url.origin).concat(url.pathname, "?").concat(searchParams.toString()), true);
249
- xhr.responseType = 'json';
250
- Object.keys(headers).forEach(function (key) {
251
- xhr.setRequestHeader(key, headers["".concat(key)]);
252
- });
253
- } else if (reqMethod === 'POST') {
254
- xhr.open('POST', "".concat(url.origin).concat(url.pathname, "?").concat(searchParams.toString()), true);
255
- xhr.setRequestHeader('Content-Type', 'application/json');
256
- xhr.responseType = 'json';
257
- Object.keys(headers).forEach(function (key) {
258
- xhr.setRequestHeader(key, headers["".concat(key)]);
219
+ var searchParams = new URLSearchParams(url.search);
220
+ var params = {};
221
+ var headers = {};
222
+ self.component.request['headers'].forEach(function (header) {
223
+ headers["".concat(header.key)] = self.parseTpl(header.value, {
224
+ data: self.rootValue
259
225
  });
260
- }
261
- xhr.onload = function () {
262
- var status = xhr.status;
263
- if (status === 200) {
264
- // 确保最后更新的数据是最新一次请求的接口数据
265
- if (lastestReqTime - self.lastestReqTime === 0) {
266
- var dataPath = self.component.request['dataPath'];
267
- if (dataPath && dataPath.length > 0) {
268
- self.dataValue = _lodash.default.get(xhr.response, dataPath);
269
- } else {
270
- self.dataValue = xhr.response;
226
+ });
227
+ // 搜索
228
+ if (self.component['dataSource'] === 'url') {} else if (self.component['dataSource'] === 'noco_db') {
229
+ if (self.component.data['noco_db_conditions']) {
230
+ var where = '';
231
+ self.component.data['noco_db_conditions'].forEach(function (item, index) {
232
+ if (item.value && item.value.length > 0) {
233
+ var conditionVal = self.parseTpl(item.value, {
234
+ data: self.rootValue
235
+ });
236
+ if (index === 0 && item.logical_operator === '~not') {
237
+ where += "(".concat(item.name, ",").concat(item.operator, ",").concat(conditionVal, ")");
238
+ } else {
239
+ where += "".concat(item.logical_operator, "(").concat(item.name, ",").concat(item.operator, ",").concat(conditionVal, ")");
240
+ }
271
241
  }
272
- self.getRoot().triggerChange({
273
- fromBlur: false
274
- }, {
275
- instance: self,
276
- component: self.component,
277
- value: self.dataValue,
278
- flags: {
279
- fromBlur: false
242
+ });
243
+ params.where = where;
244
+ }
245
+ }
246
+ Object.keys(params).forEach(function (key) {
247
+ searchParams.set(key, params["".concat(key)]);
248
+ });
249
+ try {
250
+ var lastestReqTime = new Date().getTime();
251
+ self.lastestReqTime = lastestReqTime;
252
+ var xhr = new XMLHttpRequest();
253
+ var reqMethod = self.component.request['method'];
254
+ if (reqMethod === 'GET') {
255
+ xhr.open('GET', "".concat(url.origin).concat(url.pathname, "?").concat(searchParams.toString()), true);
256
+ xhr.responseType = 'json';
257
+ Object.keys(headers).forEach(function (key) {
258
+ xhr.setRequestHeader(key, headers["".concat(key)]);
259
+ });
260
+ } else if (reqMethod === 'POST') {
261
+ xhr.open('POST', "".concat(url.origin).concat(url.pathname, "?").concat(searchParams.toString()), true);
262
+ xhr.setRequestHeader('Content-Type', 'application/json');
263
+ xhr.responseType = 'json';
264
+ Object.keys(headers).forEach(function (key) {
265
+ xhr.setRequestHeader(key, headers["".concat(key)]);
266
+ });
267
+ }
268
+ xhr.onload = function () {
269
+ var status = xhr.status;
270
+ if (status === 200) {
271
+ // 确保最后更新的数据是最新一次请求的接口数据
272
+ if (lastestReqTime - self.lastestReqTime === 0) {
273
+ var dataPath = self.component.request['dataPath'];
274
+ if (dataPath && dataPath.length > 0) {
275
+ self.dataValue = _lodash.default.get(xhr.response, dataPath);
276
+ } else {
277
+ self.dataValue = xhr.response;
280
278
  }
281
- });
279
+ self.getRoot().triggerChange({
280
+ fromBlur: false
281
+ }, {
282
+ instance: self,
283
+ component: self.component,
284
+ value: self.dataValue,
285
+ flags: {
286
+ fromBlur: false
287
+ }
288
+ });
289
+ }
282
290
  }
291
+ };
292
+ if (reqMethod === 'GET') {
293
+ xhr.send();
294
+ } else if (reqMethod === 'POST') {
295
+ var reqData = JSON.parse(this.parseTpl(JSON.stringify(self.component.request['body']) || '{}', {
296
+ data: self.rootValue
297
+ }));
298
+ xhr.send(JSON.stringify(reqData));
283
299
  }
284
- };
285
- if (reqMethod === 'GET') {
286
- xhr.send();
287
- } else if (reqMethod === 'POST') {
288
- var reqData = JSON.parse(this.parseTpl(JSON.stringify(self.component.request['body']) || '{}', {
289
- data: self.rootValue
290
- }));
291
- xhr.send(JSON.stringify(reqData));
300
+ } catch (e) {
301
+ console.log(e);
292
302
  }
293
- } catch (e) {
294
- console.log(e);
295
303
  }
304
+ return true;
296
305
  }
297
- return true;
298
306
  }
299
307
  }], [{
300
308
  key: "schema",
@@ -2323,6 +2323,17 @@ var Component = /*#__PURE__*/function (_Element) {
2323
2323
  }
2324
2324
  return empty;
2325
2325
  }
2326
+ if (["redrawOn", "refreshOn"].includes(this.key)) {
2327
+ // 特殊处理redrawOn/refreshOn,全部转为multiple
2328
+ var value = _lodash.default.get(this._data, this.key);
2329
+ if (value && value.length === 0) {
2330
+ var _empty = this.component.multiple ? [] : this.emptyValue;
2331
+ return _empty;
2332
+ }
2333
+ if (!_lodash.default.isArray(value)) {
2334
+ return [value];
2335
+ }
2336
+ }
2326
2337
  return _lodash.default.get(this._data, this.key);
2327
2338
  }
2328
2339
 
@@ -98,6 +98,7 @@ var _default = [{
98
98
  }, {
99
99
  type: 'select',
100
100
  input: true,
101
+ multiple: true,
101
102
  key: 'redrawOn',
102
103
  label: 'Redraw On',
103
104
  weight: 600,
@@ -146,7 +146,7 @@ exports.default = ECharts;
146
146
  _defineProperty(ECharts, "builderInfo", {
147
147
  title: 'ECharts',
148
148
  group: 'advanced',
149
- icon: 'chart',
149
+ icon: 'chart-line',
150
150
  weight: 70,
151
151
  documentation: 'http://help.form.io/userguide/#echarts',
152
152
  schema: ECharts.schema()
@@ -167,7 +167,7 @@ exports.default = Progress;
167
167
  _defineProperty(Progress, "builderInfo", {
168
168
  title: 'Progress',
169
169
  group: 'advanced',
170
- icon: 'bar-progress',
170
+ icon: 'bars-progress',
171
171
  weight: 70,
172
172
  documentation: 'http://help.form.io/userguide/#progress',
173
173
  schema: Progress.schema()