generated from alecodes/base-template
feat: add logic_group crud
This commit is contained in:
parent
baf70e6820
commit
d643e1c0f2
7 changed files with 98 additions and 11 deletions
7
src/app/logic_groups/create.sql
Normal file
7
src/app/logic_groups/create.sql
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
INSERT INTO
|
||||
public.logic_groups(name, uid, uri, source_id)
|
||||
VALUES
|
||||
(:name, :uid, :uri, :source_id :: int)
|
||||
RETURNING
|
||||
'redirect' AS component,
|
||||
'index.sql' AS link;
|
||||
63
src/app/logic_groups/index.sql
Normal file
63
src/app/logic_groups/index.sql
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
SELECT
|
||||
'dynamic' AS component,
|
||||
sqlpage.read_file_as_text('../shared/shell.json') AS properties;
|
||||
|
||||
-- ╭─────────────────────────────────────────────────────────╮
|
||||
-- │ Form │
|
||||
-- ╰─────────────────────────────────────────────────────────╯
|
||||
SELECT
|
||||
'form' AS component,
|
||||
'create.sql' AS "action",
|
||||
'Save' AS validate,
|
||||
'Logic Group' AS title;
|
||||
|
||||
SELECT
|
||||
'source_id' AS name,
|
||||
'Source' AS label,
|
||||
'select' AS TYPE,
|
||||
TRUE AS required,
|
||||
TRUE AS searchable,
|
||||
'Select...' AS empty_option,
|
||||
(
|
||||
SELECT
|
||||
jsonb_agg(jsonb_build_object('label', name, 'value', id))
|
||||
FROM
|
||||
public.sources
|
||||
) AS options;
|
||||
|
||||
SELECT
|
||||
'name' AS name,
|
||||
'Name' AS label,
|
||||
8 AS width,
|
||||
TRUE AS required;
|
||||
|
||||
SELECT
|
||||
'uid' AS name,
|
||||
'Identifier' AS label,
|
||||
4 AS width,
|
||||
8 AS maxlength,
|
||||
1 AS minlength,
|
||||
TRUE AS required;
|
||||
|
||||
SELECT
|
||||
'uri' AS name,
|
||||
'URI' AS label;
|
||||
|
||||
-- ╭─────────────────────────────────────────────────────────╮
|
||||
-- │ Table list │
|
||||
-- ╰─────────────────────────────────────────────────────────╯
|
||||
SELECT
|
||||
'table' AS component,
|
||||
'source' AS markdown,
|
||||
TRUE AS sort,
|
||||
TRUE AS search;
|
||||
|
||||
SELECT
|
||||
lg.id,
|
||||
lg.uid,
|
||||
format('[%s](/sources/%s)', src.name, src.id) AS Source,
|
||||
lg.name,
|
||||
lg.uri
|
||||
FROM
|
||||
public.logic_groups AS lg
|
||||
INNER JOIN public.sources AS src ON lg.source_id = src.id;
|
||||
|
|
@ -5,11 +5,9 @@ SELECT
|
|||
-- ╭─────────────────────────────────────────────────────────╮
|
||||
-- │ Form │
|
||||
-- ╰─────────────────────────────────────────────────────────╯
|
||||
|
||||
|
||||
SELECT
|
||||
'form' AS component,
|
||||
'create.sql' AS action,
|
||||
'create.sql' AS "action",
|
||||
'Save' AS validate,
|
||||
'Sources' AS title;
|
||||
|
||||
|
|
@ -23,7 +21,7 @@ SELECT
|
|||
'uid' AS name,
|
||||
'Identifier' AS label,
|
||||
4 AS width,
|
||||
5 AS maxlength,
|
||||
8 AS maxlength,
|
||||
1 AS minlength,
|
||||
TRUE AS required;
|
||||
|
||||
|
|
@ -36,8 +34,8 @@ SELECT
|
|||
-- ╰─────────────────────────────────────────────────────────╯
|
||||
SELECT
|
||||
'table' AS component,
|
||||
TRUE as sort,
|
||||
TRUE as search;
|
||||
TRUE AS sort,
|
||||
TRUE AS search;
|
||||
|
||||
SELECT
|
||||
*
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
-- migrate:up
|
||||
CREATE TABLE public.logic_groups (
|
||||
id serial PRIMARY KEY,
|
||||
name character varying(20) NOT NULL,
|
||||
uid character varying(8) NOT NULL,
|
||||
uri character varying,
|
||||
source_id int,
|
||||
created_at timestamp WITH time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||
updated_at timestamp WITH time zone,
|
||||
deleted_at timestamp WITH time zone,
|
||||
CONSTRAINT fk_source FOREIGN KEY (source_id) REFERENCES public.sources(id)
|
||||
);
|
||||
|
||||
-- migrate:down
|
||||
DROP TABLE public.logic_groups;
|
||||
|
|
@ -11,6 +11,11 @@
|
|||
"title": "Dependencies",
|
||||
"icon": "brand-stackshare",
|
||||
"submenu": [
|
||||
{
|
||||
"link": "/logic_groups/index.sql",
|
||||
"title": "Logic Groups",
|
||||
"icon": "folder"
|
||||
},
|
||||
{
|
||||
"link": "/sources/index.sql",
|
||||
"title": "Sources",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue