Browse Source

Add colors to swimlanes

fixes #1688
Benjamin Tissoires 6 years ago
parent
commit
03efeaeb1a

+ 13 - 1
client/components/swimlanes/swimlaneHeader.jade

@@ -1,5 +1,5 @@
 template(name="swimlaneHeader")
 template(name="swimlaneHeader")
-  .swimlane-header-wrap.js-swimlane-header
+  .swimlane-header-wrap.js-swimlane-header(class='{{#if colorClass}}swimlane-{{colorClass}}{{/if}}')
     +inlinedForm
     +inlinedForm
       +editSwimlaneTitleForm
       +editSwimlaneTitleForm
     else
     else
@@ -20,6 +20,9 @@ template(name="editSwimlaneTitleForm")
 
 
 template(name="swimlaneActionPopup")
 template(name="swimlaneActionPopup")
   unless currentUser.isCommentOnly
   unless currentUser.isCommentOnly
+    ul.pop-over-list
+       li: a.js-set-swimlane-color {{_ 'select-color'}}
+    hr
     ul.pop-over-list
     ul.pop-over-list
       li: a.js-close-swimlane {{_ 'archive-swimlane'}}
       li: a.js-close-swimlane {{_ 'archive-swimlane'}}
 
 
@@ -30,3 +33,12 @@ template(name="swimlaneAddPopup")
         autocomplete="off" autofocus)
         autocomplete="off" autofocus)
       .edit-controls.clearfix
       .edit-controls.clearfix
         button.primary.confirm(type="submit") {{_ 'add'}}
         button.primary.confirm(type="submit") {{_ 'add'}}
+
+template(name="setSwimlaneColorPopup")
+  form.edit-label
+    .palette-colors: each colors
+      span.card-label.palette-color.js-palette-color(class="card-details-{{color}}")
+        if(isSelected color)
+          i.fa.fa-check
+    button.primary.confirm.js-submit {{_ 'save'}}
+    button.js-remove-color.negate.wide.right {{_ 'unset-color'}}

+ 37 - 0
client/components/swimlanes/swimlaneHeader.js

@@ -1,5 +1,10 @@
 const { calculateIndexData } = Utils;
 const { calculateIndexData } = Utils;
 
 
+let swimlaneColors;
+Meteor.startup(() => {
+  swimlaneColors = Swimlanes.simpleSchema()._schema.color.allowedValues;
+});
+
 BlazeComponent.extendComponent({
 BlazeComponent.extendComponent({
   editTitle(evt) {
   editTitle(evt) {
     evt.preventDefault();
     evt.preventDefault();
@@ -20,6 +25,7 @@ BlazeComponent.extendComponent({
 }).register('swimlaneHeader');
 }).register('swimlaneHeader');
 
 
 Template.swimlaneActionPopup.events({
 Template.swimlaneActionPopup.events({
+  'click .js-set-swimlane-color': Popup.open('setSwimlaneColor'),
   'click .js-close-swimlane' (evt) {
   'click .js-close-swimlane' (evt) {
     evt.preventDefault();
     evt.preventDefault();
     this.archive();
     this.archive();
@@ -60,3 +66,34 @@ BlazeComponent.extendComponent({
     }];
     }];
   },
   },
 }).register('swimlaneAddPopup');
 }).register('swimlaneAddPopup');
+
+BlazeComponent.extendComponent({
+  onCreated() {
+    this.currentSwimlane = this.currentData();
+    this.currentColor = new ReactiveVar(this.currentSwimlane.color);
+  },
+
+  colors() {
+    return swimlaneColors.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.currentSwimlane.setColor(this.currentColor.get());
+        Popup.close();
+      },
+      'click .js-remove-color'() {
+        this.currentSwimlane.setColor(null);
+        Popup.close();
+      },
+    }];
+  },
+}).register('setSwimlaneColorPopup');

+ 81 - 0
client/components/swimlanes/swimlanes.styl

@@ -53,3 +53,84 @@
 .list-group
 .list-group
   flex-direction: row
   flex-direction: row
   height: 100%
   height: 100%
+
+swimlane-color(background, color...)
+  background: background !important
+  if color
+    color: color !important //overwrite text for better visibility
+
+.swimlane-white
+  swimlane-color(#ffffff, #4d4d4d) //Black text for better visibility
+  border: 1px solid #eee
+
+.swimlane-green
+  swimlane-color(#3cb500, #ffffff) //White text for better visibility
+
+.swimlane-yellow
+  swimlane-color(#fad900, #4d4d4d) //Black text for better visibility
+
+.swimlane-orange
+  swimlane-color(#ff9f19, #4d4d4d) //Black text for better visibility
+
+.swimlane-red
+  swimlane-color(#eb4646, #ffffff) //White text for better visibility
+
+.swimlane-purple
+  swimlane-color(#a632db, #ffffff) //White text for better visibility
+
+.swimlane-blue
+  swimlane-color(#0079bf, #ffffff) //White text for better visibility
+
+.swimlane-pink
+  swimlane-color(#ff78cb, #4d4d4d) //Black text for better visibility
+
+.swimlane-sky
+  swimlane-color(#00c2e0, #ffffff) //White text for better visibility
+
+.swimlane-black
+  swimlane-color(#4d4d4d, #ffffff) //White text for better visibility
+
+.swimlane-lime
+  swimlane-color(#51e898, #4d4d4d) //Black text for better visibility
+
+.swimlane-silver
+  swimlane-color(unset, #4d4d4d) //Black text for better visibility
+
+.swimlane-peachpuff
+  swimlane-color(#ffdab9, #4d4d4d) //Black text for better visibility
+
+.swimlane-crimson
+  swimlane-color(#dc143c, #ffffff) //White text for better visibility
+
+.swimlane-plum
+  swimlane-color(#dda0dd, #4d4d4d) //Black text for better visibility
+
+.swimlane-darkgreen
+  swimlane-color(#006400, #ffffff) //White text for better visibility
+
+.swimlane-slateblue
+  swimlane-color(#6a5acd, #ffffff) //White text for better visibility
+
+.swimlane-magenta
+  swimlane-color(#ff00ff, #ffffff) //White text for better visibility
+
+.swimlane-gold
+  swimlane-color(#ffd700, #4d4d4d) //Black text for better visibility
+
+.swimlane-navy
+  swimlane-color(#000080, #ffffff) //White text for better visibility
+
+.swimlane-gray
+  swimlane-color(#808080, #ffffff) //White text for better visibility
+
+.swimlane-saddlebrown
+  swimlane-color(#8b4513, #ffffff) //White text for better visibility
+
+.swimlane-paleturquoise
+  swimlane-color(#afeeee, #4d4d4d) //Black text for better visibility
+
+.swimlane-mistyrose
+  swimlane-color(#ffe4e1, #4d4d4d) //Black text for better visibility
+
+.swimlane-indigo
+  swimlane-color(#4b0082, #ffffff) //White text for better visibility

+ 1 - 0
i18n/en.i18n.json

@@ -520,6 +520,7 @@
     "editCardEndDatePopup-title": "Change end date",
     "editCardEndDatePopup-title": "Change end date",
     "setCardColorPopup-title": "Set color",
     "setCardColorPopup-title": "Set color",
     "setCardActionsColorPopup-title": "Choose a color",
     "setCardActionsColorPopup-title": "Choose a color",
+    "setSwimlaneColorPopup-title": "Choose a color",
     "assigned-by": "Assigned By",
     "assigned-by": "Assigned By",
     "requested-by": "Requested By",
     "requested-by": "Requested By",
     "board-delete-notice": "Deleting is permanent. You will lose all lists, cards and actions associated with this board.",
     "board-delete-notice": "Deleting is permanent. You will lose all lists, cards and actions associated with this board.",

+ 32 - 0
models/swimlanes.js

@@ -49,6 +49,21 @@ Swimlanes.attachSchema(new SimpleSchema({
     // XXX We should probably provide a default
     // XXX We should probably provide a default
     optional: true,
     optional: true,
   },
   },
+  color: {
+    /**
+     * the color of the swimlane
+     */
+    type: String,
+    optional: true,
+    // silver is the default, so it is left out
+    allowedValues: [
+      'white', 'green', 'yellow', 'orange', 'red', 'purple',
+      'blue', 'sky', 'lime', 'pink', 'black',
+      'peachpuff', 'crimson', 'plum', 'darkgreen',
+      'slateblue', 'magenta', 'gold', 'navy', 'gray',
+      'saddlebrown', 'paleturquoise', 'mistyrose', 'indigo',
+    ],
+  },
   updatedAt: {
   updatedAt: {
     /**
     /**
      * when was the swimlane last edited
      * when was the swimlane last edited
@@ -93,6 +108,12 @@ Swimlanes.helpers({
   board() {
   board() {
     return Boards.findOne(this.boardId);
     return Boards.findOne(this.boardId);
   },
   },
+
+  colorClass() {
+    if (this.color)
+      return this.color;
+    return '';
+  },
 });
 });
 
 
 Swimlanes.mutations({
 Swimlanes.mutations({
@@ -107,6 +128,17 @@ Swimlanes.mutations({
   restore() {
   restore() {
     return { $set: { archived: false } };
     return { $set: { archived: false } };
   },
   },
+
+  setColor(newColor) {
+    if (newColor === 'silver') {
+      newColor = null;
+    }
+    return {
+      $set: {
+        color: newColor,
+      },
+    };
+  },
 });
 });
 
 
 Swimlanes.hookOptions.after.update = { fetchPrevious: false };
 Swimlanes.hookOptions.after.update = { fetchPrevious: false };