ywana-core8 0.0.64 → 0.0.65

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.64",
3
+ "version": "0.0.65",
4
4
  "description": "ywana-core8",
5
5
  "author": "Ernesto Roldan Garcia",
6
6
  "license": "MIT",
@@ -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, canDelete } = props
175
174
  const [groupBy, setGroupBy] = useState(props.groupBy)
176
175
 
177
176
  function changeGroup(id, value) {
@@ -247,7 +246,7 @@ 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
  }
@@ -262,33 +261,6 @@ const TableEditor = (props) => {
262
261
  )
263
262
  })
264
263
  }
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
264
 
293
265
  function buildGroupOptions(schema) {
294
266
  return Object.values(schema)