[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - 2 commits - loleaflet/src
Pranav Kant
pranavk at collabora.co.uk
Tue Apr 3 12:23:55 UTC 2018
loleaflet/src/core/LOUtil.js | 7 +++++++
loleaflet/src/core/Socket.js | 34 ++++++++++++++++++++++++++++------
loleaflet/src/map/Map.js | 8 +++++++-
3 files changed, 42 insertions(+), 7 deletions(-)
New commits:
commit 300b254db1926ac50cc718c7503f7d89e4a37fa2
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Fri Mar 30 19:26:55 2018 +0530
Ask to save unsaved changes to a new file
... when document is changed externally.
Change-Id: Ieaad5f0ed5cd4ee3bf5385f2a5cd297b7758a43e
Reviewed-on: https://gerrit.libreoffice.org/52156
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Tested-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/loleaflet/src/core/LOUtil.js b/loleaflet/src/core/LOUtil.js
index 286f2fa4e..fad8ad527 100644
--- a/loleaflet/src/core/LOUtil.js
+++ b/loleaflet/src/core/LOUtil.js
@@ -78,5 +78,12 @@ L.LOUtil = {
}
}
return rectangles;
+ },
+
+ /// oldFileName = Example.odt, suffix = new
+ /// returns: Example_new.odt
+ generateNewFileName: function(oldFileName, suffix) {
+ var idx = oldFileName.lastIndexOf('.');
+ return oldFileName.substring(0, idx) + suffix + oldFileName.substring(idx);
}
};
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index d75c985ab..ce05a4a6d 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -433,21 +433,41 @@ L.Socket = L.Class.extend({
vex.close(id);
}
- vex.dialog.confirm({
- message: _('Document has been changed in storage. Do you want to discard your changes, and load the document from the storage?'),
+ vex.dialog.open({
+ message: _('Document has been changed in storage. What would you like to do with your unsaved changes?'),
escapeButtonCloses: false,
overlayClosesOnClick: false,
+ contentCSS: { width: '600px' },
buttons: [
- $.extend({}, vex.dialog.buttons.YES, { text: _('Discard changes') }),
- $.extend({}, vex.dialog.buttons.NO, { text: _('Overwrite document') })
+ $.extend({}, vex.dialog.buttons.YES, { text: _('Discard'),
+ click: function($vexContent) {
+ $vexContent.data().vex.value = 'discard';
+ vex.close($vexContent.data().vex.id);
+ }}),
+ $.extend({}, vex.dialog.buttons.YES, { text: _('Overwrite'),
+ click: function($vexContent) {
+ $vexContent.data().vex.value = 'overwrite';
+ vex.close($vexContent.data().vex.id);
+ }}),
+ $.extend({}, vex.dialog.buttons.YES, { text: _('Save to new file'),
+ click: function($vexContent) {
+ $vexContent.data().vex.value = 'saveas';
+ vex.close($vexContent.data().vex.id);
+ }})
],
callback: L.bind(function(value) {
- if (value) {
+ if (value === 'discard') {
// They want to refresh the page and load document again for all
this.sendMessage('closedocument');
- } else {
+ } else if (value === 'overwrite') {
// They want to overwrite
this.sendMessage('savetostorage force=1');
+ } else if (value === 'saveas') {
+ var filename = this._map['wopi'].BaseFileName;
+ if (filename) {
+ filename = L.LOUtil.generateNewFileName(filename, '_new');
+ this._map.saveAs(filename);
+ }
}
}, this)
});
commit ba9c23b20cc7a859c59aace9ace621530515f35e
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Fri Mar 30 18:54:44 2018 +0530
loleaflet: Don't close dialog on just getting the focus
User should explicitly click on individual buttons to be able to close
the dialog.
Change-Id: Ie78e057a92677c392fd97c637248c1da5597ad84
Reviewed-on: https://gerrit.libreoffice.org/52155
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Tested-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 49507a16a..d75c985ab 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -435,6 +435,8 @@ L.Socket = L.Class.extend({
vex.dialog.confirm({
message: _('Document has been changed in storage. Do you want to discard your changes, and load the document from the storage?'),
+ escapeButtonCloses: false,
+ overlayClosesOnClick: false,
buttons: [
$.extend({}, vex.dialog.buttons.YES, { text: _('Discard changes') }),
$.extend({}, vex.dialog.buttons.NO, { text: _('Overwrite document') })
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 242d2c91a..9c58ea225 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -842,7 +842,7 @@ L.Map = L.Evented.extend({
_activate: function () {
if (this._serverRecycling || this._documentIdle) {
- return;
+ return false;
}
console.debug('_activate:');
@@ -857,8 +857,14 @@ L.Map = L.Evented.extend({
if (this._doclayer) {
this._docLayer._onMessage('invalidatetiles: EMPTY', null);
}
+
if (vex.dialogID > 0) {
var id = vex.dialogID;
+
+ var options = vex.getVexByID(id).data().vex;
+ if (!options.overlayClosesOnClick || !options.escapeButtonCloses)
+ return false;
+
vex.dialogID = -1;
this._startInactiveTimer();
this.focus();
More information about the Libreoffice-commits
mailing list