mirror of
https://github.com/wekan/wekan.git
synced 2026-02-24 17:04:07 +01:00
Prefer ES5 methods over underscore utilities
Since 07cc454 (ie the switch to Meteor 1.2) we includes the `es5-shim`
polyfill to support methods like `Array.prototype.forEach` in a
consistent way across all supported browsers (IE8+).
MDG recently released a blog post recommending the use of these native
methods instead of underscore [0]. We know follow this recommendation.
This commit also favor some ES6 features (argument defaults,
destructing assignment) in places where we didn’t use them.
[0]: http://info.meteor.com/blog/es2015-get-started
This commit is contained in:
parent
c6b12dc5ad
commit
aa974aa54a
14 changed files with 33 additions and 31 deletions
|
|
@ -62,7 +62,8 @@ BlazeComponent.extendComponent({
|
|||
},
|
||||
};
|
||||
|
||||
return [_.extend(events, {
|
||||
return [{
|
||||
...events,
|
||||
'click .js-close-card-details'() {
|
||||
Utils.goBoardId(this.data().boardId);
|
||||
},
|
||||
|
|
@ -86,7 +87,7 @@ BlazeComponent.extendComponent({
|
|||
this.parentComponent().showOverlay.set(true);
|
||||
this.parentComponent().mouseHasEnterCardDetails = true;
|
||||
},
|
||||
})];
|
||||
}];
|
||||
},
|
||||
}).register('cardDetails');
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ BlazeComponent.extendComponent({
|
|||
},
|
||||
|
||||
labels() {
|
||||
return _.map(labelColors, (color) => {
|
||||
return labelColors.map((color) => {
|
||||
return { color, name: '' };
|
||||
});
|
||||
},
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ const at = HTML.CharRef({html: '@', str: '@'});
|
|||
Blaze.Template.registerHelper('mentions', new Template('mentions', function() {
|
||||
const view = this;
|
||||
const currentBoard = Boards.findOne(Session.get('currentBoard'));
|
||||
const knowedUsers = _.map(currentBoard.members, (member) => {
|
||||
const knowedUsers = currentBoard.members.map((member) => {
|
||||
member.username = Users.findOne(member.userId).username;
|
||||
return member;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -95,10 +95,10 @@ BlazeComponent.extendComponent({
|
|||
events() {
|
||||
// XXX Hacky, we need some kind of `super`
|
||||
const mixinEvents = this.getMixin(Mixins.InfiniteScrolling).events();
|
||||
return mixinEvents.concat([{
|
||||
return [...mixinEvents, {
|
||||
'click .js-toggle-sidebar': this.toggle,
|
||||
'click .js-back-home': this.setView,
|
||||
}]);
|
||||
}];
|
||||
},
|
||||
}).register('sidebar');
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ Template.changePasswordPopup.onRendered(function() {
|
|||
|
||||
Template.changeLanguagePopup.helpers({
|
||||
languages() {
|
||||
return _.map(TAPi18n.getLanguages(), (lang, tag) => {
|
||||
return TAPi18n.getLanguages().map((lang, tag) => {
|
||||
const name = lang.name;
|
||||
return { tag, name };
|
||||
});
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ AccountsTemplates.configure({
|
|||
},
|
||||
});
|
||||
|
||||
_.each(['signIn', 'signUp', 'resetPwd', 'forgotPwd', 'enrollAccount'],
|
||||
['signIn', 'signUp', 'resetPwd', 'forgotPwd', 'enrollAccount'].forEach(
|
||||
(routeName) => AccountsTemplates.configureRoute(routeName));
|
||||
|
||||
// We display the form to change the password in a popup window that already
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ Filter = {
|
|||
return {};
|
||||
|
||||
const filterSelector = {};
|
||||
_.forEach(this._fields, (fieldName) => {
|
||||
this._fields.forEach((fieldName) => {
|
||||
const filter = this[fieldName];
|
||||
if (filter._isActive())
|
||||
filterSelector[fieldName] = filter._getMongoSelector();
|
||||
|
|
@ -116,7 +116,7 @@ Filter = {
|
|||
},
|
||||
|
||||
reset() {
|
||||
_.forEach(this._fields, (fieldName) => {
|
||||
this._fields.forEach((fieldName) => {
|
||||
const filter = this[fieldName];
|
||||
filter.reset();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ window.Modal = new class {
|
|||
}
|
||||
}
|
||||
|
||||
open(modalName, options) {
|
||||
open(modalName, { onCloseGoTo = ''}) {
|
||||
this._currentModal.set(modalName);
|
||||
this._onCloseGoTo = options && options.onCloseGoTo || '';
|
||||
this._onCloseGoTo = onCloseGoTo;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -119,12 +119,13 @@ MultiSelection = {
|
|||
}
|
||||
},
|
||||
|
||||
toggle(cardIds, options) {
|
||||
toggle(cardIds, options = {}) {
|
||||
cardIds = _.isString(cardIds) ? [cardIds] : cardIds;
|
||||
options = _.extend({
|
||||
options = {
|
||||
add: true,
|
||||
remove: true,
|
||||
}, options || {});
|
||||
...options,
|
||||
};
|
||||
|
||||
if (!this.isActive()) {
|
||||
this.reset();
|
||||
|
|
@ -133,7 +134,7 @@ MultiSelection = {
|
|||
|
||||
const selectedCards = this._selectedCards.get();
|
||||
|
||||
_.each(cardIds, (cardId) => {
|
||||
cardIds.forEach((cardId) => {
|
||||
const indexOfCard = selectedCards.indexOf(cardId);
|
||||
|
||||
if (options.remove && indexOfCard > -1)
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ window.Popup = new class {
|
|||
if (!self.isOpen()) {
|
||||
self.current = Blaze.renderWithData(self.template, () => {
|
||||
self._dep.depend();
|
||||
return _.extend(self._getTopStack(), { stack: self._stack });
|
||||
return { ...self._getTopStack(), stack: self._stack };
|
||||
}, document.body);
|
||||
|
||||
} else {
|
||||
|
|
@ -191,7 +191,7 @@ window.Popup = new class {
|
|||
// We close a potential opened popup on any left click on the document, or go
|
||||
// one step back by pressing escape.
|
||||
const escapeActions = ['back', 'close'];
|
||||
_.each(escapeActions, (actionName) => {
|
||||
escapeActions.forEach((actionName) => {
|
||||
EscapeActions.register(`popup-${actionName}`,
|
||||
() => Popup[actionName](),
|
||||
() => Popup.isOpen(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue