generated from alecodes/base-template
feat: create entry form
This commit is contained in:
parent
9b5d43e9ba
commit
5dbdd5d84d
8 changed files with 174 additions and 5 deletions
|
|
@ -8,7 +8,7 @@ compose-exec +ARGS:
|
||||||
|
|
||||||
[working-directory: 'docker']
|
[working-directory: 'docker']
|
||||||
dev:
|
dev:
|
||||||
docker compose up
|
docker compose up --build
|
||||||
|
|
||||||
dbmate +ARGS: (compose-exec "index dbmate" ARGS)
|
dbmate +ARGS: (compose-exec "index dbmate" ARGS)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
FROM ghcr.io/linuxcontainers/debian-slim:latest
|
FROM ghcr.io/linuxcontainers/debian-slim:latest
|
||||||
|
|
||||||
COPY --from=ghcr.io/amacneil/dbmate /usr/local/bin/dbmate /usr/local/bin/dbmate
|
COPY --from=ghcr.io/amacneil/dbmate /usr/local/bin/dbmate /usr/local/bin/dbmate
|
||||||
COPY --from=lovasoa/sqlpage:latest /usr/local/bin/sqlpage /usr/local/bin/sqlpage
|
COPY --from=lovasoa/sqlpage:main /usr/local/bin/sqlpage /usr/local/bin/sqlpage
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,5 +17,15 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- db_data:/var/lib/postgresql/data
|
- db_data:/var/lib/postgresql/data
|
||||||
|
|
||||||
|
adminer:
|
||||||
|
image: ghcr.io/shyim/adminerevo:latest
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- 8080:8080
|
||||||
|
env_file: ../.env
|
||||||
|
environment:
|
||||||
|
ADMINER_DEFAULT_DRIVER: psql
|
||||||
|
ADMINER_DEFAULT_SERVER: db
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
db_data:
|
db_data:
|
||||||
|
|
|
||||||
107
src/app/entries/create.sql
Normal file
107
src/app/entries/create.sql
Normal file
|
|
@ -0,0 +1,107 @@
|
||||||
|
SELECT
|
||||||
|
'dynamic' AS component,
|
||||||
|
sqlpage.read_file_as_text('../shared/shell.json') AS properties;
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
'form' AS component,
|
||||||
|
TRUE AS auto_submit;
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
'source_id' AS name,
|
||||||
|
'Source - group' AS label,
|
||||||
|
'select' AS "type",
|
||||||
|
FALSE AS autocomplete,
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
jsonb_agg(
|
||||||
|
jsonb_build_object(
|
||||||
|
'label',
|
||||||
|
format('%s - %s', src.name, lg.name),
|
||||||
|
'value',
|
||||||
|
lg.id,
|
||||||
|
'selected',
|
||||||
|
lg.id = $source_id :: int
|
||||||
|
)
|
||||||
|
ORDER BY
|
||||||
|
src.name,
|
||||||
|
lg.name
|
||||||
|
)
|
||||||
|
FROM
|
||||||
|
public.logic_groups AS lg
|
||||||
|
INNER JOIN public.sources AS src ON lg.source_id = src.id
|
||||||
|
) AS options;
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
'form' AS component,
|
||||||
|
'Create' AS validate;
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
'Date' AS label,
|
||||||
|
'date' AS name,
|
||||||
|
'date' AS "type",
|
||||||
|
CURRENT_DATE AS value,
|
||||||
|
6 AS width;
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
'Time' AS label,
|
||||||
|
'time' AS name,
|
||||||
|
'time' AS "type",
|
||||||
|
LOCALTIME(0) AS value,
|
||||||
|
6 AS width;
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
'UID' AS label,
|
||||||
|
'uid' AS name,
|
||||||
|
'SOURCE:LOGIC-GROUP:DESAMBIGUATOR:ATOM' AS placeholder,
|
||||||
|
TRUE AS disabled;
|
||||||
|
|
||||||
|
-- ── Desambiguator Definitions Start ─────────────────────────────────
|
||||||
|
SET
|
||||||
|
input =
|
||||||
|
SELECT
|
||||||
|
jsonb_build_object(
|
||||||
|
'id',
|
||||||
|
dtp.id,
|
||||||
|
'input_type',
|
||||||
|
dtp.input_type,
|
||||||
|
'placeholder',
|
||||||
|
dtp.placeholder
|
||||||
|
) AS obj
|
||||||
|
FROM
|
||||||
|
public.desambiguator_types dtp
|
||||||
|
INNER JOIN public.sources AS src ON src.desambiguator_type_id = dtp.id
|
||||||
|
INNER JOIN public.logic_groups AS lg ON lg.source_id = src.id
|
||||||
|
WHERE
|
||||||
|
lg.id = $source_id :: int;
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
'Desambiguator' AS label,
|
||||||
|
'desambiguator' AS name,
|
||||||
|
$input :: jsonb ->> 'input_type' AS "type",
|
||||||
|
$input :: jsonb ->> 'placeholder' AS placeholder,
|
||||||
|
6 AS width
|
||||||
|
WHERE
|
||||||
|
$input :: jsonb ->> 'id' = '1';
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
'Desambiguator' AS label,
|
||||||
|
'desambiguator' AS name,
|
||||||
|
$input :: jsonb ->> 'input_type' AS "type",
|
||||||
|
$input :: jsonb ->> 'placeholder' AS placeholder,
|
||||||
|
CURRENT_DATE AS value,
|
||||||
|
6 AS width
|
||||||
|
WHERE
|
||||||
|
$input :: jsonb ->> 'id' = '2';
|
||||||
|
|
||||||
|
-- ── Desambiguator Definitions End ───────────────────────────────────
|
||||||
|
SELECT
|
||||||
|
'Atom' AS label,
|
||||||
|
'atom' AS name,
|
||||||
|
'FFF' AS placeholder,
|
||||||
|
6 AS width;
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
'Description' AS label,
|
||||||
|
'text' AS name,
|
||||||
|
'What is this entry about?' AS placeholder,
|
||||||
|
'textarea' AS "type";
|
||||||
|
|
@ -4,17 +4,34 @@ SELECT
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
'form' AS component,
|
'form' AS component,
|
||||||
'entries' AS "action",
|
'entries/search.sql' AS "action",
|
||||||
'Entries' AS title,
|
'Entries' AS title,
|
||||||
'Search' AS validate,
|
'' AS validate,
|
||||||
'GET' AS method;
|
'GET' AS method;
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
'query' AS name,
|
'query' AS name,
|
||||||
'' AS label,
|
'' AS label,
|
||||||
'Search query...' AS placeholder,
|
'Search query...' AS placeholder,
|
||||||
|
10 AS width,
|
||||||
TRUE AS autofocus;
|
TRUE AS autofocus;
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
'search' AS name,
|
||||||
|
'' AS label,
|
||||||
|
'Search' AS value,
|
||||||
|
2 AS width,
|
||||||
|
'btn btn-info' AS class,
|
||||||
|
'submit' AS "type";
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
'new' AS name,
|
||||||
|
'' AS label,
|
||||||
|
'New' AS value,
|
||||||
|
'entries/create.sql' AS "formaction",
|
||||||
|
'btn btn-success' AS class,
|
||||||
|
'submit' AS "type";
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
'list' AS component,
|
'list' AS component,
|
||||||
'Lastes entries' AS title,
|
'Lastes entries' AS title,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
-- migrate:up
|
||||||
|
CREATE TABLE public.desambiguator_types(
|
||||||
|
id serial PRIMARY KEY,
|
||||||
|
name varchar(15) NOT NULL,
|
||||||
|
input_type varchar(15) NOT NULL,
|
||||||
|
placeholder varchar(30),
|
||||||
|
created_at timestamp WITH time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||||
|
updated_at timestamp WITH time zone,
|
||||||
|
deleted_at timestamp WITH time zone
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO
|
||||||
|
public.desambiguator_types(name, input_type, placeholder)
|
||||||
|
VALUES
|
||||||
|
('Text', 'text', 'XXX-XXX-XXX'),
|
||||||
|
('Date', 'date', '2020-12-31');
|
||||||
|
|
||||||
|
ALTER TABLE
|
||||||
|
public.sources
|
||||||
|
ADD
|
||||||
|
COLUMN desambiguator_type_id int NOT NULL DEFAULT 1;
|
||||||
|
|
||||||
|
ALTER TABLE
|
||||||
|
public.sources
|
||||||
|
ADD
|
||||||
|
CONSTRAINT fk_desambiguator_type FOREIGN KEY (desambiguator_type_id) REFERENCES public.desambiguator_types(id);
|
||||||
|
|
||||||
|
-- migrate:down
|
||||||
|
ALTER TABLE
|
||||||
|
public.sources DROP CONSTRAINT fk_desambiguator_type;
|
||||||
|
|
||||||
|
ALTER TABLE
|
||||||
|
public.sources DROP COLUMN desambiguator_type_id;
|
||||||
|
|
||||||
|
DROP TABLE public.desambiguator_types;
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
"layout": "boxed",
|
"layout": "boxed",
|
||||||
"sidebar": true,
|
"sidebar": true,
|
||||||
"theme": "dark",
|
"theme": "dark",
|
||||||
"css": "style.css",
|
"css": "/style.css",
|
||||||
"menu_item": [
|
"menu_item": [
|
||||||
{ "link": "index.sql", "title": "Home" },
|
{ "link": "index.sql", "title": "Home" },
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue