[desktop] changed "read only" file opening

This commit is contained in:
Maxim Kadushkin 2022-11-16 19:04:46 +03:00
parent 4c4da4113f
commit b825310d30
3 changed files with 36 additions and 6 deletions

View file

@ -234,21 +234,42 @@ define([
Common.NotificationCenter.on('document:ready', function () {
if ( config.isEdit ) {
var maincontroller = webapp.getController('Main');
if (maincontroller.api.asc_getLocalRestrictions && Asc.c_oAscLocalRestrictionType.None !== maincontroller.api.asc_getLocalRestrictions()) {
maincontroller.warningDocumentIsLocked();
}
// var maincontroller = webapp.getController('Main');
// if (maincontroller.api.asc_getLocalRestrictions && Asc.c_oAscLocalRestrictionType.None !== maincontroller.api.asc_getLocalRestrictions()) {
// maincontroller.warningDocumentIsLocked();
// }
}
});
Common.NotificationCenter.on('app:face', function (mode) {
features.viewmode = !mode.isEdit;
features.crypted = mode.isCrypted;
const header = webapp.getController('Viewport').getView('Common.Views.Header');
if ( mode.isEdit ) {
const api = webapp.getController('Main').api;
if ( api.asc_getLocalRestrictions && Asc.c_oAscLocalRestrictionType.None !== api.asc_getLocalRestrictions()) {
features.readonly = true;
header.setDocumentReadOnly(true);
api.asc_setLocalRestrictions(Asc.c_oAscLocalRestrictionType.None);
(new Common.UI.SynchronizeTip({
extCls: 'no-arrow',
placement: 'bottom',
target: $('.toolbar'),
text: Common.Locale.get("tipFileLocked",{name:"Common.Translation", default: "Document is locked for editing. You can make changes and save it as local copy later."}),
showLink: false,
})).on('closeclick', function () {
this.close();
}).show();
}
}
native.execCommand('webapps:features', JSON.stringify(features));
titlebuttons = {};
if ( mode.isEdit ) {
var header = webapp.getController('Viewport').getView('Common.Views.Header');
if (!!header.btnSave) {
titlebuttons['save'] = {btn: header.btnSave};

View file

@ -709,6 +709,7 @@ define([
if (idx>0)
this.fileExtention = this.documentCaption.substring(idx);
this.isModified && (value += '*');
this.readOnly && (value += ' (' + this.textReadOnly + ')');
if ( $labelDocName ) {
this.setDocTitle( value );
}
@ -901,6 +902,11 @@ define([
return initials;
},
setDocumentReadOnly: function (readonly) {
this.readOnly = readonly;
this.setDocumentCaption(this.documentCaption);
},
textBack: 'Go to Documents',
txtRename: 'Rename',
txtAccessRights: 'Change access rights',
@ -925,7 +931,8 @@ define([
textHideNotes: 'Hide Notes',
tipSearch: 'Search',
textShare: 'Share',
tipPrintQuick: 'Quick print'
tipPrintQuick: 'Quick print',
textReadOnly: 'Read only'
}
}(), Common.Views.Header || {}))
});

View file

@ -127,6 +127,7 @@
"Common.define.chartData.textSurface": "Surface",
"Common.Translation.textMoreButton": "More",
"Common.Translation.warnFileLocked": "You can't edit this file because it's being edited in another app.",
"Common.Translation.tipFileLocked": "Document is locked for editing. You can make changes and save it as local copy later.",
"Common.Translation.warnFileLockedBtnEdit": "Create a copy",
"Common.Translation.warnFileLockedBtnView": "Open for viewing",
"Common.UI.ButtonColored.textAutoColor": "Automatic",
@ -320,6 +321,7 @@
"Common.Views.Header.txtAccessRights": "Change access rights",
"Common.Views.Header.txtRename": "Rename",
"Common.Views.Header.tipPrintQuick": "Quick print",
"Common.Views.Header.textReadOnly": "Read only",
"Common.Views.History.textCloseHistory": "Close History",
"Common.Views.History.textHide": "Collapse",
"Common.Views.History.textHideAll": "Hide detailed changes",