ywana-core8 0.0.703 → 0.0.704

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.703",
3
+ "version": "0.0.704",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
@@ -15,7 +15,8 @@ export const CollectionFilters = (props) => {
15
15
  const [open, setOpen] = useState(false)
16
16
 
17
17
  useEffect(() => {
18
- context.setLikes(schema.filter(field => field.like).map(field => field.id))
18
+ const likes = Object.keys(schema).filter(id => schema[id].filter === true)
19
+ context.setLikes(likes)
19
20
  }, [schema])
20
21
 
21
22
  function change(id, value) {
@@ -57,7 +58,7 @@ const CollectionFiltersResume = (props) => {
57
58
  {fields
58
59
  .filter(id => filters[id] !== undefined && filters[id] !== null && filters[id] !== "")
59
60
  .map(id => {
60
- const field = schema.find(field => field.id === id)
61
+ const field = schema[id]
61
62
  const value = filters[id]
62
63
  return (
63
64
  <div className='collection-filter-resume'>
@@ -5,14 +5,17 @@ import { CollectionPage } from './CollectionPage'
5
5
 
6
6
  const CollectionPageTest = (prop) => {
7
7
 
8
- const schema = [
9
- { id: "id", type: "string", label: "ID" },
10
- { id: "name", type: "string", label: "Name", filter: true },
11
- { id: "gender", type: "string", label: "Gender", filter: true, options: [
12
- { label: "Masculine", value: 1 },
13
- { label: "Feminine", value: 0 }
14
- ]},
15
- ]
8
+ const schema = {
9
+ id: { id: "id", type: "string", label: "ID" },
10
+ name: { id: "name", type: "string", label: "Name", filter: true },
11
+ gender: {
12
+ id: "gender", type: "string", label: "Gender", filter: true, options: [
13
+ { label: "Masculine", value: 1 },
14
+ { label: "Feminine", value: 0 }
15
+ ]
16
+ }
17
+ }
18
+
16
19
 
17
20
  const props = {
18
21
  host: "http://localhost:3000",
@@ -20,7 +23,7 @@ const CollectionPageTest = (prop) => {
20
23
  schema,
21
24
  layout: "ide",
22
25
  canFilter: true,
23
- customFilters: [<CustomFilter1 />,<CustomFilter2 />]
26
+ customFilters: [<CustomFilter1 />, <CustomFilter2 />]
24
27
  }
25
28
 
26
29
  return (
@@ -54,7 +57,7 @@ const CustomFilter1 = (props) => {
54
57
  }
55
58
 
56
59
  return (
57
- <CheckBox id="custom1" value={active} label="Active" onChange={change}/>
60
+ <CheckBox id="custom1" value={active} label="Active" onChange={change} />
58
61
  )
59
62
  }
60
63
 
@@ -83,6 +86,6 @@ const CustomFilter2 = (props) => {
83
86
  }
84
87
 
85
88
  return (
86
- <CheckBox id="custom1" value={active} label="Locked" onChange={change}/>
89
+ <CheckBox id="custom1" value={active} label="Locked" onChange={change} />
87
90
  )
88
91
  }
@@ -13,9 +13,10 @@ export const DynamicForm = (props) => {
13
13
  if (onChange) onChange(id, value)
14
14
  }
15
15
 
16
+ const fields = Object.values(schema)
16
17
  return (
17
18
  <div className="dynamic-form">
18
- {schema.map(field => {
19
+ {fields.map(field => {
19
20
  const { id, label, type } = field
20
21
  return (
21
22
  <DynamicFormField key={id} field={field} value={values[id]} onChange={change} />