ywana-core8 0.0.19 → 0.0.23

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.23",
4
4
  "description": "ywana-core8",
5
5
  "author": "Ernesto Roldan Garcia",
6
6
  "license": "MIT",
@@ -1,9 +1,10 @@
1
1
  import equal from 'deep-equal'
2
2
  import React, { Fragment, useContext, useEffect, useMemo, useRef, useState } from 'react'
3
- import { EditContentDialog } from '.'
4
- import { Content, ContentEditor, HTTPClient, PageContext, Session, SiteContext } from '..'
5
- import { SCENARIO1 } from '../../dev/scenario1'
6
- import { BuildGroupOptions } from '../../pages/kinds/options'
3
+ import { EditContentDialog } from './EditContentDialog'
4
+ import { Content } from './ContentType'
5
+ import { ContentEditor } from './ContentEditor'
6
+ import { HTTPClient, Session } from '../http'
7
+ import { SiteContext, PageContext } from '../site'
7
8
  import { Button, DataTable, DropDown, Header, Icon, MenuIcon, MenuItem, Text } from '../html'
8
9
  import "./TablePage.css"
9
10
 
@@ -15,7 +16,7 @@ const http = HTTPClient(window.API || process.env.REACT_APP_API, Session);
15
16
  export const TablePage = (props) => {
16
17
 
17
18
  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
19
+ 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
20
  const [pageContext, setPageContext] = useContext(PageContext)
20
21
  const { selected } = pageContext
21
22
  const timer = useRef(null)
@@ -66,7 +67,7 @@ export const TablePage = (props) => {
66
67
  async function playScenario() {
67
68
  const promises1 = pageContext.all.map(async item => await pageContext.remove(item.id))
68
69
  Promise.all(promises1).then(async () => {
69
- const promises2 = SCENARIO1.map(async (item) => await pageContext.create(item))
70
+ const promises2 = scenario.map(async (item) => await pageContext.create(item))
70
71
  Promise.all(promises2).then(async () => {
71
72
  await pageContext.load()
72
73
  setPageContext(Object.assign({}, pageContext))
@@ -266,10 +267,16 @@ const TableEditor = (props) => {
266
267
 
267
268
  table.columns.push({ id: "actions" })
268
269
 
270
+ function buildGroupOptions(schema) {
271
+ return Object.values(schema)
272
+ .filter(field => field.grouper === true)
273
+ .map(field => ({ label: field.label, value: field.id }))
274
+ }
275
+
269
276
  return (
270
277
  <Fragment>
271
278
  <Header icon={icon} title={<Text>{title}</Text>}>
272
- <DropDown id="groupBy" label="Agrupar Por" value={groupBy} options={BuildGroupOptions(schema)} onChange={changeGroup} />
279
+ <DropDown id="groupBy" label="Agrupar Por" value={groupBy} options={buildGroupOptions(schema)} onChange={changeGroup} />
273
280
  </Header>
274
281
  <main className="table-editor">
275
282
  {renderGroups()}
@@ -296,7 +303,7 @@ const TableContext = (url, field) => {
296
303
 
297
304
  const filters = filter ? Object.keys(filter).reduce((filters, key) => {
298
305
  const field = filter[key];
299
- if (field) filters[key] = field;
306
+ if (field) filters[key] === field;
300
307
  return filters;
301
308
  }, {}) : []
302
309
 
@@ -365,6 +372,11 @@ const TableAPI = (url) => {
365
372
  const filterQuery = Object.keys(filters).reduce((query, key) => {
366
373
  if (typeof (filters[key]) === 'boolean') {
367
374
  return query.concat(`${key}=${filters[key]}&`)
375
+ } else if (Array.isArray(filters[key])) {
376
+ const param = filters[key].length === 0 ? '' : filters[key].reduce((param,field) => {
377
+ param.concat(`${key}=${field}&`)
378
+ }, '')
379
+ return query.concat(param)
368
380
  } else {
369
381
  return query.concat(`${key}=%${filters[key]}%&`)
370
382
  }
@@ -16,7 +16,6 @@ export const CheckBox = (props) => {
16
16
 
17
17
  const labelTxt = <Text>{label}</Text>
18
18
 
19
- console.log(label, value)
20
19
  return value === true ? (
21
20
  <div className="checkbox" key={`${id}1`}>
22
21
  <input id={id} type="checkbox" placeholder={placeholder} checked value={value} onChange={change} />
package/src/html/tab.js CHANGED
@@ -24,7 +24,7 @@ export const Tabs = (props) => {
24
24
  return (
25
25
  <div class="tabs">
26
26
  {tabs}
27
- <div class="tab-filler" />
27
+ <div className="tab-filler" />
28
28
  </div>
29
29
  )
30
30
  }
package/src/html/table.js CHANGED
@@ -102,7 +102,7 @@ const DataTableRow = (props) => {
102
102
  return (
103
103
  <Fragment>
104
104
  <tr onClick={ev => onSelect(row, ev)}>
105
- {columns.map(column => <DataTableCell row={row} column={column} cell={row[column.id]} editable={editable}/>)}
105
+ {columns.map(column => <DataTableCell key={row.id} row={row} column={column} cell={row[column.id]} editable={editable}/>)}
106
106
  {row.info ? <Icon icon={infoIcon} clickable action={() => toggleInfo(!isInfoOpen)} /> : null}
107
107
  </tr>
108
108
  {row.info && isInfoOpen ? (
@@ -6,7 +6,7 @@ import './tokenfield.css'
6
6
  /**
7
7
  * Token Field
8
8
  */
9
- export const TokenField = ({ id, label, init, onChange }) => {
9
+ export const TokenField = ({ id, label, init = [], onChange }) => {
10
10
  const mounted = useRef(false)
11
11
  const [value, setValue] = useState()
12
12
  const [tokens, setTokens] = useState(init)