From 6e1e71a5084d8a65fef64b8fc84d34eca0070035 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 14 Mar 2023 18:28:02 +0300 Subject: [PATCH] [SSE] Range protect: disable empty user's combobox when no id in event onRequestUsers. --- apps/common/main/lib/component/ComboBox.js | 2 ++ .../main/lib/controller/ExternalUsers.js | 10 +++++----- apps/common/main/resources/less/input.less | 6 +++++- .../main/app/view/ProtectedRangesEditDlg.js | 18 +++++++++++++----- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/apps/common/main/lib/component/ComboBox.js b/apps/common/main/lib/component/ComboBox.js index 3f03b11218..f6e93f0e02 100644 --- a/apps/common/main/lib/component/ComboBox.js +++ b/apps/common/main/lib/component/ComboBox.js @@ -266,6 +266,8 @@ define([ }, openMenu: function(delay) { + if (this.store.length<1) return; + var me = this; if ( !this.scroller ) { diff --git a/apps/common/main/lib/controller/ExternalUsers.js b/apps/common/main/lib/controller/ExternalUsers.js index c58057a857..5b51172e38 100644 --- a/apps/common/main/lib/controller/ExternalUsers.js +++ b/apps/common/main/lib/controller/ExternalUsers.js @@ -45,7 +45,7 @@ if (Common.UI === undefined) { } Common.UI.ExternalUsers = new( function() { - var externalUsers = [], + var externalUsers = null, getCallback, isUsersLoading = false; @@ -53,12 +53,12 @@ Common.UI.ExternalUsers = new( function() { if (isUsersLoading) return; getCallback = null; - if (externalUsers.length>0) - callback(externalUsers); - else { + if (externalUsers===null) { getCallback = callback; isUsersLoading = true; Common.Gateway.requestUsers(); + } else { + callback(externalUsers); } }; @@ -72,7 +72,7 @@ Common.UI.ExternalUsers = new( function() { getCallback = null; }); Common.NotificationCenter.on('mentions:clearusers', function() { - externalUsers = []; + externalUsers = null; }); }; diff --git a/apps/common/main/resources/less/input.less b/apps/common/main/resources/less/input.less index 8aa6b8bd92..835ff91239 100644 --- a/apps/common/main/resources/less/input.less +++ b/apps/common/main/resources/less/input.less @@ -31,7 +31,11 @@ cursor: default; background-color: @background-normal-ie; background-color: @background-normal; - .user-select(none); + .user-select(none); + &:-ms-input-placeholder { + color: @text-normal-ie; + } + .placeholder(@text-normal); } .input-row { diff --git a/apps/spreadsheeteditor/main/app/view/ProtectedRangesEditDlg.js b/apps/spreadsheeteditor/main/app/view/ProtectedRangesEditDlg.js index 7982b4d205..64b987a316 100644 --- a/apps/spreadsheeteditor/main/app/view/ProtectedRangesEditDlg.js +++ b/apps/spreadsheeteditor/main/app/view/ProtectedRangesEditDlg.js @@ -216,9 +216,14 @@ define([ this.listUser.store.add({value: this.currentUser.id, name: this.currentUser.name + ' (' + this.textYou + ')', email: '', isCurrent: true}); var me= this, rangeUsers = props.asc_getUsers(); - if (rangeUsers && rangeUsers.length>0) { - Common.UI.ExternalUsers.get(function(users) { - if (users && users.length>0) { + Common.UI.ExternalUsers.get(function(users) { + if (users && users.length>0) { + if (!_.find(users, function(item) { return item.id!==undefined && item.id!==null; })) { // no id in user info + me.cmbUser.setDisabled(true); + me.cmbUser._input && me.cmbUser._input.attr('placeholder', me.txtYouCanEdit); + } + + if (rangeUsers && rangeUsers.length>0) { var store = me.listUser.store; rangeUsers.forEach(function(item) { var rec = _.findWhere(users, {id: item}); @@ -226,8 +231,11 @@ define([ store.add({value: item, name: rec.name, email: rec.email}); }); } - }); - } + } else { + me.cmbUser.setDisabled(true); + me.cmbUser._input && me.cmbUser._input.attr('placeholder', me.txtYouCanEdit); + } + }); } },