From 04002a766eaed4212ad888ae48d5ca5893f41336 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 29 Nov 2022 13:32:55 +0300 Subject: [PATCH] [DE] Edit and remove role --- .../main/app/view/RolesManagerDlg.js | 41 ++++++------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/apps/documenteditor/main/app/view/RolesManagerDlg.js b/apps/documenteditor/main/app/view/RolesManagerDlg.js index e36647623..dc66fbdec 100644 --- a/apps/documenteditor/main/app/view/RolesManagerDlg.js +++ b/apps/documenteditor/main/app/view/RolesManagerDlg.js @@ -214,29 +214,24 @@ define([ 'text!documenteditor/main/app/template/RolesManagerDlg.template', var me = this, xy = me.$window.offset(), - rec = this.rolesList.getSelectedRec(), - props = (isEdit && rec) ? {name: rec.get('name'), color: rec.get('color')} : null; + rec = this.rolesList.getSelectedRec(); var win = new DE.Views.RoleEditDlg({ oformManager: me.oformManager, - props : props, - isEdit : isEdit, + props : (isEdit && rec) ? {name: rec.get('name'), color: rec.get('color')} : null, + isEdit : (isEdit && rec), handler : function(result, settings) { if (result == 'ok' && settings) { - var color = settings.color, - name = settings.name; - me.lastSelectedRole = name; - if (isEdit) { - // me.api.asc_editRole(settings); - rec.set('name', name); - rec.set('color', color); + me.lastSelectedRole = settings.name; + + var role = new AscCommon.CRoleSettings(); + role.asc_putName(settings.name); + role.asc_putColor(settings.color); + if (isEdit && rec) { + me.oformManager.asc_editRole(rec.get('name'), role); } else { - var role = new AscCommon.CRoleSettings(); - role.asc_putName(name); - role.asc_putColor(color); me.oformManager.asc_addRole(role); } - me.updateButtons(); } } }).on('close', function() { @@ -264,20 +259,8 @@ define([ 'text!documenteditor/main/app/template/RolesManagerDlg.template', } var callback = function(toRole) { - var index = store.indexOf(rec); - me.lastSelectedRole = index; - me.api.asc_delRole(rec.get('name'), toRole); // remove role and move it's fields - - // if (toRole) { - // var item = store.findWhere({name: toRole}); - // item && item.set('fields', item.get('fields') + rec.get('fields')); - // // me.api.asc_moveFieldsToRole(rec.get('name'), toRole); // from - to - // } - // me.api.asc_delRole(rec.get('name'), toRole); // remove role and move it's fields - // store.remove(rec); - // (store.length>0) && me.rolesList.selectByIndex(index