[DE] Add new form with last selected role or the last role in list

This commit is contained in:
Julia Radzhabova 2022-12-01 18:38:42 +03:00
parent a5cf901aa0
commit a58534687a
3 changed files with 16 additions and 20 deletions

View file

@ -59,7 +59,10 @@ define([
initialize: function () {
},
onLaunch: function () {
this._state = {};
this._state = {
lastViewRole: undefined, // last selected role in the preview mode
lastRoleInList: undefined // last role in the roles list
};
},
setApi: function (api) {
@ -177,6 +180,7 @@ define([
var oPr,
oFormPr = new AscCommon.CSdtFormPr();
oFormPr.put_Role(Common.Utils.InternalSettings.get('de-last-form-role') || this._state.lastRoleInList);
this.toolbar.toolbar.fireEvent('insertcontrol', this.toolbar.toolbar);
if (type == 'picture')
this.api.asc_AddContentControlPicture(oFormPr);
@ -213,14 +217,14 @@ define([
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
},
onModeClick: function(state, lastRole) {
onModeClick: function(state, lastViewRole) {
if (this.api) {
this.disableEditing(state);
this.view && this.view.setPreviewMode(state); // sent role name - lastRole
this.view && this.view.setPreviewMode(state); // send role name - lastViewRole
this.api.asc_setRestriction(state ? Asc.c_oAscRestrictionType.OnlyForms : Asc.c_oAscRestrictionType.None);
this.api.asc_SetPerformContentControlActionByClick(state);
this.api.asc_SetHighlightRequiredFields(state);
state && (this._state.lastRole = lastRole);
state && (this._state.lastViewRole = lastViewRole);
}
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
},
@ -395,13 +399,7 @@ define([
// me.view.btnHighlight.currentColor = clr;
// }
config.isEdit && config.canFeatureContentControl && config.isFormCreator && me.showCreateFormTip(); // show tip only when create form in docxf
// change to event asc_onRefreshRolesList
me.onRefreshRolesList();
// me.onRefreshRolesList([
// {name: 'employee 1', color: Common.Utils.ThemeColor.getRgbColor('ff0000'), fields: 5},
// {name: 'employee 2', color: Common.Utils.ThemeColor.getRgbColor('00ff00'), fields: 1},
// {name: 'manager', color: null, fields: 10}
// ]);
me.onChangeProtectDocument();
});
},
@ -457,7 +455,8 @@ define([
var oform = this.api.asc_GetOForm();
oform && (roles = oform.asc_getAllRoles());
}
this.view && this.view.fillRolesMenu(roles, this._state.lastRole);
this._state.lastRoleInList = (roles && roles.length>0) ? roles[roles.length-1].asc_getSettings().asc_getName() : undefined;
this.view && this.view.fillRolesMenu(roles, this._state.lastViewRole);
},
onManagerClick: function() {
@ -465,12 +464,8 @@ define([
this.api.asc_GetOForm() && (new DE.Views.RolesManagerDlg({
api: me.api,
handler: function(result, settings) {
// me.roles = settings;
// me.onRefreshRolesList(me.roles);
// Common.component.Analytics.trackEvent('ToolBar', 'Roles Manager');
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
},
// roles: me.roles,
props : undefined
})).on('close', function(win){
}).show();

View file

@ -1620,6 +1620,7 @@ define([
formPr.put_Role(record.value);
props.put_FormPr(formPr);
this.api.asc_SetContentControlProperties(props, this.internalId);
Common.Utils.InternalSettings.set('de-last-form-role', record.value)
this.fireEvent('editcomplete', this);
}
},

View file

@ -510,15 +510,15 @@ define([
return this.$el;
},
fillRolesMenu: function(roles, lastRole) {
fillRolesMenu: function(roles, lastViewRole) {
if (!(this.btnViewFormRoles && this.btnViewFormRoles.menu && this.btnViewFormRoles.menu.isVisible())) {
this._state.roles = roles;
this._state.lastRole = lastRole;
this._state.lastViewRole = lastViewRole;
return;
}
roles = roles || this._state.roles;
lastRole = lastRole || this._state.lastRole;
this._state.roles = this._state.lastRole = undefined;
lastViewRole = lastViewRole || this._state.lastViewRole;
this._state.roles = this._state.lastViewRole = undefined;
if (!roles) return;
@ -530,7 +530,7 @@ define([
roles && roles.forEach(function(item, index) {
var role = item.asc_getSettings(),
color = role.asc_getColor();
if (role.asc_getName()===lastRole)
if (role.asc_getName()===lastViewRole)
checkedIndex = index;
me.btnViewFormRoles.menu.addItem(new Common.UI.MenuItem({
caption: role.asc_getName() || me.textAnyone,