ywana-core8 0.0.476 → 0.0.477

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/dist/index.umd.js CHANGED
@@ -4693,11 +4693,13 @@
4693
4693
  name = _props$name === void 0 ? "Collection 1" : _props$name,
4694
4694
  schema = props.schema,
4695
4695
  url = props.url,
4696
- page = props.page,
4696
+ field = props.field,
4697
4697
  host = props.host,
4698
+ page = props.page,
4699
+ _props$fetching = props.fetching,
4700
+ fetching = _props$fetching === void 0 ? false : _props$fetching,
4698
4701
  groupBy = props.groupBy,
4699
4702
  editor = props.editor,
4700
- field = props.field,
4701
4703
  _props$autosave = props.autosave,
4702
4704
  autosave = _props$autosave === void 0 ? false : _props$autosave,
4703
4705
  _props$delay = props.delay,
@@ -4711,7 +4713,7 @@
4711
4713
  pageContext = _useContext[0],
4712
4714
  setPageContext = _useContext[1];
4713
4715
 
4714
- var context = CollectionContext(url, field, host, page);
4716
+ var context = CollectionContext(url, field, host, page, fetching);
4715
4717
  React.useEffect(function () {
4716
4718
  try {
4717
4719
  return Promise.resolve(context.load()).then(function () {
@@ -5033,7 +5035,7 @@
5033
5035
  */
5034
5036
 
5035
5037
 
5036
- var CollectionContext = function CollectionContext(url, field, host, page) {
5038
+ var CollectionContext = function CollectionContext(url, field, host, page, fetching) {
5037
5039
  var API = CollectionAPI(url, host);
5038
5040
  return {
5039
5041
  all: [],
@@ -5056,95 +5058,123 @@
5056
5058
  }
5057
5059
  },
5058
5060
  select: function select(id) {
5059
- var result = this.all.find(function (item) {
5060
- return item.id === id;
5061
- });
5062
- this.selected = result;
5061
+ try {
5062
+ var _this4 = this;
5063
+
5064
+ var _temp4 = function () {
5065
+ if (fetching) {
5066
+ return Promise.resolve(_this4.fetch(id)).then(function (result) {
5067
+ _this4.selected = result;
5068
+ });
5069
+ } else {
5070
+ var result = _this4.all.find(function (item) {
5071
+ return item.id === id;
5072
+ });
5073
+
5074
+ _this4.selected = result;
5075
+ }
5076
+ }();
5077
+
5078
+ return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(function () {}) : void 0);
5079
+ } catch (e) {
5080
+ return Promise.reject(e);
5081
+ }
5082
+ },
5083
+ fetch: function fetch(id) {
5084
+ try {
5085
+ return Promise.resolve(_catch$2(function () {
5086
+ return Promise.resolve(API.find(id));
5087
+ }, function (error) {
5088
+ console.log(error);
5089
+ }));
5090
+ } catch (e) {
5091
+ return Promise.reject(e);
5092
+ }
5063
5093
  },
5064
5094
  clear: function clear() {
5065
5095
  this.selected = null;
5066
5096
  },
5067
5097
  create: function create(form) {
5068
5098
  try {
5069
- var _this4 = this;
5099
+ var _this6 = this;
5070
5100
 
5071
- var _temp4 = _catch$2(function () {
5101
+ var _temp6 = _catch$2(function () {
5072
5102
  return Promise.resolve(API.create(form)).then(function () {
5073
- return Promise.resolve(_this4.load()).then(function () {});
5103
+ return Promise.resolve(_this6.load()).then(function () {});
5074
5104
  });
5075
5105
  }, function (error) {
5076
5106
  console.log("CREATE ERROR", error);
5077
5107
  });
5078
5108
 
5079
- return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(function () {}) : void 0);
5109
+ return Promise.resolve(_temp6 && _temp6.then ? _temp6.then(function () {}) : void 0);
5080
5110
  } catch (e) {
5081
5111
  return Promise.reject(e);
5082
5112
  }
5083
5113
  },
5084
5114
  update: function update(form) {
5085
5115
  try {
5086
- var _this6 = this;
5116
+ var _this8 = this;
5087
5117
 
5088
- var _temp6 = _catch$2(function () {
5118
+ var _temp8 = _catch$2(function () {
5089
5119
  return Promise.resolve(API.update(form)).then(function () {
5090
- return Promise.resolve(_this6.load()).then(function () {});
5120
+ return Promise.resolve(_this8.load()).then(function () {});
5091
5121
  });
5092
5122
  }, function (error) {
5093
5123
  console.log(error);
5094
5124
  });
5095
5125
 
5096
- return Promise.resolve(_temp6 && _temp6.then ? _temp6.then(function () {}) : void 0);
5126
+ return Promise.resolve(_temp8 && _temp8.then ? _temp8.then(function () {}) : void 0);
5097
5127
  } catch (e) {
5098
5128
  return Promise.reject(e);
5099
5129
  }
5100
5130
  },
5101
5131
  patch: function patch(id, form) {
5102
5132
  try {
5103
- var _this8 = this;
5133
+ var _this10 = this;
5104
5134
 
5105
- var _temp8 = _catch$2(function () {
5135
+ var _temp10 = _catch$2(function () {
5106
5136
  return Promise.resolve(API.patch(id, form)).then(function () {
5107
- return Promise.resolve(_this8.load()).then(function () {});
5137
+ return Promise.resolve(_this10.load()).then(function () {});
5108
5138
  });
5109
5139
  }, function (error) {
5110
5140
  console.log(error);
5111
5141
  });
5112
5142
 
5113
- return Promise.resolve(_temp8 && _temp8.then ? _temp8.then(function () {}) : void 0);
5143
+ return Promise.resolve(_temp10 && _temp10.then ? _temp10.then(function () {}) : void 0);
5114
5144
  } catch (e) {
5115
5145
  return Promise.reject(e);
5116
5146
  }
5117
5147
  },
5118
5148
  updateProperty: function updateProperty(id, propertyName, form) {
5119
5149
  try {
5120
- var _this10 = this;
5150
+ var _this12 = this;
5121
5151
 
5122
- var _temp10 = _catch$2(function () {
5152
+ var _temp12 = _catch$2(function () {
5123
5153
  return Promise.resolve(API.updateProperty(id, propertyName, form)).then(function () {
5124
- return Promise.resolve(_this10.load()).then(function () {});
5154
+ return Promise.resolve(_this12.load()).then(function () {});
5125
5155
  });
5126
5156
  }, function (error) {
5127
5157
  console.log(error);
5128
5158
  });
5129
5159
 
5130
- return Promise.resolve(_temp10 && _temp10.then ? _temp10.then(function () {}) : void 0);
5160
+ return Promise.resolve(_temp12 && _temp12.then ? _temp12.then(function () {}) : void 0);
5131
5161
  } catch (e) {
5132
5162
  return Promise.reject(e);
5133
5163
  }
5134
5164
  },
5135
5165
  remove: function remove(id) {
5136
5166
  try {
5137
- var _this12 = this;
5167
+ var _this14 = this;
5138
5168
 
5139
- var _temp12 = _catch$2(function () {
5169
+ var _temp14 = _catch$2(function () {
5140
5170
  return Promise.resolve(API.remove(id)).then(function () {
5141
- return Promise.resolve(_this12.load()).then(function () {});
5171
+ return Promise.resolve(_this14.load()).then(function () {});
5142
5172
  });
5143
5173
  }, function (error) {
5144
5174
  console.log(error);
5145
5175
  });
5146
5176
 
5147
- return Promise.resolve(_temp12 && _temp12.then ? _temp12.then(function () {}) : void 0);
5177
+ return Promise.resolve(_temp14 && _temp14.then ? _temp14.then(function () {}) : void 0);
5148
5178
  } catch (e) {
5149
5179
  return Promise.reject(e);
5150
5180
  }