Remove vex from _switchToEditMode function in permission.js.
Signed-off-by: Gökay Şatır <gokaysatir@collabora.com> Change-Id: I444ea61eb6cf6c92858833a30be92ee9a6a36509
This commit is contained in:
parent
489a323742
commit
1ba537d8bf
3 changed files with 84 additions and 26 deletions
|
@ -1006,6 +1006,65 @@ L.Control.UIManager = L.Control.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Opens a yesno modal with configurable buttons.
|
||||||
|
showYesNoButton: function(id, title, message, yesButtonText, noButtonText, yesFunction, noFunction, cancellable) {
|
||||||
|
var dialogId = this.generateModalId(id);
|
||||||
|
|
||||||
|
var json = this._modalDialogJSON(id, title, cancellable, [
|
||||||
|
{
|
||||||
|
id: dialogId + '-title',
|
||||||
|
type: 'fixedtext',
|
||||||
|
text: title,
|
||||||
|
hidden: !window.mode.isMobile()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: dialogId + '-label',
|
||||||
|
type: 'fixedtext',
|
||||||
|
text: message
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '',
|
||||||
|
type: 'buttonbox',
|
||||||
|
text: '',
|
||||||
|
enabled: true,
|
||||||
|
children: [
|
||||||
|
noButtonText ? {
|
||||||
|
id: dialogId + '-nobutton',
|
||||||
|
type: 'pushbutton',
|
||||||
|
text: noButtonText
|
||||||
|
} : { type: 'container' },
|
||||||
|
{
|
||||||
|
id: dialogId + '-yesbutton',
|
||||||
|
type: 'pushbutton',
|
||||||
|
text: yesButtonText,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
vertical: false,
|
||||||
|
layoutstyle: 'end'
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
this.showModal(json,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
id: dialogId + '-nobutton',
|
||||||
|
func: function() {
|
||||||
|
if (typeof noFunction === 'function')
|
||||||
|
noFunction();
|
||||||
|
this.closeModal(dialogId);
|
||||||
|
}.bind(this)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: dialogId + '-yesbutton',
|
||||||
|
func: function() {
|
||||||
|
if (typeof yesFunction === 'function')
|
||||||
|
yesFunction();
|
||||||
|
this.closeModal(dialogId);
|
||||||
|
}.bind(this)
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
|
||||||
/// shows simple confirm modal (message + (cancel + ok) button)
|
/// shows simple confirm modal (message + (cancel + ok) button)
|
||||||
/// id - id of a dialog
|
/// id - id of a dialog
|
||||||
/// title - title of a dialog
|
/// title - title of a dialog
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/*
|
/*
|
||||||
* Document permission handler
|
* Document permission handler
|
||||||
*/
|
*/
|
||||||
/* global app $ _ vex */
|
/* global app $ _ */
|
||||||
L.Map.include({
|
L.Map.include({
|
||||||
readonlyStartingFormats: {
|
readonlyStartingFormats: {
|
||||||
'txt': { canEdit: true, odfFormat: 'odt' },
|
'txt': { canEdit: true, odfFormat: 'odt' },
|
||||||
|
@ -148,30 +148,31 @@ L.Map.include({
|
||||||
_switchToEditMode: function () {
|
_switchToEditMode: function () {
|
||||||
// This will be handled by the native mobile app instead
|
// This will be handled by the native mobile app instead
|
||||||
if (this._shouldStartReadOnly() && !window.ThisIsAMobileApp) {
|
if (this._shouldStartReadOnly() && !window.ThisIsAMobileApp) {
|
||||||
var that = this;
|
|
||||||
var fileName = this['wopi'].BaseFileName;
|
var fileName = this['wopi'].BaseFileName;
|
||||||
var extension = this._getFileExtension(fileName);
|
var extension = this._getFileExtension(fileName);
|
||||||
var extensionInfo = this.readonlyStartingFormats[extension];
|
var extensionInfo = this.readonlyStartingFormats[extension];
|
||||||
|
|
||||||
var buttonList = [];
|
var yesButtonText = !this['wopi'].UserCanNotWriteRelative ? _('Save as ODF format'): null;
|
||||||
if (!this['wopi'].UserCanNotWriteRelative) {
|
var noButtonText = extensionInfo.canEdit ? _('Continue editing') : _('Continue read only');
|
||||||
buttonList.push($.extend({}, vex.dialog.buttons.YES, { text: _('Save as ODF format') }));
|
|
||||||
}
|
|
||||||
buttonList.push($.extend({}, vex.dialog.buttons.NO, { text: extensionInfo.canEdit ? _('Continue editing') : _('Continue read only')}));
|
|
||||||
|
|
||||||
vex.dialog.open({
|
if (!yesButtonText) {
|
||||||
message: _('This document may contain formatting or content that cannot be saved in the current file format.'),
|
yesButtonText = noButtonText;
|
||||||
overlayClosesOnClick: false,
|
noButtonText = null;
|
||||||
callback: L.bind(function (value) {
|
|
||||||
if (value) {
|
|
||||||
// offer save-as instead
|
|
||||||
this._offerSaveAs();
|
|
||||||
} else {
|
|
||||||
this._proceedEditMode();
|
|
||||||
}
|
}
|
||||||
}, that),
|
|
||||||
buttons: buttonList
|
var yesFunction = !noButtonText ? function() { this._proceedEditMode(); }.bind(this) : function() { this._offerSaveAs(); }.bind(this);
|
||||||
});
|
var noFunction = function() { this._proceedEditMode(); }.bind(this);
|
||||||
|
|
||||||
|
this.uiManager.showYesNoButton(
|
||||||
|
'switch-to-edit-mode-modal', // id.
|
||||||
|
'', // Title.
|
||||||
|
_('This document may contain formatting or content that cannot be saved in the current file format.'), // Message.
|
||||||
|
yesButtonText,
|
||||||
|
noButtonText,
|
||||||
|
yesFunction,
|
||||||
|
noFunction,
|
||||||
|
false // Cancellable.
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
this._proceedEditMode();
|
this._proceedEditMode();
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ describe('Open different file types', function () {
|
||||||
.should('be.visible')
|
.should('be.visible')
|
||||||
.click();
|
.click();
|
||||||
|
|
||||||
cy.get('.vex-content button').click();
|
cy.get('#modal-dialog-switch-to-edit-mode-modal-yesbutton').click();
|
||||||
|
|
||||||
assertData();
|
assertData();
|
||||||
});
|
});
|
||||||
|
@ -94,19 +94,17 @@ describe('Open different file types', function () {
|
||||||
cy.get('#mobile-edit-button').should('be.visible')
|
cy.get('#mobile-edit-button').should('be.visible')
|
||||||
.click();
|
.click();
|
||||||
|
|
||||||
cy.get('.vex-overlay').should('be.visible');
|
cy.get('#modal-dialog-switch-to-edit-mode-modal-overlay').should('be.visible');
|
||||||
|
|
||||||
cy.get('.vex-dialog-message')
|
cy.get('#modal-dialog-switch-to-edit-mode-modal-label')
|
||||||
.should('have.text', 'This document may contain formatting or content that cannot be saved in the current file format.');
|
.should('have.text', 'This document may contain formatting or content that cannot be saved in the current file format.');
|
||||||
|
|
||||||
cy.get('.vex-dialog-buttons button')
|
cy.get('#modal-dialog-switch-to-edit-mode-modal-yesbutton')
|
||||||
.should('have.text', 'Continue read only')
|
.should('have.text', 'Continue read only')
|
||||||
.click();
|
.click();
|
||||||
|
|
||||||
cy.get('#PermissionMode').should('be.visible')
|
cy.get('#PermissionMode').should('be.visible')
|
||||||
.should('have.text', ' Read-only ');
|
.should('have.text', ' Read-only ');
|
||||||
|
|
||||||
cy.get('.vex-overlay').should('be.visible');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Open xlsm file' ,function() {
|
it('Open xlsm file' ,function() {
|
||||||
|
|
Loading…
Reference in a new issue