ywana-core8 0.0.680 → 0.0.682
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 +136 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +5 -13
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +136 -74
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +9405 -9342
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/CollectionPage.js +4 -64
package/dist/index.modern.js
CHANGED
@@ -9,6 +9,41 @@ import { ReactNotifications, Store } from 'react-notifications-component';
|
|
9
9
|
import 'react-notifications-component/dist/theme.css';
|
10
10
|
import equal from 'deep-equal';
|
11
11
|
|
12
|
+
/**
|
13
|
+
* isEmpty
|
14
|
+
*
|
15
|
+
* @param {*} obj
|
16
|
+
* @returns
|
17
|
+
*/
|
18
|
+
function isEmpty(obj) {
|
19
|
+
// null
|
20
|
+
if (obj === null) {
|
21
|
+
return true;
|
22
|
+
} // undefined
|
23
|
+
|
24
|
+
|
25
|
+
if (obj === undefined) {
|
26
|
+
return true;
|
27
|
+
} // empty string
|
28
|
+
|
29
|
+
|
30
|
+
if (typeof obj === "string" && obj.length === 0) {
|
31
|
+
return true;
|
32
|
+
} // empty array
|
33
|
+
|
34
|
+
|
35
|
+
if (Array.isArray(obj) && obj.length === 0) {
|
36
|
+
return true;
|
37
|
+
} // empty object
|
38
|
+
|
39
|
+
|
40
|
+
if (typeof obj === "object" && Object.keys(obj).length === 0 && obj.constructor === Object) {
|
41
|
+
return true;
|
42
|
+
}
|
43
|
+
|
44
|
+
return false;
|
45
|
+
}
|
46
|
+
|
12
47
|
function _catch$5(body, recover) {
|
13
48
|
try {
|
14
49
|
var result = body();
|
@@ -5599,6 +5634,82 @@ var EditContentDialog = function EditContentDialog(_ref) {
|
|
5599
5634
|
}));
|
5600
5635
|
};
|
5601
5636
|
|
5637
|
+
/**
|
5638
|
+
* Collection API
|
5639
|
+
*/
|
5640
|
+
|
5641
|
+
var CollectionAPI = function CollectionAPI(url, host) {
|
5642
|
+
var http = HTTPClient(host || window.API || process.env.REACT_APP_API, Session);
|
5643
|
+
/**
|
5644
|
+
* objectToQueryParamString
|
5645
|
+
*
|
5646
|
+
* @param {*} obj
|
5647
|
+
* @returns
|
5648
|
+
*/
|
5649
|
+
|
5650
|
+
function objectToQueryParamString(obj, likes) {
|
5651
|
+
if (isEmpty(obj)) {
|
5652
|
+
return "";
|
5653
|
+
}
|
5654
|
+
|
5655
|
+
var notEmptyFields = Object.keys(obj).filter(function (key) {
|
5656
|
+
return !isEmpty(obj[key]);
|
5657
|
+
});
|
5658
|
+
var paramString = notEmptyFields.reduce(function (query, key) {
|
5659
|
+
var value = obj[key];
|
5660
|
+
var like = likes.includes(key) ? '%' : '';
|
5661
|
+
|
5662
|
+
if (Array.isArray(value)) {
|
5663
|
+
var values = value.map(function (v) {
|
5664
|
+
return key + "=" + like + v + like;
|
5665
|
+
}).join("&");
|
5666
|
+
return "" + query + values + "&";
|
5667
|
+
} else if (typeof value === "object") {
|
5668
|
+
var params = objectToQueryParamString(value, likes);
|
5669
|
+
params.split("&").forEach(function (param) {
|
5670
|
+
query = query.concat(key + "." + param + "&");
|
5671
|
+
});
|
5672
|
+
return query;
|
5673
|
+
} else {
|
5674
|
+
return "" + query + key + "=" + like + value + like + "&";
|
5675
|
+
}
|
5676
|
+
}, "");
|
5677
|
+
return paramString;
|
5678
|
+
}
|
5679
|
+
|
5680
|
+
return {
|
5681
|
+
all: function all(filters, likes, page) {
|
5682
|
+
var queryParams = page ? "?page=" + page + "&" : "?";
|
5683
|
+
var filterQuery = objectToQueryParamString(filters, likes);
|
5684
|
+
queryParams = "" + queryParams + filterQuery;
|
5685
|
+
queryParams = queryParams.substring(0, queryParams.length - 1);
|
5686
|
+
return http.GET("" + url + queryParams);
|
5687
|
+
},
|
5688
|
+
find: function find(id) {
|
5689
|
+
return http.GET(url + "/" + id);
|
5690
|
+
},
|
5691
|
+
create: function create(form) {
|
5692
|
+
var body = JSON.stringify(form);
|
5693
|
+
return http.POST(url, body);
|
5694
|
+
},
|
5695
|
+
update: function update(form) {
|
5696
|
+
var body = JSON.stringify(form);
|
5697
|
+
return http.PUT(url + "/" + form.id, body);
|
5698
|
+
},
|
5699
|
+
updateProperty: function updateProperty(id, propertyName, form) {
|
5700
|
+
var body = JSON.stringify(form);
|
5701
|
+
return http.PUT(url + "/" + id + "/" + propertyName, body);
|
5702
|
+
},
|
5703
|
+
patch: function patch(id, form) {
|
5704
|
+
var body = JSON.stringify(form);
|
5705
|
+
return http.PATCH(url + "/" + id, body);
|
5706
|
+
},
|
5707
|
+
remove: function remove(id) {
|
5708
|
+
return http.DELETE(url + "/" + id);
|
5709
|
+
}
|
5710
|
+
};
|
5711
|
+
};
|
5712
|
+
|
5602
5713
|
/**
|
5603
5714
|
* Collection Page
|
5604
5715
|
*/
|
@@ -5791,9 +5902,11 @@ var CollectionFilters = function CollectionFilters(props) {
|
|
5791
5902
|
};
|
5792
5903
|
|
5793
5904
|
var schema = props.schema,
|
5905
|
+
_props$initial = props.initial,
|
5906
|
+
initial = _props$initial === void 0 ? {} : _props$initial,
|
5794
5907
|
onChange = props.onChange;
|
5795
5908
|
|
5796
|
-
var _useState = useState(
|
5909
|
+
var _useState = useState(initial),
|
5797
5910
|
form = _useState[0],
|
5798
5911
|
setForm = _useState[1];
|
5799
5912
|
|
@@ -5833,9 +5946,10 @@ var CollectionFilters = function CollectionFilters(props) {
|
|
5833
5946
|
}
|
5834
5947
|
|
5835
5948
|
var content = new Content(filterSchema, form);
|
5949
|
+
var expanded = showFilters ? "expanded" : "";
|
5836
5950
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Header, {
|
5837
5951
|
icon: "filter_list",
|
5838
|
-
className: "filters-header"
|
5952
|
+
className: "filters-header " + expanded
|
5839
5953
|
}, showFilters ? /*#__PURE__*/React.createElement(Icon, {
|
5840
5954
|
icon: "expand_less",
|
5841
5955
|
size: "small",
|
@@ -5847,39 +5961,43 @@ var CollectionFilters = function CollectionFilters(props) {
|
|
5847
5961
|
clickable: true,
|
5848
5962
|
action: toggleFilters
|
5849
5963
|
}), /*#__PURE__*/React.createElement(FilterResume, {
|
5850
|
-
|
5851
|
-
|
5852
|
-
|
5853
|
-
}, /*#__PURE__*/React.createElement(
|
5854
|
-
icon: "clear_all",
|
5855
|
-
size: "small",
|
5856
|
-
clickable: true,
|
5857
|
-
action: clear
|
5858
|
-
})), /*#__PURE__*/React.createElement("main", {
|
5964
|
+
schema: filterSchema,
|
5965
|
+
form: form,
|
5966
|
+
onClear: clear
|
5967
|
+
})), showFilters ? /*#__PURE__*/React.createElement("div", {
|
5859
5968
|
className: "collection-filters"
|
5860
5969
|
}, /*#__PURE__*/React.createElement(ContentEditor, {
|
5861
5970
|
content: content,
|
5862
5971
|
onChange: change
|
5863
|
-
}))
|
5972
|
+
})) : null);
|
5864
5973
|
};
|
5865
5974
|
|
5866
5975
|
var FilterResume = function FilterResume(props) {
|
5867
|
-
var
|
5868
|
-
|
5976
|
+
var schema = props.schema,
|
5977
|
+
_props$form = props.form,
|
5978
|
+
form = _props$form === void 0 ? {} : _props$form,
|
5979
|
+
onClear = props.onClear;
|
5869
5980
|
var fields = Object.keys(form).filter(function (key) {
|
5870
5981
|
return form[key] !== undefined && form[key] !== null && form[key] !== "";
|
5871
5982
|
});
|
5872
|
-
return /*#__PURE__*/React.createElement(
|
5983
|
+
return /*#__PURE__*/React.createElement(Fragment, null, fields.length > 0 ? /*#__PURE__*/React.createElement(Tooltip, {
|
5984
|
+
text: "Limpiar Filtros"
|
5985
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
5986
|
+
icon: "clear_all",
|
5987
|
+
size: "small",
|
5988
|
+
clickable: true,
|
5989
|
+
action: onClear
|
5990
|
+
})) : null, /*#__PURE__*/React.createElement("div", {
|
5873
5991
|
className: "filters-resume"
|
5874
5992
|
}, fields.length > 0 ? fields.map(function (key) {
|
5875
5993
|
return /*#__PURE__*/React.createElement("div", {
|
5876
5994
|
className: "filter-field"
|
5877
|
-
}, /*#__PURE__*/React.createElement("label", null, key), /*#__PURE__*/React.createElement("div", {
|
5995
|
+
}, /*#__PURE__*/React.createElement("label", null, schema[key].label), /*#__PURE__*/React.createElement("div", {
|
5878
5996
|
className: "value"
|
5879
5997
|
}, form[key]));
|
5880
5998
|
}) : /*#__PURE__*/React.createElement("div", {
|
5881
5999
|
className: "placeholder"
|
5882
|
-
}, "No se aplican filtros"));
|
6000
|
+
}, "No se aplican filtros")));
|
5883
6001
|
};
|
5884
6002
|
/**
|
5885
6003
|
* Collection List
|
@@ -6089,7 +6207,6 @@ var CollectionTree = function CollectionTree(props) {
|
|
6089
6207
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("main", null, /*#__PURE__*/React.createElement(Tree, null, renderNodes(nodes))), /*#__PURE__*/React.createElement("footer", null, /*#__PURE__*/React.createElement("div", {
|
6090
6208
|
className: "search-box"
|
6091
6209
|
}, /*#__PURE__*/React.createElement(TextField, {
|
6092
|
-
icon: "search",
|
6093
6210
|
label: "Search",
|
6094
6211
|
onChange: changeSearch,
|
6095
6212
|
outlined: true,
|
@@ -6402,61 +6519,6 @@ var CollectionContext = function CollectionContext(url, field, host, page, fetch
|
|
6402
6519
|
}
|
6403
6520
|
};
|
6404
6521
|
};
|
6405
|
-
/**
|
6406
|
-
* Collection API
|
6407
|
-
*/
|
6408
|
-
|
6409
|
-
var CollectionAPI = function CollectionAPI(url, host) {
|
6410
|
-
var http = HTTPClient(host || window.API || process.env.REACT_APP_API, Session);
|
6411
|
-
return {
|
6412
|
-
all: function all(filters, page) {
|
6413
|
-
var queryParams = page ? "?page=" + page + "&" : "?";
|
6414
|
-
|
6415
|
-
if (filters) {
|
6416
|
-
var filterQuery = Object.keys(filters).reduce(function (query, key) {
|
6417
|
-
var value = filters[key];
|
6418
|
-
|
6419
|
-
if (typeof value === 'boolean') {
|
6420
|
-
return query.concat(key + "=" + value + "&");
|
6421
|
-
} else if (Array.isArray(value)) {
|
6422
|
-
var param = value.length === 0 ? '' : value.reduce(function (param, item) {
|
6423
|
-
param = param.concat(key + "=" + item + "&");
|
6424
|
-
return param;
|
6425
|
-
}, "");
|
6426
|
-
return query.concat(param);
|
6427
|
-
} else {
|
6428
|
-
return query.concat(key + "=%" + filters[key] + "%&");
|
6429
|
-
}
|
6430
|
-
}, "");
|
6431
|
-
queryParams = queryParams.concat(filterQuery);
|
6432
|
-
}
|
6433
|
-
|
6434
|
-
return http.GET(url + queryParams);
|
6435
|
-
},
|
6436
|
-
find: function find(id) {
|
6437
|
-
return http.GET(url + "/" + id);
|
6438
|
-
},
|
6439
|
-
create: function create(form) {
|
6440
|
-
var body = JSON.stringify(form);
|
6441
|
-
return http.POST(url, body);
|
6442
|
-
},
|
6443
|
-
update: function update(form) {
|
6444
|
-
var body = JSON.stringify(form);
|
6445
|
-
return http.PUT(url + "/" + form.id, body);
|
6446
|
-
},
|
6447
|
-
patch: function patch(id, form) {
|
6448
|
-
var body = JSON.stringify(form);
|
6449
|
-
return http.PATCH(url + "/" + id, body);
|
6450
|
-
},
|
6451
|
-
updateProperty: function updateProperty(id, propertyName, form) {
|
6452
|
-
var body = JSON.stringify(form);
|
6453
|
-
return http.PUT(url + "/" + id + "/" + propertyName, body);
|
6454
|
-
},
|
6455
|
-
remove: function remove(id) {
|
6456
|
-
return http.DELETE(url + "/" + id);
|
6457
|
-
}
|
6458
|
-
};
|
6459
|
-
};
|
6460
6522
|
|
6461
6523
|
var QUERY = {
|
6462
6524
|
id: {
|
@@ -10042,5 +10104,5 @@ var isFunction = function isFunction(value) {
|
|
10042
10104
|
return value && (Object.prototype.toString.call(value) === "[object Function]" || "function" === typeof value || value instanceof Function);
|
10043
10105
|
};
|
10044
10106
|
|
10045
|
-
export { Accordion, Avatar, Button, Calendar, CheckBox, Chip, Chips, CircularProgress, CollectionContext, CollectionEditor$1 as CollectionEditor, CollectionFilters, CollectionPage, CollectionTree, ColorField, Content, ContentEditor, ContentForm, ContentViewer, CreateContentDialog, DataTable, Dialog, DropDown, EditContentDialog, EmptyMessage, FORMATS, FieldEditor, FileExplorer, FilesGrid, Form, HTTPClient, Header, Icon, Kanban, KanbanCard, KanbanColumn, LinearProgress, List, ListEditor, LoginBox, Menu, MenuIcon, MenuItem, MenuSeparator, Page, PageContext, PageProvider, Planner, Property, RadioButton, ResetPasswordBox, Section, Session, Site, SiteContext, SiteProvider, Stack, Switch, TEXTFORMATS, TYPES, Tab, TabbedContentEditor, TabbedTablePage, TabbedView, TableEditor$2 as TableEditor, TablePage, TablePage2, Tabs, TaskContext, TaskContextProvider, TaskMonitor, TaskProgress, Text, TextArea, TextField, Thumbnail, TokenField, Tooltip, Tree, TreeItem, TreeNode, TreededContentEditor, UploadArea, UploadDialog, UploadFile, UploadIcon, Uploader, View, Viewer, WaitScreen, Wizard, WizardContext, isFunction };
|
10107
|
+
export { Accordion, Avatar, Button, Calendar, CheckBox, Chip, Chips, CircularProgress, CollectionContext, CollectionEditor$1 as CollectionEditor, CollectionFilters, CollectionPage, CollectionTree, ColorField, Content, ContentEditor, ContentForm, ContentViewer, CreateContentDialog, DataTable, Dialog, DropDown, EditContentDialog, EmptyMessage, FORMATS, FieldEditor, FileExplorer, FilesGrid, Form, HTTPClient, Header, Icon, Kanban, KanbanCard, KanbanColumn, LinearProgress, List, ListEditor, LoginBox, Menu, MenuIcon, MenuItem, MenuSeparator, Page, PageContext, PageProvider, Planner, Property, RadioButton, ResetPasswordBox, Section, Session, Site, SiteContext, SiteProvider, Stack, Switch, TEXTFORMATS, TYPES, Tab, TabbedContentEditor, TabbedTablePage, TabbedView, TableEditor$2 as TableEditor, TablePage, TablePage2, Tabs, TaskContext, TaskContextProvider, TaskMonitor, TaskProgress, Text, TextArea, TextField, Thumbnail, TokenField, Tooltip, Tree, TreeItem, TreeNode, TreededContentEditor, UploadArea, UploadDialog, UploadFile, UploadIcon, Uploader, View, Viewer, WaitScreen, Wizard, WizardContext, isEmpty, isFunction };
|
10046
10108
|
//# sourceMappingURL=index.modern.js.map
|