Refactoring toolbar lock
This commit is contained in:
parent
f4a74837cd
commit
42391fdea4
|
@ -781,6 +781,45 @@ Common.Utils.InternalSettings = new(function() {
|
|||
}
|
||||
});
|
||||
|
||||
Common.Utils.lockControls = function(causes, lock, opts, defControls) {
|
||||
!opts && (opts = {});
|
||||
|
||||
var controls = opts.array || defControls;
|
||||
opts.merge && (controls = _.union(defControls,controls));
|
||||
|
||||
function doLock(cmp, cause) {
|
||||
if ( cmp && _.contains(cmp.options.lock, cause) ) {
|
||||
var index = cmp.keepState.indexOf(cause);
|
||||
if (lock) {
|
||||
if (index < 0) {
|
||||
cmp.keepState.push(cause);
|
||||
}
|
||||
} else {
|
||||
if (!(index < 0)) {
|
||||
cmp.keepState.splice(index, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_.each(controls, function(item) {
|
||||
if (item && _.isFunction(item.setDisabled)) {
|
||||
!item.keepState && (item.keepState = []);
|
||||
if (opts.clear && opts.clear.length > 0 && item.keepState.length > 0) {
|
||||
item.keepState = _.difference(item.keepState, opts.clear);
|
||||
}
|
||||
|
||||
_.isArray(causes) ? _.each(causes, function(c) {doLock(item, c)}) : doLock(item, causes);
|
||||
|
||||
if (!(item.keepState.length > 0)) {
|
||||
item.isDisabled() && item.setDisabled(false);
|
||||
} else {
|
||||
!item.isDisabled() && item.setDisabled(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Common.Utils.InternalSettings.set('toolbar-height-tabs', 32);
|
||||
Common.Utils.InternalSettings.set('toolbar-height-tabs-top-title', 28);
|
||||
Common.Utils.InternalSettings.set('toolbar-height-controls', 67);
|
||||
|
|
|
@ -783,7 +783,7 @@ define([
|
|||
|
||||
disableControls: function(disable) {
|
||||
if (this._initSettings) return;
|
||||
|
||||
|
||||
this.lockControls(DE.enumLockMM.lostConnect, disable, {
|
||||
array: _.union([this.btnEditData, this.btnInsField, this.chHighlight], (this.mode.mergeFolderUrl) ? [this.btnPortal] : []),
|
||||
merge: true
|
||||
|
@ -833,42 +833,7 @@ define([
|
|||
},
|
||||
|
||||
lockControls: function(causes, lock, opts) {
|
||||
!opts && (opts = {});
|
||||
|
||||
var controls = opts.array || this.emptyDBControls;
|
||||
opts.merge && (controls = _.union(this.emptyDBControls,controls));
|
||||
|
||||
function doLock(cmp, cause) {
|
||||
if ( _.contains(cmp.options.lock, cause) ) {
|
||||
var index = cmp.keepState.indexOf(cause);
|
||||
if (lock) {
|
||||
if (index < 0) {
|
||||
cmp.keepState.push(cause);
|
||||
}
|
||||
} else {
|
||||
if (!(index < 0)) {
|
||||
cmp.keepState.splice(index, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_.each(controls, function(item) {
|
||||
if (_.isFunction(item.setDisabled)) {
|
||||
!item.keepState && (item.keepState = []);
|
||||
if (opts.clear && opts.clear.length > 0 && item.keepState.length > 0) {
|
||||
item.keepState = _.difference(item.keepState, opts.clear);
|
||||
}
|
||||
|
||||
_.isArray(causes) ? _.each(causes, function(c) {doLock(item, c)}) : doLock(item, causes);
|
||||
|
||||
if (!(item.keepState.length > 0)) {
|
||||
item.isDisabled() && item.setDisabled(false);
|
||||
} else {
|
||||
!item.isDisabled() && item.setDisabled(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
Common.Utils.lockControls(causes, lock, opts, this.emptyDBControls);
|
||||
},
|
||||
|
||||
textDataSource: 'Data Source',
|
||||
|
|
|
@ -826,44 +826,7 @@ define([
|
|||
},
|
||||
|
||||
lockToolbar: function (causes, lock, opts) {
|
||||
!opts && (opts = {});
|
||||
|
||||
var controls = opts.array || this.lockControls;
|
||||
opts.merge && (controls = _.union(this.lockControls, controls));
|
||||
|
||||
function doLock(cmp, cause) {
|
||||
if (_.contains(cmp.options.lock, cause)) {
|
||||
var index = cmp.keepState.indexOf(cause);
|
||||
if (lock) {
|
||||
if (index < 0) {
|
||||
cmp.keepState.push(cause);
|
||||
}
|
||||
} else {
|
||||
if (!(index < 0)) {
|
||||
cmp.keepState.splice(index, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_.each(controls, function (item) {
|
||||
if (_.isFunction(item.setDisabled)) {
|
||||
!item.keepState && (item.keepState = []);
|
||||
if (opts.clear && opts.clear.length > 0 && item.keepState.length > 0) {
|
||||
item.keepState = _.difference(item.keepState, opts.clear);
|
||||
}
|
||||
|
||||
_.isArray(causes) ? _.each(causes, function (c) {
|
||||
doLock(item, c)
|
||||
}) : doLock(item, causes);
|
||||
|
||||
if (!(item.keepState.length > 0)) {
|
||||
item.isDisabled() && item.setDisabled(false);
|
||||
} else {
|
||||
!item.isDisabled() && item.setDisabled(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
Common.Utils.lockControls(causes, lock, opts, this.lockControls);
|
||||
},
|
||||
|
||||
render: function (mode) {
|
||||
|
|
|
@ -150,42 +150,7 @@ define([
|
|||
},
|
||||
|
||||
lockToolbar: function(causes, lock, opts) {
|
||||
!opts && (opts = {});
|
||||
|
||||
var controls = opts.array || this.lockControls;
|
||||
opts.merge && (controls = _.union(this.lockControls,controls));
|
||||
|
||||
function doLock(cmp, cause) {
|
||||
if ( cmp && _.contains(cmp.options.lock, cause) ) {
|
||||
var index = cmp.keepState.indexOf(cause);
|
||||
if (lock) {
|
||||
if (index < 0) {
|
||||
cmp.keepState.push(cause);
|
||||
}
|
||||
} else {
|
||||
if (!(index < 0)) {
|
||||
cmp.keepState.splice(index, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_.each(controls, function(item) {
|
||||
if (item && _.isFunction(item.setDisabled)) {
|
||||
!item.keepState && (item.keepState = []);
|
||||
if (opts.clear && opts.clear.length > 0 && item.keepState.length > 0) {
|
||||
item.keepState = _.difference(item.keepState, opts.clear);
|
||||
}
|
||||
|
||||
_.isArray(causes) ? _.each(causes, function(c) {doLock(item, c)}) : doLock(item, causes);
|
||||
|
||||
if (!(item.keepState.length > 0)) {
|
||||
item.isDisabled() && item.setDisabled(false);
|
||||
} else {
|
||||
!item.isDisabled() && item.setDisabled(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
Common.Utils.lockControls(causes, lock, opts, this.lockControls);
|
||||
},
|
||||
|
||||
applyLayout: function (config) {
|
||||
|
|
Loading…
Reference in a new issue