@xeplr/cli 0.1.3 → 0.1.5

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.
Files changed (37) hide show
  1. package/README.md +12 -3
  2. package/lib/generate/index.js +4 -5
  3. package/lib/plan.js +1 -0
  4. package/package.json +1 -1
  5. package/templates/CLAUDE.md +59 -0
  6. package/templates/api/app.js +13 -2
  7. package/templates/api/bin/www +5 -4
  8. package/templates/api/development.env.tpl +5 -0
  9. package/templates/api/env.required.js +1 -1
  10. package/templates/api/migrations/README.md +1 -1
  11. package/templates/api/migrations-auth/0001_home_menu.sql +1 -1
  12. package/templates/api/migrations-auth/0002_tasks_menu.sql +2 -1
  13. package/templates/api/migrations-auth/0003_configure_ui_menu.sql +20 -0
  14. package/templates/api/models/index.js +1 -1
  15. package/templates/api/package.json +4 -3
  16. package/templates/api/routes/access.js +25 -0
  17. package/templates/api/routes/index.js +1 -1
  18. package/templates/api/screens/index.js +14 -7
  19. package/templates/api/screens/task/task.model.js +29 -0
  20. package/templates/ui/package.json +2 -2
  21. package/templates/ui/src/App.jsx +29 -13
  22. package/templates/ui/src/api/factory.js +1 -1
  23. package/templates/ui/src/index.css +59 -0
  24. package/templates/ui/src/menu.js +17 -0
  25. package/templates/ui/src/pages/ConfigureUI.jsx +42 -0
  26. package/templates/ui/src/pages/EditTask.jsx +57 -0
  27. package/templates/ui/src/pages/FormDesigner.jsx +74 -0
  28. package/templates/ui/src/pages/FormRecords.jsx +24 -0
  29. package/templates/ui/src/pages/Forms.jsx +185 -0
  30. package/templates/ui/src/pages/Home.jsx +2 -2
  31. package/templates/ui/src/pages/MenuSettings.jsx +99 -0
  32. package/templates/ui/src/pages/Tasks.jsx +5 -3
  33. package/templates/ui/src/pages/TasksHelp.jsx +49 -35
  34. package/templates-tenancy/api/migrations-auth/0004_switch_menu.sql +2 -1
  35. package/templates-tenancy/api/routes/tenants.js +1 -5
  36. package/templates/api/migrations-auth/0003_designer_menu.sql +0 -19
  37. package/templates/ui/src/pages/Designer.jsx +0 -74
@@ -1,74 +0,0 @@
1
- // THE DESIGNER — change any screen: move and resize fields, add new ones,
2
- // change labels, rules, fonts and colours.
3
- //
4
- // Your edits are kept as a DRAFT automatically. Nobody else sees them until
5
- // you press Publish, which also changes the screen's database table to match:
6
- // a new field adds a column; removing one asks first, because its column and
7
- // every value in it would be deleted.
8
- import { useCallback, useEffect, useState } from 'react'
9
- import { FactoryBuilder } from '@xeplr/ui-factory'
10
- import { factory } from '../api/factory.js'
11
-
12
- export default function Designer() {
13
- const [screens, setScreens] = useState([])
14
- const [current, setCurrent] = useState(null) // { key, document, lockedNames }
15
- const [error, setError] = useState(null)
16
-
17
- useEffect(() => {
18
- factory.listScreens().then((rows) => {
19
- setScreens(rows)
20
- if (rows.length) open(rows[0].screenKey)
21
- }, (e) => setError(e.message))
22
- }, []) // eslint-disable-line react-hooks/exhaustive-deps
23
-
24
- const open = useCallback(async (key) => {
25
- try {
26
- // The draft if there is one, else the published version — with the field
27
- // names that are already columns, which the Designer will not let you rename.
28
- const row = await factory.loadDraft(key)
29
- setCurrent({ key, document: row.document, lockedNames: row.lockedNames || [] })
30
- setError(null)
31
- } catch (e) {
32
- setError(e.message)
33
- }
34
- }, [])
35
-
36
- const publish = useCallback(async (doc, options) => {
37
- const result = await factory.publish(doc, options)
38
- // New columns are now locked names too.
39
- const row = await factory.loadDraft(doc.id)
40
- setCurrent((c) => (c && c.key === doc.id ? { ...c, lockedNames: row.lockedNames || [] } : c))
41
- return result
42
- }, [])
43
-
44
- return (
45
- <div className="app-designer">
46
- <div className="app-designer-bar">
47
- <span className="app-designer-title">Designer</span>
48
- {screens.map((s) => (
49
- <button
50
- key={s.screenKey}
51
- type="button"
52
- className={'app-btn app-btn-quiet' + (current && current.key === s.screenKey ? ' is-active' : '')}
53
- onClick={() => open(s.screenKey)}
54
- >
55
- {s.name || s.screenKey}
56
- </button>
57
- ))}
58
- </div>
59
- {error && <div className="app-error">{error}</div>}
60
- {current && (
61
- <div className="app-designer-canvas">
62
- <FactoryBuilder
63
- key={current.key}
64
- {...factory.builderProps}
65
- document={current.document}
66
- lockedNames={current.lockedNames}
67
- onPublish={publish}
68
- screens={screens.map((s) => ({ id: s.screenKey, name: s.name || s.screenKey }))}
69
- />
70
- </div>
71
- )}
72
- </div>
73
- )
74
- }