Merge pull request #2117 from bentiss/color

Set the card color with the color picker
This commit is contained in:
Lauri Ojansivu 2019-01-22 14:57:00 +02:00 committed by GitHub
commit d8482b533a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 38 deletions

View file

@ -340,34 +340,13 @@ template(name="setCardColorPopup")
p.quiet p.quiet
span.clearfix span.clearfix
label {{_ "select-color"}} label {{_ "select-color"}}
select.js-select-colors form.edit-label
option(value="white") {{{_'color-white'}}} .palette-colors: each colors
option(value="green") {{{_'color-green'}}} span.card-label.palette-color.js-palette-color(class="card-details-{{color}}")
option(value="yellow") {{{_'color-yellow'}}} if(isSelected color)
option(value="orange") {{{_'color-orange'}}} i.fa.fa-check
option(value="red") {{{_'color-red'}}} button.primary.confirm.js-submit {{_ 'save'}}
option(value="purple") {{{_'color-purple'}}} button.js-remove-color.negate.wide.right {{_ 'unset-color'}}
option(value="blue") {{{_'color-blue'}}}
option(value="sky") {{{_'color-sky'}}}
option(value="lime") {{{_'color-lime'}}}
option(value="pink") {{{_'color-pink'}}}
option(value="black") {{{_'color-black'}}}
option(value="silver") {{{_'color-silver'}}}
option(value="peachpuff") {{{_'color-peachpuff'}}}
option(value="crimson") {{{_'color-crimson'}}}
option(value="plum") {{{_'color-plum'}}}
option(value="darkgreen") {{{_'color-darkgreen'}}}
option(value="slateblue") {{{_'color-slateblue'}}}
option(value="magenta") {{{_'color-magenta'}}}
option(value="gold") {{{_'color-gold'}}}
option(value="navy") {{{_'color-navy'}}}
option(value="gray") {{{_'color-gray'}}}
option(value="saddlebrown") {{{_'color-saddlebrown'}}}
option(value="paleturquoise") {{{_'color-paleturquoise'}}}
option(value="mistyrose") {{{_'color-mistyrose'}}}
option(value="indigo") {{{_'color-indigo'}}}
.edit-controls.clearfix
button.primary.confirm.js-submit {{_ 'save'}}
template(name="cardDeletePopup") template(name="cardDeletePopup")
p {{_ "card-delete-pop"}} p {{_ "card-delete-pop"}}

View file

@ -1,6 +1,11 @@
const subManager = new SubsManager(); const subManager = new SubsManager();
const { calculateIndexData, enableClickOnTouch } = Utils; const { calculateIndexData, enableClickOnTouch } = Utils;
let cardColors;
Meteor.startup(() => {
cardColors = Cards.simpleSchema()._schema['color'].allowedValues;
});
BlazeComponent.extendComponent({ BlazeComponent.extendComponent({
mixins() { mixins() {
return [Mixins.InfiniteScrolling, Mixins.PerfectScrollbar]; return [Mixins.InfiniteScrolling, Mixins.PerfectScrollbar];
@ -585,17 +590,36 @@ Template.copyChecklistToManyCardsPopup.events({
}, },
}); });
Template.setCardColorPopup.events({ BlazeComponent.extendComponent({
'click .js-submit' () { onCreated() {
// XXX We should *not* get the currentCard from the global state, but this.currentCard = this.currentData();
// instead from a “component” state. this.currentColor = new ReactiveVar(this.currentCard.color);
const card = Cards.findOne(Session.get('currentCard'));
const colorSelect = $('.js-select-colors')[0];
newColor = colorSelect.options[colorSelect.selectedIndex].value;
card.setColor(newColor);
Popup.close();
}, },
});
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({ BlazeComponent.extendComponent({
onCreated() { onCreated() {

View file

@ -192,6 +192,7 @@
"color-slateblue": "slateblue", "color-slateblue": "slateblue",
"color-white": "white", "color-white": "white",
"color-yellow": "yellow", "color-yellow": "yellow",
"unset-color": "Unset",
"comment": "Comment", "comment": "Comment",
"comment-placeholder": "Write Comment", "comment-placeholder": "Write Comment",
"comment-only": "Comment only", "comment-only": "Comment only",