ywana-core8 0.0.19 → 0.0.20

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.19",
3
+ "version": "0.0.20",
4
4
  "description": "ywana-core8",
5
5
  "author": "Ernesto Roldan Garcia",
6
6
  "license": "MIT",
@@ -2,8 +2,6 @@ import equal from 'deep-equal'
2
2
  import React, { Fragment, useContext, useEffect, useMemo, useRef, useState } from 'react'
3
3
  import { EditContentDialog } from '.'
4
4
  import { Content, ContentEditor, HTTPClient, PageContext, Session, SiteContext } from '..'
5
- import { SCENARIO1 } from '../../dev/scenario1'
6
- import { BuildGroupOptions } from '../../pages/kinds/options'
7
5
  import { Button, DataTable, DropDown, Header, Icon, MenuIcon, MenuItem, Text } from '../html'
8
6
  import "./TablePage.css"
9
7
 
@@ -15,7 +13,7 @@ const http = HTTPClient(window.API || process.env.REACT_APP_API, Session);
15
13
  export const TablePage = (props) => {
16
14
 
17
15
  const site = useContext(SiteContext)
18
- const { id = "table", icon, title, name = "table 1", schema, url, field, delay = 1000, actions, editable, canAdd = true, dev = true, autosave = true, groupBy, validator, scenario } = props
16
+ const { id = "table", icon, title, name = "table 1", schema, url, field, delay = 1000, actions, editable, canAdd = true, dev = false, autosave = true, groupBy, validator, scenario } = props
19
17
  const [pageContext, setPageContext] = useContext(PageContext)
20
18
  const { selected } = pageContext
21
19
  const timer = useRef(null)
@@ -66,7 +64,7 @@ export const TablePage = (props) => {
66
64
  async function playScenario() {
67
65
  const promises1 = pageContext.all.map(async item => await pageContext.remove(item.id))
68
66
  Promise.all(promises1).then(async () => {
69
- const promises2 = SCENARIO1.map(async (item) => await pageContext.create(item))
67
+ const promises2 = scenario.map(async (item) => await pageContext.create(item))
70
68
  Promise.all(promises2).then(async () => {
71
69
  await pageContext.load()
72
70
  setPageContext(Object.assign({}, pageContext))
@@ -266,10 +264,16 @@ const TableEditor = (props) => {
266
264
 
267
265
  table.columns.push({ id: "actions" })
268
266
 
267
+ function buildGroupOptions(schema) {
268
+ return Object.values(schema)
269
+ .filter(field => field.grouper === true)
270
+ .map(field => ({ label: field.label, value: field.id }))
271
+ }
272
+
269
273
  return (
270
274
  <Fragment>
271
275
  <Header icon={icon} title={<Text>{title}</Text>}>
272
- <DropDown id="groupBy" label="Agrupar Por" value={groupBy} options={BuildGroupOptions(schema)} onChange={changeGroup} />
276
+ <DropDown id="groupBy" label="Agrupar Por" value={groupBy} options={buildGroupOptions(schema)} onChange={changeGroup} />
273
277
  </Header>
274
278
  <main className="table-editor">
275
279
  {renderGroups()}