From efcd0ed85558e870460fb4a763cb9aa6d02fc147 Mon Sep 17 00:00:00 2001 From: Ferran Date: Mon, 13 Jan 2025 13:45:46 +0100 Subject: [PATCH] feat(mapzones manager): make mapzones manager call v_ui_type tables, make toggle active work, change order of fields, refactor triggers to make them work all in one fo each type, WIP see what happened with config_form_fields insert not correct --- updates/36/36017/utils/dml.sql | 7 +- updates/36/36017/ws/ddlview.sql | 210 +++++++++++++++++++++++--- updates/36/36017/ws/dml.sql | 63 ++++++++ updates/36/36017/ws/trg.sql | 34 +++++ utils/fct/gw_fct_getstylemapzones.sql | 10 +- utils/fct/gw_fct_infofromid.sql | 6 +- ws/ftrg/ws_gw_trg_edit_dma.sql | 76 ++++++---- ws/ftrg/ws_gw_trg_edit_dqa.sql | 74 ++++++--- ws/ftrg/ws_gw_trg_edit_presszone.sql | 58 ++++--- ws/ftrg/ws_gw_trg_edit_sector.sql | 47 ++++-- 10 files changed, 472 insertions(+), 113 deletions(-) create mode 100644 updates/36/36017/ws/dml.sql create mode 100644 updates/36/36017/ws/trg.sql diff --git a/updates/36/36017/utils/dml.sql b/updates/36/36017/utils/dml.sql index c790b7fdb7..804503ed97 100644 --- a/updates/36/36017/utils/dml.sql +++ b/updates/36/36017/utils/dml.sql @@ -74,8 +74,11 @@ update config_param_system set value = '{"table":"temp_mincut","table_id":"id","selector":"selector_mincut_result","selector_id":"result_id","label":"id, ''('', CASE WHEN work_order IS NULL THEN ''N/I'' ELSE work_order END, '') on '', forecast_start::date, '' at '', forecast_start::time, ''H-'', forecast_end::time,''H''","query_filter":"","manageAll":true}' where parameter = 'basic_selector_tab_mincut'; - - +-- 13/01/2025 +UPDATE config_form_fields SET dv_querytext = 'SELECT sector_id as id,name as idval FROM v_edit_sector WHERE sector_id > -1', +widgetcontrols = '{"setMultiline": false, "valueRelation":{"nullValue":true, "layer": "v_edit_sector", "activated": true, "keyColumn": "sector_id", +"valueColumn": "name", "filterExpression": "sector_id > -1"}}' +WHERE formname = 'v_edit_sector' AND formtype = 'form_feature' AND tabname = 'tab_none' AND columnname = 'parent_id'; diff --git a/updates/36/36017/ws/ddlview.sql b/updates/36/36017/ws/ddlview.sql index d3b18af733..a42a5ae271 100644 --- a/updates/36/36017/ws/ddlview.sql +++ b/updates/36/36017/ws/ddlview.sql @@ -884,35 +884,203 @@ AS SELECT s.sector_id, LEFT JOIN edit_typevalue et ON et.id::text = s.sector_type::text AND et.typevalue::text = 'sector_type'::text ORDER BY s.sector_id; +-- 10/01/2025 +DROP VIEW IF EXISTS v_ui_sector; +CREATE OR REPLACE VIEW v_ui_sector +AS SELECT s.sector_id, + s.name, + s.sector_type, + ms.name AS macrosector, + s.descript, + s.active, + s.undelete, + s.graphconfig, + s.stylesheet, + s.parent_id, + s.pattern_id, + s.tstamp, + s.insert_user, + s.lastupdate, + s.lastupdate_user, + s.avg_press, + s.link + FROM selector_sector ss, + sector s + LEFT JOIN macrosector ms ON ms.macrosector_id = s.macrosector_id + WHERE s.sector_id > 0 AND ss.sector_id = s.sector_id AND ss.cur_user = CURRENT_USER + ORDER BY s.sector_id; + DROP VIEW IF EXISTS v_edit_sector; CREATE OR REPLACE VIEW v_edit_sector -AS SELECT s.* -FROM vu_sector s, selector_sector -WHERE s.sector_id = selector_sector.sector_id and active AND selector_sector.cur_user = "current_user"()::text; +AS SELECT s.sector_id, + s.name, + s.sector_type, + ms.name AS macrosector, + s.descript, + s.undelete, + s.graphconfig::text AS graphconfig, + s.stylesheet, + s.parent_id, + s.pattern_id, + s.tstamp, + s.insert_user, + s.lastupdate, + s.lastupdate_user, + s.avg_press, + s.link, + s.the_geom + FROM selector_sector, + sector s + LEFT JOIN macrosector ms ON ms.macrosector_id = s.macrosector_id + WHERE s.sector_id = selector_sector.sector_id AND selector_sector.cur_user = "current_user"()::text; -create trigger gw_trg_edit_sector instead of insert or delete or update on v_edit_sector -for each row execute function gw_trg_edit_sector('sector'); +DROP VIEW IF EXISTS v_ui_dma; +CREATE OR REPLACE VIEW v_ui_dma +AS SELECT d.dma_id, + d.name, + d.dma_type, + md.name AS macrodma, + d.descript, + d.active, + d.undelete, + d.expl_id, + d.minc, + d.maxc, + d.effc, + d.pattern_id, + d.link, + d.graphconfig, + d.stylesheet, + d.avg_press, + d.tstamp, + d.insert_user, + d.lastupdate, + d.lastupdate_user + FROM selector_expl s, + dma d + LEFT JOIN macrodma md ON md.macrodma_id = d.macrodma_id + WHERE d.dma_id > 0 AND s.expl_id = d.expl_id AND s.cur_user = CURRENT_USER + ORDER BY d.dma_id; -create or replace view v_edit_presszone as -select vu.* from vu_presszone vu, selector_expl -WHERE vu.expl_id = selector_expl.expl_id and active AND selector_expl.cur_user = "current_user"()::text OR vu.expl_id IS NULL -ORDER BY vu.presszone_id; +DROP VIEW IF EXISTS v_edit_dma; +CREATE OR REPLACE VIEW v_edit_dma +AS SELECT d.dma_id, + d.name, + d.dma_type, + md.name AS macrodma, + d.descript, + d.undelete, + d.expl_id, + d.minc, + d.maxc, + d.effc, + d.pattern_id, + d.link, + d.graphconfig, + d.stylesheet, + d,avg_press, + d.tstamp, + d.insert_user, + d.lastupdate, + d.lastupdate_user, + d.the_geom + FROM + selector_expl, + dma d + LEFT JOIN macrodma md ON md.macrodma_id = d.macrodma_id + WHERE d.expl_id = selector_expl.expl_id AND d.active AND selector_expl.cur_user = "current_user"()::text OR d.expl_id IS NULL + ORDER BY d.dma_id; -create or replace view v_edit_dma as -select vu.* from vu_dma vu, selector_expl -WHERE vu.expl_id = selector_expl.expl_id and active AND selector_expl.cur_user = "current_user"()::text OR vu.expl_id IS NULL -ORDER BY vu.dma_id; +DROP VIEW IF EXISTS v_ui_presszone; +CREATE OR REPLACE VIEW v_ui_presszone +AS SELECT p.presszone_id, + p.name, + p.presszone_type, + p.descript, + p.active, + p.expl_id, + p.link, + p.head, + p.graphconfig, + p.stylesheet, + p.tstamp, + p.insert_user, + p.lastupdate, + p.lastupdate_user + FROM selector_expl s, + presszone p + WHERE (p.presszone_id::text <> ALL (ARRAY['0'::character varying::text, '-1'::character varying::text])) AND s.expl_id = p.expl_id AND s.cur_user = CURRENT_USER + ORDER BY p.presszone_id; -create or replace view v_edit_dma as -select vu.* from vu_dma vu, selector_expl -WHERE vu.expl_id = selector_expl.expl_id and active AND selector_expl.cur_user = "current_user"()::text OR vu.expl_id IS NULL -ORDER BY vu.dma_id; -create or replace view v_edit_dqa as -select vu.* from vu_dqa vu, selector_expl -WHERE vu.expl_id = selector_expl.expl_id and active AND selector_expl.cur_user = "current_user"()::text OR vu.expl_id IS NULL -ORDER BY vu.dqa_id; +DROP VIEW IF EXISTS v_edit_presszone; +CREATE OR REPLACE VIEW v_edit_presszone +AS SELECT p.presszone_id, + p.name, + p.presszone_type, + p.descript, + p.expl_id, + p.link, + p.head, + p.graphconfig, + p.stylesheet, + p.tstamp, + p.insert_user, + p.lastupdate, + p.lastupdate_user, + p.the_geom + FROM + selector_expl, + vu_presszone p + WHERE p.expl_id = selector_expl.expl_id AND p.active AND selector_expl.cur_user = "current_user"()::text OR p.expl_id IS NULL + ORDER BY p.presszone_id; +DROP VIEW IF EXISTS v_ui_dqa; +CREATE OR REPLACE VIEW v_ui_dqa +AS SELECT d.dqa_id, + d.name, + d.dqa_type, + md.name AS macrodqa_id, + d.descript, + d.active, + d.undelete, + d.expl_id, + d.pattern_id, + d.link, + d.graphconfig, + d.stylesheet, + d.tstamp, + d.insert_user, + d.lastupdate, + d.lastupdate_user + FROM selector_expl s, + vu_dqa d + LEFT JOIN macrodqa md ON md.macrodqa_id = d.macrodqa_id + WHERE d.dqa_id > 0 AND s.expl_id = d.expl_id AND s.cur_user = CURRENT_USER + ORDER BY d.dqa_id; +DROP VIEW IF EXISTS v_edit_dqa; +CREATE OR REPLACE VIEW v_edit_dqa +AS SELECT d.dqa_id, + d.name, + d.dqa_type, + md.name AS macrodqa_id, + d.descript, + d.undelete, + d.expl_id, + d.pattern_id, + d.link, + d.graphconfig, + d.stylesheet, + d.tstamp, + d.insert_user, + d.lastupdate, + d.lastupdate_user, + d.the_geom + FROM selector_expl, + vu_dqa d + LEFT JOIN macrodqa md ON md.macrodqa_id = d.macrodqa_id + WHERE d.expl_id = selector_expl.expl_id AND d.active AND selector_expl.cur_user = "current_user"()::text OR d.expl_id IS NULL + ORDER BY d.dqa_id; \ No newline at end of file diff --git a/updates/36/36017/ws/dml.sql b/updates/36/36017/ws/dml.sql new file mode 100644 index 0000000000..efe7655d4f --- /dev/null +++ b/updates/36/36017/ws/dml.sql @@ -0,0 +1,63 @@ +/* +This file is part of Giswater 3 +The program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +This version of Giswater is provided by Giswater Association +*/ + + +SET search_path = SCHEMA_NAME, public, pg_catalog; + + +-- 10/01/2025 +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_sector', 'form_feature', 'tab_none', 'sector_id', 'lyt_data_1', 1, 'integer', 'text', 'sector_id', 'sector_id', NULL, false, false, true, false, NULL, NULL, NULL, NULL, NULL, NULL, '{"label":"color:red; font-weight:bold"}'::json, '{"setMultiline": false, "valueRelation":{"nullValue":false, "layer": "v_edit_sector", "activated": true, "keyColumn": "sector_id", "valueColumn": "name", "filterExpression": null}}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_sector', 'form_feature', 'tab_none', 'name', 'lyt_data_1', 2, 'string', 'text', 'name', 'name', NULL, false, false, true, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_sector', 'form_feature', 'tab_none', 'sector_type', 'lyt_data_1', 3, 'string', 'combo', 'sector_type', 'sector_type', NULL, false, false, true, false, NULL, 'SELECT id, idval FROM edit_typevalue WHERE typevalue=''sector_type''', true, true, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_sector', 'form_feature', 'tab_none', 'macrosector', 'lyt_data_1', 4, 'string', 'combo', 'macrosector_id', 'macrosector_id', NULL, false, false, true, false, NULL, 'SELECT name as id, name as idval FROM macrosector WHERE macrosector_id IS NOT NULL', true, false, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_sector', 'form_feature', 'tab_none', 'descript', 'lyt_data_1', 5, 'text', 'text', 'descript', 'descript', NULL, false, false, true, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_sector', 'form_feature', 'tab_none', 'active', 'lyt_data_1', 6, 'boolean', 'check', 'active', 'active', NULL, false, false, true, false, false, NULL, NULL, false, NULL, NULL, NULL, NULL, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_sector', 'form_feature', 'tab_none', 'undelete', 'lyt_data_1', 7, 'boolean', 'check', 'undelete', 'undelete', NULL, false, false, true, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_sector', 'form_feature', 'tab_none', 'parent_id', 'lyt_data_1', 8, 'string', 'combo', 'parent_id', 'parent_id', NULL, false, false, true, false, false, 'SELECT sector_id as id,name as idval FROM v_ui_sector WHERE sector_id > -1 AND active IS TRUE', true, true, NULL, NULL, NULL, '{"setMultiline": false, "valueRelation":{"nullValue":true, "layer": "v_edit_sector", "activated": true, "keyColumn": "sector_id", "valueColumn": "name", "filterExpression": "sector_id > -1 AND active IS TRUE"}}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_sector', 'form_feature', 'tab_none', 'pattern_id', 'lyt_data_1', 9, 'string', 'combo', 'pattern_id', 'pattern_id', NULL, false, false, true, false, false, 'SELECT DISTINCT (pattern_id) AS id, pattern_id AS idval FROM inp_pattern WHERE pattern_id IS NOT NULL', true, true, NULL, NULL, NULL, '{"setMultiline": false, "valueRelation":{"nullValue":true, "layer": "v_edit_inp_pattern", "activated": true, "keyColumn": "pattern_id", "valueColumn": "pattern_id", "filterExpression": null}}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_sector', 'form_feature', 'tab_none', 'graphconfig', 'lyt_data_1', 10, 'string', 'text', 'graphconfig', 'graphconfig', NULL, false, false, false, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_sector', 'form_feature', 'tab_none', 'stylesheet', 'lyt_data_1', 11, 'string', 'text', 'stylesheet', 'stylesheet', NULL, false, false, true, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, false, NULL); + + +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_dma', 'form_feature', 'tab_none', 'dma_id', 'lyt_data_1', 1, 'integer', 'text', 'dma_id', 'dma_id', NULL, false, false, true, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"setMultiline": false, "valueRelation":{"nullValue":false, "layer": "v_edit_dma", "activated": true, "keyColumn": "dma_id", "valueColumn": "name", "filterExpression": null}}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_dma', 'form_feature', 'tab_none', 'name', 'lyt_data_1', 2, 'string', 'text', 'name', 'name', NULL, false, false, true, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_dma', 'form_feature', 'tab_none', 'dma_type', 'lyt_data_1', 3, 'string', 'combo', 'dma_type', 'dma_type', NULL, false, false, true, false, NULL, 'SELECT id, idval FROM edit_typevalue WHERE typevalue=''dma_type''', true, true, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_dma', 'form_feature', 'tab_none', 'macrodma_id', 'lyt_data_1', 4, 'integer', 'combo', 'macrodma_id', 'macrodma_id', NULL, false, false, true, false, NULL, 'SELECT macrodma_id as id, name as idval FROM macrodma WHERE macrodma_id IS NOT NULL', NULL, NULL, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, true, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_dma', 'form_feature', 'tab_none', 'descript', 'lyt_data_1', 5, 'text', 'text', 'descript', 'descript', NULL, false, false, true, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_dma', 'form_feature', 'tab_none', 'active', 'lyt_data_1', 6, 'boolean', 'check', 'active', 'active', NULL, false, false, true, false, false, NULL, NULL, false, NULL, NULL, NULL, NULL, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_dma', 'form_feature', 'tab_none', 'undelete', 'lyt_data_1', 7, 'boolean', 'check', 'undelete', 'undelete', NULL, false, false, true, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_dma', 'form_feature', 'tab_none', 'expl_id', 'lyt_data_1', 8, 'integer', 'combo', 'expl_id', 'expl_id', NULL, false, false, true, false, NULL, 'SELECT expl_id as id, name as idval FROM exploitation WHERE expl_id IS NOT NULL', true, false, NULL, NULL, '{"label":"color:red; font-weight:bold"}'::json, '{"setMultiline": false, "valueRelation":{"nullValue":false, "layer": "v_edit_exploitation", "activated": true, "keyColumn": "expl_id", "valueColumn": "name", "filterExpression": null}}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_dma', 'form_feature', 'tab_none', 'pattern_id', 'lyt_data_1', 9, 'string', 'combo', 'pattern_id', 'pattern_id', NULL, false, false, true, false, NULL, 'SELECT DISTINCT (pattern_id) AS id, pattern_id AS idval FROM inp_pattern WHERE pattern_id IS NOT NULL', true, true, NULL, NULL, NULL, '{"setMultiline": false, "valueRelation":{"nullValue":true, "layer": "v_edit_inp_pattern", "activated": true, "keyColumn": "pattern_id", "valueColumn": "pattern_id", "filterExpression": null}}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_dma', 'form_feature', 'tab_none', 'link', 'lyt_data_1', 10, 'text', 'text', 'link', 'link', NULL, false, false, true, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_dma', 'form_feature', 'tab_none', 'effc', 'lyt_data_1', 11, 'double', 'text', 'effc', 'effc', NULL, false, false, true, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_dma', 'form_feature', 'tab_data', 'avg_press', 'lyt_data_1', 12, 'numeric', 'text', 'average pressure', 'avg_press', NULL, false, false, true, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_dma', 'form_feature', 'tab_none', 'graphconfig', 'lyt_data_1', 13, 'string', 'text', 'graphconfig', 'graphconfig', NULL, false, false, false, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_dma', 'form_feature', 'tab_none', 'stylesheet', 'lyt_data_1', 14, 'string', 'text', 'stylesheet', 'stylesheet', NULL, false, false, true, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, false, NULL); + + +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_presszone', 'form_feature', 'tab_none', 'presszone_id', 'lyt_data_1', 1, 'string', 'text', 'Presszone', 'presszone_id', NULL, false, false, true, false, NULL, 'SELECT presszone.presszone_id AS id, presszone.name AS idval FROM presszone WHERE presszone_id IS NOT NULL', NULL, NULL, NULL, NULL, NULL, '{"setMultiline": false, "valueRelation":{"nullValue":false, "layer": "v_edit_presszone", "activated": true, "keyColumn": "presszone_id", "valueColumn": "name", "filterExpression": null}}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_presszone', 'form_feature', 'tab_none', 'name', 'lyt_data_1', 2, 'string', 'text', 'name', 'name', NULL, false, false, true, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_presszone', 'form_feature', 'tab_none', 'presszone_type', 'lyt_data_1', 3, 'string', 'combo', 'presszone_type', 'presszone_type', NULL, false, false, true, false, NULL, 'SELECT id, idval FROM edit_typevalue WHERE typevalue = ''presszone_type'' ', true, true, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_presszone', 'form_feature', 'tab_none', 'descript', 'lyt_data_1', 4, 'text', 'text', 'descript', 'descript', NULL, false, false, true, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_presszone', 'form_feature', 'tab_none', 'active', 'lyt_data_1', 5, 'boolean', 'check', 'active', 'active', NULL, false, false, true, false, false, NULL, NULL, false, NULL, NULL, NULL, NULL, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_presszone', 'form_feature', 'tab_none', 'expl_id', 'lyt_data_1', 6, 'string', 'combo', 'expl_id', 'expl_id', NULL, false, false, true, false, NULL, 'SELECT expl_id as id, name as idval FROM exploitation WHERE expl_id IS NOT NULL', true, false, NULL, NULL, '{"label":"color:red; font-weight:bold"}'::json, '{"setMultiline": false, "valueRelation":{"nullValue":false, "layer": "v_edit_exploitation", "activated": true, "keyColumn": "expl_id", "valueColumn": "name", "filterExpression": null}}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_presszone', 'form_feature', 'tab_none', 'head', 'lyt_data_1', 7, 'string', 'text', 'Head', 'head', NULL, false, false, true, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_presszone', 'form_feature', 'tab_none', 'graphconfig', 'lyt_data_1', 8, 'string', 'text', 'graphconfig', 'graphconfig', NULL, false, false, false, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_presszone', 'form_feature', 'tab_none', 'stylesheet', 'lyt_data_1', 9, 'string', 'text', 'Stylesheet', 'stylesheet', NULL, false, false, true, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, false, NULL); + + +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_dqa', 'form_feature', 'tab_none', 'dqa_id', 'lyt_data_1', 1, 'integer', 'text', 'Dqa', 'dqa_id', NULL, false, false, true, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"setMultiline": false, "valueRelation":{"nullValue":false, "layer": "v_edit_dqa", "activated": true, "keyColumn": "dqa_id", "valueColumn": "name", "filterExpression": null}}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_dqa', 'form_feature', 'tab_none', 'name', 'lyt_data_1', 2, 'string', 'text', 'name', 'name', NULL, false, false, true, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_dqa', 'form_feature', 'tab_none', 'dqa_type', 'lyt_data_1', 3, 'string', 'combo', 'dqa_type', 'dqa_type', NULL, false, false, true, false, NULL, 'SELECT DISTINCT id, idval FROM edit_typevalue WHERE id IS NOT NULL AND typevalue=''dqa_type''', true, true, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_dqa', 'form_feature', 'tab_none', 'macrodqa_id', 'lyt_data_1', 4, 'integer', 'combo', 'macrodqa_id', 'macrodqa_id', NULL, false, false, true, false, NULL, 'SELECT macrodqa_id as id, name as idval FROM macrodqa WHERE macrodqa_id IS NOT NULL', true, false, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_dqa', 'form_feature', 'tab_none', 'descript', 'lyt_data_1', 5, 'text', 'text', 'descript', 'descript', NULL, false, false, true, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_dqa', 'form_feature', 'tab_none', 'active', 'lyt_data_1', 6, 'boolean', 'check', 'active', 'active', NULL, false, false, true, false, false, NULL, NULL, false, NULL, NULL, NULL, NULL, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_dqa', 'form_feature', 'tab_none', 'undelete', 'lyt_data_1', 7, 'boolean', 'check', 'undelete', 'undelete', NULL, false, false, true, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_dqa', 'form_feature', 'tab_none', 'expl_id', 'lyt_data_1', 8, 'integer', 'combo', 'expl_id', 'expl_id', NULL, false, false, true, false, NULL, 'SELECT expl_id as id, name as idval FROM exploitation WHERE expl_id IS NOT NULL', true, false, NULL, NULL, '{"label":"color:red; font-weight:bold"}'::json, '{"setMultiline": false, "valueRelation":{"nullValue":false, "layer": "v_edit_exploitation", "activated": true, "keyColumn": "expl_id", "valueColumn": "name", "filterExpression": null}}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_dqa', 'form_feature', 'tab_none', 'pattern_id', 'lyt_data_1', 9, 'string', 'combo', 'pattern_id', 'pattern_id', NULL, false, false, true, false, NULL, 'SELECT DISTINCT (pattern_id) AS id, pattern_id AS idval FROM inp_pattern WHERE pattern_id IS NOT NULL', true, true, NULL, NULL, NULL, '{"setMultiline": false, "valueRelation":{"nullValue":true, "layer": "v_edit_inp_pattern", "activated": true, "keyColumn": "pattern_id", "valueColumn": "pattern_id", "filterExpression": null}}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_dqa', 'form_feature', 'tab_none', 'link', 'lyt_data_1', 10, 'text', 'text', 'link', 'link', NULL, false, false, true, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_dqa', 'form_feature', 'tab_none', 'graphconfig', 'lyt_data_1', 11, 'string', 'text', 'graphconfig', 'graphconfig', NULL, false, false, false, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, false, NULL); +INSERT INTO config_form_fields (formname, formtype, tabname, columnname, layoutname, layoutorder, "datatype", widgettype, "label", tooltip, placeholder, ismandatory, isparent, iseditable, isautoupdate, isfilter, dv_querytext, dv_orderby_id, dv_isnullvalue, dv_parent_id, dv_querytext_filterc, stylesheet, widgetcontrols, widgetfunction, linkedobject, hidden, web_layoutorder) VALUES('v_ui_dqa', 'form_feature', 'tab_none', 'stylesheet', 'lyt_data_1', 12, 'string', 'text', 'stylesheet', 'stylesheet', NULL, false, false, true, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"setMultiline":false}'::json, NULL, NULL, false, NULL); diff --git a/updates/36/36017/ws/trg.sql b/updates/36/36017/ws/trg.sql new file mode 100644 index 0000000000..26d00cdd44 --- /dev/null +++ b/updates/36/36017/ws/trg.sql @@ -0,0 +1,34 @@ +/* +This file is part of Giswater 3 +The program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +This version of Giswater is provided by Giswater Association +*/ + + +SET search_path = SCHEMA_NAME, public, pg_catalog; + + +-- 10/01/2025 +CREATE TRIGGER gw_trg_edit_sector INSTEAD OF INSERT OR DELETE OR UPDATE +ON v_edit_sector FOR EACH ROW EXECUTE FUNCTION gw_trg_edit_sector('edit'); + +CREATE TRIGGER gw_trg_v_ui_sector INSTEAD OF INSERT OR DELETE OR UPDATE +ON v_ui_sector FOR EACH ROW EXECUTE FUNCTION gw_trg_edit_sector('ui'); + +CREATE TRIGGER gw_trg_edit_dma INSTEAD OF INSERT OR DELETE OR UPDATE +ON v_edit_dma FOR EACH ROW EXECUTE FUNCTION gw_trg_edit_dma('edit'); + +CREATE TRIGGER gw_trg_v_ui_dma INSTEAD OF INSERT OR DELETE OR UPDATE +ON v_ui_dma FOR EACH ROW EXECUTE FUNCTION gw_trg_edit_dma('ui'); + +CREATE TRIGGER gw_trg_edit_presszone INSTEAD OF INSERT OR DELETE OR UPDATE +ON v_edit_presszone FOR EACH ROW EXECUTE FUNCTION gw_trg_edit_presszone('edit'); + +CREATE TRIGGER gw_trg_v_ui_presszone INSTEAD OF INSERT OR DELETE OR UPDATE +ON v_ui_presszone FOR EACH ROW EXECUTE FUNCTION gw_trg_edit_presszone('ui'); + +CREATE TRIGGER gw_trg_edit_dqa INSTEAD OF INSERT OR DELETE OR UPDATE +ON v_edit_dqa FOR EACH ROW EXECUTE FUNCTION gw_trg_edit_dqa('edit'); + +CREATE TRIGGER gw_trg_v_ui_dqa INSTEAD OF INSERT OR DELETE OR UPDATE +ON v_ui_dqa FOR EACH ROW EXECUTE FUNCTION gw_trg_edit_dqa('ui'); diff --git a/utils/fct/gw_fct_getstylemapzones.sql b/utils/fct/gw_fct_getstylemapzones.sql index 1b498ae099..755716c5a6 100644 --- a/utils/fct/gw_fct_getstylemapzones.sql +++ b/utils/fct/gw_fct_getstylemapzones.sql @@ -66,8 +66,8 @@ BEGIN v_tradma := (SELECT (value::json->>'DMA')::json->>'transparency' FROM config_param_system WHERE parameter='utils_graphanalytics_style'); -- get mapzone values - EXECUTE 'SELECT to_json(array_agg(row_to_json(row)))FROM (SELECT '||v_colsector||' as id, stylesheet::json FROM v_edit_sector WHERE sector_id > 0 and active IS TRUE) row' INTO v_sector; - EXECUTE 'SELECT to_json(array_agg(row_to_json(row))) FROM (SELECT '||v_coldma||' as id, stylesheet::json FROM v_edit_dma WHERE dma_id > 0 and active IS TRUE) row' INTO v_dma; + EXECUTE 'SELECT to_json(array_agg(row_to_json(row)))FROM (SELECT '||v_colsector||' as id, stylesheet::json FROM v_edit_sector WHERE sector_id > 0) row' INTO v_sector; + EXECUTE 'SELECT to_json(array_agg(row_to_json(row))) FROM (SELECT '||v_coldma||' as id, stylesheet::json FROM v_edit_dma WHERE dma_id > 0) row' INTO v_dma; IF v_project_type = 'WS' THEN @@ -80,8 +80,8 @@ BEGIN v_trapresszone := (SELECT (value::json->>'PRESSZONE')::json->>'transparency' FROM config_param_system WHERE parameter='utils_graphanalytics_style'); v_tradqa := (SELECT (value::json->>'DQA')::json->>'transparency' FROM config_param_system WHERE parameter='utils_graphanalytics_style'); - EXECUTE 'SELECT to_json(array_agg(row_to_json(row))) FROM (SELECT '||v_colpresszone||' as id, stylesheet::json FROM v_edit_presszone WHERE presszone_id NOT IN (''0'', ''-1'') and active IS TRUE) row' INTO v_presszone ; - EXECUTE 'SELECT to_json(array_agg(row_to_json(row))) FROM (SELECT '||v_coldqa||' as id, stylesheet::json FROM v_edit_dqa WHERE dqa_id > 0 and active IS TRUE) row' INTO v_dqa ; + EXECUTE 'SELECT to_json(array_agg(row_to_json(row))) FROM (SELECT '||v_colpresszone||' as id, stylesheet::json FROM v_edit_presszone WHERE presszone_id NOT IN (''0'', ''-1'')) row' INTO v_presszone ; + EXECUTE 'SELECT to_json(array_agg(row_to_json(row))) FROM (SELECT '||v_coldqa||' as id, stylesheet::json FROM v_edit_dqa WHERE dqa_id > 0) row' INTO v_dqa ; EXECUTE 'SELECT to_json(array_agg(row_to_json(row))) FROM (SELECT '||v_coldma||' as id, null as stylesheet FROM v_edit_plan_netscenario_dma WHERE dma_id > 0 ) row' INTO v_netscenario_dma; EXECUTE 'SELECT to_json(array_agg(row_to_json(row))) FROM (SELECT '||v_colpresszone||' as id, null as stylesheet FROM v_edit_plan_netscenario_presszone WHERE presszone_id NOT IN (''0'', ''-1'') ) row' INTO v_netscenario_presszone ; @@ -97,7 +97,7 @@ BEGIN v_tradrainzone := (SELECT (value::json->>'DRAINZONE')::json->>'transparency' FROM config_param_system WHERE parameter='utils_graphanalytics_style'); -- get mapzone values - EXECUTE 'SELECT to_json(array_agg(row_to_json(row)))FROM (SELECT '||v_coldrainzone||' as id, stylesheet::json FROM v_edit_drainzone WHERE drainzone_id > 0 and active IS TRUE) row' INTO v_drainzone; + EXECUTE 'SELECT to_json(array_agg(row_to_json(row)))FROM (SELECT '||v_coldrainzone||' as id, stylesheet::json FROM v_edit_drainzone WHERE drainzone_id > 0) row' INTO v_drainzone; END IF; diff --git a/utils/fct/gw_fct_infofromid.sql b/utils/fct/gw_fct_infofromid.sql index bb918593b1..430bb6e0f7 100644 --- a/utils/fct/gw_fct_infofromid.sql +++ b/utils/fct/gw_fct_infofromid.sql @@ -738,10 +738,10 @@ BEGIN -- getting id from URN IF v_id IS NULL AND v_isepa IS true THEN v_id = ''; - ELSIF v_id IS NULL AND v_tablename in ('v_edit_dma', 'v_edit_dqa', 'v_edit_sector', 'v_edit_drainzone') THEN - v_zone = replace(v_tablename,'v_edit_',''); + ELSIF v_id IS NULL AND v_tablename in ('v_ui_dma', 'v_ui_dqa', 'v_ui_sector', 'v_ui_drainzone') THEN + v_zone = replace(v_tablename,'v_ui_',''); v_id = (SELECT nextval(concat('SCHEMA_NAME.',v_zone,'_',v_zone,'_id_seq'))); - ELSIF v_id IS NULL AND v_tablename = 'v_edit_presszone' THEN + ELSIF v_id IS NULL AND v_tablename = 'v_ui_presszone' THEN select max(presszone_id::integer)+1 INTO v_id from presszone where presszone_id ~ '^[0-9]+$'; ELSIF v_id IS NULL AND v_islayer is not true then v_id = (SELECT nextval('SCHEMA_NAME.urn_id_seq')); diff --git a/ws/ftrg/ws_gw_trg_edit_dma.sql b/ws/ftrg/ws_gw_trg_edit_dma.sql index e5c0ec9216..5e55ef6314 100644 --- a/ws/ftrg/ws_gw_trg_edit_dma.sql +++ b/ws/ftrg/ws_gw_trg_edit_dma.sql @@ -9,40 +9,48 @@ This version of Giswater is provided by Giswater Association CREATE OR REPLACE FUNCTION "SCHEMA_NAME".gw_trg_edit_dma() RETURNS trigger AS $BODY$ -DECLARE +DECLARE v_newpattern json; v_status boolean; v_value text; +view_name TEXT; BEGIN EXECUTE 'SET search_path TO '||quote_literal(TG_TABLE_SCHEMA)||', public'; - + + -- Arg will be or 'edit' or 'ui' + view_name = TG_ARGV[0]; + IF TG_OP = 'INSERT' THEN - + v_newpattern = (SELECT value::json->>'forcePatternOnNewDma' FROM config_param_system WHERE parameter = 'epa_patterns'); v_status = v_newpattern->>'status'; v_value = v_newpattern->>'value'; - + -- expl_id IF ((SELECT COUNT(*) FROM exploitation WHERE active IS TRUE) = 0) THEN RETURN NULL; END IF; - IF NEW.the_geom IS NOT NULL THEN - IF NEW.expl_id IS NULL THEN - NEW.expl_id := (SELECT expl_id FROM exploitation WHERE active IS TRUE AND ST_DWithin(NEW.the_geom, exploitation.the_geom,0.001) LIMIT 1); + IF view_name = 'edit'THEN + IF NEW.the_geom IS NOT NULL THEN + IF NEW.expl_id IS NULL THEN + NEW.expl_id := (SELECT expl_id FROM exploitation WHERE active IS TRUE AND ST_DWithin(NEW.the_geom, exploitation.the_geom,0.001) LIMIT 1); + END IF; END IF; END IF; -- active - IF NEW.active IS NULL THEN - NEW.active = TRUE; + IF view_name = 'ui'THEN + IF NEW.active IS NULL THEN + NEW.active = TRUE; + END IF; END IF; -- pattern_id IF v_status THEN - + IF v_value = 'dma_id' OR v_value IS NULL THEN NEW.pattern_id = NEW.dma_id; ELSE @@ -52,32 +60,48 @@ BEGIN INSERT INTO inp_pattern values (NEW.pattern_id) ON CONFLICT (pattern_id) DO NOTHING; END IF; - - INSERT INTO dma (dma_id, name, descript, macrodma_id, the_geom, undelete, expl_id, pattern_id, link, effc, graphconfig, stylesheet, active, avg_press, dma_type) - VALUES (NEW.dma_id, NEW.name, NEW.descript, NEW.macrodma_id, NEW.the_geom, NEW.undelete, NEW.expl_id, NEW.pattern_id, NEW.link, - NEW.effc, NEW.graphconfig::json, NEW.stylesheet::json, NEW.active, NEW.avg_press, NEW.dma_type); + + INSERT INTO dma (dma_id, name, descript, macrodma_id, undelete, expl_id, pattern_id, link, effc, graphconfig, stylesheet, avg_press, dma_type) + VALUES (NEW.dma_id, NEW.name, NEW.descript, (SELECT macrodma_id FROM macrodma WHERE name = NEW.macrodma), NEW.undelete, NEW.expl_id, NEW.pattern_id, NEW.link, + NEW.effc, NEW.graphconfig::json, NEW.stylesheet::json, NEW.avg_press, NEW.dma_type); + + IF view_name = 'ui' THEN + UPDATE dma SET active = NEW.active WHERE dma_id = NEW.dma_id; + + ELSIF view_name = 'edit' THEN + UPDATE dma SET the_geom = NEW.the_geom WHERE dma_id = NEW.dma_id; + + END IF; RETURN NEW; - + ELSIF TG_OP = 'UPDATE' THEN - - UPDATE dma - SET dma_id=NEW.dma_id, name=NEW.name, descript=NEW.descript, the_geom=NEW.the_geom, undelete=NEW.undelete, expl_id=NEW.expl_id, - pattern_id=NEW.pattern_id, link=NEW.link, effc=NEW.effc, graphconfig=NEW.graphconfig::json, dma_type=NEW.dma_type, - stylesheet = NEW.stylesheet::json, active=NEW.active, avg_press=NEW.avg_press, macrodma_id = NEW.macrodma_id, lastupdate=now(), lastupdate_user = current_user + + UPDATE dma + SET dma_id=NEW.dma_id, name=NEW.name, descript=NEW.descript, undelete=NEW.undelete, expl_id=NEW.expl_id, + pattern_id=NEW.pattern_id, link=NEW.link, effc=NEW.effc, graphconfig=NEW.graphconfig::json, dma_type=NEW.dma_type, + stylesheet = NEW.stylesheet::json, avg_press=NEW.avg_press, macrodma_id = (SELECT macrodma_id FROM macrodma WHERE name = NEW.macrodma), lastupdate=now(), lastupdate_user = current_user WHERE dma_id=OLD.dma_id; - + + IF view_name = 'ui' THEN + UPDATE dma SET active = NEW.active WHERE dma_id = OLD.dma_id; + + ELSIF view_name = 'edit' THEN + UPDATE dma SET the_geom = NEW.the_geom WHERE dma_id = OLD.dma_id; + + END IF; + RETURN NEW; - - ELSIF TG_OP = 'DELETE' THEN - + + ELSIF TG_OP = 'DELETE' THEN + DELETE FROM dma WHERE dma_id = OLD.dma_id; RETURN NULL; - + END IF; END; - + $BODY$ LANGUAGE plpgsql VOLATILE COST 100; \ No newline at end of file diff --git a/ws/ftrg/ws_gw_trg_edit_dqa.sql b/ws/ftrg/ws_gw_trg_edit_dqa.sql index 70cf40eec8..564d2aa7f9 100644 --- a/ws/ftrg/ws_gw_trg_edit_dqa.sql +++ b/ws/ftrg/ws_gw_trg_edit_dqa.sql @@ -9,52 +9,76 @@ This version of Giswater is provided by Giswater Association CREATE OR REPLACE FUNCTION "SCHEMA_NAME".gw_trg_edit_dqa() RETURNS trigger AS $BODY$ -DECLARE +DECLARE +view_name TEXT; BEGIN EXECUTE 'SET search_path TO '||quote_literal(TG_TABLE_SCHEMA)||', public'; - + + -- Arg will be or 'edit' or 'ui' + view_name = TG_ARGV[0]; + IF TG_OP = 'INSERT' THEN - - -- expl_id + + -- expl_id IF ((SELECT COUNT(*) FROM exploitation WHERE active IS TRUE) = 0) THEN RETURN NULL; END IF; - IF NEW.the_geom IS NOT NULL THEN - IF NEW.expl_id IS NULL THEN - NEW.expl_id := (SELECT expl_id FROM exploitation WHERE active IS TRUE AND ST_DWithin(NEW.the_geom, exploitation.the_geom,0.001) LIMIT 1); + + IF view_name = 'edit'THEN + IF NEW.the_geom IS NOT NULL THEN + IF NEW.expl_id IS NULL THEN + NEW.expl_id := (SELECT expl_id FROM exploitation WHERE active IS TRUE AND ST_DWithin(NEW.the_geom, exploitation.the_geom,0.001) LIMIT 1); + END IF; END IF; END IF; - -- active - IF NEW.active IS NULL THEN - NEW.active = TRUE; + IF view_name = 'ui'THEN + IF NEW.active IS NULL THEN + NEW.active = TRUE; + END IF; + END IF; + + INSERT INTO dqa (dqa_id, name, expl_id, macrodqa_id, descript, undelete, pattern_id, dqa_type, link, graphconfig, stylesheet) + VALUES (NEW.dqa_id, NEW.name, NEW.expl_id, (SELECT macrodqa_id FROM macrodqa WHERE name = NEW.macrodqa_id), NEW.descript, NEW.undelete, NEW.pattern_id, NEW.dqa_type, + NEW.link, NEW.graphconfig::json, NEW.stylesheet::json); + + IF view_name = 'ui' THEN + UPDATE dqa SET active = NEW.active WHERE dqa_id = NEW.dqa_id; + + ELSIF view_name = 'edit' THEN + UPDATE dqa SET the_geom = NEW.the_geom WHERE dqa_id = NEW.dqa_id; + END IF; - - INSERT INTO dqa (dqa_id, name, expl_id, macrodqa_id, descript, undelete, the_geom, pattern_id, dqa_type, link, graphconfig, stylesheet,active) - VALUES (NEW.dqa_id, NEW.name, NEW.expl_id, NEW.macrodqa_id, NEW.descript, NEW.undelete, NEW.the_geom, NEW.pattern_id, NEW.dqa_type, - NEW.link, NEW.graphconfig::json, NEW.stylesheet::json, NEW.active); RETURN NEW; - + ELSIF TG_OP = 'UPDATE' THEN - - UPDATE dqa - SET dqa_id=NEW.dqa_id, name=NEW.name, expl_id=NEW.expl_id, macrodqa_id=NEW.macrodqa_id, descript=NEW.descript, undelete=NEW.undelete, - the_geom=NEW.the_geom, pattern_id=NEW.pattern_id, dqa_type=NEW.dqa_type, link=NEW.link, graphconfig=NEW.graphconfig::json, - stylesheet = NEW.stylesheet::json, active=NEW.active, lastupdate=now(), lastupdate_user = current_user + + UPDATE dqa + SET dqa_id=NEW.dqa_id, name=NEW.name, expl_id=NEW.expl_id, macrodqa_id=(SELECT macrodqa_id FROM macrodqa WHERE name = NEW.macrodqa_id), descript=NEW.descript, undelete=NEW.undelete, + pattern_id=NEW.pattern_id, dqa_type=NEW.dqa_type, link=NEW.link, graphconfig=NEW.graphconfig::json, + stylesheet = NEW.stylesheet::json, lastupdate=now(), lastupdate_user = current_user WHERE dqa_id=OLD.dqa_id; - + + IF view_name = 'ui' THEN + UPDATE dqa SET active = NEW.active WHERE dqa_id = OLD.dqa_id; + + ELSIF view_name = 'edit' THEN + UPDATE dqa SET the_geom = NEW.the_geom WHERE dqa_id = OLD.dqa_id; + + END IF; + RETURN NEW; - - ELSIF TG_OP = 'DELETE' THEN - + + ELSIF TG_OP = 'DELETE' THEN + DELETE FROM dqa WHERE dqa_id = OLD.dqa_id; RETURN NULL; END IF; END; - + $BODY$ LANGUAGE plpgsql VOLATILE COST 100; diff --git a/ws/ftrg/ws_gw_trg_edit_presszone.sql b/ws/ftrg/ws_gw_trg_edit_presszone.sql index 6484b5166d..853ddefd79 100644 --- a/ws/ftrg/ws_gw_trg_edit_presszone.sql +++ b/ws/ftrg/ws_gw_trg_edit_presszone.sql @@ -9,17 +9,21 @@ This version of Giswater is provided by Giswater Association CREATE OR REPLACE FUNCTION "SCHEMA_NAME".gw_trg_edit_presszone() RETURNS trigger AS $BODY$ -DECLARE +DECLARE +view_name TEXT; BEGIN EXECUTE 'SET search_path TO '||quote_literal(TG_TABLE_SCHEMA)||', public'; - + + -- Arg will be or 'edit' or 'ui' + view_name = TG_ARGV[0]; + IF TG_OP = 'INSERT' THEN - -- expl_id + -- expl_id IF ((SELECT COUNT(*) FROM exploitation WHERE active IS TRUE) = 0) THEN - RETURN NULL; + RETURN NULL; END IF; IF NEW.the_geom IS NOT NULL THEN IF NEW.expl_id IS NULL THEN @@ -28,35 +32,53 @@ BEGIN END IF; -- active - IF NEW.active IS NULL THEN - NEW.active = TRUE; + IF view_name = 'ui'THEN + IF NEW.active IS NULL THEN + NEW.active = TRUE; + END IF; END IF; - INSERT INTO presszone (presszone_id, name, expl_id, the_geom, graphconfig, head, stylesheet, active, descript, avg_press, presszone_type) - VALUES (NEW.presszone_id, NEW.name, NEW.expl_id, NEW.the_geom, NEW.graphconfig::json, NEW.head, NEW.stylesheet::json, NEW.active, NEW.descript, + INSERT INTO presszone (presszone_id, name, expl_id, graphconfig, head, stylesheet, descript, avg_press, presszone_type) + VALUES (NEW.presszone_id, NEW.name, NEW.expl_id, NEW.graphconfig::json, NEW.head, NEW.stylesheet::json, NEW.descript, NEW.avg_press, NEW.presszone_type); + IF view_name = 'ui' THEN + UPDATE presszone SET active = NEW.active WHERE presszone_id = NEW.presszone_id; + + ELSIF view_name = 'edit' THEN + UPDATE presszone SET the_geom = NEW.the_geom WHERE presszone_id = NEW.presszone_id; + + END IF; + RETURN NEW; - + ELSIF TG_OP = 'UPDATE' THEN - + UPDATE presszone - SET presszone_id=NEW.presszone_id, name=NEW.name, expl_id=NEW.expl_id, the_geom=NEW.the_geom, graphconfig=NEW.graphconfig::json, - head = NEW.head, stylesheet=NEW.stylesheet::json, active=NEW.active, descript=NEW.descript, lastupdate=now(), lastupdate_user = current_user, + SET presszone_id=NEW.presszone_id, name=NEW.name, expl_id=NEW.expl_id, graphconfig=NEW.graphconfig::json, + head = NEW.head, stylesheet=NEW.stylesheet::json, descript=NEW.descript, lastupdate=now(), lastupdate_user = current_user, avg_press = NEW.avg_press, presszone_type = NEW.presszone_type WHERE presszone_id=OLD.presszone_id; - + + IF view_name = 'ui' THEN + UPDATE presszone SET active = NEW.active WHERE presszone_id = OLD.presszone_id; + + ELSIF view_name = 'edit' THEN + UPDATE presszone SET the_geom = NEW.the_geom WHERE presszone_id = OLD.presszone_id; + + END IF; + RETURN NEW; - - ELSIF TG_OP = 'DELETE' THEN - + + ELSIF TG_OP = 'DELETE' THEN + DELETE FROM presszone WHERE presszone_id = OLD.presszone_id; RETURN NULL; - + END IF; END; - + $BODY$ LANGUAGE plpgsql VOLATILE COST 100; diff --git a/ws/ftrg/ws_gw_trg_edit_sector.sql b/ws/ftrg/ws_gw_trg_edit_sector.sql index ce19dcb3b6..002995ef59 100644 --- a/ws/ftrg/ws_gw_trg_edit_sector.sql +++ b/ws/ftrg/ws_gw_trg_edit_sector.sql @@ -9,41 +9,62 @@ This version of Giswater is provided by Giswater Association CREATE OR REPLACE FUNCTION "SCHEMA_NAME".gw_trg_edit_sector() RETURNS trigger AS $BODY$ -DECLARE +DECLARE +view_name TEXT; BEGIN EXECUTE 'SET search_path TO '||quote_literal(TG_TABLE_SCHEMA)||', public'; - + + -- Arg will be or 'edit' or 'ui' + view_name = TG_ARGV[0]; + + -- We recive name as a parameter of macrosector so we select id from NEW.macrosector of corresponding table IF TG_OP = 'INSERT' THEN - INSERT INTO sector (sector_id, name, descript, macrosector_id, sector_type, the_geom, undelete, graphconfig, stylesheet, active, parent_id, pattern_id, avg_press) - VALUES (NEW.sector_id, NEW.name, NEW.descript, NEW.macrosector_id, NEW.sector_type, NEW.the_geom, NEW.undelete, - NEW.graphconfig::json, NEW.stylesheet::json, true, NEW.parent_id, NEW.pattern_id, NEW.avg_press); - + INSERT INTO sector (sector_id, name, descript, macrosector_id, sector_type, undelete, graphconfig, stylesheet, parent_id, pattern_id, avg_press) + VALUES (NEW.sector_id, NEW.name, NEW.descript, (SELECT macrosector_id FROM macrosector WHERE name = NEW.macrosector), NEW.sector_type, NEW.undelete, + NEW.graphconfig::json, NEW.stylesheet::json, NEW.parent_id, NEW.pattern_id, NEW.avg_press); + + IF view_name = 'ui' THEN + UPDATE sector SET active = NEW.active WHERE sector_id = NEW.sector_id; + + ELSIF view_name = 'edit' THEN + UPDATE sector SET the_geom = NEW.the_geom WHERE sector_id = NEW.sector_id; + + END IF; + INSERT INTO selector_sector VALUES (NEW.sector_id, current_user); RETURN NEW; - + ELSIF TG_OP = 'UPDATE' THEN - UPDATE sector - SET sector_id=NEW.sector_id, name=NEW.name, descript=NEW.descript, sector_type = NEW.sector_type, macrosector_id=NEW.macrosector_id, the_geom=NEW.the_geom, - undelete=NEW.undelete, graphconfig=NEW.graphconfig::json, stylesheet = NEW.stylesheet::json, active = NEW.active, parent_id = NEW.parent_id, pattern_id = NEW.pattern_id, + UPDATE sector + SET sector_id=NEW.sector_id, name=NEW.name, descript=NEW.descript, sector_type = NEW.sector_type, macrosector_id=(SELECT macrosector_id FROM macrosector WHERE name = NEW.macrosector), + undelete=NEW.undelete, graphconfig=NEW.graphconfig::json, stylesheet = NEW.stylesheet::json, parent_id = NEW.parent_id, pattern_id = NEW.pattern_id, lastupdate=now(), lastupdate_user = current_user, avg_press = NEW.avg_press WHERE sector_id=OLD.sector_id; + IF view_name = 'ui' THEN + UPDATE sector SET active = NEW.active WHERE sector_id = OLD.sector_id; + + ELSIF view_name = 'edit' THEN + UPDATE sector SET the_geom = NEW.the_geom WHERE sector_id = OLD.sector_id; + + END IF; + RETURN NEW; - - ELSIF TG_OP = 'DELETE' THEN + + ELSIF TG_OP = 'DELETE' THEN DELETE FROM sector WHERE sector_id = OLD.sector_id; RETURN NEW; END IF; - + END; $BODY$ LANGUAGE plpgsql VOLATILE