ywana-core8 0.0.472 → 0.0.475

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.472",
3
+ "version": "0.0.475",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
@@ -25,6 +25,7 @@ export const FORMATS = {
25
25
  TOKENS: 'TOKENS'
26
26
  }
27
27
 
28
+
28
29
  /**
29
30
  * CHECK
30
31
  */
@@ -45,10 +45,9 @@ export const TabbedTablePage = (props) => {
45
45
  }, [])
46
46
 
47
47
  useEffect( async () => {
48
- console.log("TAB", tab)
49
48
  if (tab) {
50
49
  const filter = { [tab.field]: tab.value }
51
- await pageContext.load(filter, false)
50
+ await pageContext.load(filter, [])
52
51
  setPageContext(Object.assign({}, pageContext))
53
52
  }
54
53
  }, [tab])
@@ -102,7 +101,6 @@ export const TabbedTablePage = (props) => {
102
101
  }
103
102
 
104
103
  async function save() {
105
- console.log('saving.....')
106
104
  await pageContext.update(form)
107
105
  setPageContext(Object.assign({}, pageContext))
108
106
  }
@@ -153,9 +151,8 @@ export const TabbedTablePage = (props) => {
153
151
 
154
152
  function renderTabs() {
155
153
  const selected = tab ? tab.value : null
156
- console.log(selected)
157
154
  return (
158
- <Tabs selected={selected} onChange={changeTab}>
155
+ <Tabs selected={selected} onChange={changeTab} fillRight={true} fillLeft={false}>
159
156
  {tabs.map(tab => <Tab id={tab.value} label={tab.label} />)}
160
157
  </Tabs>
161
158
  )
@@ -326,6 +323,14 @@ const TableFilters = (props) => {
326
323
  return filterSchema
327
324
  }, [schema])
328
325
 
326
+ const likes = useMemo(() => {
327
+ const fields = Object.values(schema)
328
+ return fields.reduce((likes, field) => {
329
+ if (field.like === true) likes.push(field.id)
330
+ return likes
331
+ }, [])
332
+ }, [schema])
333
+
329
334
  useEffect(() => {
330
335
  if (filters) setForm(filters)
331
336
  }, [filters])
@@ -339,7 +344,7 @@ const TableFilters = (props) => {
339
344
  }
340
345
 
341
346
  async function reload() {
342
- await pageContext.load(form)
347
+ await pageContext.load(form, likes)
343
348
  setPageContext(Object.assign({}, pageContext))
344
349
  }
345
350
 
@@ -527,7 +532,7 @@ const TableContext = (url, field, host, urlQuery) => {
527
532
  queries: [],
528
533
  tab: null,
529
534
 
530
- async load(filter, like) {
535
+ async load(filter, like = []) {
531
536
  try {
532
537
  const filters = filter ? Object.keys(filter).reduce((filters, key) => {
533
538
  const field = filter[key];
@@ -581,7 +586,7 @@ const TableContext = (url, field, host, urlQuery) => {
581
586
  async create(form) {
582
587
  try {
583
588
  await API.create(form);
584
- await this.load({}, false);
589
+ await this.load({}, []);
585
590
  } catch (error) {
586
591
  console.log(error)
587
592
  }
@@ -650,7 +655,7 @@ const TableAPI = (url, host) => {
650
655
  const http = HTTPClient(host || window.API || process.env.REACT_APP_API, Session);
651
656
 
652
657
  return {
653
- all(filters, like = true) {
658
+ all(filters, like = []) {
654
659
  let queryParams = "?"
655
660
  if (filters) {
656
661
  const filterQuery = Object.keys(filters).reduce((query, key) => {
@@ -664,7 +669,7 @@ const TableAPI = (url, host) => {
664
669
  }, "")
665
670
  return query.concat(param)
666
671
  } else {
667
- return like ? query.concat(`${key}=%${filters[key]}%&`) : query.concat(`${key}=${filters[key]}&`)
672
+ return like.includes(key) ? query.concat(`${key}=%${filters[key]}%&`) : query.concat(`${key}=${filters[key]}&`)
668
673
  }
669
674
  }, "")
670
675
  queryParams = queryParams.concat(filterQuery)
package/src/html/tab.js CHANGED
@@ -7,7 +7,7 @@ import './tab.css'
7
7
  */
8
8
  export const Tabs = (props) => {
9
9
 
10
- const { children, selected, onChange } = props
10
+ const { children, selected, onChange, fillLeft=false, fillRight=true } = props
11
11
 
12
12
  const tabs = React.Children.map(children, (child, index) => {
13
13
 
@@ -23,8 +23,9 @@ export const Tabs = (props) => {
23
23
 
24
24
  return (
25
25
  <div className="tabs">
26
+ { fillLeft ? <div className="tab-filler" /> : null }
26
27
  {tabs}
27
- <div className="tab-filler" />
28
+ { fillRight ? <div className="tab-filler" /> : null }
28
29
  </div>
29
30
  )
30
31
  }
@@ -115,19 +115,19 @@ const Page2 = (props) => {
115
115
  const Page3 = (props) => {
116
116
 
117
117
  const schema = {
118
- name : { id: "name" , type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, column: true , filter: true , label: "Name" },
119
- state : { id: "state" , type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: true , column: true , filter: false, label: "State" , options: [
118
+ name : { id: "name" , type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, column: true , filter: true , like: true, label: "Name" },
119
+ state : { id: "state" , type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: true , column: true , filter: false , label: "State" , options: [
120
120
  { label: "Pendiente", value: "NOT_CLASSIFIED" },
121
121
  { label: "Clasificada", value: "CLASSIFIED"},
122
122
  ]},
123
- field1: { id: "field1", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, column: true , filter: true , label: "field1" },
124
- field2: { id: "field2", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, column: true , filter: true , label: "field2" },
125
- field4: { id: "field4", type: TYPES.STRING, format: FORMATS.COLOR, required: true, tab: false, column: true , filter: true , label: "Color" },
123
+ field1: { id: "field1", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, column: true , filter: true , label: "field1" },
124
+ field2: { id: "field2", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, column: true , filter: true , label: "field2" },
125
+ field4: { id: "field4", type: TYPES.STRING, format: FORMATS.COLOR, required: true, tab: false, column: true , filter: true , label: "Color" },
126
126
  }
127
127
 
128
128
  return (
129
129
  <Fragment>
130
- <TabbedTablePage title="Referencias" schema={schema} host="http://localhost:3000" url="/references"/>
130
+ <TabbedTablePage title="Referencias" schema={schema} host="http://localhost:3000" url="/references" canFilter={true} />
131
131
  </Fragment>
132
132
  )
133
133
  }