summaryrefslogtreecommitdiffstats
path: root/client/components/cards
diff options
context:
space:
mode:
authorMaxime Quandalle <maxime@quandalle.com>2015-09-03 23:12:46 +0200
committerMaxime Quandalle <maxime@quandalle.com>2015-09-03 23:12:46 +0200
commitb3851817ecd59b039f2c2228d08a1c6fd8e60d60 (patch)
tree82a50f69788d5c20632f3ec9c7d3e136502b93b4 /client/components/cards
parent039cfe7edf8faf901069a94b3ca9b66f7973b26a (diff)
downloadwekan-b3851817ecd59b039f2c2228d08a1c6fd8e60d60.tar.gz
wekan-b3851817ecd59b039f2c2228d08a1c6fd8e60d60.tar.bz2
wekan-b3851817ecd59b039f2c2228d08a1c6fd8e60d60.zip
Enforce a consistent ES6 coding style
Replace the old (and broken) jshint + jscsrc by eslint and configure it to support some of the ES6 features. The command `eslint` currently has one error which is a bug that was discovered by its static analysis and should be fixed (usage of a dead object).
Diffstat (limited to 'client/components/cards')
-rw-r--r--client/components/cards/attachments.js24
-rw-r--r--client/components/cards/cardDetails.js102
-rw-r--r--client/components/cards/labels.js114
-rw-r--r--client/components/cards/minicard.js4
4 files changed, 122 insertions, 122 deletions
diff --git a/client/components/cards/attachments.js b/client/components/cards/attachments.js
index 9e299cc0..ba56aa1a 100644
--- a/client/components/cards/attachments.js
+++ b/client/components/cards/attachments.js
@@ -1,32 +1,32 @@
Template.attachmentsGalery.events({
'click .js-add-attachment': Popup.open('cardAttachments'),
'click .js-confirm-delete': Popup.afterConfirm('attachmentDelete',
- function() {
+ () => {
Attachments.remove(this._id);
Popup.close();
}
),
// If we let this event bubble, FlowRouter will handle it and empty the page
// content, see #101.
- 'click .js-download': function(event) {
+ 'click .js-download'(event) {
event.stopPropagation();
},
- 'click .js-open-viewer': function() {
+ 'click .js-open-viewer'() {
// XXX Not implemented!
},
- 'click .js-add-cover': function() {
+ 'click .js-add-cover'() {
Cards.update(this.cardId, { $set: { coverId: this._id } });
},
- 'click .js-remove-cover': function() {
+ 'click .js-remove-cover'() {
Cards.update(this.cardId, { $unset: { coverId: '' } });
- }
+ },
});
Template.cardAttachmentsPopup.events({
- 'change .js-attach-file': function(evt) {
- var card = this;
- FS.Utility.eachFile(evt, function(f) {
- var file = new FS.File(f);
+ 'change .js-attach-file'(evt) {
+ const card = this;
+ FS.Utility.eachFile(evt, (f) => {
+ const file = new FS.File(f);
file.boardId = card.boardId;
file.cardId = card._id;
@@ -34,8 +34,8 @@ Template.cardAttachmentsPopup.events({
Popup.close();
});
},
- 'click .js-computer-upload': function(evt, tpl) {
+ 'click .js-computer-upload'(evt, tpl) {
tpl.find('.js-attach-file').click();
evt.preventDefault();
- }
+ },
});
diff --git a/client/components/cards/cardDetails.js b/client/components/cards/cardDetails.js
index aba7254a..69e0cfdd 100644
--- a/client/components/cards/cardDetails.js
+++ b/client/components/cards/cardDetails.js
@@ -1,39 +1,39 @@
BlazeComponent.extendComponent({
- template: function() {
+ template() {
return 'cardDetails';
},
- mixins: function() {
+ mixins() {
return [Mixins.InfiniteScrolling, Mixins.PerfectScrollbar];
},
- calculateNextPeak: function() {
- var altitude = this.find('.js-card-details').scrollHeight;
+ calculateNextPeak() {
+ const altitude = this.find('.js-card-details').scrollHeight;
this.callFirstWith(this, 'setNextPeak', altitude);
},
- reachNextPeak: function() {
- var activitiesComponent = this.componentChildren('activities')[0];
+ reachNextPeak() {
+ const activitiesComponent = this.componentChildren('activities')[0];
activitiesComponent.loadNextPage();
},
- onCreated: function() {
+ onCreated() {
this.isLoaded = new ReactiveVar(false);
this.componentParent().showOverlay.set(true);
this.componentParent().mouseHasEnterCardDetails = false;
},
- scrollParentContainer: function() {
+ scrollParentContainer() {
const cardPanelWidth = 510;
- let bodyBoardComponent = this.componentParent();
+ const bodyBoardComponent = this.componentParent();
- let $cardContainer = bodyBoardComponent.$('.js-lists');
- let $cardView = this.$(this.firstNode());
- let cardContainerScroll = $cardContainer.scrollLeft();
- let cardContainerWidth = $cardContainer.width();
+ const $cardContainer = bodyBoardComponent.$('.js-lists');
+ const $cardView = this.$(this.firstNode());
+ const cardContainerScroll = $cardContainer.scrollLeft();
+ const cardContainerWidth = $cardContainer.width();
- let cardViewStart = $cardView.offset().left;
- let cardViewEnd = cardViewStart + cardPanelWidth;
+ const cardViewStart = $cardView.offset().left;
+ const cardViewEnd = cardViewStart + cardPanelWidth;
let offset = false;
if (cardViewStart < 0) {
@@ -47,53 +47,53 @@ BlazeComponent.extendComponent({
}
},
- onRendered: function() {
+ onRendered() {
this.scrollParentContainer();
},
- onDestroyed: function() {
+ onDestroyed() {
this.componentParent().showOverlay.set(false);
},
- updateCard: function(modifier) {
+ updateCard(modifier) {
Cards.update(this.data()._id, {
- $set: modifier
+ $set: modifier,
});
},
- events: function() {
- var events = {
- [CSSEvents.animationend + ' .js-card-details']: function() {
+ events() {
+ const events = {
+ [`${CSSEvents.animationend} .js-card-details`]() {
this.isLoaded.set(true);
- }
+ },
};
return [_.extend(events, {
- 'click .js-close-card-details': function() {
+ 'click .js-close-card-details'() {
Utils.goBoardId(this.data().boardId);
},
'click .js-open-card-details-menu': Popup.open('cardDetailsActions'),
- 'submit .js-card-description': function(evt) {
+ 'submit .js-card-description'(evt) {
evt.preventDefault();
- var description = this.currentComponent().getValue();
- this.updateCard({ description: description });
+ const description = this.currentComponent().getValue();
+ this.updateCard({ description });
},
- 'submit .js-card-details-title': function(evt) {
+ 'submit .js-card-details-title'(evt) {
evt.preventDefault();
- var title = this.currentComponent().getValue();
+ const title = this.currentComponent().getValue();
if ($.trim(title)) {
- this.updateCard({ title: title });
+ this.updateCard({ title });
}
},
'click .js-member': Popup.open('cardMember'),
'click .js-add-members': Popup.open('cardMembers'),
'click .js-add-labels': Popup.open('cardLabels'),
- 'mouseenter .js-card-details': function() {
+ 'mouseenter .js-card-details'() {
this.componentParent().showOverlay.set(true);
this.componentParent().mouseHasEnterCardDetails = true;
- }
+ },
})];
- }
+ },
}).register('cardDetails');
// We extends the normal InlinedForm component to support UnsavedEdits draft
@@ -103,12 +103,12 @@ BlazeComponent.extendComponent({
return {
fieldName: 'cardDescription',
docId: Session.get('currentCard'),
- }
+ };
}
close(isReset = false) {
- if (this.isOpen.get() && ! isReset) {
- let draft = $.trim(this.getValue());
+ if (this.isOpen.get() && !isReset) {
+ const draft = $.trim(this.getValue());
if (draft !== Cards.findOne(Session.get('currentCard')).description) {
UnsavedEdits.set(this._getUnsavedEditKey(), this.getValue());
}
@@ -136,45 +136,45 @@ Template.cardDetailsActionsPopup.events({
'click .js-attachments': Popup.open('cardAttachments'),
'click .js-move-card': Popup.open('moveCard'),
// 'click .js-copy': Popup.open(),
- 'click .js-archive': function(evt) {
+ 'click .js-archive'(evt) {
evt.preventDefault();
Cards.update(this._id, {
$set: {
- archived: true
- }
+ archived: true,
+ },
});
Popup.close();
},
- 'click .js-more': Popup.open('cardMore')
+ 'click .js-more': Popup.open('cardMore'),
});
Template.moveCardPopup.events({
- 'click .js-select-list': function() {
+ 'click .js-select-list'() {
// XXX We should *not* get the currentCard from the global state, but
// instead from a “component” state.
- var cardId = Session.get('currentCard');
- var newListId = this._id;
+ const cardId = Session.get('currentCard');
+ const newListId = this._id;
Cards.update(cardId, {
$set: {
- listId: newListId
- }
+ listId: newListId,
+ },
});
Popup.close();
- }
+ },
});
Template.cardMorePopup.events({
- 'click .js-delete': Popup.afterConfirm('cardDelete', function() {
+ 'click .js-delete': Popup.afterConfirm('cardDelete', () => {
Popup.close();
Cards.remove(this._id);
Utils.goBoardId(this.board()._id);
- })
+ }),
});
// Close the card details pane by pressing escape
EscapeActions.register('detailsPane',
- function() { Utils.goBoardId(Session.get('currentBoard')); },
- function() { return ! Session.equals('currentCard', null); }, {
- noClickEscapeOn: '.js-card-details,.board-sidebar,#header'
+ () => { Utils.goBoardId(Session.get('currentBoard')); },
+ () => { return !Session.equals('currentCard', null); }, {
+ noClickEscapeOn: '.js-card-details,.board-sidebar,#header',
}
);
diff --git a/client/components/cards/labels.js b/client/components/cards/labels.js
index 4e6ceb3a..2da3b80b 100644
--- a/client/components/cards/labels.js
+++ b/client/components/cards/labels.js
@@ -1,136 +1,136 @@
-
-var labelColors;
-Meteor.startup(function() {
+let labelColors;
+Meteor.startup(() => {
labelColors = Boards.simpleSchema()._schema['labels.$.color'].allowedValues;
});
BlazeComponent.extendComponent({
- template: function() {
+ template() {
return 'formLabel';
},
- onCreated: function() {
+ onCreated() {
this.currentColor = new ReactiveVar(this.data().color);
},
- labels: function() {
- return _.map(labelColors, function(color) {
- return { color: color, name: '' };
+ labels() {
+ return _.map(labelColors, (color) => {
+ return { color, name: '' };
});
},
- isSelected: function(color) {
+ isSelected(color) {
return this.currentColor.get() === color;
},
- events: function() {
+ events() {
return [{
- 'click .js-palette-color': function() {
+ 'click .js-palette-color'() {
this.currentColor.set(this.currentData().color);
- }
+ },
}];
- }
+ },
}).register('formLabel');
Template.createLabelPopup.helpers({
// This is the default color for a new label. We search the first color that
// is not already used in the board (although it's not a problem if two
// labels have the same color).
- defaultColor: function() {
- var labels = Boards.findOne(Session.get('currentBoard')).labels;
- var usedColors = _.pluck(labels, 'color');
- var availableColors = _.difference(labelColors, usedColors);
+ defaultColor() {
+ const labels = Boards.findOne(Session.get('currentBoard')).labels;
+ const usedColors = _.pluck(labels, 'color');
+ const availableColors = _.difference(labelColors, usedColors);
return availableColors.length > 1 ? availableColors[0] : labelColors[0];
- }
+ },
});
Template.cardLabelsPopup.events({
- 'click .js-select-label': function(evt) {
- var cardId = Template.parentData(2).data._id;
- var labelId = this._id;
- var operation;
+ 'click .js-select-label'(evt) {
+ const cardId = Template.parentData(2).data._id;
+ const labelId = this._id;
+ let operation;
if (Cards.find({ _id: cardId, labelIds: labelId}).count() === 0)
operation = '$addToSet';
else
operation = '$pull';
- var query = {};
- query[operation] = {
- labelIds: labelId
- };
- Cards.update(cardId, query);
+ Cards.update(cardId, {
+ [operation]: {
+ labelIds: labelId,
+ },
+ });
evt.preventDefault();
},
'click .js-edit-label': Popup.open('editLabel'),
- 'click .js-add-label': Popup.open('createLabel')
+ 'click .js-add-label': Popup.open('createLabel'),
});
Template.formLabel.events({
- 'click .js-palette-color': function(evt) {
- var $this = $(evt.currentTarget);
+ 'click .js-palette-color'(evt) {
+ const $this = $(evt.currentTarget);
// hide selected ll colors
$('.js-palette-select').addClass('hide');
// show select color
$this.find('.js-palette-select').removeClass('hide');
- }
+ },
});
Template.createLabelPopup.events({
// Create the new label
- 'submit .create-label': function(evt, tpl) {
- var name = tpl.$('#labelName').val().trim();
- var boardId = Session.get('currentBoard');
- var color = Blaze.getData(tpl.find('.fa-check')).color;
+ 'submit .create-label'(evt, tpl) {
+ const name = tpl.$('#labelName').val().trim();
+ const boardId = Session.get('currentBoard');
+ const color = Blaze.getData(tpl.find('.fa-check')).color;
Boards.update(boardId, {
$push: {
labels: {
+ name,
+ color,
_id: Random.id(6),
- name: name,
- color: color
- }
- }
+ },
+ },
});
Popup.back();
evt.preventDefault();
- }
+ },
});
Template.editLabelPopup.events({
'click .js-delete-label': Popup.afterConfirm('deleteLabel', function() {
- var boardId = Session.get('currentBoard');
+ const boardId = Session.get('currentBoard');
Boards.update(boardId, {
$pull: {
labels: {
- _id: this._id
- }
- }
+ _id: this._id,
+ },
+ },
});
Popup.back(2);
}),
- 'submit .edit-label': function(evt, tpl) {
+ 'submit .edit-label'(evt, tpl) {
evt.preventDefault();
- var name = tpl.$('#labelName').val().trim();
- var boardId = Session.get('currentBoard');
- var getLabel = Utils.getLabelIndex(boardId, this._id);
- var color = Blaze.getData(tpl.find('.fa-check')).color;
+ const name = tpl.$('#labelName').val().trim();
+ const boardId = Session.get('currentBoard');
+ const getLabel = Utils.getLabelIndex(boardId, this._id);
+ const color = Blaze.getData(tpl.find('.fa-check')).color;
- var $set = {};
- $set[getLabel.key('name')] = name;
- $set[getLabel.key('color')] = color;
-
- Boards.update(boardId, { $set: $set });
+ Boards.update(boardId, {
+ $set: {
+ [getLabel.key('name')]: name,
+ [getLabel.key('color')]: color,
+ },
+ });
Popup.back();
- }
+ },
});
Template.cardLabelsPopup.helpers({
- isLabelSelected: function(cardId) {
+ isLabelSelected(cardId) {
return _.contains(Cards.findOne(cardId).labelIds, this._id);
- }
+ },
});
diff --git a/client/components/cards/minicard.js b/client/components/cards/minicard.js
index 70751152..a98b5730 100644
--- a/client/components/cards/minicard.js
+++ b/client/components/cards/minicard.js
@@ -3,7 +3,7 @@
// });
BlazeComponent.extendComponent({
- template: function() {
+ template() {
return 'minicard';
- }
+ },
}).register('minicard');