summaryrefslogtreecommitdiffstats
path: root/client/components/cards/cardDetails.js
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2019-01-22 14:57:00 +0200
committerGitHub <noreply@github.com>2019-01-22 14:57:00 +0200
commitd8482b533a3d525071d5733df9e38629da5b8342 (patch)
treeb9c099c9633160529374d7c48ad9123383de6361 /client/components/cards/cardDetails.js
parente8c4e394fdaa23b4af6c3e8c4beb4d64e24f0db8 (diff)
parent2082480ddd91343250d0fc8752750bd8801b45da (diff)
downloadwekan-d8482b533a3d525071d5733df9e38629da5b8342.tar.gz
wekan-d8482b533a3d525071d5733df9e38629da5b8342.tar.bz2
wekan-d8482b533a3d525071d5733df9e38629da5b8342.zip
Merge pull request #2117 from bentiss/color
Set the card color with the color picker
Diffstat (limited to 'client/components/cards/cardDetails.js')
-rw-r--r--client/components/cards/cardDetails.js44
1 files changed, 34 insertions, 10 deletions
diff --git a/client/components/cards/cardDetails.js b/client/components/cards/cardDetails.js
index 7883f129..c936f0f4 100644
--- a/client/components/cards/cardDetails.js
+++ b/client/components/cards/cardDetails.js
@@ -1,6 +1,11 @@
const subManager = new SubsManager();
const { calculateIndexData, enableClickOnTouch } = Utils;
+let cardColors;
+Meteor.startup(() => {
+ cardColors = Cards.simpleSchema()._schema['color'].allowedValues;
+});
+
BlazeComponent.extendComponent({
mixins() {
return [Mixins.InfiniteScrolling, Mixins.PerfectScrollbar];
@@ -585,17 +590,36 @@ Template.copyChecklistToManyCardsPopup.events({
},
});
-Template.setCardColorPopup.events({
- 'click .js-submit' () {
- // XXX We should *not* get the currentCard from the global state, but
- // instead from a “component” state.
- const card = Cards.findOne(Session.get('currentCard'));
- const colorSelect = $('.js-select-colors')[0];
- newColor = colorSelect.options[colorSelect.selectedIndex].value;
- card.setColor(newColor);
- Popup.close();
+BlazeComponent.extendComponent({
+ onCreated() {
+ this.currentCard = this.currentData();
+ this.currentColor = new ReactiveVar(this.currentCard.color);
},
-});
+
+ colors() {
+ return cardColors.map((color) => ({ color, name: '' }));
+ },
+
+ isSelected(color) {
+ return this.currentColor.get() === color;
+ },
+
+ events() {
+ return [{
+ 'click .js-palette-color'() {
+ this.currentColor.set(this.currentData().color);
+ },
+ 'click .js-submit' () {
+ this.currentCard.setColor(this.currentColor.get());
+ Popup.close();
+ },
+ 'click .js-remove-color'() {
+ this.currentCard.setColor(null);
+ Popup.close();
+ },
+ }];
+ },
+}).register('setCardColorPopup');
BlazeComponent.extendComponent({
onCreated() {