-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsupports.sql
More file actions
82 lines (66 loc) · 1.99 KB
/
Copy pathsupports.sql
File metadata and controls
82 lines (66 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
-- GLOBAL DATA
-- $c : application constants as json
-- $p : parameters as json
-- $t : translation texts as json
-- MORE DATA SETUP
SET action = IIF($action IN ('create', 'update', 'delete'),
$action, 'create');
SET form_id = 'supports';
SET record =
SELECT json_object(
'id', id,
'name', name,
'sign', sign
)
FROM supports
WHERE id=$id;
SET options =
SELECT json_group_array(
json_object(
'label', value,
'value', value
)
)
FROM json_each(json_array('-', '+'));
-- FORM
SELECT
'form' AS component,
$form_id AS id,
'' AS validate;
SELECT
'name' AS name,
$t->>'support'->>'name' AS label,
$record->>'name' AS value,
TRUE AS required;
SELECT
'sign' AS name,
$t->>'support'->>'sign' AS label,
$record->>'sign' AS value,
'select' AS type,
$options AS options;
-- BUTTONS FORM
SELECT 'dynamic' AS component,
sqlpage.run_sql('buttons_form.sql') AS properties;
-- TABLE OF SUPPORTS
SET actions = format(
"[✎](index?no=%s&id=%s&action=update '%s')
[✘](index?no=%s&id=%s&action=delete '%s')",
$no, '%s', CONCAT($t->'actions'->>'edit','…'),
$no, '%s', CONCAT($t->'actions'->>'delete','…')
);
SELECT
'table' AS component,
$t->>'action' AS markdown,
$t->>'action' AS align_center,
TRUE AS sort,
TRUE AS freeze_headers,
$p->>'search_area' AS search,
$t->>'no_data' AS empty_description,
$t->>'search' || '…' AS search_placeholder;
SELECT 'dynamic' AS component,
json_group_array(json_object(
$t->'support'->>'name', name,
$t->'support'->>'sign', sign,
$t->>'action', format($actions, id, id, id)
)) AS properties
FROM supports;