[SSE] AutoFiltersDialog: set 'Select All' option to 'indeterminate' state, if cells list contains checked and unchecked items.

This commit is contained in:
Julia Radzhabova 2017-03-27 15:14:06 +03:00
parent a87dc0c2e3
commit 6019ee19e0

View file

@ -748,10 +748,12 @@ define([
itemTemplate: _.template([ itemTemplate: _.template([
'<div>', '<div>',
'<label class="checkbox-indeterminate" style="position:absolute;">', '<label class="checkbox-indeterminate" style="position:absolute;">',
'<% if (!check) { %>', '<% if (check=="indeterminate") { %>',
'<input type="button" class="img-commonctrl"/>', '<input type="button" class="indeterminate img-commonctrl"/>',
'<% } else { %>', '<% } else if (check) { %>',
'<input type="button" class="checked img-commonctrl"/>', '<input type="button" class="checked img-commonctrl"/>',
'<% } else { %>',
'<input type="button" class="img-commonctrl"/>',
'<% } %>', '<% } %>',
'</label>', '</label>',
'<div id="<%= id %>" class="list-item" style="pointer-events:none;margin-left:20px;display:inline-block;width: 185px;"><%= Common.Utils.String.htmlEncode(value) %></div>', '<div id="<%= id %>" class="list-item" style="pointer-events:none;margin-left:20px;display:inline-block;width: 185px;"><%= Common.Utils.String.htmlEncode(value) %></div>',
@ -1035,6 +1037,18 @@ define([
} else { } else {
record.set('check', check); record.set('check', check);
idxs[parseInt(record.get('throughIndex'))] = check; idxs[parseInt(record.get('throughIndex'))] = check;
var selectAllState = check;
for (var i=0; i< this.cells.length; i++) {
var cell = this.cells.at(i);
if ('1' == cell.get('groupid') && cell.get('check') !== check) {
selectAllState = 'indeterminate';
break;
}
}
this.checkCellTrigerBlock = true;
this.cells.at(0).set('check', selectAllState);
this.checkCellTrigerBlock = undefined;
} }
this.btnOk.setDisabled(false); this.btnOk.setDisabled(false);
@ -1182,7 +1196,8 @@ define([
isnumber, value, isnumber, value,
index = 0, throughIndex = 2, index = 0, throughIndex = 2,
applyfilter = true, applyfilter = true,
haveUnselectedCell = false, selectAllState = false,
selectedCells = 0,
arr = [], arrEx = [], arr = [], arrEx = [],
idxs = (me.filter) ? me.filteredIndexes : me.throughIndexes; idxs = (me.filter) ? me.filteredIndexes : me.throughIndexes;
@ -1212,9 +1227,7 @@ define([
check : idxs[throughIndex], check : idxs[throughIndex],
throughIndex : throughIndex throughIndex : throughIndex
})); }));
if (!idxs[throughIndex]) { if (idxs[throughIndex]) selectedCells++;
haveUnselectedCell = true;
}
} else { } else {
arrEx.push(new Common.UI.DataViewModel({ arrEx.push(new Common.UI.DataViewModel({
cellvalue : value cellvalue : value
@ -1224,6 +1237,9 @@ define([
++throughIndex; ++throughIndex;
}); });
if (selectedCells==arr.length) selectAllState = true;
else if (selectedCells>0) selectAllState = 'indeterminate';
if (me.filter || idxs[0]==undefined) if (me.filter || idxs[0]==undefined)
idxs[0] = true; idxs[0] = true;
if (!me.filter || arr.length>0) if (!me.filter || arr.length>0)
@ -1255,7 +1271,7 @@ define([
if (this.cells.length) { if (this.cells.length) {
this.checkCellTrigerBlock = true; this.checkCellTrigerBlock = true;
this.cells.at(0).set('check', !haveUnselectedCell); this.cells.at(0).set('check', selectAllState);
this.checkCellTrigerBlock = undefined; this.checkCellTrigerBlock = undefined;
} }
this.btnOk.setDisabled(this.cells.length<1); this.btnOk.setDisabled(this.cells.length<1);