ywana-core8 0.0.470 → 0.0.473
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 +1125 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +1124 -32
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +1125 -32
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/ContentType.js +1 -0
- package/src/domain/TabbedTablePage.js +20 -11
- package/src/domain/index.js +1 -0
- package/src/site/site.test.js +2 -2
package/package.json
CHANGED
@@ -48,7 +48,7 @@ export const TabbedTablePage = (props) => {
|
|
48
48
|
console.log("TAB", tab)
|
49
49
|
if (tab) {
|
50
50
|
const filter = { [tab.field]: tab.value }
|
51
|
-
await pageContext.load(filter,
|
51
|
+
await pageContext.load(filter, [])
|
52
52
|
setPageContext(Object.assign({}, pageContext))
|
53
53
|
}
|
54
54
|
}, [tab])
|
@@ -173,9 +173,6 @@ export const TabbedTablePage = (props) => {
|
|
173
173
|
</MenuIcon>
|
174
174
|
) : null}
|
175
175
|
{renderActions()}
|
176
|
-
|
177
|
-
{renderTabs()}
|
178
|
-
|
179
176
|
</Header>
|
180
177
|
{canQuery || canFilter ? (
|
181
178
|
<menu className="table-page">
|
@@ -184,7 +181,7 @@ export const TabbedTablePage = (props) => {
|
|
184
181
|
</menu>
|
185
182
|
) : null}
|
186
183
|
<main key={id} className="table-page">
|
187
|
-
<TableEditor icon={icon} title={name} schema={schema} delay={delay} editable={editable} groupBy={groupBy} filter={tableFilter} actions={tableActions} canDelete={canDelete} />
|
184
|
+
<TableEditor icon={icon} title={name} tabs={renderTabs()} schema={schema} delay={delay} editable={editable} groupBy={groupBy} filter={tableFilter} actions={tableActions} canDelete={canDelete} />
|
188
185
|
{children ? <article>{children}</article> : null}
|
189
186
|
</main>
|
190
187
|
{renderAside()}
|
@@ -329,6 +326,14 @@ const TableFilters = (props) => {
|
|
329
326
|
return filterSchema
|
330
327
|
}, [schema])
|
331
328
|
|
329
|
+
const likes = useMemo(() => {
|
330
|
+
const fields = Object.values(schema)
|
331
|
+
return fields.reduce((likes, field) => {
|
332
|
+
if (field.like === true) likes.push(field.id)
|
333
|
+
return likes
|
334
|
+
}, [])
|
335
|
+
}, [schema])
|
336
|
+
|
332
337
|
useEffect(() => {
|
333
338
|
if (filters) setForm(filters)
|
334
339
|
}, [filters])
|
@@ -342,7 +347,7 @@ const TableFilters = (props) => {
|
|
342
347
|
}
|
343
348
|
|
344
349
|
async function reload() {
|
345
|
-
await pageContext.load(form)
|
350
|
+
await pageContext.load(form, likes)
|
346
351
|
setPageContext(Object.assign({}, pageContext))
|
347
352
|
}
|
348
353
|
|
@@ -378,7 +383,7 @@ export const TableEditor = (props) => {
|
|
378
383
|
const site = useContext(SiteContext)
|
379
384
|
const [pageContext, setPageContext] = useContext(PageContext)
|
380
385
|
const { all = [], filters } = pageContext
|
381
|
-
const { icon, title, schema, editable, canDelete, filter, actions } = props
|
386
|
+
const { icon, title, schema, editable, canDelete, filter, actions, tabs } = props
|
382
387
|
const [groupBy, setGroupBy] = useState(props.groupBy)
|
383
388
|
|
384
389
|
function changeGroup(id, value) {
|
@@ -505,6 +510,7 @@ export const TableEditor = (props) => {
|
|
505
510
|
<Fragment>
|
506
511
|
<Header icon={icon} title={<Text>{title}</Text>}>
|
507
512
|
<DropDown id="groupBy" label="Agrupar Por" value={groupBy} options={buildGroupOptions(schema)} onChange={changeGroup} />
|
513
|
+
{tabs}
|
508
514
|
</Header>
|
509
515
|
<main className="table-editor">
|
510
516
|
{renderGroups()}
|
@@ -529,7 +535,7 @@ const TableContext = (url, field, host, urlQuery) => {
|
|
529
535
|
queries: [],
|
530
536
|
tab: null,
|
531
537
|
|
532
|
-
async load(filter, like) {
|
538
|
+
async load(filter, like = []) {
|
533
539
|
try {
|
534
540
|
const filters = filter ? Object.keys(filter).reduce((filters, key) => {
|
535
541
|
const field = filter[key];
|
@@ -583,7 +589,7 @@ const TableContext = (url, field, host, urlQuery) => {
|
|
583
589
|
async create(form) {
|
584
590
|
try {
|
585
591
|
await API.create(form);
|
586
|
-
await this.load({},
|
592
|
+
await this.load({}, []);
|
587
593
|
} catch (error) {
|
588
594
|
console.log(error)
|
589
595
|
}
|
@@ -652,7 +658,10 @@ const TableAPI = (url, host) => {
|
|
652
658
|
const http = HTTPClient(host || window.API || process.env.REACT_APP_API, Session);
|
653
659
|
|
654
660
|
return {
|
655
|
-
all(filters, like =
|
661
|
+
all(filters, like = []) {
|
662
|
+
|
663
|
+
console.log(like)
|
664
|
+
|
656
665
|
let queryParams = "?"
|
657
666
|
if (filters) {
|
658
667
|
const filterQuery = Object.keys(filters).reduce((query, key) => {
|
@@ -666,7 +675,7 @@ const TableAPI = (url, host) => {
|
|
666
675
|
}, "")
|
667
676
|
return query.concat(param)
|
668
677
|
} else {
|
669
|
-
return like ? query.concat(`${key}=%${filters[key]}%&`) : query.concat(`${key}=${filters[key]}&`)
|
678
|
+
return like.includes(key) ? query.concat(`${key}=%${filters[key]}%&`) : query.concat(`${key}=${filters[key]}&`)
|
670
679
|
}
|
671
680
|
}, "")
|
672
681
|
queryParams = queryParams.concat(filterQuery)
|
package/src/domain/index.js
CHANGED
@@ -5,3 +5,4 @@ export { CreateContentDialog } from './CreateContentDialog'
|
|
5
5
|
export { EditContentDialog } from './EditContentDialog'
|
6
6
|
export { CollectionPage, CollectionContext, CollectionTree } from './CollectionPage'
|
7
7
|
export { TablePage, TableEditor } from './TablePage'
|
8
|
+
export { TabbedTablePage } from './TabbedTablePage'
|
package/src/site/site.test.js
CHANGED
@@ -115,7 +115,7 @@ const Page2 = (props) => {
|
|
115
115
|
const Page3 = (props) => {
|
116
116
|
|
117
117
|
const schema = {
|
118
|
-
name : { id: "name" , type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, column: true , filter: true , label: "Name" },
|
118
|
+
name : { id: "name" , type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, column: true , filter: true , like: true, label: "Name" },
|
119
119
|
state : { id: "state" , type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: true , column: true , filter: false, label: "State" , options: [
|
120
120
|
{ label: "Pendiente", value: "NOT_CLASSIFIED" },
|
121
121
|
{ label: "Clasificada", value: "CLASSIFIED"},
|
@@ -127,7 +127,7 @@ const Page3 = (props) => {
|
|
127
127
|
|
128
128
|
return (
|
129
129
|
<Fragment>
|
130
|
-
<TabbedTablePage title="Referencias" schema={schema} host="http://localhost:3000" url="/references"/>
|
130
|
+
<TabbedTablePage title="Referencias" schema={schema} host="http://localhost:3000" url="/references" canFilter={true} />
|
131
131
|
</Fragment>
|
132
132
|
)
|
133
133
|
}
|