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
|
|
@ -13,3 +13,5 @@ dev:
|
||||||
dbmate +ARGS: (compose-exec "index dbmate" ARGS)
|
dbmate +ARGS: (compose-exec "index dbmate" ARGS)
|
||||||
|
|
||||||
migrate: (dbmate "migrate")
|
migrate: (dbmate "migrate")
|
||||||
|
|
||||||
|
rollback: (dbmate "rollback")
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,8 @@ services:
|
||||||
build:
|
build:
|
||||||
context: ..
|
context: ..
|
||||||
dockerfile: ./docker/Dockerfile
|
dockerfile: ./docker/Dockerfile
|
||||||
develop:
|
volumes:
|
||||||
watch:
|
- ../src:/app
|
||||||
- action: sync
|
|
||||||
path: ../src
|
|
||||||
target: /app
|
|
||||||
ports:
|
ports:
|
||||||
- 3000:8080
|
- 3000:8080
|
||||||
env_file: ../.env
|
env_file: ../.env
|
||||||
|
|
|
||||||
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 │
|
-- │ Form │
|
||||||
-- ╰─────────────────────────────────────────────────────────╯
|
-- ╰─────────────────────────────────────────────────────────╯
|
||||||
|
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
'form' AS component,
|
'form' AS component,
|
||||||
'create.sql' AS action,
|
'create.sql' AS "action",
|
||||||
'Save' AS validate,
|
'Save' AS validate,
|
||||||
'Sources' AS title;
|
'Sources' AS title;
|
||||||
|
|
||||||
|
|
@ -23,7 +21,7 @@ SELECT
|
||||||
'uid' AS name,
|
'uid' AS name,
|
||||||
'Identifier' AS label,
|
'Identifier' AS label,
|
||||||
4 AS width,
|
4 AS width,
|
||||||
5 AS maxlength,
|
8 AS maxlength,
|
||||||
1 AS minlength,
|
1 AS minlength,
|
||||||
TRUE AS required;
|
TRUE AS required;
|
||||||
|
|
||||||
|
|
@ -36,8 +34,8 @@ SELECT
|
||||||
-- ╰─────────────────────────────────────────────────────────╯
|
-- ╰─────────────────────────────────────────────────────────╯
|
||||||
SELECT
|
SELECT
|
||||||
'table' AS component,
|
'table' AS component,
|
||||||
TRUE as sort,
|
TRUE AS sort,
|
||||||
TRUE as search;
|
TRUE AS search;
|
||||||
|
|
||||||
SELECT
|
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",
|
"title": "Dependencies",
|
||||||
"icon": "brand-stackshare",
|
"icon": "brand-stackshare",
|
||||||
"submenu": [
|
"submenu": [
|
||||||
|
{
|
||||||
|
"link": "/logic_groups/index.sql",
|
||||||
|
"title": "Logic Groups",
|
||||||
|
"icon": "folder"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"link": "/sources/index.sql",
|
"link": "/sources/index.sql",
|
||||||
"title": "Sources",
|
"title": "Sources",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue