mirror of
https://github.com/wekan/wekan.git
synced 2026-01-23 01:36:09 +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,99 +1,98 @@
|
|||
var activitiesPerPage = 20;
|
||||
const activitiesPerPage = 20;
|
||||
|
||||
BlazeComponent.extendComponent({
|
||||
template: function() {
|
||||
template() {
|
||||
return 'activities';
|
||||
},
|
||||
|
||||
onCreated: function() {
|
||||
var self = this;
|
||||
onCreated() {
|
||||
// XXX Should we use ReactiveNumber?
|
||||
self.page = new ReactiveVar(1);
|
||||
self.loadNextPageLocked = false;
|
||||
var sidebar = self.componentParent(); // XXX for some reason not working
|
||||
this.page = new ReactiveVar(1);
|
||||
this.loadNextPageLocked = false;
|
||||
const sidebar = this.componentParent(); // XXX for some reason not working
|
||||
sidebar.callFirstWith(null, 'resetNextPeak');
|
||||
self.autorun(function() {
|
||||
var mode = self.data().mode;
|
||||
var capitalizedMode = Utils.capitalize(mode);
|
||||
var id = Session.get('current' + capitalizedMode);
|
||||
var limit = self.page.get() * activitiesPerPage;
|
||||
this.autorun(() => {
|
||||
const mode = this.data().mode;
|
||||
const capitalizedMode = Utils.capitalize(mode);
|
||||
const id = Session.get(`current${capitalizedMode}`);
|
||||
const limit = this.page.get() * activitiesPerPage;
|
||||
if (id === null)
|
||||
return;
|
||||
|
||||
self.subscribe('activities', mode, id, limit, function() {
|
||||
self.loadNextPageLocked = false;
|
||||
this.subscribe('activities', mode, id, limit, () => {
|
||||
this.loadNextPageLocked = false;
|
||||
|
||||
// If the sibear peak hasn't increased, that mean that there are no more
|
||||
// activities, and we can stop calling new subscriptions.
|
||||
// XXX This is hacky! We need to know excatly and reactively how many
|
||||
// activities there are, we probably want to denormalize this number
|
||||
// dirrectly into card and board documents.
|
||||
var a = sidebar.callFirstWith(null, 'getNextPeak');
|
||||
const nextPeakBefore = sidebar.callFirstWith(null, 'getNextPeak');
|
||||
sidebar.calculateNextPeak();
|
||||
var b = sidebar.callFirstWith(null, 'getNextPeak');
|
||||
if (a === b) {
|
||||
const nextPeakAfter = sidebar.callFirstWith(null, 'getNextPeak');
|
||||
if (nextPeakBefore === nextPeakAfter) {
|
||||
sidebar.callFirstWith(null, 'resetNextPeak');
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
loadNextPage: function() {
|
||||
loadNextPage() {
|
||||
if (this.loadNextPageLocked === false) {
|
||||
this.page.set(this.page.get() + 1);
|
||||
this.loadNextPageLocked = true;
|
||||
}
|
||||
},
|
||||
|
||||
boardLabel: function() {
|
||||
boardLabel() {
|
||||
return TAPi18n.__('this-board');
|
||||
},
|
||||
|
||||
cardLabel: function() {
|
||||
cardLabel() {
|
||||
return TAPi18n.__('this-card');
|
||||
},
|
||||
|
||||
cardLink: function() {
|
||||
var card = this.currentData().card();
|
||||
cardLink() {
|
||||
const card = this.currentData().card();
|
||||
return card && Blaze.toHTML(HTML.A({
|
||||
href: card.absoluteUrl(),
|
||||
'class': 'action-card'
|
||||
'class': 'action-card',
|
||||
}, card.title));
|
||||
},
|
||||
|
||||
memberLink: function() {
|
||||
memberLink() {
|
||||
return Blaze.toHTMLWithData(Template.memberName, {
|
||||
user: this.currentData().member()
|
||||
user: this.currentData().member(),
|
||||
});
|
||||
},
|
||||
|
||||
attachmentLink: function() {
|
||||
var attachment = this.currentData().attachment();
|
||||
attachmentLink() {
|
||||
const attachment = this.currentData().attachment();
|
||||
return attachment && Blaze.toHTML(HTML.A({
|
||||
href: attachment.url(),
|
||||
'class': 'js-open-attachment-viewer'
|
||||
'class': 'js-open-attachment-viewer',
|
||||
}, attachment.name()));
|
||||
},
|
||||
|
||||
events: function() {
|
||||
events() {
|
||||
return [{
|
||||
// XXX We should use Popup.afterConfirmation here
|
||||
'click .js-delete-comment': function() {
|
||||
var commentId = this.currentData().commentId;
|
||||
'click .js-delete-comment'() {
|
||||
const commentId = this.currentData().commentId;
|
||||
CardComments.remove(commentId);
|
||||
},
|
||||
'submit .js-edit-comment': function(evt) {
|
||||
'submit .js-edit-comment'(evt) {
|
||||
evt.preventDefault();
|
||||
var commentText = this.currentComponent().getValue();
|
||||
var commentId = Template.parentData().commentId;
|
||||
const commentText = this.currentComponent().getValue();
|
||||
const commentId = Template.parentData().commentId;
|
||||
if ($.trim(commentText)) {
|
||||
CardComments.update(commentId, {
|
||||
$set: {
|
||||
text: commentText
|
||||
}
|
||||
text: commentText,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
}];
|
||||
}
|
||||
},
|
||||
}).register('activities');
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
let commentFormIsOpen = new ReactiveVar(false);
|
||||
const commentFormIsOpen = new ReactiveVar(false);
|
||||
|
||||
BlazeComponent.extendComponent({
|
||||
template() {
|
||||
|
|
@ -19,16 +19,16 @@ BlazeComponent.extendComponent({
|
|||
|
||||
events() {
|
||||
return [{
|
||||
'click .js-new-comment:not(.focus)': function() {
|
||||
'click .js-new-comment:not(.focus)'() {
|
||||
commentFormIsOpen.set(true);
|
||||
},
|
||||
'submit .js-new-comment-form': function(evt) {
|
||||
let input = this.getInput();
|
||||
'submit .js-new-comment-form'(evt) {
|
||||
const input = this.getInput();
|
||||
if ($.trim(input.val())) {
|
||||
CardComments.insert({
|
||||
boardId: this.currentData().boardId,
|
||||
cardId: this.currentData()._id,
|
||||
text: input.val()
|
||||
text: input.val(),
|
||||
});
|
||||
resetCommentInput(input);
|
||||
Tracker.flush();
|
||||
|
|
@ -37,13 +37,13 @@ BlazeComponent.extendComponent({
|
|||
evt.preventDefault();
|
||||
},
|
||||
// Pressing Ctrl+Enter should submit the form
|
||||
'keydown form textarea': function(evt) {
|
||||
'keydown form textarea'(evt) {
|
||||
if (evt.keyCode === 13 && (evt.metaKey || evt.ctrlKey)) {
|
||||
this.find('button[type=submit]').click();
|
||||
}
|
||||
}
|
||||
},
|
||||
}];
|
||||
}
|
||||
},
|
||||
}).register('commentForm');
|
||||
|
||||
// XXX This should be a static method of the `commentForm` component
|
||||
|
|
@ -63,15 +63,15 @@ Tracker.autorun(() => {
|
|||
Tracker.afterFlush(() => {
|
||||
autosize.update($('.js-new-comment-input'));
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
EscapeActions.register('inlinedForm',
|
||||
function() {
|
||||
() => {
|
||||
const draftKey = {
|
||||
fieldName: 'cardComment',
|
||||
docId: Session.get('currentCard')
|
||||
docId: Session.get('currentCard'),
|
||||
};
|
||||
let commentInput = $('.js-new-comment-input');
|
||||
const commentInput = $('.js-new-comment-input');
|
||||
if ($.trim(commentInput.val())) {
|
||||
UnsavedEdits.set(draftKey, commentInput.val());
|
||||
} else {
|
||||
|
|
@ -79,7 +79,7 @@ EscapeActions.register('inlinedForm',
|
|||
}
|
||||
resetCommentInput(commentInput);
|
||||
},
|
||||
function() { return commentFormIsOpen.get(); }, {
|
||||
noClickEscapeOn: '.js-new-comment'
|
||||
() => { return commentFormIsOpen.get(); }, {
|
||||
noClickEscapeOn: '.js-new-comment',
|
||||
}
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue