From 0ec00075690dd649dd1f1965b95b5053f1950112 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Mon, 7 Sep 2020 07:09:23 +0900 Subject: [PATCH] Fix for edit tables declare, add return function for DB IO DB IO return functions for inserted primary key and extended RETURNING data Add dev set for html options grouping addition for nested arrays/object lists Fix edit tables edit access uid declaration --- 4dev/database/ORDER | 1 - .../trigger/trg_set_edit_access_uid.sql | 4 --- www/layout/admin/javascript/edit.jq.js | 29 +++++++++++++++++++ www/lib/CoreLibs/DB/IO.php | 29 +++++++++++++++---- 4 files changed, 52 insertions(+), 11 deletions(-) delete mode 100644 4dev/database/trigger/trg_set_edit_access_uid.sql diff --git a/4dev/database/ORDER b/4dev/database/ORDER index 9fd388e6..2209c22e 100644 --- a/4dev/database/ORDER +++ b/4dev/database/ORDER @@ -43,6 +43,5 @@ trigger/trg_edit_scheme.sql trigger/trg_edit_user.sql trigger/trg_edit_visible_group.sql trigger/trg_edit_menu_group.sql -trigger/trg_set_edit_access_uid.sql # insert data data/edit_tables.sql diff --git a/4dev/database/trigger/trg_set_edit_access_uid.sql b/4dev/database/trigger/trg_set_edit_access_uid.sql deleted file mode 100644 index b602a293..00000000 --- a/4dev/database/trigger/trg_set_edit_access_uid.sql +++ /dev/null @@ -1,4 +0,0 @@ --- DROP TRIGGER trg_set_edit_access_uid ON edit_access; -CREATE TRIGGER trg_set_edit_access_uid -BEFORE INSERT OR UPDATE ON edit_access -FOR EACH ROW EXECUTE PROCEDURE set_edit_access_uid(); diff --git a/www/layout/admin/javascript/edit.jq.js b/www/layout/admin/javascript/edit.jq.js index fc4bacc8..a03d6fe2 100644 --- a/www/layout/admin/javascript/edit.jq.js +++ b/www/layout/admin/javascript/edit.jq.js @@ -1049,6 +1049,35 @@ function html_options_block(name, data, selected = '', multiple = 0, options_onl element_option = cel('option', '', value, '', options); // attach it to the select element ael(element_select, element_option); + /* + // get the original data for this key + var opt_value = r_value[opt_key]; + // if it is an object, we assume a sub group [original data] + if (isObject(opt_value)) { + element_group = document.createElement('optgroup'); + element_group.label = opt_key; + // loop through attached sub key elements in order (key is orignal) + $.each(data.form_reference_order[key][opt_key], function(opt_group_pos, opt_group_key) { + var opt_group_value = r_value[opt_key][opt_group_key]; + element_sub = document.createElement('option'); + // check if w is object, if yes, the element is a subset drop down + element_sub.label = opt_group_value; + element_sub.value = opt_group_key; + element_sub.innerHTML = opt_group_value; + element_group.appendChild(element_sub); + }); + element.appendChild(element_group); + } else if (!isObject(opt_key)) { + // if this is a plain element, attach as is + // we also skip any objects in the reference order group as they are handled different + element_sub = document.createElement('option'); + element_sub.label = opt_value; + element_sub.value = opt_key; + element_sub.innerHTML = opt_value; + element.appendChild(element_sub); + } + + */ } // if with select part, convert to text if (!options_only) { diff --git a/www/lib/CoreLibs/DB/IO.php b/www/lib/CoreLibs/DB/IO.php index 8ce998d4..30079b68 100644 --- a/www/lib/CoreLibs/DB/IO.php +++ b/www/lib/CoreLibs/DB/IO.php @@ -1992,12 +1992,6 @@ class IO extends \CoreLibs\Basic return $this->db_functions->__dbArrayParse($text, $output); } - // METHOD: dbSqlEscape - // WAS : db_sql_escape - // PARAMS: value -> to escape data - // kbn -> escape trigger type - // RETURN: escaped value - // DESC : clear up any data for valid DB insert /** * clear up any data for valid DB insert * @param int|float|string $value to escape data @@ -2025,6 +2019,29 @@ class IO extends \CoreLibs\Basic } return $value; } + + /** + * return current set insert_id as is + * @return string|int|null Primary key value, most likely int + * Empty string for unset + * Null for error + */ + public function getInsertPK() + { + return $this->insert_id; + } + + /** + * return the extended insert return string set + * Most likely Array + * @return array|string|null RETURNING values as array + * Empty string for unset + * Null for error + */ + public function getInsertReturn() + { + return $this->insert_id_ext; + } } // end if db class // __END__