From 7cab3e566368d6f418bc4883a407634425422b8b Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 11 Mar 2021 17:59:19 +0300 Subject: [PATCH] [SSE] Fix rules lock --- .../main/app/view/FormatRulesManagerDlg.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/FormatRulesManagerDlg.js b/apps/spreadsheeteditor/main/app/view/FormatRulesManagerDlg.js index b5460d890..ee469c9d0 100644 --- a/apps/spreadsheeteditor/main/app/view/FormatRulesManagerDlg.js +++ b/apps/spreadsheeteditor/main/app/view/FormatRulesManagerDlg.js @@ -62,6 +62,10 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesManagerDlg.templa me.render(); me.trigger('change', me, me.model); }); + me.listenTo(me.model, 'change:lock', function() { + me.render(); + me.trigger('change', me, me.model); + }); me.listenTo(me.model, 'change:tip', function() { var el = me.$el || $(me.el), tip = el.data('bs.tooltip'); @@ -113,6 +117,7 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesManagerDlg.templa this.rulesDeleted = []; this.listSettings = {length: 0, min: 0, max: 0}; this.locked = options.locked || false; + this.userTooltip = true; this.wrapEvents = { onLockCFManager: _.bind(this.onLockCFManager, this), @@ -143,7 +148,7 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesManagerDlg.templa emptyText: '', template: _.template(['
'].join('')), itemTemplate: _.template([ - '
', + '
', '
<%= name %>
', '
', '
', @@ -498,7 +503,7 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesManagerDlg.templa style : 'width: 100%;', btnHint : this.textSelectData, allowBlank : true, - disabled : !item.get('activeSheet'), + disabled : !item.get('activeSheet') || item.get('lock'), validateOnChange: true }).on('changed:after', function(input, newValue, oldValue, e) { if (rule.dataRangeValid !== newValue) { @@ -776,11 +781,15 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesManagerDlg.templa onLockCFManager: function(index) { if (this.currentSheet !== index) return; this.locked = true; + this.updateButtons(); + if (this.userTooltip===true && this.rulesList.cmpEl.find('.lock-user').length>0) + this.rulesList.cmpEl.on('mouseover', _.bind(this.onMouseOverLock, this)).on('mouseout', _.bind(this.onMouseOutLock, this)); }, onUnLockCFManager: function(index) { if (this.currentSheet !== index) return; this.locked = false; + this.updateButtons(); }, onLockCFRule: function(index, ruleId, userId) { @@ -788,10 +797,12 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesManagerDlg.templa var store = this.rulesList.store, rec = store.findWhere({ruleId: ruleId}); if (rec) { - rec.set('lock', true); rec.set('lockuser', (userId) ? this.getUserName(userId) : this.guestText); + rec.set('lock', true); this.updateButtons(); } + if (this.userTooltip===true && this.rulesList.cmpEl.find('.lock-user').length>0) + this.rulesList.cmpEl.on('mouseover', _.bind(this.onMouseOverLock, this)).on('mouseout', _.bind(this.onMouseOutLock, this)); }, onUnLockCFRule: function(index, ruleId) { @@ -799,8 +810,8 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesManagerDlg.templa var store = this.rulesList.store, rec = store.findWhere({ruleId: ruleId}); if (rec) { - rec.set('lock', false); rec.set('lockuser', ''); + rec.set('lock', false); this.updateButtons(); } },