mirror of
https://github.com/wekan/wekan.git
synced 2025-12-23 02:40:14 +01:00
Allow description and member two way binding
This commit is contained in:
parent
a93de07fb9
commit
0a62089df0
6 changed files with 82 additions and 14 deletions
|
|
@ -55,7 +55,7 @@ template(name="cardDetails")
|
||||||
.card-details-items
|
.card-details-items
|
||||||
.card-details-item.card-details-item-members
|
.card-details-item.card-details-item-members
|
||||||
h3.card-details-item-title {{_ 'members'}}
|
h3.card-details-item-title {{_ 'members'}}
|
||||||
each members
|
each getMembers
|
||||||
+userAvatar(userId=this cardId=../_id)
|
+userAvatar(userId=this cardId=../_id)
|
||||||
| {{! XXX Hack to hide syntaxic coloration /// }}
|
| {{! XXX Hack to hide syntaxic coloration /// }}
|
||||||
if canModifyCard
|
if canModifyCard
|
||||||
|
|
@ -92,15 +92,15 @@ template(name="cardDetails")
|
||||||
h3.card-details-item-title {{_ 'description'}}
|
h3.card-details-item-title {{_ 'description'}}
|
||||||
+inlinedCardDescription(classNames="card-description js-card-description")
|
+inlinedCardDescription(classNames="card-description js-card-description")
|
||||||
+editor(autofocus=true)
|
+editor(autofocus=true)
|
||||||
| {{getUnsavedValue 'cardDescription' _id description}}
|
| {{getUnsavedValue 'cardDescription' _id getDescription}}
|
||||||
.edit-controls.clearfix
|
.edit-controls.clearfix
|
||||||
button.primary(type="submit") {{_ 'save'}}
|
button.primary(type="submit") {{_ 'save'}}
|
||||||
a.fa.fa-times-thin.js-close-inlined-form
|
a.fa.fa-times-thin.js-close-inlined-form
|
||||||
else
|
else
|
||||||
a.js-open-inlined-form
|
a.js-open-inlined-form
|
||||||
if description
|
if getDescription
|
||||||
+viewer
|
+viewer
|
||||||
= description
|
= getDescription
|
||||||
else
|
else
|
||||||
| {{_ 'edit'}}
|
| {{_ 'edit'}}
|
||||||
if (hasUnsavedValue 'cardDescription' _id)
|
if (hasUnsavedValue 'cardDescription' _id)
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,7 @@ BlazeComponent.extendComponent({
|
||||||
},
|
},
|
||||||
|
|
||||||
canModifyCard() {
|
canModifyCard() {
|
||||||
return Meteor.user() && Meteor.user().isBoardMember() &&
|
return Meteor.user() && Meteor.user().isBoardMember() && !Meteor.user().isCommentOnly();
|
||||||
!Meteor.user().isCommentOnly() && !this.currentData().isImported();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
scrollParentContainer() {
|
scrollParentContainer() {
|
||||||
|
|
@ -275,7 +274,7 @@ BlazeComponent.extendComponent({
|
||||||
close(isReset = false) {
|
close(isReset = false) {
|
||||||
if (this.isOpen.get() && !isReset) {
|
if (this.isOpen.get() && !isReset) {
|
||||||
const draft = this.getValue().trim();
|
const draft = this.getValue().trim();
|
||||||
if (draft !== Cards.findOne(Session.get('currentCard')).description) {
|
if (draft !== Cards.findOne(Session.get('currentCard')).getDescription()) {
|
||||||
UnsavedEdits.set(this._getUnsavedEditKey(), this.getValue());
|
UnsavedEdits.set(this._getUnsavedEditKey(), this.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,9 +57,9 @@ template(name="minicard")
|
||||||
+viewer
|
+viewer
|
||||||
= trueValue
|
= trueValue
|
||||||
|
|
||||||
if members
|
if getMembers
|
||||||
.minicard-members.js-minicard-members
|
.minicard-members.js-minicard-members
|
||||||
each members
|
each getMembers
|
||||||
+userAvatar(userId=this)
|
+userAvatar(userId=this)
|
||||||
|
|
||||||
.badges
|
.badges
|
||||||
|
|
|
||||||
|
|
@ -300,9 +300,10 @@ BlazeComponent.extendComponent({
|
||||||
// Swimlane where to insert card
|
// Swimlane where to insert card
|
||||||
const swimlane = $(Popup._getTopStack().openerElement).closest('.js-swimlane');
|
const swimlane = $(Popup._getTopStack().openerElement).closest('.js-swimlane');
|
||||||
this.swimlaneId = '';
|
this.swimlaneId = '';
|
||||||
if (board.view === 'board-view-swimlanes')
|
const boardView = Meteor.user().profile.boardView;
|
||||||
|
if (boardView === 'board-view-swimlanes')
|
||||||
this.swimlaneId = Blaze.getData(swimlane[0])._id;
|
this.swimlaneId = Blaze.getData(swimlane[0])._id;
|
||||||
else
|
else if (boardView === 'board-view-lists')
|
||||||
this.swimlaneId = Swimlanes.findOne({boardId: this.boardId})._id;
|
this.swimlaneId = Swimlanes.findOne({boardId: this.boardId})._id;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -382,7 +383,6 @@ BlazeComponent.extendComponent({
|
||||||
sort: Lists.findOne(this.listId).cards().count(),
|
sort: Lists.findOne(this.listId).cards().count(),
|
||||||
type: 'cardType-importedBoard',
|
type: 'cardType-importedBoard',
|
||||||
importedId: impBoardId,
|
importedId: impBoardId,
|
||||||
description: Boards.findOne({_id: impBoardId}).description,
|
|
||||||
});
|
});
|
||||||
Filter.addException(_id);
|
Filter.addException(_id);
|
||||||
Popup.close();
|
Popup.close();
|
||||||
|
|
|
||||||
|
|
@ -134,8 +134,9 @@ BlazeComponent.extendComponent({
|
||||||
|
|
||||||
Template.cardMembersPopup.helpers({
|
Template.cardMembersPopup.helpers({
|
||||||
isCardMember() {
|
isCardMember() {
|
||||||
const cardId = Template.parentData()._id;
|
const card = Template.parentData();
|
||||||
const cardMembers = Cards.findOne(cardId).members || [];
|
const cardMembers = card.getMembers();
|
||||||
|
|
||||||
return _.contains(cardMembers, this.userId);
|
return _.contains(cardMembers, this.userId);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -406,6 +406,18 @@ Cards.helpers({
|
||||||
return this.isImportedCard() || this.isImportedBoard();
|
return this.isImportedCard() || this.isImportedBoard();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setDescription(description) {
|
||||||
|
if (this.isImportedCard()) {
|
||||||
|
const card = Cards.findOne({_id: this.importedId});
|
||||||
|
return Cards.update({_id: this.importedId}, {$set: {description}});
|
||||||
|
} else if (this.isImportedBoard()) {
|
||||||
|
const board = Boards.findOne({_id: this.importedId});
|
||||||
|
return Boards.update({_id: this.importedId}, {$set: {description}});
|
||||||
|
} else {
|
||||||
|
return {$set: {description}};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
getDescription() {
|
getDescription() {
|
||||||
if (this.isImportedCard()) {
|
if (this.isImportedCard()) {
|
||||||
const card = Cards.findOne({_id: this.importedId});
|
const card = Cards.findOne({_id: this.importedId});
|
||||||
|
|
@ -426,6 +438,62 @@ Cards.helpers({
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getMembers() {
|
||||||
|
if (this.isImportedCard()) {
|
||||||
|
const card = Cards.findOne({_id: this.importedId});
|
||||||
|
return card.members;
|
||||||
|
} else if (this.isImportedBoard()) {
|
||||||
|
const board = Boards.findOne({_id: this.importedId});
|
||||||
|
return board.activeMembers().map((member) => {
|
||||||
|
return member.userId;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return this.members;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
assignMember(memberId) {
|
||||||
|
if (this.isImportedCard()) {
|
||||||
|
return Cards.update(
|
||||||
|
{ _id: this.importedId },
|
||||||
|
{ $addToSet: { members: memberId }}
|
||||||
|
);
|
||||||
|
} else if (this.isImportedBoard()) {
|
||||||
|
const board = Boards.findOne({_id: this.importedId});
|
||||||
|
return board.addMember(memberId);
|
||||||
|
} else {
|
||||||
|
return Cards.update(
|
||||||
|
{ _id: this._id },
|
||||||
|
{ $addToSet: { members: memberId}}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
unassignMember(memberId) {
|
||||||
|
if (this.isImportedCard()) {
|
||||||
|
return Cards.update(
|
||||||
|
{ _id: this.importedId },
|
||||||
|
{ $pull: { members: memberId }}
|
||||||
|
);
|
||||||
|
} else if (this.isImportedBoard()) {
|
||||||
|
const board = Boards.findOne({_id: this.importedId});
|
||||||
|
return board.removeMember(memberId);
|
||||||
|
} else {
|
||||||
|
return Cards.update(
|
||||||
|
{ _id: this._id },
|
||||||
|
{ $pull: { members: memberId}}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
toggleMember(memberId) {
|
||||||
|
if (this.getMembers() && this.getMembers().indexOf(memberId) > -1) {
|
||||||
|
return this.unassignMember(memberId);
|
||||||
|
} else {
|
||||||
|
return this.assignMember(memberId);
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
Cards.mutations({
|
Cards.mutations({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue