Added the option to "restore" and archived card

This commit is contained in:
Giulio Cesare Solaroli 2014-10-12 10:56:27 +02:00
parent c1041f75ca
commit a891853d32
3 changed files with 15 additions and 8 deletions

View File

@ -250,8 +250,15 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.Record, Clipperz.PM.DataModel.Encrypt
], {trace:false});
},
'archive': function () {
return this.addTag(Clipperz.PM.DataModel.Record.archivedTag);
'toggleArchive': function () {
return Clipperz.Async.callbacks("Record.toggleArchive", [
MochiKit.Base.method(this, 'isArchived'),
Clipperz.Async.deferredIf("Record is archived", [
MochiKit.Base.method(this, 'removeTag', Clipperz.PM.DataModel.Record.archivedTag)
], [
MochiKit.Base.method(this, 'addTag', Clipperz.PM.DataModel.Record.archivedTag)
]),
], {trace:false});
},
'isArchived': function () {

View File

@ -38,7 +38,7 @@ Clipperz.PM.UI.Components.Cards.CommandToolbar = React.createClass({
getInitialState: function() {
return {'showCommandMenu': false };
},
//----------------------------------------------------------------------------
commands: function () {
@ -48,8 +48,8 @@ Clipperz.PM.UI.Components.Cards.CommandToolbar = React.createClass({
'broadcastEvent': 'deleteCard'
},
'archive': {
'label': "archive",
'broadcastEvent': 'archiveCard'
'label': this.props['_isArchived'] ? "restore" : "archive",
'broadcastEvent': 'toggleArchiveCard'
},
// 'share': {
// 'label': "share",

View File

@ -65,7 +65,7 @@ Clipperz.PM.UI.MainController = function() {
'saveCardEdits', 'cancelCardEdits',
'cardSelected',
'addCardClick',
'deleteCard', 'archiveCard', 'cloneCard', 'editCard',
'deleteCard', 'toggleArchiveCard', 'cloneCard', 'editCard',
'addTag', 'removeTag',
'showArchivedCards', 'hideArchivedCards',
'goBackToMainPage',
@ -1056,10 +1056,10 @@ console.log("SET USER", aUser);
], {trace:false});
},
archiveCard_handler: function (anEvent) {
toggleArchiveCard_handler: function (anEvent) {
return Clipperz.Async.callbacks("MainController.archiveCard_handler", [
MochiKit.Base.method(this.user(), 'getRecord', anEvent['reference']),
MochiKit.Base.methodcaller('archive'),
MochiKit.Base.methodcaller('toggleArchive'),
MochiKit.Base.method(this.user(), 'saveChanges'),
MochiKit.Base.method(this, 'refreshUI', anEvent['reference'])
], {trace:false});