ywana-core8 0.0.191 → 0.0.195

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.191",
3
+ "version": "0.0.195",
4
4
  "description": "ywana-core8",
5
5
  "author": "Ernesto Roldan Garcia",
6
6
  "license": "MIT",
@@ -0,0 +1,3 @@
1
+ .content-viewer>main>.property {
2
+ border-bottom: solid 1px var(--divider-color);
3
+ }
@@ -0,0 +1,80 @@
1
+ import React from 'react'
2
+ import { Property } from '../html'
3
+ import { TYPES } from './ContentType'
4
+
5
+ /**
6
+ * Content Viewer
7
+ *
8
+ * @param {*} props
9
+ * @returns
10
+ */
11
+ export const ContentViewer = (props) => {
12
+
13
+ const { content } = props
14
+
15
+ if (!content) return <div>No Content...</div>
16
+
17
+ const sections = content.sections()
18
+ const value = content.value()
19
+ console.log(value)
20
+ return (
21
+ <div className="content-viewer">
22
+ {sections.map(section => {
23
+ const { title, fields } = section
24
+ return (
25
+ <section key={title} className="content-viewer">
26
+ <header>
27
+ {title}
28
+ </header>
29
+ <main>
30
+ { fields.map( field => <FieldViewer key={field.id} field={field} value={value[field.id]} />)}
31
+ </main>
32
+ </section>
33
+ )
34
+ })}
35
+ </div>
36
+ )
37
+ }
38
+
39
+ /**
40
+ * Field Viewer
41
+ * @param {} props
42
+ * @returns
43
+ */
44
+ const FieldViewer = (props) => {
45
+
46
+ const { field, value } = props
47
+ const { id, type, item, label } = field
48
+
49
+ console.log('FieldViewer', field, value)
50
+
51
+ switch(type) {
52
+ case TYPES.STRING:
53
+ return <Property label={label} value={value} />
54
+ case TYPES.ENTITY:
55
+ return <EntityViewer field={field} value={value} />
56
+ default:
57
+ return <div>{label}</div>
58
+ }
59
+ }
60
+
61
+ /**
62
+ * EntityViewer
63
+ */
64
+ const EntityViewer = (props) => {
65
+ const { field, value } = props
66
+ const { item, label } = field
67
+ const content = new Content(item, value)
68
+ const form = content.form()
69
+ const fields = Object.keys(form).map(key => form[key])
70
+ return (
71
+ <div className='entity-viewer'>
72
+ <header>
73
+ {label}
74
+ </header>
75
+ <main>
76
+ { fields.map( field => <FieldViewer field={field} value={value[field.id]} /> )}
77
+ </main>
78
+ </div>
79
+ )
80
+ }
@@ -5,6 +5,7 @@ import { HTTPClient, Session } from '../http'
5
5
  import { PageContext, SiteContext } from '../site'
6
6
  import { ContentEditor } from './ContentEditor'
7
7
  import { Content } from './ContentType'
8
+ import { ContentViewer } from './ContentViewer'
8
9
  import { CreateContentDialog } from './CreateContentDialog'
9
10
  import "./TablePage.css"
10
11
 
@@ -145,7 +146,7 @@ const TableRowEditor = (props) => {
145
146
  <Icon icon="close" clickable action={onClose} />
146
147
  </Header>
147
148
  <main>
148
- { editable ? <ContentEditor content={content} onChange={onChange} filter={filter} /> : <ContentViewer content={content} />
149
+ { editable ? <ContentEditor content={content} onChange={onChange} filter={filter} /> : <ContentViewer content={content} /> }
149
150
  </main>
150
151
  </div>
151
152
  )