Просмотр исходного кода

form improvements: descriptive project id, auto focus on form element, remove duration

Daniel Sheffield 3 дней назад
Родитель
Сommit
1a1be553d4
1 измененных файлов с 18 добавлено и 9 удалено
  1. 18 9
      site/add_item.sql

+ 18 - 9
site/add_item.sql

@@ -1,6 +1,7 @@
 SET TIME ZONE 'Pacific/Auckland';
 SET ":title" = 'Timesheet Form';
 SELECT 'shell' AS component
+, 'fluid' AS layout
 , 'dark' AS theme
 , '/clock-2.svg' AS favicon
 , 'clock-2' AS icon
@@ -14,17 +15,31 @@ SELECT 'form' AS component
 , 'post' AS method
 ;
 
+SET ":project_options" = (SELECT JSON_ARRAYAGG(JSON_OBJECT(ARRAY['label', CASE description IS NULL
+	WHEN TRUE THEN project
+	ELSE CASE description
+		WHEN '' THEN id::text
+		ELSE description
+	END
+END, 'value', id::text, 'selected', CASE id WHEN 166 THEN 'selected' ELSE NULL END::text]))
+FROM project);
+
 SELECT 'Project ID' AS label
+, TRUE AS autofocus
+, TRUE AS required
+, 1 AS step
 , 'project_id' AS name
-, 'number' AS type
+, 'select' AS type
 , 'input-project-id' AS id
-, 1 AS width
+, :project_options AS options
+, 2 AS width
 ;
 SELECT 'Description' AS label
+, TRUE AS required
 , 'description' AS name
 , 'text' AS type
 , 'input-description' AS id
-, 5 AS width
+, 6 AS width
 ;
 SELECT 'Start' AS label
 , 'start_time' AS name
@@ -38,12 +53,6 @@ SELECT 'End' AS label
 , 'input-end-time' AS id
 , 2 AS width
 ;
-SELECT 'Duration' AS label
-, 'duration' AS name
-, 'time' AS type
-, 'input-duration' AS id
-, 2 AS width
-;
 
 SELECT 'card' as component
 , '' AS title