Session history

This commit is contained in:
Mo Bitar
2018-07-19 22:25:14 -05:00
parent 8a127f97a1
commit 1250f3fd5e
13 changed files with 456 additions and 843 deletions

View File

@@ -0,0 +1,72 @@
class SessionHistoryMenu {
constructor() {
this.restrict = "E";
this.templateUrl = "directives/session-history-menu.html";
this.scope = {
item: "="
};
}
controller($scope, modelManager, sessionHistory, actionsManager, $timeout) {
'ngInject';
$scope.diskEnabled = sessionHistory.diskEnabled;
$scope.reloadHistory = function() {
$scope.history = sessionHistory.historyForItem($scope.item);
}
$scope.reloadHistory();
$scope.openRevision = function(revision) {
actionsManager.presentRevisionPreviewModal(revision);
}
$scope.classForRevision = function(revision) {
var vector = revision.operationVector();
if(vector == 0) {
return "default";
} else if(vector == 1) {
return "success";
} else if(vector == -1) {
return "danger";
}
}
$scope.clearItemHistory = function() {
if(!confirm("Are you sure you want to delete the local session history for this note?")) {
return;
}
sessionHistory.clearItemHistory($scope.item).then(() => {
$timeout(() => {
$scope.reloadHistory();
})
});
}
$scope.clearAllHistory = function() {
if(!confirm("Are you sure you want to delete the local session history for all notes?")) {
return;
}
sessionHistory.clearAllHistory().then(() => {
$timeout(() => {
$scope.reloadHistory();
})
});
}
$scope.toggleDiskSaving = function() {
sessionHistory.toggleDiskSaving().then(() => {
$timeout(() => {
$scope.diskEnabled = sessionHistory.diskEnabled;
})
});
}
}
}
angular.module('app').directive('sessionHistoryMenu', () => new SessionHistoryMenu);