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