ywana-core8 0.0.475 → 0.0.478

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.
@@ -1956,7 +1956,7 @@ var TokenField = function TokenField(_ref) {
1956
1956
  event.preventDefault();
1957
1957
  event.stopPropagation();
1958
1958
  var token = event.target.value;
1959
- var next = tokens.concat(token);
1959
+ var next = tokens.concat(token.trim());
1960
1960
  if (onChange) onChange(id, next);
1961
1961
  setValue('');
1962
1962
  }
@@ -4666,7 +4666,7 @@ function _catch$2(body, recover) {
4666
4666
  return result;
4667
4667
  }
4668
4668
  /**
4669
- * Collection List
4669
+ * Collection Filters
4670
4670
  */
4671
4671
 
4672
4672
 
@@ -4690,25 +4690,32 @@ var CollectionPage = function CollectionPage(props) {
4690
4690
  name = _props$name === void 0 ? "Collection 1" : _props$name,
4691
4691
  schema = props.schema,
4692
4692
  url = props.url,
4693
- page = props.page,
4694
- host = props.host,
4695
- groupBy = props.groupBy,
4696
- editor = props.editor,
4697
4693
  field = props.field,
4694
+ host = props.host,
4695
+ page = props.page,
4696
+ _props$fetching = props.fetching,
4697
+ fetching = _props$fetching === void 0 ? false : _props$fetching,
4698
+ _props$actions = props.actions,
4699
+ actions = _props$actions === void 0 ? [] : _props$actions,
4700
+ onSelect = props.onSelect,
4701
+ _props$canFilter = props.canFilter,
4702
+ canFilter = _props$canFilter === void 0 ? false : _props$canFilter,
4703
+ _props$canAdd = props.canAdd,
4704
+ canAdd = _props$canAdd === void 0 ? false : _props$canAdd,
4698
4705
  _props$autosave = props.autosave,
4699
4706
  autosave = _props$autosave === void 0 ? false : _props$autosave,
4700
4707
  _props$delay = props.delay,
4701
4708
  delay = _props$delay === void 0 ? 1000 : _props$delay,
4702
- actions = props.actions,
4709
+ groupBy = props.groupBy,
4703
4710
  levels = props.levels,
4704
- onSelect = props.onSelect,
4711
+ editor = props.editor,
4705
4712
  children = props.children;
4706
4713
 
4707
4714
  var _useContext = useContext(PageContext),
4708
4715
  pageContext = _useContext[0],
4709
4716
  setPageContext = _useContext[1];
4710
4717
 
4711
- var context = CollectionContext(url, field, host, page);
4718
+ var context = CollectionContext(url, field, host, page, fetching);
4712
4719
  useEffect(function () {
4713
4720
  try {
4714
4721
  return Promise.resolve(context.load()).then(function () {
@@ -4753,11 +4760,11 @@ var CollectionPage = function CollectionPage(props) {
4753
4760
  return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Header, {
4754
4761
  className: "collection-page",
4755
4762
  title: /*#__PURE__*/React.createElement(Text, null, title)
4756
- }, /*#__PURE__*/React.createElement(Button, {
4763
+ }, canAdd ? /*#__PURE__*/React.createElement(Button, {
4757
4764
  icon: "add",
4758
4765
  label: "Add",
4759
4766
  action: add
4760
- }), /*#__PURE__*/React.createElement(Button, {
4767
+ }) : false, "\xA0", /*#__PURE__*/React.createElement(Button, {
4761
4768
  icon: "refresh",
4762
4769
  label: "Reload",
4763
4770
  action: reload
@@ -4765,7 +4772,9 @@ var CollectionPage = function CollectionPage(props) {
4765
4772
  className: "collection-page"
4766
4773
  }, /*#__PURE__*/React.createElement(Header, {
4767
4774
  title: /*#__PURE__*/React.createElement(Text, null, "Lista de ", name)
4768
- }), levels ? /*#__PURE__*/React.createElement(CollectionTree, {
4775
+ }), canFilter ? /*#__PURE__*/React.createElement(CollectionFilters, {
4776
+ schema: schema
4777
+ }) : null, levels ? /*#__PURE__*/React.createElement(CollectionTree, {
4769
4778
  levels: levels,
4770
4779
  onSelect: onSelect
4771
4780
  }) : /*#__PURE__*/React.createElement(CollectionList, {
@@ -4783,6 +4792,16 @@ var CollectionPage = function CollectionPage(props) {
4783
4792
  }), children ? /*#__PURE__*/React.createElement("article", null, children) : null));
4784
4793
  };
4785
4794
 
4795
+ var CollectionFilters = function CollectionFilters(props) {
4796
+ return /*#__PURE__*/React.createElement("div", {
4797
+ className: "collection-filters"
4798
+ }, "TODO: filters");
4799
+ };
4800
+ /**
4801
+ * Collection List
4802
+ */
4803
+
4804
+
4786
4805
  var CollectionList = function CollectionList(props) {
4787
4806
  var select = function select(id) {
4788
4807
  try {
@@ -4814,7 +4833,8 @@ var CollectionList = function CollectionList(props) {
4814
4833
  var items = all ? all.map(function (content) {
4815
4834
  return {
4816
4835
  id: content.id,
4817
- line1: content.name,
4836
+ line1: content.name || content.centre,
4837
+ // centre: Signflow legacy
4818
4838
  line2: content.description,
4819
4839
  content: content
4820
4840
  };
@@ -5030,7 +5050,7 @@ var CollectionEditor = function CollectionEditor(props) {
5030
5050
  */
5031
5051
 
5032
5052
 
5033
- var CollectionContext = function CollectionContext(url, field, host, page) {
5053
+ var CollectionContext = function CollectionContext(url, field, host, page, fetching) {
5034
5054
  var API = CollectionAPI(url, host);
5035
5055
  return {
5036
5056
  all: [],
@@ -5053,95 +5073,123 @@ var CollectionContext = function CollectionContext(url, field, host, page) {
5053
5073
  }
5054
5074
  },
5055
5075
  select: function select(id) {
5056
- var result = this.all.find(function (item) {
5057
- return item.id === id;
5058
- });
5059
- this.selected = result;
5076
+ try {
5077
+ var _this4 = this;
5078
+
5079
+ var _temp4 = function () {
5080
+ if (fetching) {
5081
+ return Promise.resolve(_this4.fetch(id)).then(function (result) {
5082
+ _this4.selected = result;
5083
+ });
5084
+ } else {
5085
+ var result = _this4.all.find(function (item) {
5086
+ return item.id === id;
5087
+ });
5088
+
5089
+ _this4.selected = result;
5090
+ }
5091
+ }();
5092
+
5093
+ return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(function () {}) : void 0);
5094
+ } catch (e) {
5095
+ return Promise.reject(e);
5096
+ }
5097
+ },
5098
+ fetch: function fetch(id) {
5099
+ try {
5100
+ return Promise.resolve(_catch$2(function () {
5101
+ return Promise.resolve(API.find(id));
5102
+ }, function (error) {
5103
+ console.log(error);
5104
+ }));
5105
+ } catch (e) {
5106
+ return Promise.reject(e);
5107
+ }
5060
5108
  },
5061
5109
  clear: function clear() {
5062
5110
  this.selected = null;
5063
5111
  },
5064
5112
  create: function create(form) {
5065
5113
  try {
5066
- var _this4 = this;
5114
+ var _this6 = this;
5067
5115
 
5068
- var _temp4 = _catch$2(function () {
5116
+ var _temp6 = _catch$2(function () {
5069
5117
  return Promise.resolve(API.create(form)).then(function () {
5070
- return Promise.resolve(_this4.load()).then(function () {});
5118
+ return Promise.resolve(_this6.load()).then(function () {});
5071
5119
  });
5072
5120
  }, function (error) {
5073
5121
  console.log("CREATE ERROR", error);
5074
5122
  });
5075
5123
 
5076
- return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(function () {}) : void 0);
5124
+ return Promise.resolve(_temp6 && _temp6.then ? _temp6.then(function () {}) : void 0);
5077
5125
  } catch (e) {
5078
5126
  return Promise.reject(e);
5079
5127
  }
5080
5128
  },
5081
5129
  update: function update(form) {
5082
5130
  try {
5083
- var _this6 = this;
5131
+ var _this8 = this;
5084
5132
 
5085
- var _temp6 = _catch$2(function () {
5133
+ var _temp8 = _catch$2(function () {
5086
5134
  return Promise.resolve(API.update(form)).then(function () {
5087
- return Promise.resolve(_this6.load()).then(function () {});
5135
+ return Promise.resolve(_this8.load()).then(function () {});
5088
5136
  });
5089
5137
  }, function (error) {
5090
5138
  console.log(error);
5091
5139
  });
5092
5140
 
5093
- return Promise.resolve(_temp6 && _temp6.then ? _temp6.then(function () {}) : void 0);
5141
+ return Promise.resolve(_temp8 && _temp8.then ? _temp8.then(function () {}) : void 0);
5094
5142
  } catch (e) {
5095
5143
  return Promise.reject(e);
5096
5144
  }
5097
5145
  },
5098
5146
  patch: function patch(id, form) {
5099
5147
  try {
5100
- var _this8 = this;
5148
+ var _this10 = this;
5101
5149
 
5102
- var _temp8 = _catch$2(function () {
5150
+ var _temp10 = _catch$2(function () {
5103
5151
  return Promise.resolve(API.patch(id, form)).then(function () {
5104
- return Promise.resolve(_this8.load()).then(function () {});
5152
+ return Promise.resolve(_this10.load()).then(function () {});
5105
5153
  });
5106
5154
  }, function (error) {
5107
5155
  console.log(error);
5108
5156
  });
5109
5157
 
5110
- return Promise.resolve(_temp8 && _temp8.then ? _temp8.then(function () {}) : void 0);
5158
+ return Promise.resolve(_temp10 && _temp10.then ? _temp10.then(function () {}) : void 0);
5111
5159
  } catch (e) {
5112
5160
  return Promise.reject(e);
5113
5161
  }
5114
5162
  },
5115
5163
  updateProperty: function updateProperty(id, propertyName, form) {
5116
5164
  try {
5117
- var _this10 = this;
5165
+ var _this12 = this;
5118
5166
 
5119
- var _temp10 = _catch$2(function () {
5167
+ var _temp12 = _catch$2(function () {
5120
5168
  return Promise.resolve(API.updateProperty(id, propertyName, form)).then(function () {
5121
- return Promise.resolve(_this10.load()).then(function () {});
5169
+ return Promise.resolve(_this12.load()).then(function () {});
5122
5170
  });
5123
5171
  }, function (error) {
5124
5172
  console.log(error);
5125
5173
  });
5126
5174
 
5127
- return Promise.resolve(_temp10 && _temp10.then ? _temp10.then(function () {}) : void 0);
5175
+ return Promise.resolve(_temp12 && _temp12.then ? _temp12.then(function () {}) : void 0);
5128
5176
  } catch (e) {
5129
5177
  return Promise.reject(e);
5130
5178
  }
5131
5179
  },
5132
5180
  remove: function remove(id) {
5133
5181
  try {
5134
- var _this12 = this;
5182
+ var _this14 = this;
5135
5183
 
5136
- var _temp12 = _catch$2(function () {
5184
+ var _temp14 = _catch$2(function () {
5137
5185
  return Promise.resolve(API.remove(id)).then(function () {
5138
- return Promise.resolve(_this12.load()).then(function () {});
5186
+ return Promise.resolve(_this14.load()).then(function () {});
5139
5187
  });
5140
5188
  }, function (error) {
5141
5189
  console.log(error);
5142
5190
  });
5143
5191
 
5144
- return Promise.resolve(_temp12 && _temp12.then ? _temp12.then(function () {}) : void 0);
5192
+ return Promise.resolve(_temp14 && _temp14.then ? _temp14.then(function () {}) : void 0);
5145
5193
  } catch (e) {
5146
5194
  return Promise.reject(e);
5147
5195
  }