remove feature

This commit is contained in:
guillaume 2019-04-23 18:00:09 +02:00
parent 6933424fca
commit 8137f2692f
10 changed files with 135 additions and 14 deletions

View file

@ -2,6 +2,10 @@ template(name="archivesSidebar")
+basicTabs(tabs=tabs) +basicTabs(tabs=tabs)
+tabContent(slug="cards") +tabContent(slug="cards")
p.quiet
a.js-restore-all-cards {{_ 'restore-all'}}
| -
a.js-delete-all-cards {{_ 'delete-all'}}
each archivedCards each archivedCards
.minicard-wrapper.js-minicard .minicard-wrapper.js-minicard
+minicard(this) +minicard(this)
@ -16,23 +20,35 @@ template(name="archivesSidebar")
p.no-items-message {{_ 'no-archived-cards'}} p.no-items-message {{_ 'no-archived-cards'}}
+tabContent(slug="lists") +tabContent(slug="lists")
p.quiet
a.js-restore-all-lists {{_ 'restore-all'}}
| -
a.js-delete-all-lists {{_ 'delete-all'}}
ul.archived-lists ul.archived-lists
each archivedLists each archivedLists
li.archived-lists-item li.archived-lists-item
if currentUser.isBoardMember
button.js-restore-list
i.fa.fa-undo
= title = title
if currentUser.isBoardMember
p.quiet
a.js-restore-list {{_ 'restore'}}
| -
a.js-delete-list {{_ 'delete'}}
else else
li.no-items-message {{_ 'no-archived-lists'}} li.no-items-message {{_ 'no-archived-lists'}}
+tabContent(slug="swimlanes") +tabContent(slug="swimlanes")
p.quiet
a.js-restore-all-swimlanes {{_ 'restore-all'}}
| -
a.js-delete-all-swimlanes {{_ 'delete-all'}}
ul.archived-lists ul.archived-lists
each archivedSwimlanes each archivedSwimlanes
li.archived-lists-item li.archived-lists-item
if currentUser.isBoardMember
button.js-restore-swimlane
i.fa.fa-undo
= title = title
if currentUser.isBoardMember
p.quiet
a.js-restore-swimlane {{_ 'restore'}}
| -
a.js-delete-swimlane {{_ 'delete'}}
else else
li.no-items-message {{_ 'no-archived-swimlanes'}} li.no-items-message {{_ 'no-archived-swimlanes'}}

View file

@ -44,19 +44,67 @@ BlazeComponent.extendComponent({
card.restore(); card.restore();
} }
}, },
'click .js-restore-all-cards'() {
this.archivedCards().forEach((card) => {
if(card.canBeRestored()){
card.restore();
}
});
},
'click .js-delete-card': Popup.afterConfirm('cardDelete', function() { 'click .js-delete-card': Popup.afterConfirm('cardDelete', function() {
const cardId = this._id; const cardId = this._id;
Cards.remove(cardId); Cards.remove(cardId);
Popup.close(); Popup.close();
}), }),
'click .js-delete-all-cards': Popup.afterConfirm('cardDelete', () => {
this.archivedCards().forEach((card) => {
Cards.remove(card._id);
});
Popup.close();
}),
'click .js-restore-list'() { 'click .js-restore-list'() {
const list = this.currentData(); const list = this.currentData();
list.restore(); list.restore();
}, },
'click .js-restore-all-lists'() {
this.archivedLists().forEach((list) => {
list.restore();
});
},
'click .js-delete-list': Popup.afterConfirm('listDelete', function() {
this.remove();
Popup.close();
}),
'click .js-delete-all-lists': Popup.afterConfirm('listDelete', () => {
this.archivedLists().forEach((list) => {
list.remove();
});
Popup.close();
}),
'click .js-restore-swimlane'() { 'click .js-restore-swimlane'() {
const swimlane = this.currentData(); const swimlane = this.currentData();
swimlane.restore(); swimlane.restore();
}, },
'click .js-restore-all-swimlanes'() {
this.archivedSwimlanes().forEach((swimlane) => {
swimlane.restore();
});
},
'click .js-delete-swimlane': Popup.afterConfirm('swimlaneDelete', function() {
this.remove();
Popup.close();
}),
'click .js-delete-all-swimlanes': Popup.afterConfirm('swimlaneDelete', () => {
this.archivedSwimlanes().forEach((swimlane) => {
swimlane.remove();
});
Popup.close();
}),
}]; }];
}, },
}).register('archivesSidebar'); }).register('archivesSidebar');

View file

@ -54,3 +54,7 @@ template(name="setSwimlaneColorPopup")
i.fa.fa-check i.fa.fa-check
button.primary.confirm.js-submit {{_ 'save'}} button.primary.confirm.js-submit {{_ 'save'}}
button.js-remove-color.negate.wide.right {{_ 'unset-color'}} button.js-remove-color.negate.wide.right {{_ 'unset-color'}}
template(name="swimlaneDeletePopup")
p {{_ "swimlane-delete-pop"}}
button.js-confirm.negate.full(type="submit") {{_ 'delete'}}

View file

@ -687,5 +687,9 @@
"display-authentication-method": "Display Authentication Method", "display-authentication-method": "Display Authentication Method",
"default-authentication-method": "Default Authentication Method", "default-authentication-method": "Default Authentication Method",
"duplicate-board": "Duplicate Board", "duplicate-board": "Duplicate Board",
"people-number": "The number of people is: " "people-number": "The number of people is: ",
"swimlaneDeletePopup-title": "Delete Swimlane ?",
"swimlane-delete-pop": "All actions will be removed from the activity feed and you won't be able to recover the swimlane. There is no undo.",
"restore-all": "Restore all",
"delete-all": "Delete all"
} }

View file

@ -684,5 +684,9 @@
"display-authentication-method": "Afficher la méthode d'authentification", "display-authentication-method": "Afficher la méthode d'authentification",
"default-authentication-method": "Méthode d'authentification par défaut", "default-authentication-method": "Méthode d'authentification par défaut",
"duplicate-board": "Dupliquer le tableau", "duplicate-board": "Dupliquer le tableau",
"people-number": "Le nombre d'utilisateurs est de :" "people-number": "Le nombre d'utilisateurs est de :",
} "swimlaneDeletePopup-title": "Supprimer le couloir ?",
"swimlane-delete-pop": "Toutes les actions vont être supprimées du suivi d'activités et vous ne pourrez plus utiliser ce couloir. Cette action est irréversible.",
"restore-all": "Tout supprimer",
"delete-all": "Tout restaurer"
}

View file

@ -803,6 +803,13 @@ Boards.mutations({
}, },
}); });
function boardRemover(userId, doc) {
[Cards, Lists, Swimlanes, Integrations, Rules, Activities].forEach((element) => {
element.remove({ boardId: doc._id });
});
}
if (Meteor.isServer) { if (Meteor.isServer) {
Boards.allow({ Boards.allow({
insert: Meteor.userId, insert: Meteor.userId,
@ -966,6 +973,18 @@ if (Meteor.isServer) {
} }
}); });
Boards.before.remove((userId, doc) => {
boardRemover(userId, doc);
// Add removeBoard activity to keep it
Activities.insert({
userId,
type: 'board',
activityTypeId: doc._id,
activityType: 'removeBoard',
boardId: doc._id,
});
});
// Add a new activity if we add or remove a member to the board // Add a new activity if we add or remove a member to the board
Boards.after.update((userId, doc, fieldNames, modifier) => { Boards.after.update((userId, doc, fieldNames, modifier) => {
if (!_.contains(fieldNames, 'members')) { if (!_.contains(fieldNames, 'members')) {

View file

@ -1518,7 +1518,7 @@ function cardCreation(userId, doc) {
} }
function cardRemover(userId, doc) { function cardRemover(userId, doc) {
Activities.remove({ ChecklistItems.remove({
cardId: doc._id, cardId: doc._id,
}); });
Checklists.remove({ Checklists.remove({
@ -1583,7 +1583,7 @@ if (Meteor.isServer) {
// Remove all activities associated with a card if we remove the card // Remove all activities associated with a card if we remove the card
// Remove also card_comments / checklists / attachments // Remove also card_comments / checklists / attachments
Cards.after.remove((userId, doc) => { Cards.before.remove((userId, doc) => {
cardRemover(userId, doc); cardRemover(userId, doc);
}); });
} }

View file

@ -157,8 +157,6 @@ if (Meteor.isServer) {
listId: doc.listId, listId: doc.listId,
swimlaneId: doc.swimlaneId, swimlaneId: doc.swimlaneId,
}); });
}); });
} }

View file

@ -217,6 +217,10 @@ Lists.helpers({
isTemplateList() { isTemplateList() {
return this.type === 'template-list'; return this.type === 'template-list';
}, },
remove() {
Lists.remove({ _id: this._id});
},
}); });
Lists.mutations({ Lists.mutations({
@ -310,6 +314,12 @@ if (Meteor.isServer) {
}); });
Lists.before.remove((userId, doc) => { Lists.before.remove((userId, doc) => {
const cards = Cards.find({ listId: doc._id });
if (cards) {
cards.forEach((card) => {
Cards.remove(card._id);
});
}
Activities.insert({ Activities.insert({
userId, userId,
type: 'list', type: 'list',

View file

@ -180,6 +180,10 @@ Swimlanes.helpers({
const user = Users.findOne(Meteor.userId()); const user = Users.findOne(Meteor.userId());
return user.profile.boardTemplatesSwimlaneId === this._id; return user.profile.boardTemplatesSwimlaneId === this._id;
}, },
remove() {
Swimlanes.remove({ _id: this._id});
},
}); });
Swimlanes.mutations({ Swimlanes.mutations({
@ -234,7 +238,21 @@ if (Meteor.isServer) {
}); });
}); });
Swimlanes.before.remove((userId, doc) => { Swimlanes.before.remove(function(userId, doc) {
const lists = Lists.find({
boardId: doc.boardId,
swimlaneId: {$in: [doc._id, '']},
archived: false,
}, { sort: ['sort'] });
if (lists.count() < 2) {
lists.forEach((list) => {
list.remove();
});
} else {
Cards.remove({swimlaneId: doc._id});
}
Activities.insert({ Activities.insert({
userId, userId,
type: 'swimlane', type: 'swimlane',