|
@@ -1,9 +1,3 @@
|
|
-SET input_log_scale = COALESCE($input_log_scale, 'checkbox');
|
|
|
|
-SET input_start = COALESCE($input_start, 'date');
|
|
|
|
-SET input_end = COALESCE($input_end, 'date');
|
|
|
|
-SET input_unit_mass = COALESCE($input_unit_mass, 'select');
|
|
|
|
-SET input_unit_volume = COALESCE($input_unit_volume, 'select');
|
|
|
|
-SET input_unit_count = COALESCE($input_unit_count, 'select');
|
|
|
|
SELECT 'tab' AS component, TRUE AS center;
|
|
SELECT 'tab' AS component, TRUE AS center;
|
|
|
|
|
|
SELECT title
|
|
SELECT title
|
|
@@ -26,29 +20,26 @@ SELECT 'hidden' AS type
|
|
, $title AS value
|
|
, $title AS value
|
|
;
|
|
;
|
|
|
|
|
|
-SELECT v#>>'{name}' AS name
|
|
|
|
|
|
+SELECT j.name
|
|
--, fo.j#>>'{options}' AS label
|
|
--, fo.j#>>'{options}' AS label
|
|
-, v#>>'{label}' AS label
|
|
|
|
-, COALESCE(c.value#>>'{type}', v#>>'{type}') AS type
|
|
|
|
-, v#>>'{dropdown}' AS dropdown
|
|
|
|
-, v#>>'{multiple}' AS multiple
|
|
|
|
-, v#>>'{width}' AS width
|
|
|
|
|
|
+, j.label
|
|
|
|
+, COALESCE(c.type, j.type) AS type
|
|
|
|
+, j.dropdown AS dropdown
|
|
|
|
+, j.multiple
|
|
|
|
+, COALESCE(c.width, j.width) AS width
|
|
, o.j#>'{options}' AS options
|
|
, o.j#>'{options}' AS options
|
|
-, CASE v#>>'{type}'
|
|
|
|
- WHEN 'checkbox' THEN 'true'
|
|
|
|
- ELSE v.value#>>'{}'
|
|
|
|
- END AS value
|
|
|
|
-, CASE v#>>'{type}'
|
|
|
|
- WHEN 'checkbox' THEN (v.value#>>'{}')::bool
|
|
|
|
- ELSE NULL
|
|
|
|
-END AS checked
|
|
|
|
-FROM json_array_elements(sqlpage.read_file_as_text('sqlpage/json/filters.json')::json) j(v)
|
|
|
|
-LEFT JOIN json_each($filter_config::json) c(k,value)
|
|
|
|
-ON c.k = (v#>>'{name}')
|
|
|
|
|
|
+, COALESCE(v.value#>>'{}', j.value) AS value
|
|
|
|
+, CASE j.type
|
|
|
|
+ WHEN 'checkbox' THEN (v.value#>>'{}')::bool
|
|
|
|
+ ELSE NULL
|
|
|
|
+ END AS checked
|
|
|
|
+FROM json_populate_recordset(null::sqlpage_filter_type, sqlpage.read_file_as_text('sqlpage/json/filters.json')::json) j
|
|
|
|
+LEFT JOIN json_populate_recordset(null::sqlpage_filter_type, $filter_config::json) c
|
|
|
|
+USING (name)
|
|
LEFT JOIN json_array_elements($filter_options::json) o(j)
|
|
LEFT JOIN json_array_elements($filter_options::json) o(j)
|
|
-ON (o.j#>>'{name}') = (v#>>'{name}')
|
|
|
|
|
|
+ON (o.j#>>'{name}') = j.name
|
|
LEFT JOIN json_each(sqlpage.variables()::json) v(key, value)
|
|
LEFT JOIN json_each(sqlpage.variables()::json) v(key, value)
|
|
-ON v.key = (v#>>'{name}')
|
|
|
|
|
|
+ON v.key = j.name
|
|
;
|
|
;
|
|
|
|
|
|
SELECT 'Apply' AS value
|
|
SELECT 'Apply' AS value
|