ywana-core8 0.0.472 → 0.0.473

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.473",
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
  */
@@ -48,7 +48,7 @@ export const TabbedTablePage = (props) => {
48
48
  console.log("TAB", tab)
49
49
  if (tab) {
50
50
  const filter = { [tab.field]: tab.value }
51
- await pageContext.load(filter, false)
51
+ await pageContext.load(filter, [])
52
52
  setPageContext(Object.assign({}, pageContext))
53
53
  }
54
54
  }, [tab])
@@ -326,6 +326,14 @@ const TableFilters = (props) => {
326
326
  return filterSchema
327
327
  }, [schema])
328
328
 
329
+ const likes = useMemo(() => {
330
+ const fields = Object.values(schema)
331
+ return fields.reduce((likes, field) => {
332
+ if (field.like === true) likes.push(field.id)
333
+ return likes
334
+ }, [])
335
+ }, [schema])
336
+
329
337
  useEffect(() => {
330
338
  if (filters) setForm(filters)
331
339
  }, [filters])
@@ -339,7 +347,7 @@ const TableFilters = (props) => {
339
347
  }
340
348
 
341
349
  async function reload() {
342
- await pageContext.load(form)
350
+ await pageContext.load(form, likes)
343
351
  setPageContext(Object.assign({}, pageContext))
344
352
  }
345
353
 
@@ -527,7 +535,7 @@ const TableContext = (url, field, host, urlQuery) => {
527
535
  queries: [],
528
536
  tab: null,
529
537
 
530
- async load(filter, like) {
538
+ async load(filter, like = []) {
531
539
  try {
532
540
  const filters = filter ? Object.keys(filter).reduce((filters, key) => {
533
541
  const field = filter[key];
@@ -581,7 +589,7 @@ const TableContext = (url, field, host, urlQuery) => {
581
589
  async create(form) {
582
590
  try {
583
591
  await API.create(form);
584
- await this.load({}, false);
592
+ await this.load({}, []);
585
593
  } catch (error) {
586
594
  console.log(error)
587
595
  }
@@ -650,7 +658,10 @@ const TableAPI = (url, host) => {
650
658
  const http = HTTPClient(host || window.API || process.env.REACT_APP_API, Session);
651
659
 
652
660
  return {
653
- all(filters, like = true) {
661
+ all(filters, like = []) {
662
+
663
+ console.log(like)
664
+
654
665
  let queryParams = "?"
655
666
  if (filters) {
656
667
  const filterQuery = Object.keys(filters).reduce((query, key) => {
@@ -664,7 +675,7 @@ const TableAPI = (url, host) => {
664
675
  }, "")
665
676
  return query.concat(param)
666
677
  } else {
667
- return like ? query.concat(`${key}=%${filters[key]}%&`) : query.concat(`${key}=${filters[key]}&`)
678
+ return like.includes(key) ? query.concat(`${key}=%${filters[key]}%&`) : query.concat(`${key}=${filters[key]}&`)
668
679
  }
669
680
  }, "")
670
681
  queryParams = queryParams.concat(filterQuery)
@@ -115,7 +115,7 @@ 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" },
118
+ name : { id: "name" , type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, column: true , filter: true , like: true, label: "Name" },
119
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"},
@@ -127,7 +127,7 @@ const Page3 = (props) => {
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
  }