ywana-core8 0.0.668 → 0.0.670

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ywana-core8",
3
- "version": "0.0.668",
3
+ "version": "0.0.670",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
@@ -21,16 +21,15 @@ export const CollectionPage = (props) => {
21
21
  schema, url, field, host, page, fetching = false,
22
22
  actions = [], onSelect, onChange,
23
23
  canFilter = false, canAdd = false, canDelete = false, searchBy, addValidator,
24
- autosave = false, delay = 1000, patch = false,
24
+ autosave = false, delay = 1000, patch = false, versioning = false,
25
25
  groupBy, levels, sorter, namer,
26
26
  editor,
27
27
  footer,
28
28
  children
29
29
  } = props
30
30
 
31
+ const context = CollectionContext(url, field, host, page, fetching, versioning)
31
32
  const [pageContext, setPageContext] = useContext(PageContext)
32
- const context = CollectionContext(url, field, host, page, fetching)
33
-
34
33
  const { all } = pageContext
35
34
 
36
35
  useEffect(async () => {
@@ -393,7 +392,7 @@ const CollectionEditor = (props) => {
393
392
  /**
394
393
  * Collection Context
395
394
  */
396
- export const CollectionContext = (url, field, host, page, fetching) => {
395
+ export const CollectionContext = (url, field, host, page, fetching, versioning = false) => {
397
396
 
398
397
  const API = CollectionAPI(url, host)
399
398
 
@@ -447,6 +446,7 @@ export const CollectionContext = (url, field, host, page, fetching) => {
447
446
 
448
447
  async create(form) {
449
448
  try {
449
+ if (versioning) form.version = 1
450
450
  await API.create(form);
451
451
  await this.load();
452
452
  } catch (error) {
@@ -457,6 +457,7 @@ export const CollectionContext = (url, field, host, page, fetching) => {
457
457
 
458
458
  async update(form) {
459
459
  try {
460
+ if (versioning) form.version = form.version ? form.version + 1 : 1
460
461
  await API.update(form)
461
462
  await this.load()
462
463
  } catch (error) {
@@ -467,6 +468,7 @@ export const CollectionContext = (url, field, host, page, fetching) => {
467
468
 
468
469
  async patch(id, form) {
469
470
  try {
471
+ if (versioning) form.version = form.version ? form.version + 1 : 1
470
472
  await API.patch(id, form)
471
473
  await this.load()
472
474
  } catch (error) {
package/src/site/site.js CHANGED
@@ -87,7 +87,7 @@ export const SiteProvider = ({ children, siteLang, siteDictionary }) => {
87
87
  openPromptDialog: (dialog) => {setPromptDialog(dialog)},
88
88
  closePromptDialog: () => { setPromptDialog(null)},
89
89
 
90
- notify: ({ title, body, type = "success" }) => {
90
+ notify: ({ title, body, type = "success", duration=3000, onRemoval }) => {
91
91
  Store.addNotification({
92
92
  title,
93
93
  message: body,
@@ -97,9 +97,10 @@ export const SiteProvider = ({ children, siteLang, siteDictionary }) => {
97
97
  animationIn: ["animate__animated", "animate__fadeIn"],
98
98
  animationOut: ["animate__animated", "animate__fadeOut"],
99
99
  dismiss: {
100
- duration: 3000,
100
+ duration,
101
101
  onScreen: true
102
- }
102
+ },
103
+ onRemoval
103
104
  });
104
105
  }
105
106
  }