ywana-core8 0.0.536 → 0.0.537
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/db/db.json +3 -3
- package/dist/index.cjs +40 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +40 -15
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +40 -15
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/CollectionPage.js +33 -11
- package/src/site/site.test.js +3 -1
package/package.json
CHANGED
@@ -20,7 +20,7 @@ export const CollectionPage = (props) => {
|
|
20
20
|
icon, title, name = "Collection 1", className,
|
21
21
|
schema, url, field, host, page, fetching = false,
|
22
22
|
actions = [], onSelect,
|
23
|
-
canFilter = false, canAdd = false, canDelete = false, canEdit = false,
|
23
|
+
canFilter = false, canAdd = false, canDelete = false, canEdit = false, searchBy,
|
24
24
|
autosave = false, delay = 1000,
|
25
25
|
groupBy, levels, sorter,
|
26
26
|
editor,
|
@@ -68,7 +68,7 @@ export const CollectionPage = (props) => {
|
|
68
68
|
<Header title={<Text>{name}</Text>} >
|
69
69
|
</Header>
|
70
70
|
{canFilter ? <CollectionFilters schema={schema} /> : null}
|
71
|
-
{levels ? <CollectionTree icon={icon} levels={levels} onSelect={onSelect} sorter={sorter} /> : <CollectionList groupBy={groupBy} onSelect={onSelect} />}
|
71
|
+
{levels ? <CollectionTree icon={icon} levels={levels} onSelect={onSelect} sorter={sorter} searchBy={searchBy} /> : <CollectionList groupBy={groupBy} onSelect={onSelect} searchBy={searchBy} />}
|
72
72
|
</menu>
|
73
73
|
<main key={id} className={`collection-page ${className}`}>
|
74
74
|
<CollectionEditor icon={icon} schema={schema} layout={editor} autosave={autosave} delay={delay} />
|
@@ -133,7 +133,7 @@ export const CollectionFilters = (props) => {
|
|
133
133
|
*/
|
134
134
|
const CollectionList = (props) => {
|
135
135
|
|
136
|
-
const { groupBy, onSelect } = props
|
136
|
+
const { groupBy, onSelect, searchBy=[] } = props
|
137
137
|
const [pageContext, setPageContext] = useContext(PageContext)
|
138
138
|
const { all = [] } = pageContext
|
139
139
|
const [filter, setFilter] = useState()
|
@@ -150,11 +150,22 @@ const CollectionList = (props) => {
|
|
150
150
|
if (onSelect) onSelect(id)
|
151
151
|
}
|
152
152
|
|
153
|
-
function
|
153
|
+
function changeSearch(id, value) {
|
154
154
|
setFilter(value)
|
155
155
|
}
|
156
156
|
|
157
|
-
|
157
|
+
function search() {
|
158
|
+
const items = filter ? all.filter(item => {
|
159
|
+
const result = searchBy.some(fieldName => {
|
160
|
+
const value = item[fieldName]
|
161
|
+
return value ? value.indexOf(filter.toUpperCase()) >= 0 : false
|
162
|
+
})
|
163
|
+
return result
|
164
|
+
}) : all
|
165
|
+
return items
|
166
|
+
}
|
167
|
+
|
168
|
+
const items = search()
|
158
169
|
const items2 = items.map(content => ({
|
159
170
|
id: content.id,
|
160
171
|
line1: content.name || content.centre || content.tag, // centre: Signflow legacy
|
@@ -169,7 +180,7 @@ const CollectionList = (props) => {
|
|
169
180
|
</main>
|
170
181
|
<footer>
|
171
182
|
<div className='search-box'>
|
172
|
-
<TextField icon="search" label="Search" onChange={
|
183
|
+
<TextField icon="search" label="Search" onChange={changeSearch} outlined className="search-box" />
|
173
184
|
</div>
|
174
185
|
</footer>
|
175
186
|
</>
|
@@ -181,7 +192,7 @@ const CollectionList = (props) => {
|
|
181
192
|
*/
|
182
193
|
export const CollectionTree = (props) => {
|
183
194
|
|
184
|
-
const { icon = "description", levels, onSelect, sorter } = props
|
195
|
+
const { icon = "description", levels, onSelect, sorter, searchBy=[] } = props
|
185
196
|
const [pageContext, setPageContext] = useContext(PageContext)
|
186
197
|
const { all = [] } = pageContext
|
187
198
|
const [filter, setFilter] = useState()
|
@@ -198,7 +209,7 @@ export const CollectionTree = (props) => {
|
|
198
209
|
if (onSelect) onSelect(id)
|
199
210
|
}
|
200
211
|
|
201
|
-
function
|
212
|
+
function changeSearch(id, value) {
|
202
213
|
setFilter(value)
|
203
214
|
}
|
204
215
|
|
@@ -233,8 +244,19 @@ export const CollectionTree = (props) => {
|
|
233
244
|
})
|
234
245
|
}
|
235
246
|
|
236
|
-
|
237
|
-
|
247
|
+
function search() {
|
248
|
+
const items = filter ? all.filter(item => {
|
249
|
+
const result = searchBy.some(fieldName => {
|
250
|
+
const value = item[fieldName]
|
251
|
+
return value ? value.indexOf(filter.toUpperCase()) >= 0 : false
|
252
|
+
})
|
253
|
+
return result
|
254
|
+
}) : all
|
255
|
+
return items
|
256
|
+
}
|
257
|
+
|
258
|
+
const items = search()
|
259
|
+
const items2 = sorter ? sorter(items) : items
|
238
260
|
const nodes = generateNodes(levels, items2)
|
239
261
|
return (
|
240
262
|
<>
|
@@ -245,7 +267,7 @@ export const CollectionTree = (props) => {
|
|
245
267
|
</main>
|
246
268
|
<footer>
|
247
269
|
<div className='search-box'>
|
248
|
-
<TextField icon="search" label="Search" onChange={
|
270
|
+
<TextField icon="search" label="Search" onChange={changeSearch} outlined className="search-box" />
|
249
271
|
</div>
|
250
272
|
</footer>
|
251
273
|
</>
|
package/src/site/site.test.js
CHANGED
@@ -200,6 +200,8 @@ const Page5 = (props) => {
|
|
200
200
|
}
|
201
201
|
|
202
202
|
const schema = {
|
203
|
+
id : { id: "id", type: TYPES.STRING },
|
204
|
+
|
203
205
|
name : { id: "name" , section: "A", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , like: true, label: "Name" },
|
204
206
|
state : { id: "state" , section: "A", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: true , grouper: true , column: true , filter: false , label: "State" , options: [
|
205
207
|
{ label: "Pendiente", value: "NOT_CLASSIFIED" },
|
@@ -214,7 +216,7 @@ const Page5 = (props) => {
|
|
214
216
|
|
215
217
|
return (
|
216
218
|
<Fragment>
|
217
|
-
<CollectionPage title="Referencias" schema={schema} host="http://localhost:3000" url="/references"
|
219
|
+
<CollectionPage title="Referencias" schema={schema} host="http://localhost:3000" url="/references" canAdd={true} searchBy={["field1"]} levels={["color"]}/>
|
218
220
|
</Fragment>
|
219
221
|
)
|
220
222
|
}
|