ywana-core8 0.0.192 → 0.0.196
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/dist/index.cjs +86 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +86 -0
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +86 -0
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/ContentViewer.css +3 -0
- package/src/domain/ContentViewer.js +36 -6
- package/src/domain/TablePage.js +1 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import React from 'react'
|
2
2
|
import { Property } from '../html'
|
3
|
-
import { TYPES } from './ContentType'
|
3
|
+
import { Content, TYPES } from './ContentType'
|
4
4
|
|
5
5
|
/**
|
6
6
|
* Content Viewer
|
@@ -10,23 +10,24 @@ import { TYPES } from './ContentType'
|
|
10
10
|
*/
|
11
11
|
export const ContentViewer = (props) => {
|
12
12
|
|
13
|
-
const { content
|
13
|
+
const { content } = props
|
14
14
|
|
15
15
|
if (!content) return <div>No Content...</div>
|
16
16
|
|
17
17
|
const sections = content.sections()
|
18
|
-
|
18
|
+
const value = content.value()
|
19
|
+
console.log(value)
|
19
20
|
return (
|
20
21
|
<div className="content-viewer">
|
21
22
|
{sections.map(section => {
|
22
23
|
const { title, fields } = section
|
23
24
|
return (
|
24
|
-
<section key={title}>
|
25
|
+
<section key={title} className="content-viewer">
|
25
26
|
<header>
|
26
27
|
{title}
|
27
28
|
</header>
|
28
29
|
<main>
|
29
|
-
{ fields.map( field => <FieldViewer key={field.id} field={field} value={
|
30
|
+
{ fields.map( field => <FieldViewer key={field.id} field={field} value={value[field.id]} />)}
|
30
31
|
</main>
|
31
32
|
</section>
|
32
33
|
)
|
@@ -35,17 +36,46 @@ export const ContentViewer = (props) => {
|
|
35
36
|
)
|
36
37
|
}
|
37
38
|
|
39
|
+
/**
|
40
|
+
* Field Viewer
|
41
|
+
*
|
42
|
+
* @param {} props
|
43
|
+
* @returns
|
44
|
+
*/
|
38
45
|
const FieldViewer = (props) => {
|
39
46
|
|
40
47
|
const { field, value } = props
|
41
48
|
const { id, type, item, label } = field
|
42
49
|
|
43
50
|
console.log('FieldViewer', field, value)
|
44
|
-
|
51
|
+
|
45
52
|
switch(type) {
|
46
53
|
case TYPES.STRING:
|
47
54
|
return <Property label={label} value={value} />
|
55
|
+
case TYPES.ENTITY:
|
56
|
+
return <EntityViewer field={field} value={value} />
|
48
57
|
default:
|
49
58
|
return <div>{label}</div>
|
50
59
|
}
|
60
|
+
}
|
61
|
+
|
62
|
+
/**
|
63
|
+
* EntityViewer
|
64
|
+
*/
|
65
|
+
const EntityViewer = (props) => {
|
66
|
+
const { field, value } = props
|
67
|
+
const { item, label } = field
|
68
|
+
const content = new Content(item, value)
|
69
|
+
const form = content.form()
|
70
|
+
const fields = Object.keys(form).map(key => form[key])
|
71
|
+
return (
|
72
|
+
<div className='entity-viewer'>
|
73
|
+
<header>
|
74
|
+
{label}
|
75
|
+
</header>
|
76
|
+
<main>
|
77
|
+
{ fields.map( field => <FieldViewer field={field} value={value[field.id]} /> )}
|
78
|
+
</main>
|
79
|
+
</div>
|
80
|
+
)
|
51
81
|
}
|
package/src/domain/TablePage.js
CHANGED
@@ -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
|
|