Select current revision when showing the revision popup

Closes #12472
This commit is contained in:
Cédric Krier
2023-08-14 19:44:38 +02:00
parent 7b02a795c7
commit 93dc054222
2 changed files with 16 additions and 7 deletions
+7 -1
View File
@@ -993,7 +993,13 @@
return this.screen.model.execute('history_revisions',
[ids], this.screen.context)
.then(revisions => {
new Sao.Window.Revision(revisions, set_revision(revisions));
const revision = this.screen.context._datetime;
if (revision) {
// Remove a millisecond as microseconds are truncated
revision.add(-1, 'milliseconds');
}
new Sao.Window.Revision(
revisions, revision, set_revision(revisions));
});
});
},
+9 -6
View File
@@ -1083,7 +1083,7 @@
});
Sao.Window.Revision = Sao.class_(Object, {
init: function(revisions, callback) {
init: function(revisions, revision, callback) {
this.callback = callback;
var dialog = new Sao.Dialog(
Sao.i18n.gettext('Revision'), '', 'lg');
@@ -1124,15 +1124,18 @@
value: null,
text: ''
}));
for (let revision of revisions) {
var name = revision[2];
revision = revision[0];
for (let rev of revisions) {
var name = rev[2];
rev = rev[0];
this.select.append(jQuery('<option/>', {
value: revision.valueOf(),
value: rev.valueOf(),
text: Sao.common.format_datetime(
date_format + ' ' + time_format, revision) + ' ' + name,
date_format + ' ' + time_format, rev) + ' ' + name,
}));
}
if (revision) {
this.select.val(revision.valueOf());
}
this.el.modal('show');
this.el.on('hidden.bs.modal', function(event) {
jQuery(this).remove();