Add/remove file to favorites

This commit is contained in:
Julia Radzhabova 2020-12-14 22:45:30 +03:00
parent a44b9ce686
commit a30176fae1
10 changed files with 110 additions and 4 deletions

View file

@ -36,7 +36,8 @@
isLink: false isLink: false
}, },
... ...
] ],
favorite: '<file is favorite>' // true/false/undefined (undefined - don't show fav. button)
}, },
permissions: { permissions: {
edit: <can edit>, // default = true edit: <can edit>, // default = true
@ -638,6 +639,13 @@
}); });
}; };
var _setFavorite = function(data) {
_sendCommand({
command: 'setFavorite',
data: data
});
};
var _processMouse = function(evt) { var _processMouse = function(evt) {
var r = iframe.getBoundingClientRect(); var r = iframe.getBoundingClientRect();
var data = { var data = {
@ -683,7 +691,8 @@
setSharingSettings : _setSharingSettings, setSharingSettings : _setSharingSettings,
insertImage : _insertImage, insertImage : _insertImage,
setMailMergeRecipients: _setMailMergeRecipients, setMailMergeRecipients: _setMailMergeRecipients,
setRevisedFile : _setRevisedFile setRevisedFile : _setRevisedFile,
setFavorite : _setFavorite
} }
}; };

View file

@ -122,6 +122,10 @@ if (Common === undefined) {
'setRevisedFile': function(data) { 'setRevisedFile': function(data) {
$me.trigger('setrevisedfile', data); $me.trigger('setrevisedfile', data);
},
'setFavorite': function(data) {
$me.trigger('setfavorite', data);
} }
}; };

View file

@ -659,7 +659,7 @@ define([
changeIcon: function(opts) { changeIcon: function(opts) {
var me = this; var me = this;
if ( opts && (opts.curr || opts.next)) { if ( opts && (opts.curr || opts.next) && me.$icon) {
!!opts.curr && (me.$icon.removeClass(opts.curr)); !!opts.curr && (me.$icon.removeClass(opts.curr));
!!opts.next && !me.$icon.hasClass(opts.next) && (me.$icon.addClass(opts.next)); !!opts.next && !me.$icon.hasClass(opts.next) && (me.$icon.addClass(opts.next));

View file

@ -98,6 +98,7 @@ define([
'</div>' + '</div>' +
'<div class="hedset">' + '<div class="hedset">' +
'<div class="btn-slot" id="slot-btn-back"></div>' + '<div class="btn-slot" id="slot-btn-back"></div>' +
'<div class="btn-slot" id="slot-btn-favorite"></div>' +
'<div class="btn-slot" id="slot-btn-options"></div>' + '<div class="btn-slot" id="slot-btn-options"></div>' +
'</div>' + '</div>' +
'</section>' + '</section>' +
@ -232,6 +233,13 @@ define([
Common.NotificationCenter.trigger('goback'); Common.NotificationCenter.trigger('goback');
}); });
me.btnFavorite.on('click', function (e) {
me.options.favorite = !me.options.favorite;
me.btnFavorite.changeIcon(me.options.favorite ? {next: 'btn-in-favorite'} : {curr: 'btn-in-favorite'});
me.btnFavorite.updateHint(!me.options.favorite ? me.textAddFavorite : me.textRemoveFavorite);
Common.NotificationCenter.trigger('markfavorite', me.options.favorite);
});
if ( me.logo ) if ( me.logo )
me.logo.children(0).on('click', function (e) { me.logo.children(0).on('click', function (e) {
var _url = !!me.branding && !!me.branding.logo && (me.branding.logo.url!==undefined) ? var _url = !!me.branding && !!me.branding.logo && (me.branding.logo.url!==undefined) ?
@ -402,6 +410,12 @@ define([
me.mnuZoom = {options: {value: 100}}; me.mnuZoom = {options: {value: 100}};
me.btnFavorite = new Common.UI.Button({
id: 'btn-favorite',
cls: 'btn-header',
iconCls: 'toolbar__icon icon--inverse btn-favorite'
});
Common.NotificationCenter.on({ Common.NotificationCenter.on({
'app:ready': function(mode) {Common.Utils.asyncCall(onAppReady, me, mode);}, 'app:ready': function(mode) {Common.Utils.asyncCall(onAppReady, me, mode);},
'app:face': function(mode) {Common.Utils.asyncCall(onAppShowed, me, mode);} 'app:face': function(mode) {Common.Utils.asyncCall(onAppShowed, me, mode);}
@ -463,6 +477,14 @@ define([
$html.find('#slot-btn-back').hide(); $html.find('#slot-btn-back').hide();
} }
if ( this.options.favorite !== undefined ) {
me.btnFavorite.render($html.find('#slot-btn-favorite'));
me.btnFavorite.changeIcon(!!me.options.favorite ? {next: 'btn-in-favorite'} : {curr: 'btn-in-favorite'});
me.btnFavorite.updateHint(!me.options.favorite ? me.textAddFavorite : me.textRemoveFavorite);
} else {
$html.find('#slot-btn-favorite').hide();
}
if ( !config.isEdit ) { if ( !config.isEdit ) {
if ( (config.canDownload || config.canDownloadOrigin) && !config.isOffline ) if ( (config.canDownload || config.canDownloadOrigin) && !config.isOffline )
this.btnDownload = createTitleButton('toolbar__icon icon--inverse btn-download', $html.findById('#slot-hbtn-download')); this.btnDownload = createTitleButton('toolbar__icon icon--inverse btn-download', $html.findById('#slot-hbtn-download'));
@ -582,6 +604,19 @@ define([
return this.options.canBack; return this.options.canBack;
}, },
setFavorite: function (value) {
this.options.favorite = value;
this.btnFavorite[value!==undefined ? 'show' : 'hide']();
this.btnFavorite.changeIcon(!!value ? {next: 'btn-in-favorite'} : {curr: 'btn-in-favorite'});
this.btnFavorite.updateHint(!value ? this.textAddFavorite : this.textRemoveFavorite);
return this;
},
getFavorite: function () {
return this.options.favorite;
},
setCanRename: function (rename) { setCanRename: function (rename) {
rename = false; rename = false;
@ -691,7 +726,9 @@ define([
textHideLines: 'Hide Rulers', textHideLines: 'Hide Rulers',
textZoom: 'Zoom', textZoom: 'Zoom',
textAdvSettings: 'Advanced Settings', textAdvSettings: 'Advanced Settings',
tipViewSettings: 'View Settings' tipViewSettings: 'View Settings',
textRemoveFavorite: 'Remove from Favorites',
textAddFavorite: 'Mark as favorite'
} }
}(), Common.Views.Header || {})) }(), Common.Views.Header || {}))
}); });

View file

@ -202,6 +202,7 @@ define([
Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this));
Common.NotificationCenter.on('goback', _.bind(this.goBack, this)); Common.NotificationCenter.on('goback', _.bind(this.goBack, this));
Common.NotificationCenter.on('markfavorite', _.bind(this.markFavorite, this));
Common.NotificationCenter.on('download:advanced', _.bind(this.onAdvancedOptions, this)); Common.NotificationCenter.on('download:advanced', _.bind(this.onAdvancedOptions, this));
Common.NotificationCenter.on('showmessage', _.bind(this.onExternalMessage, this)); Common.NotificationCenter.on('showmessage', _.bind(this.onExternalMessage, this));
Common.NotificationCenter.on('showerror', _.bind(this.onError, this)); Common.NotificationCenter.on('showerror', _.bind(this.onError, this));
@ -440,6 +441,8 @@ define([
if (type && typeof type[1] === 'string') { if (type && typeof type[1] === 'string') {
this.permissions.edit = this.permissions.review = false; this.permissions.edit = this.permissions.review = false;
} }
this.appOptions.canFavorite = data.doc.info && (data.doc.info.favorite!==undefined);
} }
this.api.asc_registerCallback('asc_onGetEditorPermissions', _.bind(this.onEditorPermissions, this)); this.api.asc_registerCallback('asc_onGetEditorPermissions', _.bind(this.onEditorPermissions, this));
@ -451,6 +454,7 @@ define([
if (data.doc) { if (data.doc) {
appHeader.setDocumentCaption(data.doc.title); appHeader.setDocumentCaption(data.doc.title);
} }
this.appOptions.canFavorite && appHeader.setFavorite(data.doc.info.favorite);
}, },
onProcessSaveResult: function(data) { onProcessSaveResult: function(data) {
@ -700,6 +704,18 @@ define([
} }
}, },
markFavorite: function(favorite) {
if ( !Common.Controllers.Desktop.process('markfavorite') ) {
Common.Gateway.metaChange({
favorite: favorite
});
}
},
onSetFavorite: function(favorite) {
this.appOptions.canFavorite && appHeader.setFavorite(!!favorite);
},
onEditComplete: function(cmp) { onEditComplete: function(cmp) {
// this.getMainMenu().closeFullScaleMenu(); // this.getMainMenu().closeFullScaleMenu();
var application = this.getApplication(), var application = this.getApplication(),
@ -1111,6 +1127,7 @@ define([
Common.Gateway.on('processmouse', _.bind(me.onProcessMouse, me)); Common.Gateway.on('processmouse', _.bind(me.onProcessMouse, me));
Common.Gateway.on('refreshhistory', _.bind(me.onRefreshHistory, me)); Common.Gateway.on('refreshhistory', _.bind(me.onRefreshHistory, me));
Common.Gateway.on('downloadas', _.bind(me.onDownloadAs, me)); Common.Gateway.on('downloadas', _.bind(me.onDownloadAs, me));
Common.Gateway.on('setfavorite', _.bind(me.onSetFavorite, me));
Common.Gateway.sendInfo({mode:me.appOptions.isEdit?'edit':'view'}); Common.Gateway.sendInfo({mode:me.appOptions.isEdit?'edit':'view'});

View file

@ -261,6 +261,8 @@
"Common.Views.Header.tipViewUsers": "View users and manage document access rights", "Common.Views.Header.tipViewUsers": "View users and manage document access rights",
"Common.Views.Header.txtAccessRights": "Change access rights", "Common.Views.Header.txtAccessRights": "Change access rights",
"Common.Views.Header.txtRename": "Rename", "Common.Views.Header.txtRename": "Rename",
"Common.Views.Header.textRemoveFavorite": "Remove from Favorites",
"Common.Views.Header.textAddFavorite": "Mark as favorite",
"Common.Views.History.textCloseHistory": "Close History", "Common.Views.History.textCloseHistory": "Close History",
"Common.Views.History.textHide": "Collapse", "Common.Views.History.textHide": "Collapse",
"Common.Views.History.textHideAll": "Hide detailed changes", "Common.Views.History.textHideAll": "Hide detailed changes",

View file

@ -185,6 +185,7 @@ define([
Common.NotificationCenter.on('goback', _.bind(this.goBack, this)); Common.NotificationCenter.on('goback', _.bind(this.goBack, this));
Common.NotificationCenter.on('showmessage', _.bind(this.onExternalMessage, this)); Common.NotificationCenter.on('showmessage', _.bind(this.onExternalMessage, this));
Common.NotificationCenter.on('showerror', _.bind(this.onError, this)); Common.NotificationCenter.on('showerror', _.bind(this.onError, this));
Common.NotificationCenter.on('markfavorite', _.bind(this.markFavorite, this));
this.isShowOpenDialog = false; this.isShowOpenDialog = false;
@ -391,6 +392,8 @@ define([
docInfo.asc_putIsEnabledMacroses(!!enable); docInfo.asc_putIsEnabledMacroses(!!enable);
enable = !this.editorConfig.customization || (this.editorConfig.customization.plugins!==false); enable = !this.editorConfig.customization || (this.editorConfig.customization.plugins!==false);
docInfo.asc_putIsEnabledPlugins(!!enable); docInfo.asc_putIsEnabledPlugins(!!enable);
this.appOptions.canFavorite = data.doc.info && (data.doc.info.favorite!==undefined);
} }
this.api.asc_registerCallback('asc_onGetEditorPermissions', _.bind(this.onEditorPermissions, this)); this.api.asc_registerCallback('asc_onGetEditorPermissions', _.bind(this.onEditorPermissions, this));
@ -402,6 +405,7 @@ define([
if (data.doc) { if (data.doc) {
appHeader.setDocumentCaption(data.doc.title); appHeader.setDocumentCaption(data.doc.title);
} }
this.appOptions.canFavorite && appHeader.setFavorite(data.doc.info.favorite);
}, },
onProcessSaveResult: function(data) { onProcessSaveResult: function(data) {
@ -487,6 +491,18 @@ define([
} }
}, },
markFavorite: function(favorite) {
if ( !Common.Controllers.Desktop.process('markfavorite') ) {
Common.Gateway.metaChange({
favorite: favorite
});
}
},
onSetFavorite: function(favorite) {
this.appOptions.canFavorite && appHeader.setFavorite(!!favorite);
},
onEditComplete: function(cmp) { onEditComplete: function(cmp) {
var application = this.getApplication(), var application = this.getApplication(),
toolbarView = application.getController('Toolbar').getView('Toolbar'); toolbarView = application.getController('Toolbar').getView('Toolbar');
@ -835,6 +851,7 @@ define([
Common.Gateway.on('processrightschange', _.bind(me.onProcessRightsChange, me)); Common.Gateway.on('processrightschange', _.bind(me.onProcessRightsChange, me));
Common.Gateway.on('processmouse', _.bind(me.onProcessMouse, me)); Common.Gateway.on('processmouse', _.bind(me.onProcessMouse, me));
Common.Gateway.on('downloadas', _.bind(me.onDownloadAs, me)); Common.Gateway.on('downloadas', _.bind(me.onDownloadAs, me));
Common.Gateway.on('setfavorite', _.bind(me.onSetFavorite, me));
Common.Gateway.sendInfo({mode:me.appOptions.isEdit?'edit':'view'}); Common.Gateway.sendInfo({mode:me.appOptions.isEdit?'edit':'view'});

View file

@ -158,6 +158,8 @@
"Common.Views.Header.tipViewUsers": "View users and manage document access rights", "Common.Views.Header.tipViewUsers": "View users and manage document access rights",
"Common.Views.Header.txtAccessRights": "Change access rights", "Common.Views.Header.txtAccessRights": "Change access rights",
"Common.Views.Header.txtRename": "Rename", "Common.Views.Header.txtRename": "Rename",
"Common.Views.Header.textRemoveFavorite": "Remove from Favorites",
"Common.Views.Header.textAddFavorite": "Mark as favorite",
"Common.Views.ImageFromUrlDialog.textUrl": "Paste an image URL:", "Common.Views.ImageFromUrlDialog.textUrl": "Paste an image URL:",
"Common.Views.ImageFromUrlDialog.txtEmpty": "This field is required", "Common.Views.ImageFromUrlDialog.txtEmpty": "This field is required",
"Common.Views.ImageFromUrlDialog.txtNotUrl": "This field should be a URL in the \"http://www.example.com\" format", "Common.Views.ImageFromUrlDialog.txtNotUrl": "This field should be a URL in the \"http://www.example.com\" format",

View file

@ -193,6 +193,7 @@ define([
Common.NotificationCenter.on('download:cancel', _.bind(this.onDownloadCancel, this)); Common.NotificationCenter.on('download:cancel', _.bind(this.onDownloadCancel, this));
Common.NotificationCenter.on('download:advanced', _.bind(this.onAdvancedOptions, this)); Common.NotificationCenter.on('download:advanced', _.bind(this.onAdvancedOptions, this));
Common.NotificationCenter.on('showmessage', _.bind(this.onExternalMessage, this)); Common.NotificationCenter.on('showmessage', _.bind(this.onExternalMessage, this));
Common.NotificationCenter.on('markfavorite', _.bind(this.markFavorite, this));
this.stackLongActions = new Common.IrregularStack({ this.stackLongActions = new Common.IrregularStack({
strongCompare : this._compareActionStrong, strongCompare : this._compareActionStrong,
@ -445,6 +446,8 @@ define([
docInfo.asc_putIsEnabledPlugins(!!enable); docInfo.asc_putIsEnabledPlugins(!!enable);
this.headerView && this.headerView.setDocumentCaption(data.doc.title); this.headerView && this.headerView.setDocumentCaption(data.doc.title);
this.appOptions.canFavorite = data.doc.info && (data.doc.info.favorite!==undefined);
this.appOptions.canFavorite && this.headerView && this.headerView.setFavorite(data.doc.info.favorite);
Common.Utils.InternalSettings.set("sse-doc-info-key", data.doc.key); Common.Utils.InternalSettings.set("sse-doc-info-key", data.doc.key);
} }
@ -541,6 +544,18 @@ define([
} }
}, },
markFavorite: function(favorite) {
if ( !Common.Controllers.Desktop.process('markfavorite') ) {
Common.Gateway.metaChange({
favorite: favorite
});
}
},
onSetFavorite: function(favorite) {
this.appOptions.canFavorite && this.headerView && this.headerView.setFavorite(!!favorite);
},
onEditComplete: function(cmp, opts) { onEditComplete: function(cmp, opts) {
if (opts && opts.restorefocus && this.api.isCEditorFocused) { if (opts && opts.restorefocus && this.api.isCEditorFocused) {
this.formulaInput.blur(); this.formulaInput.blur();
@ -887,6 +902,7 @@ define([
Common.Gateway.on('processrightschange', _.bind(me.onProcessRightsChange, me)); Common.Gateway.on('processrightschange', _.bind(me.onProcessRightsChange, me));
Common.Gateway.on('processmouse', _.bind(me.onProcessMouse, me)); Common.Gateway.on('processmouse', _.bind(me.onProcessMouse, me));
Common.Gateway.on('downloadas', _.bind(me.onDownloadAs, me)); Common.Gateway.on('downloadas', _.bind(me.onDownloadAs, me));
Common.Gateway.on('setfavorite', _.bind(me.onSetFavorite, me));
Common.Gateway.sendInfo({mode:me.appOptions.isEdit?'edit':'view'}); Common.Gateway.sendInfo({mode:me.appOptions.isEdit?'edit':'view'});
$(document).on('contextmenu', _.bind(me.onContextMenu, me)); $(document).on('contextmenu', _.bind(me.onContextMenu, me));

View file

@ -154,6 +154,8 @@
"Common.Views.Header.tipViewUsers": "View users and manage document access rights", "Common.Views.Header.tipViewUsers": "View users and manage document access rights",
"Common.Views.Header.txtAccessRights": "Change access rights", "Common.Views.Header.txtAccessRights": "Change access rights",
"Common.Views.Header.txtRename": "Rename", "Common.Views.Header.txtRename": "Rename",
"Common.Views.Header.textRemoveFavorite": "Remove from Favorites",
"Common.Views.Header.textAddFavorite": "Mark as favorite",
"Common.Views.ImageFromUrlDialog.textUrl": "Paste an image URL:", "Common.Views.ImageFromUrlDialog.textUrl": "Paste an image URL:",
"Common.Views.ImageFromUrlDialog.txtEmpty": "This field is required", "Common.Views.ImageFromUrlDialog.txtEmpty": "This field is required",
"Common.Views.ImageFromUrlDialog.txtNotUrl": "This field should be a URL in the \"http://www.example.com\" format", "Common.Views.ImageFromUrlDialog.txtNotUrl": "This field should be a URL in the \"http://www.example.com\" format",