ywana-core8 0.0.706 → 0.0.707

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.706",
3
+ "version": "0.0.707",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
@@ -39,7 +39,7 @@ export const CollectionContextProvider = (props) => {
39
39
 
40
40
  async function select(id) {
41
41
  if (fetching) {
42
- const result = await this.fetch(id)
42
+ const result = await fetch(id)
43
43
  setSelected(result)
44
44
  } else {
45
45
  const result = this.all.find(item => item.id === id);
@@ -56,13 +56,7 @@ export const CollectionContextProvider = (props) => {
56
56
  delete next[id]
57
57
  setCustomFilters(next)
58
58
  }
59
-
60
- /*
61
- async function reloadSelection() {
62
- const result = await this.fetch(this.selected.id)
63
- this.selected = result
64
- }
65
-
59
+
66
60
  async function fetch(id) {
67
61
  try {
68
62
  const result = await API.find(id)
@@ -71,6 +65,13 @@ export const CollectionContextProvider = (props) => {
71
65
  console.log(error)
72
66
  }
73
67
  }
68
+
69
+ /*
70
+ async function reloadSelection() {
71
+ const result = await this.fetch(this.selected.id)
72
+ this.selected = result
73
+ }
74
+
74
75
 
75
76
  function clear() {
76
77
  this.selected = null
@@ -1,17 +1,15 @@
1
1
  import React, { useContext } from 'react'
2
- import { CollectionContext } from './CollectionContext'
3
2
 
4
3
  /**
5
4
  * Collection Editor
6
5
  */
7
6
  export const CollectionEditor = (props) => {
8
7
 
9
- const context = useContext(CollectionContext)
10
- const { selected } = context
8
+ const { customEditor } = props
11
9
 
12
10
  return (
13
11
  <div className="collection-editor">
14
- editor
12
+ {customEditor}
15
13
  </div>
16
14
  )
17
15
  }
@@ -29,6 +29,7 @@
29
29
  padding: 0.5rem;
30
30
  font-size: .8rem;
31
31
  font-weight: 300;
32
+ text-transform: uppercase;
32
33
  }
33
34
 
34
35
  .collection-filter-resume-label {
@@ -20,7 +20,7 @@ export const CollectionFilters = (props) => {
20
20
  }, [schema])
21
21
 
22
22
  function change(id, value) {
23
- context.setFilters({ ...filters, [id]: value })
23
+ if (filters) context.setFilters({ ...filters, [id]: value })
24
24
  }
25
25
 
26
26
  function toggle() {
@@ -14,8 +14,13 @@ export const CollectionList = (props) => {
14
14
  context.load()
15
15
  }, [filters, customFilters])
16
16
 
17
+ function select(id) {
18
+ context.select(id)
19
+ }
20
+
17
21
  const items = all.map(item => {
18
22
  return {
23
+ id: item.id,
19
24
  icon: "folder",
20
25
  line1: item.name,
21
26
  meta: item.state,
@@ -24,7 +29,7 @@ export const CollectionList = (props) => {
24
29
 
25
30
  return (
26
31
  <div className="collection-list">
27
- <List items={items} />
32
+ <List items={items} onSelect={select} />
28
33
  </div>
29
34
  )
30
35
  }
@@ -13,17 +13,19 @@ export const CollectionPage = (props) => {
13
13
 
14
14
  const {
15
15
  host, url, schema,
16
- layout,
17
- canFilter, customFilters
16
+ layout,
17
+ title,
18
+ canFilter, customFilters,
19
+ customEditor
18
20
  } = props
19
21
 
20
22
  return (
21
23
  <div className={`collection-page ${layout}`}>
22
24
  <CollectionContextProvider host={host} url={url}>
23
- <Header title="CollectionPage" />
25
+ <Header title={title} />
24
26
  {canFilter ? <CollectionFilters schema={schema} >{customFilters}</CollectionFilters> : null}
25
27
  <CollectionList />
26
- <CollectionEditor />
28
+ <CollectionEditor customEditor={customEditor}/>
27
29
  </CollectionContextProvider>
28
30
  </div>
29
31
 
@@ -16,14 +16,15 @@ const CollectionPageTest = (prop) => {
16
16
  }
17
17
  }
18
18
 
19
-
20
19
  const props = {
21
20
  host: "http://localhost:3000",
22
21
  url: "/references",
23
22
  schema,
24
23
  layout: "ide",
24
+ title: <CustomTitle />,
25
25
  canFilter: true,
26
- customFilters: [<CustomFilter1 />, <CustomFilter2 />]
26
+ customFilters: [<CustomFilter1 />, <CustomFilter2 />],
27
+ customEditor: <CustomEditor />
27
28
  }
28
29
 
29
30
  return (
@@ -33,6 +34,29 @@ const CollectionPageTest = (prop) => {
33
34
  )
34
35
  }
35
36
 
37
+ const CustomTitle = (props) => {
38
+ return (
39
+ <h1>Custom Title</h1>
40
+ )
41
+ }
42
+
43
+ const CustomEditor = () => {
44
+
45
+ const context = useContext(CollectionContext)
46
+ const { all, selected } = context
47
+
48
+ return (
49
+ <div>
50
+ <header>
51
+ CUSTOM EDITOR {all.length}
52
+ </header>
53
+ <main>
54
+ ID: {selected ? selected.id : null}
55
+ </main>
56
+ </div>
57
+ )
58
+ }
59
+
36
60
  const CustomFilter1 = (props) => {
37
61
 
38
62
  const context = useContext(CollectionContext)