Improve title and state toolbar in history and snapshot views

pull/1/head
yflory 4 years ago
parent ac4322cfab
commit 8d6fe7120f

@ -663,6 +663,20 @@
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
} }
&.cp-toolbar-unsync {
.cp-toolbar-title-edit, .cp-toolbar-title-save {
display: none !important;
}
.cp-toolbar-title-unsync {
display: inline-flex;
}
.cp-toolbar-title-editable, .cp-toolbar-title-edit {
border: none !important;
}
}
.cp-toolbar-title-unsync {
display: none;
}
.cp-toolbar-title-hoverable { .cp-toolbar-title-hoverable {
display: inline-flex; display: inline-flex;
overflow: hidden; overflow: hidden;

@ -162,6 +162,8 @@ define([
} else { } else {
state = newState; state = newState;
} }
} else if (state === STATE.READY) {
// Refreshing ready state
} }
switch (state) { switch (state) {
case STATE.DISCONNECTED: case STATE.DISCONNECTED:
@ -311,6 +313,7 @@ define([
}; };
var closeSnapshot = function (restore) { var closeSnapshot = function (restore) {
if (restore && state !== STATE.READY) { return false; } if (restore && state !== STATE.READY) { return false; }
toolbar.setSnapshot(false);
setUnsyncMode(false); // Unlock onLocal and onRemote setUnsyncMode(false); // Unlock onLocal and onRemote
if (restore) { onLocal(); } // Restore? commit the content if (restore) { onLocal(); } // Restore? commit the content
onRemote(); // Make sure we're back to the realtime content onRemote(); // Make sure we're back to the realtime content
@ -318,6 +321,7 @@ define([
}; };
var loadSnapshot = function (hash, data) { var loadSnapshot = function (hash, data) {
setUnsyncMode(true); setUnsyncMode(true);
toolbar.setSnapshot(true);
Snapshots.create(common, { Snapshots.create(common, {
readOnly: readOnly, readOnly: readOnly,
$toolbar: $(toolbarContainer), $toolbar: $(toolbarContainer),
@ -326,10 +330,8 @@ define([
close: closeSnapshot, close: closeSnapshot,
applyVal: function (val) { applyVal: function (val) {
var newContent = JSON.parse(val); var newContent = JSON.parse(val);
/*
var meta = extractMetadata(newContent); var meta = extractMetadata(newContent);
cpNfInner.metadataMgr.updateMetadata(meta); cpNfInner.metadataMgr.updateMetadata(meta);
*/
contentUpdate(normalize(newContent) || ["BODY",{},[]], function (h) { contentUpdate(normalize(newContent) || ["BODY",{},[]], function (h) {
return h; return h;
}); });

@ -661,6 +661,8 @@ MessengerUI, Messages) {
.text('('+Messages.readonly+')')); .text('('+Messages.readonly+')'));
return $titleContainer; return $titleContainer;
} }
$hoverable.append($('<span>', {'class': 'cp-toolbar-title-readonly cp-toolbar-title-unsync'})
.text('('+Messages.readonly+')'));
var $input = $('<input>', { var $input = $('<input>', {
type: 'text', type: 'text',
placeholder: placeholder placeholder: placeholder
@ -1348,10 +1350,22 @@ MessengerUI, Messages) {
} }
}; };
toolbar.setSnapshot = function (bool) {
toolbar.history = bool;
toolbar.title.toggleClass('cp-toolbar-unsync', bool);
if (bool && toolbar.spinner) {
toolbar.spinner.text("SNAPSHOT"); // XXX
} else {
kickSpinner(toolbar, config);
}
};
toolbar.setHistory = function (bool) { toolbar.setHistory = function (bool) {
toolbar.history = bool; toolbar.history = bool;
toolbar.title.toggleClass('cp-toolbar-unsync', bool);
if (bool && toolbar.spinner) { if (bool && toolbar.spinner) {
toolbar.spinner.text("HISTORY"); // XXX toolbar.spinner.text("HISTORY"); // XXX
} else {
kickSpinner(toolbar, config);
} }
}; };

Loading…
Cancel
Save