linter corrections

This commit is contained in:
Ignatz 2018-05-18 10:24:51 +02:00
parent c1d2e27c09
commit d6cfac0122
7 changed files with 236 additions and 230 deletions

View file

@ -32,7 +32,7 @@
"comma-spacing": 2, "comma-spacing": 2,
"comma-style": 2, "comma-style": 2,
"eol-last": 2, "eol-last": 2,
"linebreak-style": [2, "unix"], "linebreak-style": [2, "windows"],
"new-parens": 2, "new-parens": 2,
"no-lonely-if": 2, "no-lonely-if": 2,
"no-multiple-empty-lines": 2, "no-multiple-empty-lines": 2,
@ -100,7 +100,9 @@
"Attachments": true, "Attachments": true,
"Boards": true, "Boards": true,
"CardComments": true, "CardComments": true,
"DatePicker" : true,
"Cards": true, "Cards": true,
"CustomFields": true,
"Lists": true, "Lists": true,
"UnsavedEditCollection": true, "UnsavedEditCollection": true,
"Users": true, "Users": true,

View file

@ -1,179 +1,179 @@
Template.cardCustomFieldsPopup.helpers({ Template.cardCustomFieldsPopup.helpers({
hasCustomField() { hasCustomField() {
const card = Cards.findOne(Session.get('currentCard')); const card = Cards.findOne(Session.get('currentCard'));
const customFieldId = this._id; const customFieldId = this._id;
return card.customFieldIndex(customFieldId) > -1; return card.customFieldIndex(customFieldId) > -1;
}, },
}); });
Template.cardCustomFieldsPopup.events({ Template.cardCustomFieldsPopup.events({
'click .js-select-field'(evt) { 'click .js-select-field'(evt) {
const card = Cards.findOne(Session.get('currentCard')); const card = Cards.findOne(Session.get('currentCard'));
const customFieldId = this._id; const customFieldId = this._id;
card.toggleCustomField(customFieldId); card.toggleCustomField(customFieldId);
evt.preventDefault(); evt.preventDefault();
}, },
'click .js-settings'(evt) { 'click .js-settings'(evt) {
EscapeActions.executeUpTo('detailsPane'); EscapeActions.executeUpTo('detailsPane');
Sidebar.setView('customFields'); Sidebar.setView('customFields');
evt.preventDefault(); evt.preventDefault();
} },
}); });
// cardCustomField // cardCustomField
const CardCustomField = BlazeComponent.extendComponent({ const CardCustomField = BlazeComponent.extendComponent({
getTemplate() { getTemplate() {
return 'cardCustomField-' + this.data().definition.type; return 'cardCustomField-${this.data().definition.type}';
}, },
onCreated() { onCreated() {
const self = this; const self = this;
self.card = Cards.findOne(Session.get('currentCard')); self.card = Cards.findOne(Session.get('currentCard'));
self.customFieldId = this.data()._id; self.customFieldId = this.data()._id;
}, },
canModifyCard() { canModifyCard() {
return Meteor.user() && Meteor.user().isBoardMember() && !Meteor.user().isCommentOnly(); return Meteor.user() && Meteor.user().isBoardMember() && !Meteor.user().isCommentOnly();
}, },
}); });
CardCustomField.register('cardCustomField'); CardCustomField.register('cardCustomField');
// cardCustomField-text // cardCustomField-text
(class extends CardCustomField { (class extends CardCustomField {
onCreated() { onCreated() {
super.onCreated(); super.onCreated();
} }
events() { events() {
return [{ return [{
'submit .js-card-customfield-text'(evt) { 'submit .js-card-customfield-text'(evt) {
evt.preventDefault(); evt.preventDefault();
const value = this.currentComponent().getValue(); const value = this.currentComponent().getValue();
this.card.setCustomField(this.customFieldId, value); this.card.setCustomField(this.customFieldId, value);
}, },
}]; }];
} }
}).register('cardCustomField-text'); }).register('cardCustomField-text');
// cardCustomField-number // cardCustomField-number
(class extends CardCustomField { (class extends CardCustomField {
onCreated() { onCreated() {
super.onCreated(); super.onCreated();
} }
events() { events() {
return [{ return [{
'submit .js-card-customfield-number'(evt) { 'submit .js-card-customfield-number'(evt) {
evt.preventDefault(); evt.preventDefault();
const value = parseInt(this.find('input').value); const value = parseInt(this.find('input').value, 10);
this.card.setCustomField(this.customFieldId, value); this.card.setCustomField(this.customFieldId, value);
}, },
}]; }];
} }
}).register('cardCustomField-number'); }).register('cardCustomField-number');
// cardCustomField-date // cardCustomField-date
(class extends CardCustomField { (class extends CardCustomField {
onCreated() { onCreated() {
super.onCreated(); super.onCreated();
const self = this; const self = this;
self.date = ReactiveVar(); self.date = ReactiveVar();
self.now = ReactiveVar(moment()); self.now = ReactiveVar(moment());
window.setInterval(() => { window.setInterval(() => {
self.now.set(moment()); self.now.set(moment());
}, 60000); }, 60000);
self.autorun(() => { self.autorun(() => {
self.date.set(moment(self.data().value)); self.date.set(moment(self.data().value));
}); });
} }
showDate() { showDate() {
// this will start working once mquandalle:moment // this will start working once mquandalle:moment
// is updated to at least moment.js 2.10.5 // is updated to at least moment.js 2.10.5
// until then, the date is displayed in the "L" format // until then, the date is displayed in the "L" format
return this.date.get().calendar(null, { return this.date.get().calendar(null, {
sameElse: 'llll', sameElse: 'llll',
}); });
} }
showISODate() { showISODate() {
return this.date.get().toISOString(); return this.date.get().toISOString();
} }
classes() { classes() {
if (this.date.get().isBefore(this.now.get(), 'minute') && if (this.date.get().isBefore(this.now.get(), 'minute') &&
this.now.get().isBefore(this.data().value)) { this.now.get().isBefore(this.data().value)) {
return 'current'; return 'current';
}
return '';
} }
return '';
}
showTitle() { showTitle() {
return `${TAPi18n.__('card-start-on')} ${this.date.get().format('LLLL')}`; return `${TAPi18n.__('card-start-on')} ${this.date.get().format('LLLL')}`;
} }
events() { events() {
return [{ return [{
'click .js-edit-date': Popup.open('cardCustomField-date'), 'click .js-edit-date': Popup.open('cardCustomField-date'),
}]; }];
} }
}).register('cardCustomField-date'); }).register('cardCustomField-date');
// cardCustomField-datePopup // cardCustomField-datePopup
(class extends DatePicker { (class extends DatePicker {
onCreated() { onCreated() {
super.onCreated(); super.onCreated();
const self = this; const self = this;
self.card = Cards.findOne(Session.get('currentCard')); self.card = Cards.findOne(Session.get('currentCard'));
self.customFieldId = this.data()._id; self.customFieldId = this.data()._id;
this.data().value && this.date.set(moment(this.data().value)); this.data().value && this.date.set(moment(this.data().value));
} }
_storeDate(date) { _storeDate(date) {
this.card.setCustomField(this.customFieldId, date); this.card.setCustomField(this.customFieldId, date);
} }
_deleteDate() { _deleteDate() {
this.card.setCustomField(this.customFieldId, ''); this.card.setCustomField(this.customFieldId, '');
} }
}).register('cardCustomField-datePopup'); }).register('cardCustomField-datePopup');
// cardCustomField-dropdown // cardCustomField-dropdown
(class extends CardCustomField { (class extends CardCustomField {
onCreated() { onCreated() {
super.onCreated(); super.onCreated();
this._items = this.data().definition.settings.dropdownItems; this._items = this.data().definition.settings.dropdownItems;
this.items = this._items.slice(0); this.items = this._items.slice(0);
this.items.unshift({ this.items.unshift({
_id: "", _id: '',
name: TAPi18n.__('custom-field-dropdown-none') name: TAPi18n.__('custom-field-dropdown-none'),
}); });
} }
selectedItem() { selectedItem() {
const selected = this._items.find((item) => { const selected = this._items.find((item) => {
return item._id == this.data().value; return item._id === this.data().value;
}); });
return (selected) ? selected.name : TAPi18n.__('custom-field-dropdown-unknown'); return (selected) ? selected.name : TAPi18n.__('custom-field-dropdown-unknown');
} }
events() { events() {
return [{ return [{
'submit .js-card-customfield-dropdown'(evt) { 'submit .js-card-customfield-dropdown'(evt) {
evt.preventDefault(); evt.preventDefault();
const value = this.find('select').value; const value = this.find('select').value;
this.card.setCustomField(this.customFieldId, value); this.card.setCustomField(this.customFieldId, value);
}, },
}]; }];
} }
}).register('cardCustomField-dropdown'); }).register('cardCustomField-dropdown');

View file

@ -36,9 +36,9 @@ BlazeComponent.extendComponent({
const members = formComponent.members.get(); const members = formComponent.members.get();
const labelIds = formComponent.labels.get(); const labelIds = formComponent.labels.get();
const customFields = formComponent.customFields.get(); const customFields = formComponent.customFields.get();
console.log("members", members); //console.log('members', members);
console.log("labelIds", labelIds); //console.log('labelIds', labelIds);
console.log("customFields", customFields); //console.log('customFields', customFields);
const boardId = this.data().board()._id; const boardId = this.data().board()._id;
let swimlaneId = ''; let swimlaneId = '';

View file

@ -27,11 +27,11 @@ const CreateCustomFieldPopup = BlazeComponent.extendComponent({
types() { types() {
const currentType = this.data().type; const currentType = this.data().type;
return this._types. return this._types.
map(type => {return { map((type) => {return {
value: type, value: type,
name: TAPi18n.__('custom-field-' + type), name: TAPi18n.__('custom-field-${type}'),
selected: type == currentType, selected: type === currentType,
}}); };});
}, },
isTypeNotSelected(type) { isTypeNotSelected(type) {
@ -39,7 +39,7 @@ const CreateCustomFieldPopup = BlazeComponent.extendComponent({
}, },
getDropdownItems() { getDropdownItems() {
var items = this.dropdownItems.get(); const items = this.dropdownItems.get();
Array.from(this.findAll('.js-field-settings-dropdown input')).forEach((el, index) => { Array.from(this.findAll('.js-field-settings-dropdown input')).forEach((el, index) => {
//console.log('each item!', index, el.value); //console.log('each item!', index, el.value);
if (!items[index]) items[index] = { if (!items[index]) items[index] = {
@ -51,12 +51,13 @@ const CreateCustomFieldPopup = BlazeComponent.extendComponent({
}, },
getSettings() { getSettings() {
let settings = {}; const settings = {};
switch (this.type.get()) { switch (this.type.get()) {
case 'dropdown': case 'dropdown': {
let dropdownItems = this.getDropdownItems().filter(item => !!item.name.trim()); const dropdownItems = this.getDropdownItems().filter((item) => !!item.name.trim());
settings.dropdownItems = dropdownItems; settings.dropdownItems = dropdownItems;
break; break;
}
} }
return settings; return settings;
}, },
@ -69,7 +70,7 @@ const CreateCustomFieldPopup = BlazeComponent.extendComponent({
}, },
'keydown .js-dropdown-item.last'(evt) { 'keydown .js-dropdown-item.last'(evt) {
if (evt.target.value.trim() && evt.keyCode === 13) { if (evt.target.value.trim() && evt.keyCode === 13) {
let items = this.getDropdownItems(); const items = this.getDropdownItems();
this.dropdownItems.set(items); this.dropdownItems.set(items);
evt.target.value = ''; evt.target.value = '';
} }
@ -90,8 +91,8 @@ const CreateCustomFieldPopup = BlazeComponent.extendComponent({
name: this.find('.js-field-name').value.trim(), name: this.find('.js-field-name').value.trim(),
type: this.type.get(), type: this.type.get(),
settings: this.getSettings(), settings: this.getSettings(),
showOnCard: this.find('.js-field-show-on-card.is-checked') != null showOnCard: this.find('.js-field-show-on-card.is-checked') !== null,
} };
// insert or update // insert or update
if (!this.data()._id) { if (!this.data()._id) {

View file

@ -1,86 +1,86 @@
DatePicker = BlazeComponent.extendComponent({ DatePicker = BlazeComponent.extendComponent({
template() { template() {
return 'datepicker'; return 'datepicker';
}, },
onCreated() { onCreated() {
this.error = new ReactiveVar(''); this.error = new ReactiveVar('');
this.card = this.data(); this.card = this.data();
this.date = new ReactiveVar(moment.invalid()); this.date = new ReactiveVar(moment.invalid());
}, },
onRendered() { onRendered() {
const $picker = this.$('.js-datepicker').datepicker({ const $picker = this.$('.js-datepicker').datepicker({
todayHighlight: true, todayHighlight: true,
todayBtn: 'linked', todayBtn: 'linked',
language: TAPi18n.getLanguage(), language: TAPi18n.getLanguage(),
}).on('changeDate', function(evt) { }).on('changeDate', function(evt) {
this.find('#date').value = moment(evt.date).format('L'); this.find('#date').value = moment(evt.date).format('L');
this.error.set(''); this.error.set('');
this.find('#time').focus(); this.find('#time').focus();
}.bind(this)); }.bind(this));
if (this.date.get().isValid()) { if (this.date.get().isValid()) {
$picker.datepicker('update', this.date.get().toDate()); $picker.datepicker('update', this.date.get().toDate());
} }
}, },
showDate() { showDate() {
if (this.date.get().isValid()) if (this.date.get().isValid())
return this.date.get().format('L'); return this.date.get().format('L');
return ''; return '';
}, },
showTime() { showTime() {
if (this.date.get().isValid()) if (this.date.get().isValid())
return this.date.get().format('LT'); return this.date.get().format('LT');
return ''; return '';
}, },
dateFormat() { dateFormat() {
return moment.localeData().longDateFormat('L'); return moment.localeData().longDateFormat('L');
}, },
timeFormat() { timeFormat() {
return moment.localeData().longDateFormat('LT'); return moment.localeData().longDateFormat('LT');
}, },
events() { events() {
return [{ return [{
'keyup .js-date-field'() { 'keyup .js-date-field'() {
// parse for localized date format in strict mode // parse for localized date format in strict mode
const dateMoment = moment(this.find('#date').value, 'L', true); const dateMoment = moment(this.find('#date').value, 'L', true);
if (dateMoment.isValid()) { if (dateMoment.isValid()) {
this.error.set(''); this.error.set('');
this.$('.js-datepicker').datepicker('update', dateMoment.toDate()); this.$('.js-datepicker').datepicker('update', dateMoment.toDate());
} }
}, },
'keyup .js-time-field'() { 'keyup .js-time-field'() {
// parse for localized time format in strict mode // parse for localized time format in strict mode
const dateMoment = moment(this.find('#time').value, 'LT', true); const dateMoment = moment(this.find('#time').value, 'LT', true);
if (dateMoment.isValid()) { if (dateMoment.isValid()) {
this.error.set(''); this.error.set('');
} }
}, },
'submit .edit-date'(evt) { 'submit .edit-date'(evt) {
evt.preventDefault(); evt.preventDefault();
// if no time was given, init with 12:00 // if no time was given, init with 12:00
const time = evt.target.time.value || moment(new Date().setHours(12, 0, 0)).format('LT'); const time = evt.target.time.value || moment(new Date().setHours(12, 0, 0)).format('LT');
const dateString = `${evt.target.date.value} ${time}`; const dateString = `${evt.target.date.value} ${time}`;
const newDate = moment(dateString, 'L LT', true); const newDate = moment(dateString, 'L LT', true);
if (newDate.isValid()) { if (newDate.isValid()) {
this._storeDate(newDate.toDate()); this._storeDate(newDate.toDate());
Popup.close(); Popup.close();
} }
else { else {
this.error.set('invalid-date'); this.error.set('invalid-date');
evt.target.date.focus(); evt.target.date.focus();
} }
}, },
'click .js-delete-date'(evt) { 'click .js-delete-date'(evt) {
evt.preventDefault(); evt.preventDefault();
this._deleteDate(); this._deleteDate();
Popup.close(); Popup.close();
}, },
}]; }];
}, },
}); });

View file

@ -51,10 +51,10 @@ Cards.attachSchema(new SimpleSchema({
type: String, type: String,
}, },
value: { value: {
type: Match.OneOf(String,Number,Boolean,Date), type: Match.OneOf(String, Number, Boolean, Date),
optional: true, optional: true,
}, },
}) }),
}, },
dateLastActivity: { dateLastActivity: {
type: Date, type: Date,
@ -225,9 +225,9 @@ Cards.helpers({
_id: customField._id, _id: customField._id,
value: customField.value, value: customField.value,
definition: definitions.find((definition) => { definition: definitions.find((definition) => {
return definition._id == customField._id; return definition._id === customField._id;
}) }),
} };
}); });
}, },
@ -331,10 +331,13 @@ Cards.mutations({
// todo // todo
const index = this.customFieldIndex(customFieldId); const index = this.customFieldIndex(customFieldId);
if (index > -1) { if (index > -1) {
var update = {$set: {}}; const update = {$set: {}};
update.$set["customFields." + index + ".value"] = value; update.$set['customFields.${index}.value'] = value;
return update; return update;
} }
// TODO
// Ignatz 18.05.2018: Return null to silence ESLint. No Idea if that is correct
return null;
}, },
setCover(coverId) { setCover(coverId) {

View file

@ -9,14 +9,14 @@ CustomFields.attachSchema(new SimpleSchema({
}, },
type: { type: {
type: String, type: String,
allowedValues: ['text', 'number', 'date', 'dropdown'] allowedValues: ['text', 'number', 'date', 'dropdown'],
}, },
settings: { settings: {
type: Object, type: Object,
}, },
'settings.dropdownItems': { 'settings.dropdownItems': {
type: [Object], type: [Object],
optional: true optional: true,
}, },
'settings.dropdownItems.$': { 'settings.dropdownItems.$': {
type: new SimpleSchema({ type: new SimpleSchema({
@ -26,11 +26,11 @@ CustomFields.attachSchema(new SimpleSchema({
name: { name: {
type: String, type: String,
}, },
}) }),
}, },
showOnCard: { showOnCard: {
type: Boolean, type: Boolean,
} },
})); }));
CustomFields.allow({ CustomFields.allow({
@ -76,16 +76,16 @@ if (Meteor.isServer) {
//CUSTOM FIELD REST API //CUSTOM FIELD REST API
if (Meteor.isServer) { if (Meteor.isServer) {
JsonRoutes.add('GET', '/api/boards/:boardId/custom-fields', function (req, res, next) { JsonRoutes.add('GET', '/api/boards/:boardId/custom-fields', function (req, res) {
Authentication.checkUserId( req.userId); Authentication.checkUserId( req.userId);
const paramBoardId = req.params.boardId; const paramBoardId = req.params.boardId;
JsonRoutes.sendResult(res, { JsonRoutes.sendResult(res, {
code: 200, code: 200,
data: CustomFields.find({ boardId: paramBoardId }) data: CustomFields.find({ boardId: paramBoardId }),
}); });
}); });
JsonRoutes.add('GET', '/api/boards/:boardId/custom-fields/:customFieldId', function (req, res, next) { JsonRoutes.add('GET', '/api/boards/:boardId/custom-fields/:customFieldId', function (req, res) {
Authentication.checkUserId( req.userId); Authentication.checkUserId( req.userId);
const paramBoardId = req.params.boardId; const paramBoardId = req.params.boardId;
const paramCustomFieldId = req.params.customFieldId; const paramCustomFieldId = req.params.customFieldId;
@ -95,7 +95,7 @@ if (Meteor.isServer) {
}); });
}); });
JsonRoutes.add('POST', '/api/boards/:boardId/custom-fields', function (req, res, next) { JsonRoutes.add('POST', '/api/boards/:boardId/custom-fields', function (req, res) {
Authentication.checkUserId( req.userId); Authentication.checkUserId( req.userId);
const paramBoardId = req.params.boardId; const paramBoardId = req.params.boardId;
const id = CustomFields.direct.insert({ const id = CustomFields.direct.insert({
@ -117,7 +117,7 @@ if (Meteor.isServer) {
}); });
}); });
JsonRoutes.add('DELETE', '/api/boards/:boardId/custom-fields/:customFieldId', function (req, res, next) { JsonRoutes.add('DELETE', '/api/boards/:boardId/custom-fields/:customFieldId', function (req, res) {
Authentication.checkUserId( req.userId); Authentication.checkUserId( req.userId);
const paramBoardId = req.params.boardId; const paramBoardId = req.params.boardId;
const id = req.params.customFieldId; const id = req.params.customFieldId;