Skip to content

Commit

Permalink
Merge pull request #557 from nextcloud/feature/undo-delete-cards-and-…
Browse files Browse the repository at this point in the history
…stacks

Feature/undo delete cards and stacks
  • Loading branch information
juliusknorr authored Aug 15, 2018
2 parents 3e4dedf + 43e76ec commit a3a70f6
Show file tree
Hide file tree
Showing 27 changed files with 447 additions and 141 deletions.
16 changes: 16 additions & 0 deletions appinfo/database.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@
<length>8</length>
<notnull>false</notnull>
</field>
<field>
<name>deleted_at</name>
<type>integer</type>
<default>0</default>
<length>8</length>
<notnull>false</notnull>
<unsigned>true</unsigned>
</field>
<index>
<name>deck_stacks_board_id_index</name>
<field>
Expand Down Expand Up @@ -167,6 +175,14 @@
<type>boolean</type>
<default>false</default>
</field>
<field>
<name>deleted_at</name>
<type>integer</type>
<default>0</default>
<length>8</length>
<notnull>false</notnull>
<unsigned>true</unsigned>
</field>
<index>
<name>deck_cards_stack_id_index</name>
<field>
Expand Down
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
- 🚀 Get your project organized

</description>
<version>0.5.0-dev1</version>
<version>0.5.0-dev2</version>
<licence>agpl</licence>
<author>Julius Härtl</author>
<namespace>Deck</namespace>
Expand Down
10 changes: 6 additions & 4 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
* @author Julius Härtl <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/

return [
Expand All @@ -43,13 +43,15 @@
['name' => 'stack#update', 'url' => '/stacks/{stackId}', 'verb' => 'PUT'],
['name' => 'stack#reorder', 'url' => '/stacks/{stackId}/reorder', 'verb' => 'PUT'],
['name' => 'stack#delete', 'url' => '/stacks/{stackId}', 'verb' => 'DELETE'],
['name' => 'stack#deleted', 'url' => '/{boardId}/stacks/deleted', 'verb' => 'GET'],
['name' => 'stack#archived', 'url' => '/stacks/{boardId}/archived', 'verb' => 'GET'],

// cards
['name' => 'card#read', 'url' => '/cards/{cardId}', 'verb' => 'GET'],
['name' => 'card#create', 'url' => '/cards', 'verb' => 'POST'],
['name' => 'card#update', 'url' => '/cards/{cardId}', 'verb' => 'PUT'],
['name' => 'card#delete', 'url' => '/cards/{cardId}', 'verb' => 'DELETE'],
['name' => 'card#deleted', 'url' => '/{boardId}/cards/deleted', 'verb' => 'GET'],
['name' => 'card#rename', 'url' => '/cards/{cardId}/rename', 'verb' => 'PUT'],
['name' => 'card#reorder', 'url' => '/cards/{cardId}/reorder', 'verb' => 'PUT'],
['name' => 'card#archive', 'url' => '/cards/{cardId}/archive', 'verb' => 'PUT'],
Expand Down
18 changes: 17 additions & 1 deletion css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,16 @@ input.input-inline {
position: relative;
}

.board-detail__deleted-list__item {
display: flex;
flex-direction: row;
justify-content: space-between;

* {
flex-basis: 20%;
}
}

#board-detail-labels {
ul li {
input {
Expand Down Expand Up @@ -1215,12 +1225,18 @@ input.input-inline {

.tabHeaders {
clear: both;
overflow: hidden;
overflow: initial;
margin-bottom: 0;
}

.tabsContainer {
margin-top: 15px;
height: 100%;

.tab {
height: 100%;
overflow: scroll;
}
}

.ui-select-offscreen {
Expand Down
73 changes: 62 additions & 11 deletions js/controller/BoardController.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
* @author Julius Härtl <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/

import app from '../app/App.js';
Expand All @@ -42,6 +42,15 @@ app.controller('BoardController', function ($rootScope, $scope, $stateParams, St
$scope.board = BoardService.getCurrent();
$scope.uploader = FileService.uploader;

$scope.$watch(function() {
return $state.current;
}, function(currentState) {
if(currentState.name === 'board.detail') {
CardService.fetchDeleted($scope.id);
StackService.fetchDeleted($scope.id);
}
});

// workaround for $stateParams changes not being propagated
$scope.$watch(function() {
return $state.params;
Expand Down Expand Up @@ -186,20 +195,58 @@ app.controller('BoardController', function ($rootScope, $scope, $stateParams, St
});
};

$scope.stackDelete = function (stack) {
$scope.stackservice.delete(stack.id);
};

$scope.stackUndoDelete = function (deletedStack) {
return StackService.undoDelete(deletedStack);
};

$scope.cardDelete = function (card) {
OC.dialogs.confirm(t('deck', 'Are you sure you want to delete this card with all of its data?'), t('deck', 'Delete'), function(state) {
if (!state) {
return;
CardService.delete(card.id).then(function () {
StackService.removeCard(card);
});
};

$scope.cardOrCardAndStackUndoDelete = function (deletedCard) {
var associatedDeletedStack = $scope.stackservice.deleted[deletedCard.stackId];
if(associatedDeletedStack !== undefined) {
$scope.cardAndStackUndoDeleteAskForConfirmation(deletedCard, associatedDeletedStack);
} else {
$scope.cardUndoDelete(deletedCard);
}
};

$scope.cardAndStackUndoDeleteAskForConfirmation = function(deletedCard, associatedDeletedStack) {
OC.dialogs.confirm(
t('deck', 'The associated stack is deleted as well, it will be restored as well.'),
t('deck', 'Restore associated stack'),
function(state) {
if (state) {
$scope.cardAndStackUndoDelete(deletedCard, associatedDeletedStack);
}
}
CardService.delete(card.id).then(function () {
StackService.removeCard(card);
});
);
};

$scope.cardAndStackUndoDelete = function(deletedCard, associatedDeletedStack) {
$scope.stackUndoDelete(associatedDeletedStack).then(function() {
$scope.cardUndoDelete(deletedCard);
});
};

$scope.cardUndoDelete = function(deletedCard) {
CardService.undoDelete(deletedCard).then(function() {
StackService.addCard(deletedCard);
});
};

$scope.cardArchive = function (card) {
CardService.archive(card);
StackService.removeCard(card);
};

$scope.isCurrentUserAssigned = function (card) {
if (! CardService.get(card.id).assignedUsers) {
return false;
Expand All @@ -209,6 +256,7 @@ app.controller('BoardController', function ($rootScope, $scope, $stateParams, St
});
return userList.length === 1;
};

$scope.cardAssignToMe = function (card) {
CardService.assignUser(card, OC.getCurrentUser().uid)
.then(
Expand All @@ -217,6 +265,7 @@ app.controller('BoardController', function ($rootScope, $scope, $stateParams, St
// TODO: remove this jquery call. Fix and use appPopoverMenuUtils instead
$('.popovermenu').addClass('hidden');
};

$scope.cardUnassignFromMe = function (card) {
CardService.unassignUser(card, OC.getCurrentUser().uid);
StackService.updateCard(card);
Expand All @@ -235,6 +284,7 @@ app.controller('BoardController', function ($rootScope, $scope, $stateParams, St
BoardService.getCurrent().labels.splice(i, 1);
// TODO: remove from cards
};

$scope.labelCreate = function (label) {
label.boardId = $scope.id;
LabelService.create(label).then(function (data) {
Expand All @@ -254,12 +304,14 @@ app.controller('BoardController', function ($rootScope, $scope, $stateParams, St
BoardService.addAcl(sharee);
$scope.status.addSharee = null;
};

$scope.aclDelete = function (acl) {
BoardService.deleteAcl(acl).then(function(data) {
$scope.loadDefault();
$scope.refreshData();
});
};

$scope.aclUpdate = function (acl) {
BoardService.updateAcl(acl);
};
Expand Down Expand Up @@ -383,5 +435,4 @@ app.controller('BoardController', function ($rootScope, $scope, $stateParams, St
}
return card.attachmentCount;
};

});
Loading

0 comments on commit a3a70f6

Please sign in to comment.