ywana-core8 0.0.64 → 0.0.68
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 +42 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +12 -0
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +42 -34
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +42 -33
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/TablePage.css +2 -1
- package/src/domain/TablePage.js +9 -35
- package/src/widgets/avatar/Avatar.css +10 -0
- package/src/widgets/avatar/Avatar.js +24 -0
- package/src/widgets/index.js +2 -1
package/package.json
CHANGED
package/src/domain/TablePage.css
CHANGED
package/src/domain/TablePage.js
CHANGED
@@ -16,7 +16,7 @@ const http = HTTPClient(window.API || process.env.REACT_APP_API, Session);
|
|
16
16
|
export const TablePage = (props) => {
|
17
17
|
|
18
18
|
const site = useContext(SiteContext)
|
19
|
-
const { id = "table", icon, title, name = "table 1", schema, url, field, delay = 1000, actions, editable, canAdd = true, dev = false, autosave = true, groupBy, validator, scenario, formFilter, tableFilter, tableActions } = props
|
19
|
+
const { id = "table", icon, title, name = "table 1", schema, url, field, delay = 1000, actions, editable, canAdd = true, canDelete = true, dev = false, autosave = true, groupBy, validator, scenario, formFilter, tableFilter, tableActions } = props
|
20
20
|
const [pageContext, setPageContext] = useContext(PageContext)
|
21
21
|
const { selected } = pageContext
|
22
22
|
const timer = useRef(null)
|
@@ -46,7 +46,6 @@ export const TablePage = (props) => {
|
|
46
46
|
await pageContext.create(form);
|
47
47
|
setPageContext(Object.assign({}, pageContext))
|
48
48
|
}
|
49
|
-
//site.openDialog(<EditContentDialog label={`Crear ${name}`} type={schema} onOK={onOK} validator={validator} />);
|
50
49
|
site.openDialog(<CreateContentDialog label={`Crear ${name}`} type={schema} onOK={onOK} validator={validator} filter={formFilter}/>);
|
51
50
|
}
|
52
51
|
|
@@ -111,7 +110,7 @@ export const TablePage = (props) => {
|
|
111
110
|
<TableFilters schema={schema} />
|
112
111
|
</menu>
|
113
112
|
<main key={id} className="table-page">
|
114
|
-
<TableEditor icon={icon} title={name} schema={schema} delay={delay} editable={editable} groupBy={groupBy} filter={tableFilter} actions={tableActions} />
|
113
|
+
<TableEditor icon={icon} title={name} schema={schema} delay={delay} editable={editable} groupBy={groupBy} filter={tableFilter} actions={tableActions} canDelete={canDelete}/>
|
115
114
|
</main>
|
116
115
|
{renderAside()}
|
117
116
|
</Fragment>
|
@@ -171,7 +170,7 @@ const TableEditor = (props) => {
|
|
171
170
|
|
172
171
|
const [pageContext, setPageContext] = useContext(PageContext)
|
173
172
|
const { all = [], filters } = pageContext
|
174
|
-
const { icon, title, schema, editable, filter, actions } = props
|
173
|
+
const { icon, title, schema, editable, canDelete, filter, actions } = props
|
175
174
|
const [groupBy, setGroupBy] = useState(props.groupBy)
|
176
175
|
|
177
176
|
function changeGroup(id, value) {
|
@@ -247,48 +246,24 @@ const TableEditor = (props) => {
|
|
247
246
|
action.filter(item) ? <Icon icon={action.icon} clickable size="small" action={() => run(action, item) }/> : null
|
248
247
|
: <Icon icon={action.icon} clickable size="small" action={() => run(action, item) }/>
|
249
248
|
}) : []
|
250
|
-
item.actions.push(<Icon icon="delete" size="small" clickable action={() => remove(item.id)} />)
|
249
|
+
if (canDelete) item.actions.push(<Icon icon="delete" size="small" clickable action={() => remove(item.id)} />)
|
251
250
|
return item
|
252
251
|
})
|
253
252
|
}
|
254
253
|
|
255
254
|
table.columns.push({ id: "actions" })
|
256
|
-
|
255
|
+
const groupSize = groups[groupName].length
|
256
|
+
|
257
257
|
return (
|
258
258
|
<Fragment key={groupName}>
|
259
|
-
<Header title={groupName}
|
259
|
+
<Header title={groupName} >
|
260
|
+
<span className="size">{groupSize}</span>
|
261
|
+
</Header>
|
260
262
|
<DataTable {...table} onRowSelection={select} editable={editable} />
|
261
263
|
</Fragment>
|
262
264
|
)
|
263
265
|
})
|
264
266
|
}
|
265
|
-
|
266
|
-
/* DUPLIDCADO
|
267
|
-
const table = {
|
268
|
-
columns: Object.values(schema)
|
269
|
-
.filter(field => field.column === true)
|
270
|
-
.map(field => {
|
271
|
-
let options = field.options;
|
272
|
-
if (options && typeof (options) == 'function') {
|
273
|
-
options = options()
|
274
|
-
}
|
275
|
-
return {
|
276
|
-
id: field.id,
|
277
|
-
label: field.label,
|
278
|
-
type: field.type,
|
279
|
-
onChange: field.editable ? change : null,
|
280
|
-
options
|
281
|
-
}
|
282
|
-
}),
|
283
|
-
rows: all
|
284
|
-
.map(item => {
|
285
|
-
item.actions = [<Icon icon="delete" size="small" clickable action={() => remove(item.id)} />]
|
286
|
-
return item
|
287
|
-
})
|
288
|
-
}
|
289
|
-
|
290
|
-
table.columns.push({ id: "actions" })
|
291
|
-
*/
|
292
267
|
|
293
268
|
function buildGroupOptions(schema) {
|
294
269
|
return Object.values(schema)
|
@@ -401,7 +376,6 @@ const TableAPI = (url) => {
|
|
401
376
|
param = param.concat(`${key}=${item}&`)
|
402
377
|
return param
|
403
378
|
}, "")
|
404
|
-
console.log(param)
|
405
379
|
return query.concat(param)
|
406
380
|
} else {
|
407
381
|
return query.concat(`${key}=%${filters[key]}%&`)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import './Avatar.css'
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Avatar
|
6
|
+
*/
|
7
|
+
export const Avatar = (props) => {
|
8
|
+
|
9
|
+
const { id, name, src, size="small", clickable=false, action} = props
|
10
|
+
|
11
|
+
function click() {
|
12
|
+
if (clickable) {
|
13
|
+
action(id)
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
const style = clickable ? 'clickable' : ''
|
18
|
+
const className= `avatar ${size} ${style}`
|
19
|
+
return (
|
20
|
+
<div className={className} onClick={click}>
|
21
|
+
{ src ? <img src={src} /> : <span>{name}</span>}
|
22
|
+
</div>
|
23
|
+
)
|
24
|
+
}
|
package/src/widgets/index.js
CHANGED