Remove vex from documentconflict message.
Signed-off-by: Gökay Şatır <gokaysatir@collabora.com> Change-Id: Idd09bb8c376e50c64db4f145f907b7a3e17436d0
This commit is contained in:
parent
08d74ee23e
commit
3f4ac24bb2
2 changed files with 88 additions and 82 deletions
|
@ -917,6 +917,55 @@ L.Control.UIManager = L.Control.extend({
|
|||
], cancelButtonId);
|
||||
},
|
||||
|
||||
/// buttonObjectList: [{id: button's id, text: button's text, ..other properties if needed}, ...]
|
||||
/// callbackList: [{id: button's id, func_: function}, ...]
|
||||
showModalWithCustomButtons: function(id, title, message, cancellable, buttonObjectList, callbackList) {
|
||||
var dialogId = this.generateModalId(id);
|
||||
|
||||
for (var i = 0; i < buttonObjectList.length; i++)
|
||||
buttonObjectList[i].type = 'pushbutton';
|
||||
|
||||
var json = this._modalDialogJSON(id, title, !!cancellable, [
|
||||
{
|
||||
id: 'info-modal-tile-m',
|
||||
type: 'fixedtext',
|
||||
text: title,
|
||||
hidden: !window.mode.isMobile()
|
||||
},
|
||||
{
|
||||
id: 'info-modal-label1',
|
||||
type: 'fixedtext',
|
||||
text: message
|
||||
},
|
||||
{
|
||||
id: '',
|
||||
type: 'buttonbox',
|
||||
text: '',
|
||||
enabled: true,
|
||||
children: buttonObjectList,
|
||||
vertical: false,
|
||||
layoutstyle: 'end'
|
||||
},
|
||||
]);
|
||||
|
||||
buttonObjectList.forEach(function(button) {
|
||||
callbackList.forEach(function(callback) {
|
||||
if (button.id === callback.id) {
|
||||
if (typeof callback.func_ === 'function') {
|
||||
callback.func = function() {
|
||||
callback.func_();
|
||||
this.closeModal(dialogId);
|
||||
}.bind(this);
|
||||
}
|
||||
else
|
||||
callback.func = function() { this.closeModal(dialogId); }.bind(this);
|
||||
}
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
|
||||
this.showModal(json, callbackList);
|
||||
},
|
||||
|
||||
/// shows simple input modal (message + input + (cancel + ok) button)
|
||||
/// id - id of a dialog
|
||||
/// title - title of a dialog
|
||||
|
|
|
@ -848,88 +848,10 @@ app.definitions.Socket = L.Class.extend({
|
|||
}
|
||||
else if (command.errorKind === 'documentconflict')
|
||||
{
|
||||
var that = this;
|
||||
storageError = errorMessages.storage.documentconflict;
|
||||
|
||||
vex.closeAll();
|
||||
|
||||
var dialogButtons = [
|
||||
$.extend({}, vex.dialog.buttons.YES, {
|
||||
text: _('Discard'),
|
||||
className: 'button-secondary',
|
||||
click: function() {
|
||||
this.value = 'discard';
|
||||
this.close();
|
||||
}}),
|
||||
$.extend({}, vex.dialog.buttons.YES, {
|
||||
text: _('Overwrite'),
|
||||
className: 'button-secondary',
|
||||
click: function() {
|
||||
this.value = 'overwrite';
|
||||
this.close();
|
||||
}}),
|
||||
$.extend({}, vex.dialog.buttons.YES, {
|
||||
text: '',
|
||||
className: 'vex-dialog-button-spacer'
|
||||
})
|
||||
];
|
||||
|
||||
if (!that._map['wopi'].UserCanNotWriteRelative) {
|
||||
dialogButtons.push(
|
||||
$.extend({}, vex.dialog.buttons.YES, {
|
||||
text: _('Save to new file'),
|
||||
className: 'button-primary',
|
||||
click: function() {
|
||||
this.value = 'saveas';
|
||||
this.close();
|
||||
}}),
|
||||
$.extend({}, vex.dialog.buttons.YES, {
|
||||
text: _('Cancel'),
|
||||
className: 'button-secondary vex-dialog-button-cancel',
|
||||
click: function() {
|
||||
this.value = 'cancel';
|
||||
this.close();
|
||||
}})
|
||||
);
|
||||
} else {
|
||||
dialogButtons.push(
|
||||
$.extend({}, vex.dialog.buttons.YES, {
|
||||
text: _('Cancel'),
|
||||
className: 'button-primary vex-dialog-button-cancel',
|
||||
click: function() {
|
||||
this.value = 'cancel';
|
||||
this.close();
|
||||
}})
|
||||
);
|
||||
}
|
||||
if (!this._map.isReadOnlyMode()) {
|
||||
vex.dialog.open({
|
||||
unsafeMessage: '<h1 class="vex-dialog-title">' + vex._escapeHtml(_('Document has been changed')) + '</h1><p class="vex-dialog-message">' + vex._escapeHtml(_('Document has been changed in storage. What would you like to do with your unsaved changes?')) + '</p>',
|
||||
escapeButtonCloses: false,
|
||||
overlayClosesOnClick: false,
|
||||
contentClassName: 'vex-content vex-3btns',
|
||||
buttons: dialogButtons,
|
||||
showCloseButton: true,
|
||||
callback: function(value) {
|
||||
if (value === 'discard') {
|
||||
// They want to refresh the page and load document again for all
|
||||
that.sendMessage('closedocument');
|
||||
} else if (value === 'overwrite') {
|
||||
// They want to overwrite
|
||||
that.sendMessage('savetostorage force=1');
|
||||
} else if (value === 'saveas') {
|
||||
var filename = that._map['wopi'].BaseFileName;
|
||||
if (filename) {
|
||||
filename = L.LOUtil.generateNewFileName(filename, '_new');
|
||||
that._map.saveAs(filename);
|
||||
}
|
||||
}
|
||||
},
|
||||
afterOpen: function() {
|
||||
this.contentEl.style.width = '600px';
|
||||
}
|
||||
});
|
||||
}
|
||||
if (this._map.isReadOnlyMode())
|
||||
return;
|
||||
else
|
||||
this._showDocumentConflictPopUp();
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -1241,6 +1163,41 @@ app.definitions.Socket = L.Class.extend({
|
|||
}.bind(this), true /* password input */);
|
||||
},
|
||||
|
||||
_showDocumentConflictPopUp: function() {
|
||||
var buttonList = [];
|
||||
var callbackList = [];
|
||||
|
||||
buttonList.push({ id: 'cancel-conflict-popup', text: _('Cancel') });
|
||||
callbackList.push({ id: 'cancel-conflict-popup', func_: null });
|
||||
|
||||
buttonList.push({ id: 'discard-button', text: _('Discard') });
|
||||
buttonList.push({ id: 'overwrite-button', text: _('Overwrite') });
|
||||
|
||||
callbackList.push({id: 'discard-button', func_: function() {
|
||||
this.sendMessage('closedocument');
|
||||
}.bind(this) });
|
||||
|
||||
callbackList.push({id: 'overwrite-button', func_: function() {
|
||||
this.sendMessage('savetostorage force=1'); }.bind(this)
|
||||
});
|
||||
|
||||
if (!this._map['wopi'].UserCanNotWriteRelative) {
|
||||
buttonList.push({ id: 'save-to-new-file', text: _('Save to new file') });
|
||||
callbackList.push({ id: 'save-to-new-file', func_: function() {
|
||||
var filename = this._map['wopi'].BaseFileName;
|
||||
if (filename) {
|
||||
filename = L.LOUtil.generateNewFileName(filename, '_new');
|
||||
this._map.saveAs(filename);
|
||||
}
|
||||
}.bind(this)});
|
||||
}
|
||||
|
||||
var title = _('Document has been changed');
|
||||
var message = _('Document has been changed in storage. What would you like to do with your unsaved changes?');
|
||||
|
||||
this._map.uiManager.showModalWithCustomButtons('document-conflict-popup', title, message, false, buttonList, callbackList);
|
||||
},
|
||||
|
||||
_renameOrSaveAsCallback: function(textMsg, command) {
|
||||
this._map.hideBusy();
|
||||
if (command !== undefined && command.url !== undefined && command.url !== '') {
|
||||
|
|
Loading…
Reference in a new issue