ywana-core8 0.0.438 → 0.0.441

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.438",
3
+ "version": "0.0.441",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
@@ -15,9 +15,9 @@ import "./CollectionPage.css"
15
15
  export const CollectionPage = (props) => {
16
16
 
17
17
  const site = useContext(SiteContext)
18
- const { id = "collection", icon, title, name = "Collection 1", schema, url, host, groupBy, editor, field, autosave = false, delay = 1000, actions, levels, onSelect, children } = props
18
+ const { id = "collection", icon, title, name = "Collection 1", schema, url, page, host, groupBy, editor, field, autosave = false, delay = 1000, actions, levels, onSelect, children } = props
19
19
  const [pageContext, setPageContext] = useContext(PageContext)
20
- const context = CollectionContext(url, field, host)
20
+ const context = CollectionContext(url, field, host, page)
21
21
 
22
22
  useEffect(async () => {
23
23
  await context.load()
@@ -237,7 +237,7 @@ const CollectionEditor = (props) => {
237
237
  /**
238
238
  * Collection Context
239
239
  */
240
- export const CollectionContext = (url, field, host) => {
240
+ export const CollectionContext = (url, field, host, page) => {
241
241
 
242
242
  const API = CollectionAPI(url, host)
243
243
 
@@ -248,7 +248,7 @@ export const CollectionContext = (url, field, host) => {
248
248
 
249
249
  async load() {
250
250
  try {
251
- const data = await API.all();
251
+ const data = await API.all(null, page);
252
252
  this.all = field ? data[field] : data;
253
253
  } catch (error) {
254
254
  console.log(error)
@@ -325,8 +325,8 @@ const CollectionAPI = (url, host) => {
325
325
  const http = HTTPClient(host || window.API || process.env.REACT_APP_API, Session);
326
326
 
327
327
  return {
328
- all(filters) {
329
- let queryParams = "?"
328
+ all(filters, page) {
329
+ let queryParams = page ? `?page=${page}&` : "?"
330
330
  if (filters) {
331
331
  const filterQuery = Object.keys(filters).reduce((query, key) => {
332
332
  const value = filters[key]
@@ -344,7 +344,7 @@ const CollectionAPI = (url, host) => {
344
344
  }, "")
345
345
  queryParams = queryParams.concat(filterQuery)
346
346
  }
347
- return http.GET(url)
347
+ return http.GET(url + queryParams)
348
348
  },
349
349
 
350
350
  find(id) {
@@ -48,6 +48,7 @@ const FieldViewer = (props) => {
48
48
  const { type, item, label, visible = true } = field
49
49
 
50
50
  if (!visible) return null
51
+ if (optional && !value) return null
51
52
 
52
53
  switch (type) {
53
54
  case TYPES.STRING: