mirror of
https://github.com/wekan/wekan.git
synced 2025-12-27 20:58:48 +01:00
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).
This commit is contained in:
parent
039cfe7edf
commit
b3851817ec
60 changed files with 1604 additions and 1692 deletions
|
|
@ -1,11 +1,11 @@
|
|||
var subManager = new SubsManager();
|
||||
const subManager = new SubsManager();
|
||||
|
||||
BlazeComponent.extendComponent({
|
||||
template: function() {
|
||||
template() {
|
||||
return 'board';
|
||||
},
|
||||
|
||||
onCreated: function() {
|
||||
onCreated() {
|
||||
this.draggingActive = new ReactiveVar(false);
|
||||
this.showOverlay = new ReactiveVar(false);
|
||||
this.isBoardReady = new ReactiveVar(false);
|
||||
|
|
@ -15,15 +15,15 @@ BlazeComponent.extendComponent({
|
|||
// XXX The boardId should be readed from some sort the component "props",
|
||||
// unfortunatly, Blaze doesn't have this notion.
|
||||
this.autorun(() => {
|
||||
let currentBoardId = Session.get('currentBoard');
|
||||
if (! currentBoardId)
|
||||
const currentBoardId = Session.get('currentBoard');
|
||||
if (!currentBoardId)
|
||||
return;
|
||||
var handle = subManager.subscribe('board', currentBoardId);
|
||||
const handle = subManager.subscribe('board', currentBoardId);
|
||||
Tracker.nonreactive(() => {
|
||||
Tracker.autorun(() => {
|
||||
this.isBoardReady.set(handle.ready());
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
this._isDragging = false;
|
||||
|
|
@ -33,52 +33,52 @@ BlazeComponent.extendComponent({
|
|||
this.mouseHasEnterCardDetails = false;
|
||||
},
|
||||
|
||||
openNewListForm: function() {
|
||||
openNewListForm() {
|
||||
this.componentChildren('addListForm')[0].open();
|
||||
},
|
||||
|
||||
// XXX Flow components allow us to avoid creating these two setter methods by
|
||||
// exposing a public API to modify the component state. We need to investigate
|
||||
// best practices here.
|
||||
setIsDragging: function(bool) {
|
||||
setIsDragging(bool) {
|
||||
this.draggingActive.set(bool);
|
||||
},
|
||||
|
||||
scrollLeft: function(position = 0) {
|
||||
scrollLeft(position = 0) {
|
||||
this.$('.js-lists').animate({
|
||||
scrollLeft: position
|
||||
scrollLeft: position,
|
||||
});
|
||||
},
|
||||
|
||||
currentCardIsInThisList: function() {
|
||||
var currentCard = Cards.findOne(Session.get('currentCard'));
|
||||
var listId = this.currentData()._id;
|
||||
currentCardIsInThisList() {
|
||||
const currentCard = Cards.findOne(Session.get('currentCard'));
|
||||
const listId = this.currentData()._id;
|
||||
return currentCard && currentCard.listId === listId;
|
||||
},
|
||||
|
||||
events: function() {
|
||||
events() {
|
||||
return [{
|
||||
// XXX The board-overlay div should probably be moved to the parent
|
||||
// component.
|
||||
'mouseenter .board-overlay': function() {
|
||||
'mouseenter .board-overlay'() {
|
||||
if (this.mouseHasEnterCardDetails) {
|
||||
this.showOverlay.set(false);
|
||||
}
|
||||
},
|
||||
|
||||
// Click-and-drag action
|
||||
'mousedown .board-canvas': function(evt) {
|
||||
'mousedown .board-canvas'(evt) {
|
||||
if ($(evt.target).closest('a,.js-list-header').length === 0) {
|
||||
this._isDragging = true;
|
||||
this._lastDragPositionX = evt.clientX;
|
||||
}
|
||||
},
|
||||
'mouseup': function(evt) {
|
||||
'mouseup'() {
|
||||
if (this._isDragging) {
|
||||
this._isDragging = false;
|
||||
}
|
||||
},
|
||||
'mousemove': function(evt) {
|
||||
'mousemove'(evt) {
|
||||
if (this._isDragging) {
|
||||
// Update the canvas position
|
||||
this.listsDom.scrollLeft -= evt.clientX - this._lastDragPositionX;
|
||||
|
|
@ -91,40 +91,40 @@ BlazeComponent.extendComponent({
|
|||
EscapeActions.executeUpTo('popup-close');
|
||||
EscapeActions.preventNextClick();
|
||||
}
|
||||
}
|
||||
},
|
||||
}];
|
||||
}
|
||||
},
|
||||
}).register('board');
|
||||
|
||||
Template.boardBody.onRendered(function() {
|
||||
var self = BlazeComponent.getComponentForElement(this.firstNode);
|
||||
const self = BlazeComponent.getComponentForElement(this.firstNode);
|
||||
|
||||
self.listsDom = this.find('.js-lists');
|
||||
|
||||
if (! Session.get('currentCard')) {
|
||||
if (!Session.get('currentCard')) {
|
||||
self.scrollLeft();
|
||||
}
|
||||
|
||||
// We want to animate the card details window closing. We rely on CSS
|
||||
// transition for the actual animation.
|
||||
self.listsDom._uihooks = {
|
||||
removeElement: function(node) {
|
||||
var removeNode = _.once(function() {
|
||||
removeElement(node) {
|
||||
const removeNode = _.once(() => {
|
||||
node.parentNode.removeChild(node);
|
||||
});
|
||||
if ($(node).hasClass('js-card-details')) {
|
||||
$(node).css({
|
||||
flexBasis: 0,
|
||||
padding: 0
|
||||
padding: 0,
|
||||
});
|
||||
$(self.listsDom).one(CSSEvents.transitionend, removeNode);
|
||||
} else {
|
||||
removeNode();
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
if (! Meteor.user() || ! Meteor.user().isBoardMember())
|
||||
if (!Meteor.user() || !Meteor.user().isBoardMember())
|
||||
return;
|
||||
|
||||
self.$(self.listsDom).sortable({
|
||||
|
|
@ -134,63 +134,63 @@ Template.boardBody.onRendered(function() {
|
|||
items: '.js-list:not(.js-list-composer)',
|
||||
placeholder: 'list placeholder',
|
||||
distance: 7,
|
||||
start: function(evt, ui) {
|
||||
start(evt, ui) {
|
||||
ui.placeholder.height(ui.helper.height());
|
||||
Popup.close();
|
||||
},
|
||||
stop: function() {
|
||||
stop() {
|
||||
self.$('.js-lists').find('.js-list:not(.js-list-composer)').each(
|
||||
function(i, list) {
|
||||
var data = Blaze.getData(list);
|
||||
(i, list) => {
|
||||
const data = Blaze.getData(list);
|
||||
Lists.update(data._id, {
|
||||
$set: {
|
||||
sort: i
|
||||
}
|
||||
sort: i,
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
// Disable drag-dropping while in multi-selection mode
|
||||
self.autorun(function() {
|
||||
self.autorun(() => {
|
||||
self.$(self.listsDom).sortable('option', 'disabled',
|
||||
MultiSelection.isActive());
|
||||
});
|
||||
|
||||
// If there is no data in the board (ie, no lists) we autofocus the list
|
||||
// creation form by clicking on the corresponding element.
|
||||
var currentBoard = Boards.findOne(Session.get('currentBoard'));
|
||||
const currentBoard = Boards.findOne(Session.get('currentBoard'));
|
||||
if (currentBoard.lists().count() === 0) {
|
||||
self.openNewListForm();
|
||||
}
|
||||
});
|
||||
|
||||
BlazeComponent.extendComponent({
|
||||
template: function() {
|
||||
template() {
|
||||
return 'addListForm';
|
||||
},
|
||||
|
||||
// Proxy
|
||||
open: function() {
|
||||
open() {
|
||||
this.componentChildren('inlinedForm')[0].open();
|
||||
},
|
||||
|
||||
events: function() {
|
||||
events() {
|
||||
return [{
|
||||
submit: function(evt) {
|
||||
submit(evt) {
|
||||
evt.preventDefault();
|
||||
var title = this.find('.list-name-input');
|
||||
const title = this.find('.list-name-input');
|
||||
if ($.trim(title.value)) {
|
||||
Lists.insert({
|
||||
title: title.value,
|
||||
boardId: Session.get('currentBoard'),
|
||||
sort: $('.list').length
|
||||
sort: $('.list').length,
|
||||
});
|
||||
|
||||
title.value = '';
|
||||
}
|
||||
}
|
||||
},
|
||||
}];
|
||||
}
|
||||
},
|
||||
}).register('addListForm');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue