ywana-core8 0.0.476 → 0.0.479

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
@@ -4674,7 +4674,7 @@ function _catch$2(body, recover) {
4674
4674
  return result;
4675
4675
  }
4676
4676
  /**
4677
- * Collection List
4677
+ * Collection Filters
4678
4678
  */
4679
4679
 
4680
4680
 
@@ -4698,25 +4698,32 @@ 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,
4702
- host = props.host,
4703
- groupBy = props.groupBy,
4704
- editor = props.editor,
4705
4701
  field = props.field,
4702
+ host = props.host,
4703
+ page = props.page,
4704
+ _props$fetching = props.fetching,
4705
+ fetching = _props$fetching === void 0 ? false : _props$fetching,
4706
+ _props$actions = props.actions,
4707
+ actions = _props$actions === void 0 ? [] : _props$actions,
4708
+ onSelect = props.onSelect,
4709
+ _props$canFilter = props.canFilter,
4710
+ canFilter = _props$canFilter === void 0 ? false : _props$canFilter,
4711
+ _props$canAdd = props.canAdd,
4712
+ canAdd = _props$canAdd === void 0 ? false : _props$canAdd,
4706
4713
  _props$autosave = props.autosave,
4707
4714
  autosave = _props$autosave === void 0 ? false : _props$autosave,
4708
4715
  _props$delay = props.delay,
4709
4716
  delay = _props$delay === void 0 ? 1000 : _props$delay,
4710
- actions = props.actions,
4717
+ groupBy = props.groupBy,
4711
4718
  levels = props.levels,
4712
- onSelect = props.onSelect,
4719
+ editor = props.editor,
4713
4720
  children = props.children;
4714
4721
 
4715
4722
  var _useContext = React.useContext(PageContext),
4716
4723
  pageContext = _useContext[0],
4717
4724
  setPageContext = _useContext[1];
4718
4725
 
4719
- var context = CollectionContext(url, field, host, page);
4726
+ var context = CollectionContext(url, field, host, page, fetching);
4720
4727
  React.useEffect(function () {
4721
4728
  try {
4722
4729
  return Promise.resolve(context.load()).then(function () {
@@ -4761,11 +4768,11 @@ var CollectionPage = function CollectionPage(props) {
4761
4768
  return /*#__PURE__*/React__default["default"].createElement(React.Fragment, null, /*#__PURE__*/React__default["default"].createElement(Header, {
4762
4769
  className: "collection-page",
4763
4770
  title: /*#__PURE__*/React__default["default"].createElement(Text, null, title)
4764
- }, /*#__PURE__*/React__default["default"].createElement(Button, {
4771
+ }, canAdd ? /*#__PURE__*/React__default["default"].createElement(Button, {
4765
4772
  icon: "add",
4766
4773
  label: "Add",
4767
4774
  action: add
4768
- }), /*#__PURE__*/React__default["default"].createElement(Button, {
4775
+ }) : false, "\xA0", /*#__PURE__*/React__default["default"].createElement(Button, {
4769
4776
  icon: "refresh",
4770
4777
  label: "Reload",
4771
4778
  action: reload
@@ -4773,7 +4780,9 @@ var CollectionPage = function CollectionPage(props) {
4773
4780
  className: "collection-page"
4774
4781
  }, /*#__PURE__*/React__default["default"].createElement(Header, {
4775
4782
  title: /*#__PURE__*/React__default["default"].createElement(Text, null, "Lista de ", name)
4776
- }), levels ? /*#__PURE__*/React__default["default"].createElement(CollectionTree, {
4783
+ }), canFilter ? /*#__PURE__*/React__default["default"].createElement(CollectionFilters, {
4784
+ schema: schema
4785
+ }) : null, levels ? /*#__PURE__*/React__default["default"].createElement(CollectionTree, {
4777
4786
  levels: levels,
4778
4787
  onSelect: onSelect
4779
4788
  }) : /*#__PURE__*/React__default["default"].createElement(CollectionList, {
@@ -4791,6 +4800,16 @@ var CollectionPage = function CollectionPage(props) {
4791
4800
  }), children ? /*#__PURE__*/React__default["default"].createElement("article", null, children) : null));
4792
4801
  };
4793
4802
 
4803
+ var CollectionFilters = function CollectionFilters(props) {
4804
+ return /*#__PURE__*/React__default["default"].createElement("div", {
4805
+ className: "collection-filters"
4806
+ }, "TODO: filters");
4807
+ };
4808
+ /**
4809
+ * Collection List
4810
+ */
4811
+
4812
+
4794
4813
  var CollectionList = function CollectionList(props) {
4795
4814
  var select = function select(id) {
4796
4815
  try {
@@ -4822,7 +4841,8 @@ var CollectionList = function CollectionList(props) {
4822
4841
  var items = all ? all.map(function (content) {
4823
4842
  return {
4824
4843
  id: content.id,
4825
- line1: content.name,
4844
+ line1: content.name || content.centre || content.tag,
4845
+ // centre: Signflow legacy
4826
4846
  line2: content.description,
4827
4847
  content: content
4828
4848
  };
@@ -5038,7 +5058,7 @@ var CollectionEditor = function CollectionEditor(props) {
5038
5058
  */
5039
5059
 
5040
5060
 
5041
- var CollectionContext = function CollectionContext(url, field, host, page) {
5061
+ var CollectionContext = function CollectionContext(url, field, host, page, fetching) {
5042
5062
  var API = CollectionAPI(url, host);
5043
5063
  return {
5044
5064
  all: [],
@@ -5061,95 +5081,123 @@ var CollectionContext = function CollectionContext(url, field, host, page) {
5061
5081
  }
5062
5082
  },
5063
5083
  select: function select(id) {
5064
- var result = this.all.find(function (item) {
5065
- return item.id === id;
5066
- });
5067
- this.selected = result;
5084
+ try {
5085
+ var _this4 = this;
5086
+
5087
+ var _temp4 = function () {
5088
+ if (fetching) {
5089
+ return Promise.resolve(_this4.fetch(id)).then(function (result) {
5090
+ _this4.selected = result;
5091
+ });
5092
+ } else {
5093
+ var result = _this4.all.find(function (item) {
5094
+ return item.id === id;
5095
+ });
5096
+
5097
+ _this4.selected = result;
5098
+ }
5099
+ }();
5100
+
5101
+ return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(function () {}) : void 0);
5102
+ } catch (e) {
5103
+ return Promise.reject(e);
5104
+ }
5105
+ },
5106
+ fetch: function fetch(id) {
5107
+ try {
5108
+ return Promise.resolve(_catch$2(function () {
5109
+ return Promise.resolve(API.find(id));
5110
+ }, function (error) {
5111
+ console.log(error);
5112
+ }));
5113
+ } catch (e) {
5114
+ return Promise.reject(e);
5115
+ }
5068
5116
  },
5069
5117
  clear: function clear() {
5070
5118
  this.selected = null;
5071
5119
  },
5072
5120
  create: function create(form) {
5073
5121
  try {
5074
- var _this4 = this;
5122
+ var _this6 = this;
5075
5123
 
5076
- var _temp4 = _catch$2(function () {
5124
+ var _temp6 = _catch$2(function () {
5077
5125
  return Promise.resolve(API.create(form)).then(function () {
5078
- return Promise.resolve(_this4.load()).then(function () {});
5126
+ return Promise.resolve(_this6.load()).then(function () {});
5079
5127
  });
5080
5128
  }, function (error) {
5081
5129
  console.log("CREATE ERROR", error);
5082
5130
  });
5083
5131
 
5084
- return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(function () {}) : void 0);
5132
+ return Promise.resolve(_temp6 && _temp6.then ? _temp6.then(function () {}) : void 0);
5085
5133
  } catch (e) {
5086
5134
  return Promise.reject(e);
5087
5135
  }
5088
5136
  },
5089
5137
  update: function update(form) {
5090
5138
  try {
5091
- var _this6 = this;
5139
+ var _this8 = this;
5092
5140
 
5093
- var _temp6 = _catch$2(function () {
5141
+ var _temp8 = _catch$2(function () {
5094
5142
  return Promise.resolve(API.update(form)).then(function () {
5095
- return Promise.resolve(_this6.load()).then(function () {});
5143
+ return Promise.resolve(_this8.load()).then(function () {});
5096
5144
  });
5097
5145
  }, function (error) {
5098
5146
  console.log(error);
5099
5147
  });
5100
5148
 
5101
- return Promise.resolve(_temp6 && _temp6.then ? _temp6.then(function () {}) : void 0);
5149
+ return Promise.resolve(_temp8 && _temp8.then ? _temp8.then(function () {}) : void 0);
5102
5150
  } catch (e) {
5103
5151
  return Promise.reject(e);
5104
5152
  }
5105
5153
  },
5106
5154
  patch: function patch(id, form) {
5107
5155
  try {
5108
- var _this8 = this;
5156
+ var _this10 = this;
5109
5157
 
5110
- var _temp8 = _catch$2(function () {
5158
+ var _temp10 = _catch$2(function () {
5111
5159
  return Promise.resolve(API.patch(id, form)).then(function () {
5112
- return Promise.resolve(_this8.load()).then(function () {});
5160
+ return Promise.resolve(_this10.load()).then(function () {});
5113
5161
  });
5114
5162
  }, function (error) {
5115
5163
  console.log(error);
5116
5164
  });
5117
5165
 
5118
- return Promise.resolve(_temp8 && _temp8.then ? _temp8.then(function () {}) : void 0);
5166
+ return Promise.resolve(_temp10 && _temp10.then ? _temp10.then(function () {}) : void 0);
5119
5167
  } catch (e) {
5120
5168
  return Promise.reject(e);
5121
5169
  }
5122
5170
  },
5123
5171
  updateProperty: function updateProperty(id, propertyName, form) {
5124
5172
  try {
5125
- var _this10 = this;
5173
+ var _this12 = this;
5126
5174
 
5127
- var _temp10 = _catch$2(function () {
5175
+ var _temp12 = _catch$2(function () {
5128
5176
  return Promise.resolve(API.updateProperty(id, propertyName, form)).then(function () {
5129
- return Promise.resolve(_this10.load()).then(function () {});
5177
+ return Promise.resolve(_this12.load()).then(function () {});
5130
5178
  });
5131
5179
  }, function (error) {
5132
5180
  console.log(error);
5133
5181
  });
5134
5182
 
5135
- return Promise.resolve(_temp10 && _temp10.then ? _temp10.then(function () {}) : void 0);
5183
+ return Promise.resolve(_temp12 && _temp12.then ? _temp12.then(function () {}) : void 0);
5136
5184
  } catch (e) {
5137
5185
  return Promise.reject(e);
5138
5186
  }
5139
5187
  },
5140
5188
  remove: function remove(id) {
5141
5189
  try {
5142
- var _this12 = this;
5190
+ var _this14 = this;
5143
5191
 
5144
- var _temp12 = _catch$2(function () {
5192
+ var _temp14 = _catch$2(function () {
5145
5193
  return Promise.resolve(API.remove(id)).then(function () {
5146
- return Promise.resolve(_this12.load()).then(function () {});
5194
+ return Promise.resolve(_this14.load()).then(function () {});
5147
5195
  });
5148
5196
  }, function (error) {
5149
5197
  console.log(error);
5150
5198
  });
5151
5199
 
5152
- return Promise.resolve(_temp12 && _temp12.then ? _temp12.then(function () {}) : void 0);
5200
+ return Promise.resolve(_temp14 && _temp14.then ? _temp14.then(function () {}) : void 0);
5153
5201
  } catch (e) {
5154
5202
  return Promise.reject(e);
5155
5203
  }