Commit 420990bf authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic
Browse files

Bug 1856260: update element count when deleting a standard

so it will add the correct number at the end of a
standard element when adding a new one

behatnotneeded

Change-Id: I24e2b0a0d729b56efd6f271c4c609dab53322846
parent b8d26c1f
......@@ -1054,8 +1054,15 @@ jQuery(function($) {
$('[data-schemaid="standard"] > h3 > div > button.json-editor-btn-delete').off('click');
$('[data-schemaid="standard"] > h3 > div > button.json-editor-btn-delete').on('click', function(e) {
var standardid = 0,
last_standardid = 0,
standard_array_temp = standard_array;
// get the last standard id from the list of standards,
// to check if it's the one being deleted
if (standard_array.length) {
last_standardid = standard_array[standard_array.length - 1]
}
update_standard_shortname_handler();
update_standard_array();
update_delete_standard_button_handlers();
......@@ -1065,9 +1072,34 @@ jQuery(function($) {
standardid = $(standard_array_temp).not(standard_array).get()[0];
// delete all the standard elements under the standard that was removed
delete_child_standard_elements(standardid, '');
// if the standard is the last one (or the one that has focus) change the standar element count
if ((last_standardid == standardid)) {
update_eid_number();
}
});
}
function update_eid_number() {
// no standard or no standard elements, then reset the count
if (!standard_array.length || parent_array.length < 2) {
eid = 0;
}
else {
// last standard element name
var spl = parent_array[parent_array.length -1].split('.');
// last standard element parent matches last added standard
if (spl[0] == standard_array[standard_array.length - 1]) {
eid = spl[spl.length-1];
}
else {
// last added standard doesnt have standard elements
eid = 0;
}
}
}
function delete_child_standard_elements(std_id, el_id) {
var change_tab = false,
new_rows = [],
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment