ywana-core8 0.0.19 → 0.0.23

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.
@@ -3,7 +3,7 @@ import React, { useContext, useState, useEffect, Fragment, useRef, Children, use
3
3
  import equal from 'deep-equal';
4
4
  import ResumableJS from 'resumablejs';
5
5
 
6
- function _catch$1(body, recover) {
6
+ function _catch$2(body, recover) {
7
7
  try {
8
8
  var result = body();
9
9
  } catch (e) {
@@ -34,7 +34,7 @@ var fetchAsync = function fetchAsync(method, URL, body, token) {
34
34
  },
35
35
  body: body
36
36
  };
37
- return Promise.resolve(_catch$1(function () {
37
+ return Promise.resolve(_catch$2(function () {
38
38
  return Promise.resolve(fetch(URL, request)).then(function (response) {
39
39
  var _exit;
40
40
 
@@ -235,7 +235,6 @@ var CheckBox = function CheckBox(props) {
235
235
  }
236
236
 
237
237
  var labelTxt = /*#__PURE__*/React.createElement(Text, null, label);
238
- console.log(label, value);
239
238
  return value === true ? /*#__PURE__*/React.createElement("div", {
240
239
  className: "checkbox",
241
240
  key: id + "1"
@@ -800,7 +799,7 @@ var Tabs = function Tabs(props) {
800
799
  return /*#__PURE__*/React.createElement("div", {
801
800
  "class": "tabs"
802
801
  }, tabs, /*#__PURE__*/React.createElement("div", {
803
- "class": "tab-filler"
802
+ className: "tab-filler"
804
803
  }));
805
804
  };
806
805
  /**
@@ -1086,6 +1085,7 @@ var DataTableRow = function DataTableRow(props) {
1086
1085
  }
1087
1086
  }, columns.map(function (column) {
1088
1087
  return /*#__PURE__*/React.createElement(DataTableCell, {
1088
+ key: row.id,
1089
1089
  row: row,
1090
1090
  column: column,
1091
1091
  cell: row[column.id],
@@ -1311,7 +1311,8 @@ var StringCellEditor = function StringCellEditor(_ref5) {
1311
1311
  var TokenField = function TokenField(_ref) {
1312
1312
  var id = _ref.id,
1313
1313
  label = _ref.label,
1314
- init = _ref.init,
1314
+ _ref$init = _ref.init,
1315
+ init = _ref$init === void 0 ? [] : _ref$init,
1315
1316
  onChange = _ref.onChange;
1316
1317
  var mounted = useRef(false);
1317
1318
 
@@ -3390,7 +3391,7 @@ var CreateContentDialog = function CreateContentDialog(_ref) {
3390
3391
  }));
3391
3392
  };
3392
3393
 
3393
- function _catch(body, recover) {
3394
+ function _catch$1(body, recover) {
3394
3395
  try {
3395
3396
  var result = body();
3396
3397
  } catch (e) {
@@ -3404,7 +3405,7 @@ function _catch(body, recover) {
3404
3405
  return result;
3405
3406
  }
3406
3407
 
3407
- var http = HTTPClient(window.API || process.env.REACT_APP_API, Session);
3408
+ var http$1 = HTTPClient(window.API || process.env.REACT_APP_API, Session);
3408
3409
  /**
3409
3410
  * Collection Page
3410
3411
  */
@@ -3759,7 +3760,7 @@ var CollectionContext = function CollectionContext(url, field) {
3759
3760
  try {
3760
3761
  var _this2 = this;
3761
3762
 
3762
- var _temp2 = _catch(function () {
3763
+ var _temp2 = _catch$1(function () {
3763
3764
  return Promise.resolve(API.all()).then(function (data) {
3764
3765
  _this2.all = field ? data[field] : data;
3765
3766
  });
@@ -3785,7 +3786,7 @@ var CollectionContext = function CollectionContext(url, field) {
3785
3786
  try {
3786
3787
  var _this4 = this;
3787
3788
 
3788
- var _temp4 = _catch(function () {
3789
+ var _temp4 = _catch$1(function () {
3789
3790
  return Promise.resolve(API.create(form)).then(function () {
3790
3791
  return Promise.resolve(_this4.load()).then(function () {});
3791
3792
  });
@@ -3802,7 +3803,7 @@ var CollectionContext = function CollectionContext(url, field) {
3802
3803
  try {
3803
3804
  var _this6 = this;
3804
3805
 
3805
- var _temp6 = _catch(function () {
3806
+ var _temp6 = _catch$1(function () {
3806
3807
  return Promise.resolve(API.update(form)).then(function () {
3807
3808
  return Promise.resolve(_this6.load()).then(function () {});
3808
3809
  });
@@ -3819,7 +3820,7 @@ var CollectionContext = function CollectionContext(url, field) {
3819
3820
  try {
3820
3821
  var _this8 = this;
3821
3822
 
3822
- var _temp8 = _catch(function () {
3823
+ var _temp8 = _catch$1(function () {
3823
3824
  return Promise.resolve(API.patch(id, form)).then(function () {
3824
3825
  return Promise.resolve(_this8.load()).then(function () {});
3825
3826
  });
@@ -3836,7 +3837,7 @@ var CollectionContext = function CollectionContext(url, field) {
3836
3837
  try {
3837
3838
  var _this10 = this;
3838
3839
 
3839
- var _temp10 = _catch(function () {
3840
+ var _temp10 = _catch$1(function () {
3840
3841
  return Promise.resolve(API.updateProperty(id, propertyName, form)).then(function () {
3841
3842
  return Promise.resolve(_this10.load()).then(function () {});
3842
3843
  });
@@ -3853,7 +3854,7 @@ var CollectionContext = function CollectionContext(url, field) {
3853
3854
  try {
3854
3855
  var _this12 = this;
3855
3856
 
3856
- var _temp12 = _catch(function () {
3857
+ var _temp12 = _catch$1(function () {
3857
3858
  return Promise.resolve(API.remove(id)).then(function () {
3858
3859
  return Promise.resolve(_this12.load()).then(function () {});
3859
3860
  });
@@ -3875,26 +3876,604 @@ var CollectionContext = function CollectionContext(url, field) {
3875
3876
  var CollectionAPI = function CollectionAPI(url) {
3876
3877
  return {
3877
3878
  all: function all() {
3878
- return http.GET(url);
3879
+ return http$1.GET(url);
3879
3880
  },
3880
3881
  find: function find(id) {
3881
- return http.GET(url + "/" + id);
3882
+ return http$1.GET(url + "/" + id);
3882
3883
  },
3883
3884
  create: function create(form) {
3884
3885
  var body = JSON.stringify(form);
3885
- return http.POST(url, body);
3886
+ return http$1.POST(url, body);
3886
3887
  },
3887
3888
  update: function update(form) {
3888
3889
  var body = JSON.stringify(form);
3889
- return http.PUT(url + "/" + form.id, body);
3890
+ return http$1.PUT(url + "/" + form.id, body);
3890
3891
  },
3891
3892
  patch: function patch(id, form) {
3892
3893
  var body = JSON.stringify(form);
3893
- return http.PATCH(url + "/" + id, body);
3894
+ return http$1.PATCH(url + "/" + id, body);
3894
3895
  },
3895
3896
  updateProperty: function updateProperty(id, propertyName, form) {
3896
3897
  var body = JSON.stringify(form);
3897
- return http.PUT(url + "/" + id + "/" + propertyName, body);
3898
+ return http$1.PUT(url + "/" + id + "/" + propertyName, body);
3899
+ },
3900
+ remove: function remove(id) {
3901
+ return http$1.DELETE(url + "/" + id);
3902
+ }
3903
+ };
3904
+ };
3905
+
3906
+ function _catch(body, recover) {
3907
+ try {
3908
+ var result = body();
3909
+ } catch (e) {
3910
+ return recover(e);
3911
+ }
3912
+
3913
+ if (result && result.then) {
3914
+ return result.then(void 0, recover);
3915
+ }
3916
+
3917
+ return result;
3918
+ }
3919
+
3920
+ var http = HTTPClient(window.API || process.env.REACT_APP_API, Session);
3921
+ /**
3922
+ * Table Page
3923
+ */
3924
+
3925
+ var TablePage = function TablePage(props) {
3926
+ var playScenario = function playScenario() {
3927
+ try {
3928
+ var promises1 = pageContext.all.map(function (item) {
3929
+ try {
3930
+ return Promise.resolve(pageContext.remove(item.id));
3931
+ } catch (e) {
3932
+ return Promise.reject(e);
3933
+ }
3934
+ });
3935
+ Promise.all(promises1).then(function () {
3936
+ try {
3937
+ var promises2 = scenario.map(function (item) {
3938
+ try {
3939
+ return Promise.resolve(pageContext.create(item));
3940
+ } catch (e) {
3941
+ return Promise.reject(e);
3942
+ }
3943
+ });
3944
+ Promise.all(promises2).then(function () {
3945
+ try {
3946
+ return Promise.resolve(pageContext.load()).then(function () {
3947
+ setPageContext(Object.assign({}, pageContext));
3948
+ });
3949
+ } catch (e) {
3950
+ return Promise.reject(e);
3951
+ }
3952
+ });
3953
+ return Promise.resolve();
3954
+ } catch (e) {
3955
+ return Promise.reject(e);
3956
+ }
3957
+ });
3958
+ return Promise.resolve();
3959
+ } catch (e) {
3960
+ return Promise.reject(e);
3961
+ }
3962
+ };
3963
+
3964
+ var save = function save() {
3965
+ try {
3966
+ console.log('saving.....');
3967
+ return Promise.resolve(pageContext.update(form)).then(function () {
3968
+ setPageContext(Object.assign({}, pageContext));
3969
+ });
3970
+ } catch (e) {
3971
+ return Promise.reject(e);
3972
+ }
3973
+ };
3974
+
3975
+ var site = useContext(SiteContext);
3976
+ var _props$id = props.id,
3977
+ id = _props$id === void 0 ? "table" : _props$id,
3978
+ icon = props.icon,
3979
+ title = props.title,
3980
+ _props$name = props.name,
3981
+ name = _props$name === void 0 ? "table 1" : _props$name,
3982
+ schema = props.schema,
3983
+ url = props.url,
3984
+ field = props.field,
3985
+ _props$delay = props.delay,
3986
+ delay = _props$delay === void 0 ? 1000 : _props$delay,
3987
+ actions = props.actions,
3988
+ editable = props.editable,
3989
+ _props$canAdd = props.canAdd,
3990
+ canAdd = _props$canAdd === void 0 ? true : _props$canAdd,
3991
+ _props$dev = props.dev,
3992
+ dev = _props$dev === void 0 ? false : _props$dev,
3993
+ _props$autosave = props.autosave,
3994
+ autosave = _props$autosave === void 0 ? true : _props$autosave,
3995
+ groupBy = props.groupBy,
3996
+ validator = props.validator,
3997
+ scenario = props.scenario;
3998
+
3999
+ var _useContext = useContext(PageContext),
4000
+ pageContext = _useContext[0],
4001
+ setPageContext = _useContext[1];
4002
+
4003
+ var selected = pageContext.selected;
4004
+ var timer = useRef(null);
4005
+
4006
+ var _useState = useState(selected),
4007
+ form = _useState[0],
4008
+ setForm = _useState[1];
4009
+
4010
+ useEffect(function () {
4011
+ setForm(selected);
4012
+ }, [selected]);
4013
+ useEffect(function () {
4014
+ if (autosave) {
4015
+ clearTimeout(timer.current);
4016
+ timer.current = setTimeout(function () {
4017
+ if (canSave()) save();
4018
+ }, delay);
4019
+ }
4020
+ }, [form]);
4021
+ useEffect(function () {
4022
+ try {
4023
+ var context = TableContext(url, field);
4024
+ return Promise.resolve(context.load()).then(function () {
4025
+ setPageContext(context);
4026
+ });
4027
+ } catch (e) {
4028
+ return Promise.reject(e);
4029
+ }
4030
+ }, []);
4031
+
4032
+ function add() {
4033
+ var onOK = function onOK(form) {
4034
+ try {
4035
+ return Promise.resolve(pageContext.create(form)).then(function () {
4036
+ setPageContext(Object.assign({}, pageContext));
4037
+ });
4038
+ } catch (e) {
4039
+ return Promise.reject(e);
4040
+ }
4041
+ };
4042
+
4043
+ site.openDialog( /*#__PURE__*/React.createElement(EditContentDialog, {
4044
+ label: "Crear " + name,
4045
+ type: schema,
4046
+ onOK: onOK,
4047
+ validator: validator
4048
+ }));
4049
+ }
4050
+
4051
+ function change(next) {
4052
+ setForm(next);
4053
+ }
4054
+
4055
+ function canSave() {
4056
+ var can = !equal(form, selected);
4057
+ return can;
4058
+ }
4059
+
4060
+ function closeAside() {
4061
+ pageContext.select(null);
4062
+ setPageContext(Object.assign({}, pageContext));
4063
+ }
4064
+
4065
+ function renderAside() {
4066
+ if (selected && form) {
4067
+ var content = new Content(schema, form);
4068
+ return /*#__PURE__*/React.createElement("aside", {
4069
+ className: "table-page"
4070
+ }, /*#__PURE__*/React.createElement(Header, {
4071
+ icon: "local_offer",
4072
+ title: selected.name || "Propiedades"
4073
+ }, /*#__PURE__*/React.createElement(Icon, {
4074
+ icon: "close",
4075
+ clickable: true,
4076
+ action: closeAside
4077
+ })), /*#__PURE__*/React.createElement(ContentEditor, {
4078
+ content: content,
4079
+ onChange: change
4080
+ }));
4081
+ }
4082
+
4083
+ return null;
4084
+ }
4085
+
4086
+ return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Header, {
4087
+ className: "table-page",
4088
+ title: /*#__PURE__*/React.createElement(Text, null, title)
4089
+ }, canAdd ? /*#__PURE__*/React.createElement(Button, {
4090
+ icon: "add",
4091
+ label: "A\xF1adir",
4092
+ action: add,
4093
+ raised: true
4094
+ }) : null, dev ? /*#__PURE__*/React.createElement(MenuIcon, {
4095
+ align: "alignRight"
4096
+ }, /*#__PURE__*/React.createElement(MenuItem, {
4097
+ label: "Cargar Escenario 1",
4098
+ onSelect: playScenario
4099
+ })) : null, actions), /*#__PURE__*/React.createElement("menu", {
4100
+ className: "table-page"
4101
+ }, /*#__PURE__*/React.createElement(TableFilters, {
4102
+ schema: schema
4103
+ })), /*#__PURE__*/React.createElement("main", {
4104
+ key: id,
4105
+ className: "table-page"
4106
+ }, /*#__PURE__*/React.createElement(TableEditor, {
4107
+ icon: icon,
4108
+ title: name,
4109
+ schema: schema,
4110
+ delay: delay,
4111
+ editable: editable,
4112
+ groupBy: groupBy
4113
+ })), renderAside());
4114
+ };
4115
+ /**
4116
+ * Table Filters
4117
+ */
4118
+
4119
+ var TableFilters = function TableFilters(props) {
4120
+ var change = function change(next) {
4121
+ try {
4122
+ setForm(next);
4123
+ return Promise.resolve(pageContext.load(next)).then(function () {
4124
+ setPageContext(Object.assign({}, pageContext));
4125
+ });
4126
+ } catch (e) {
4127
+ return Promise.reject(e);
4128
+ }
4129
+ };
4130
+
4131
+ var _useContext2 = useContext(PageContext),
4132
+ pageContext = _useContext2[0],
4133
+ setPageContext = _useContext2[1];
4134
+
4135
+ var schema = props.schema;
4136
+
4137
+ var _useState2 = useState({}),
4138
+ form = _useState2[0],
4139
+ setForm = _useState2[1];
4140
+
4141
+ var filterSchema = useMemo(function () {
4142
+ var filterSchema = Object.assign({}, schema);
4143
+ Object.values(filterSchema).forEach(function (field) {
4144
+ return field.section = null;
4145
+ });
4146
+ delete filterSchema.flows;
4147
+ return filterSchema;
4148
+ }, [schema]);
4149
+
4150
+ function clear() {
4151
+ setForm({});
4152
+ }
4153
+
4154
+ var content = new Content(filterSchema, form);
4155
+ return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Header, {
4156
+ title: /*#__PURE__*/React.createElement(Text, null, "Filtros")
4157
+ }, /*#__PURE__*/React.createElement(Button, {
4158
+ icon: "filter_list_off",
4159
+ label: "Limpiar",
4160
+ action: clear
4161
+ })), /*#__PURE__*/React.createElement("main", null, /*#__PURE__*/React.createElement(ContentEditor, {
4162
+ content: content,
4163
+ onChange: change
4164
+ })));
4165
+ };
4166
+ /**
4167
+ * Table Editor
4168
+ */
4169
+
4170
+
4171
+ var TableEditor = function TableEditor(props) {
4172
+ var select = function select(row, event) {
4173
+ try {
4174
+ clear();
4175
+ return Promise.resolve(pageContext.select(row.id)).then(function () {
4176
+ setPageContext(Object.assign({}, pageContext));
4177
+ });
4178
+ } catch (e) {
4179
+ return Promise.reject(e);
4180
+ }
4181
+ };
4182
+
4183
+ var remove = function remove(id) {
4184
+ try {
4185
+ return Promise.resolve(pageContext.remove(id)).then(function () {
4186
+ pageContext.clear();
4187
+ setPageContext(Object.assign({}, pageContext));
4188
+ });
4189
+ } catch (e) {
4190
+ return Promise.reject(e);
4191
+ }
4192
+ };
4193
+
4194
+ var _useContext3 = useContext(PageContext),
4195
+ pageContext = _useContext3[0],
4196
+ setPageContext = _useContext3[1];
4197
+
4198
+ var _pageContext$all = pageContext.all,
4199
+ all = _pageContext$all === void 0 ? [] : _pageContext$all;
4200
+ var icon = props.icon,
4201
+ title = props.title,
4202
+ schema = props.schema,
4203
+ editable = props.editable;
4204
+
4205
+ var _useState3 = useState(props.groupBy),
4206
+ groupBy = _useState3[0],
4207
+ setGroupBy = _useState3[1];
4208
+
4209
+ function changeGroup(id, value) {
4210
+ setGroupBy(value);
4211
+ }
4212
+
4213
+ function change(rowID, cellID, value) {
4214
+ var _Object$assign;
4215
+
4216
+ var row = all.find(function (r) {
4217
+ return r.id === rowID;
4218
+ });
4219
+ var next = Object.assign({}, row, (_Object$assign = {}, _Object$assign[cellID] = value, _Object$assign));
4220
+ delete next.actions;
4221
+ pageContext.update(next);
4222
+ setPageContext(Object.assign({}, pageContext));
4223
+ }
4224
+
4225
+ function clear() {
4226
+ pageContext.clear();
4227
+ setPageContext(Object.assign({}, pageContext));
4228
+ }
4229
+
4230
+ function renderGroups() {
4231
+ var groups = all.reduce(function (groups, filter) {
4232
+ var groupName = filter[groupBy];
4233
+ var group = groups[groupName];
4234
+ if (!group) groups[groupName] = [];
4235
+ groups[groupName].push(filter);
4236
+ return groups;
4237
+ }, {});
4238
+ return Object.keys(groups).map(function (groupName) {
4239
+ var table = {
4240
+ columns: Object.values(schema).filter(function (field) {
4241
+ return field.column === true;
4242
+ }).map(function (field) {
4243
+ var options = field.options;
4244
+
4245
+ if (options && typeof options == 'function') {
4246
+ options = options();
4247
+ }
4248
+
4249
+ return {
4250
+ id: field.id,
4251
+ label: field.label,
4252
+ type: field.type,
4253
+ onChange: field.editable ? change : null,
4254
+ options: options
4255
+ };
4256
+ }),
4257
+ rows: groups[groupName].map(function (item) {
4258
+ item.actions = [/*#__PURE__*/React.createElement(Icon, {
4259
+ icon: "delete",
4260
+ size: "small",
4261
+ clickable: true,
4262
+ action: function action() {
4263
+ return remove(item.id);
4264
+ }
4265
+ })];
4266
+ return item;
4267
+ })
4268
+ };
4269
+ table.columns.push({
4270
+ id: "actions"
4271
+ });
4272
+ return /*#__PURE__*/React.createElement(Fragment, {
4273
+ key: groupName
4274
+ }, /*#__PURE__*/React.createElement(Header, {
4275
+ title: groupName
4276
+ }), /*#__PURE__*/React.createElement(DataTable, _extends({}, table, {
4277
+ onRowSelection: select,
4278
+ editable: editable
4279
+ })));
4280
+ });
4281
+ }
4282
+
4283
+ var table = {
4284
+ columns: Object.values(schema).filter(function (field) {
4285
+ return field.column === true;
4286
+ }).map(function (field) {
4287
+ var options = field.options;
4288
+
4289
+ if (options && typeof options == 'function') {
4290
+ options = options();
4291
+ }
4292
+
4293
+ return {
4294
+ id: field.id,
4295
+ label: field.label,
4296
+ type: field.type,
4297
+ onChange: field.editable ? change : null,
4298
+ options: options
4299
+ };
4300
+ }),
4301
+ rows: all.map(function (item) {
4302
+ item.actions = [/*#__PURE__*/React.createElement(Icon, {
4303
+ icon: "delete",
4304
+ size: "small",
4305
+ clickable: true,
4306
+ action: function action() {
4307
+ return remove(item.id);
4308
+ }
4309
+ })];
4310
+ return item;
4311
+ })
4312
+ };
4313
+ table.columns.push({
4314
+ id: "actions"
4315
+ });
4316
+
4317
+ function buildGroupOptions(schema) {
4318
+ return Object.values(schema).filter(function (field) {
4319
+ return field.grouper === true;
4320
+ }).map(function (field) {
4321
+ return {
4322
+ label: field.label,
4323
+ value: field.id
4324
+ };
4325
+ });
4326
+ }
4327
+
4328
+ return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Header, {
4329
+ icon: icon,
4330
+ title: /*#__PURE__*/React.createElement(Text, null, title)
4331
+ }, /*#__PURE__*/React.createElement(DropDown, {
4332
+ id: "groupBy",
4333
+ label: "Agrupar Por",
4334
+ value: groupBy,
4335
+ options: buildGroupOptions(schema),
4336
+ onChange: changeGroup
4337
+ })), /*#__PURE__*/React.createElement("main", {
4338
+ className: "table-editor"
4339
+ }, renderGroups()));
4340
+ };
4341
+ /**
4342
+ * table Context
4343
+ */
4344
+
4345
+
4346
+ var TableContext = function TableContext(url, field) {
4347
+ var API = TableAPI(url);
4348
+ return {
4349
+ all: [],
4350
+ selected: null,
4351
+ filters: {},
4352
+ load: function load(filter) {
4353
+ try {
4354
+ var _this2 = this;
4355
+
4356
+ var _temp2 = _catch(function () {
4357
+ var filters = filter ? Object.keys(filter).reduce(function (filters, key) {
4358
+ var field = filter[key];
4359
+ if (field) filters[key] === field;
4360
+ return filters;
4361
+ }, {}) : [];
4362
+ return Promise.resolve(API.all(filters)).then(function (data) {
4363
+ _this2.all = field ? data[field] : data;
4364
+ });
4365
+ }, function (error) {
4366
+ console.log(error);
4367
+ });
4368
+
4369
+ return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
4370
+ } catch (e) {
4371
+ return Promise.reject(e);
4372
+ }
4373
+ },
4374
+ select: function select(id) {
4375
+ var result = this.all.find(function (item) {
4376
+ return item.id === id;
4377
+ });
4378
+ this.selected = result;
4379
+ },
4380
+ clear: function clear() {
4381
+ this.selected = null;
4382
+ },
4383
+ create: function create(form) {
4384
+ try {
4385
+ var _this4 = this;
4386
+
4387
+ var _temp4 = _catch(function () {
4388
+ return Promise.resolve(API.create(form)).then(function () {
4389
+ return Promise.resolve(_this4.load()).then(function () {});
4390
+ });
4391
+ }, function (error) {
4392
+ console.log(error);
4393
+ });
4394
+
4395
+ return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(function () {}) : void 0);
4396
+ } catch (e) {
4397
+ return Promise.reject(e);
4398
+ }
4399
+ },
4400
+ update: function update(form) {
4401
+ try {
4402
+ var _this6 = this;
4403
+
4404
+ var _temp6 = _catch(function () {
4405
+ return Promise.resolve(API.update(form)).then(function () {
4406
+ return Promise.resolve(_this6.load()).then(function () {});
4407
+ });
4408
+ }, function (error) {
4409
+ console.log(error);
4410
+ });
4411
+
4412
+ return Promise.resolve(_temp6 && _temp6.then ? _temp6.then(function () {}) : void 0);
4413
+ } catch (e) {
4414
+ return Promise.reject(e);
4415
+ }
4416
+ },
4417
+ remove: function remove(id) {
4418
+ try {
4419
+ var _this8 = this;
4420
+
4421
+ var _temp8 = _catch(function () {
4422
+ return Promise.resolve(API.remove(id)).then(function () {
4423
+ return Promise.resolve(_this8.load()).then(function () {});
4424
+ });
4425
+ }, function (error) {
4426
+ console.log(error);
4427
+ });
4428
+
4429
+ return Promise.resolve(_temp8 && _temp8.then ? _temp8.then(function () {}) : void 0);
4430
+ } catch (e) {
4431
+ return Promise.reject(e);
4432
+ }
4433
+ },
4434
+ changeFilters: function changeFilters(filters) {
4435
+ this.filters = filters;
4436
+ }
4437
+ };
4438
+ };
4439
+ /**
4440
+ * table API
4441
+ */
4442
+
4443
+
4444
+ var TableAPI = function TableAPI(url) {
4445
+ return {
4446
+ all: function all(filters) {
4447
+ var queryParams = "?";
4448
+
4449
+ if (filters) {
4450
+ var filterQuery = Object.keys(filters).reduce(function (query, key) {
4451
+ if (typeof filters[key] === 'boolean') {
4452
+ return query.concat(key + "=" + filters[key] + "&");
4453
+ } else if (Array.isArray(filters[key])) {
4454
+ var param = filters[key].length === 0 ? '' : filters[key].reduce(function (param, field) {
4455
+ param.concat(key + "=" + field + "&");
4456
+ }, '');
4457
+ return query.concat(param);
4458
+ } else {
4459
+ return query.concat(key + "=%" + filters[key] + "%&");
4460
+ }
4461
+ }, "");
4462
+ queryParams = queryParams.concat(filterQuery);
4463
+ }
4464
+
4465
+ return http.GET(url + queryParams);
4466
+ },
4467
+ find: function find(id) {
4468
+ return http.GET(url + "/" + id);
4469
+ },
4470
+ create: function create(form) {
4471
+ var body = JSON.stringify(form);
4472
+ return http.POST(url, body);
4473
+ },
4474
+ update: function update(form) {
4475
+ var body = JSON.stringify(form);
4476
+ return http.PUT(url + "/" + form.id, body);
3898
4477
  },
3899
4478
  remove: function remove(id) {
3900
4479
  return http.DELETE(url + "/" + id);
@@ -4170,5 +4749,5 @@ var isFunction = function isFunction(value) {
4170
4749
  return value && (Object.prototype.toString.call(value) === "[object Function]" || "function" === typeof value || value instanceof Function);
4171
4750
  };
4172
4751
 
4173
- export { Button, CheckBox, Chip, Chips, CircularProgress, CollectionContext, CollectionEditor$1 as CollectionEditor, CollectionPage, Content, ContentEditor, ContentForm, CreateContentDialog$1 as CreateContentDialog, DataTable, Dialog, DropDown, EditContentDialog, FieldEditor, Form, HTTPClient, Header, Icon, Kanban, KanbanCard, KanbanColumn, LinearProgress, List, ListEditor, LoginBox, Menu, MenuIcon, MenuItem, MenuSeparator, Page, PageContext, PageProvider, Property, RadioButton, ResetPasswordBox, Section, Session, Site, SiteContext, SiteProvider, Stack, TYPES, Tab, TabbedContentEditor, Tabs, Text, TextField, TokenField, Tree, TreeItem, TreeNode, TreededContentEditor, UploadArea, UploadDialog, UploadFile, Uploader, Viewer, isFunction };
4752
+ export { Button, CheckBox, Chip, Chips, CircularProgress, CollectionContext, CollectionEditor$1 as CollectionEditor, CollectionPage, Content, ContentEditor, ContentForm, CreateContentDialog$1 as CreateContentDialog, DataTable, Dialog, DropDown, EditContentDialog, FieldEditor, Form, HTTPClient, Header, Icon, Kanban, KanbanCard, KanbanColumn, LinearProgress, List, ListEditor, LoginBox, Menu, MenuIcon, MenuItem, MenuSeparator, Page, PageContext, PageProvider, Property, RadioButton, ResetPasswordBox, Section, Session, Site, SiteContext, SiteProvider, Stack, TYPES, Tab, TabbedContentEditor, TablePage, Tabs, Text, TextField, TokenField, Tree, TreeItem, TreeNode, TreededContentEditor, UploadArea, UploadDialog, UploadFile, Uploader, Viewer, isFunction };
4174
4753
  //# sourceMappingURL=index.modern.js.map