Improve select all checkbox process on designer and fix a bug

The bug is:
- select a column name checkbox
- select all columns checkbox
- deselect all columns checkbox
- build query
- the first checked column is added and can not be removed now (this is the bug)

Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
William Desportes 2019-11-20 01:01:35 +01:00
parent 39a98a7fdf
commit 4b6f04c142
No known key found for this signature in database
GPG Key ID: 90A0EF1B8251A889
2 changed files with 24 additions and 28 deletions

View File

@ -73,7 +73,6 @@ var timeoutID;
var layer_menu_cur_click = 0;
var step = 10;
var from_array = [];
var downer;
var menu_moved = false;
var grid_size = 10;
@ -1848,36 +1847,33 @@ function Close_option () {
}
function Select_all (id_this, owner) {
var parent = document.form1;
downer = owner;
var i;
var k;
var tab = [];
for (i = 0; i < parent.elements.length; i++) {
if (parent.elements[i].type === 'checkbox' && parent.elements[i].id.substring(0, (9 + id_this.length)) === 'select_' + id_this + '._') {
if (document.getElementById('select_all_' + id_this).checked === true) {
parent.elements[i].checked = true;
parent.elements[i].disabled = true;
var temp = '`' + id_this.substring(owner.length + 1) + '`.*';
} else {
parent.elements[i].checked = false;
parent.elements[i].disabled = false;
}
function Select_all (tableName, dbName, idSelectAll) {
var parentIsChecked = $('#' + idSelectAll).is(':checked');
var checkboxAll = $('#container-form input[id_check_all=\'' + idSelectAll + '\']:checkbox');
checkboxAll.each(function () {
// already checked and then check parent
if (parentIsChecked === true && this.checked) {
// was checked, removing column from selected fields
// trigger unchecked event
this.click();
}
}
if (document.getElementById('select_all_' + id_this).checked === true) {
select_field.push('`' + id_this.substring(owner.length + 1) + '`.*');
tab = id_this.split('.');
from_array.push(tab[1]);
this.checked = parentIsChecked;
this.disabled = parentIsChecked;
});
if (parentIsChecked) {
select_field.push('`' + tableName + '`.*');
from_array.push(tableName);
} else {
var i;
for (i = 0; i < select_field.length; i++) {
if (select_field[i] === ('`' + id_this.substring(owner.length + 1) + '`.*')) {
if (select_field[i] === ('`' + tableName + '`.*')) {
select_field.splice(i, 1);
}
}
var k;
for (k = 0; k < from_array.length; k++) {
if (from_array[k] === id_this) {
if (from_array[k] === tableName) {
from_array.splice(k, 1);
break;
}
@ -2009,7 +2005,7 @@ function enablePageContentEvents() {
*/
function enableTableEvents(index, element) {
$(element).on('click', '.select_all_1', function () {
Select_all($(this).attr('designer_url_table_name'), $(this).attr('designer_out_owner'));
Select_all($(this).attr('table_name'), $(this).attr('db_name'), $(this).attr('id'));
});
$(element).on('click', '.small_tab,.small_tab2', function () {
Small_tab($(this).attr('table_name'), 1);

View File

@ -27,10 +27,10 @@
type="checkbox"
style="margin: 0;"
value="select_all_{{ t_n_url }}"
id="select_all_{{ t_n_url }}"
id="select_all_{{ i }}"
title="{% trans 'Select all' %}"
designer_url_table_name="{{ t_n_url }}"
designer_out_owner="{{ designerTable.getDatabaseName() }}">
table_name="{{ table_name }}"
db_name="{{ db }}">
</td>
{% endif %}
<td class="small_tab"