diff options
author | Ignatz <computer-freak94@gmx.de> | 2018-05-18 10:24:51 +0200 |
---|---|---|
committer | Ignatz <computer-freak94@gmx.de> | 2018-05-18 10:24:51 +0200 |
commit | d6cfac0122dc5e6819c82f73c728488e0600cb70 (patch) | |
tree | 4f392116329e8e7cbd8e679837ce90fa7f5a0ee3 /client | |
parent | c1d2e27c092f9bce4a9982d6b714b442dbf66a4b (diff) | |
download | wekan-d6cfac0122dc5e6819c82f73c728488e0600cb70.tar.gz wekan-d6cfac0122dc5e6819c82f73c728488e0600cb70.tar.bz2 wekan-d6cfac0122dc5e6819c82f73c728488e0600cb70.zip |
linter corrections
Diffstat (limited to 'client')
-rw-r--r-- | client/components/cards/cardCustomFields.js | 256 | ||||
-rw-r--r-- | client/components/lists/listBody.js | 6 | ||||
-rw-r--r-- | client/components/sidebar/sidebarCustomFields.js | 27 | ||||
-rw-r--r-- | client/lib/datepicker.js | 150 |
4 files changed, 220 insertions, 219 deletions
diff --git a/client/components/cards/cardCustomFields.js b/client/components/cards/cardCustomFields.js index e014de4a..821ca02b 100644 --- a/client/components/cards/cardCustomFields.js +++ b/client/components/cards/cardCustomFields.js @@ -1,179 +1,179 @@ Template.cardCustomFieldsPopup.helpers({ - hasCustomField() { - const card = Cards.findOne(Session.get('currentCard')); - const customFieldId = this._id; - return card.customFieldIndex(customFieldId) > -1; - }, + hasCustomField() { + const card = Cards.findOne(Session.get('currentCard')); + const customFieldId = this._id; + return card.customFieldIndex(customFieldId) > -1; + }, }); Template.cardCustomFieldsPopup.events({ - 'click .js-select-field'(evt) { - const card = Cards.findOne(Session.get('currentCard')); - const customFieldId = this._id; - card.toggleCustomField(customFieldId); - evt.preventDefault(); - }, - 'click .js-settings'(evt) { - EscapeActions.executeUpTo('detailsPane'); - Sidebar.setView('customFields'); - evt.preventDefault(); - } + 'click .js-select-field'(evt) { + const card = Cards.findOne(Session.get('currentCard')); + const customFieldId = this._id; + card.toggleCustomField(customFieldId); + evt.preventDefault(); + }, + 'click .js-settings'(evt) { + EscapeActions.executeUpTo('detailsPane'); + Sidebar.setView('customFields'); + evt.preventDefault(); + }, }); // cardCustomField const CardCustomField = BlazeComponent.extendComponent({ - getTemplate() { - return 'cardCustomField-' + this.data().definition.type; - }, + getTemplate() { + return 'cardCustomField-${this.data().definition.type}'; + }, - onCreated() { - const self = this; - self.card = Cards.findOne(Session.get('currentCard')); - self.customFieldId = this.data()._id; - }, + onCreated() { + const self = this; + self.card = Cards.findOne(Session.get('currentCard')); + self.customFieldId = this.data()._id; + }, - canModifyCard() { - return Meteor.user() && Meteor.user().isBoardMember() && !Meteor.user().isCommentOnly(); - }, + canModifyCard() { + return Meteor.user() && Meteor.user().isBoardMember() && !Meteor.user().isCommentOnly(); + }, }); CardCustomField.register('cardCustomField'); // cardCustomField-text (class extends CardCustomField { - onCreated() { - super.onCreated(); - } + onCreated() { + super.onCreated(); + } - events() { - return [{ - 'submit .js-card-customfield-text'(evt) { - evt.preventDefault(); - const value = this.currentComponent().getValue(); - this.card.setCustomField(this.customFieldId, value); - }, - }]; - } + events() { + return [{ + 'submit .js-card-customfield-text'(evt) { + evt.preventDefault(); + const value = this.currentComponent().getValue(); + this.card.setCustomField(this.customFieldId, value); + }, + }]; + } }).register('cardCustomField-text'); // cardCustomField-number (class extends CardCustomField { - onCreated() { - super.onCreated(); - } + onCreated() { + super.onCreated(); + } - events() { - return [{ - 'submit .js-card-customfield-number'(evt) { - evt.preventDefault(); - const value = parseInt(this.find('input').value); - this.card.setCustomField(this.customFieldId, value); - }, - }]; - } + events() { + return [{ + 'submit .js-card-customfield-number'(evt) { + evt.preventDefault(); + const value = parseInt(this.find('input').value, 10); + this.card.setCustomField(this.customFieldId, value); + }, + }]; + } }).register('cardCustomField-number'); // cardCustomField-date (class extends CardCustomField { - onCreated() { - super.onCreated(); - const self = this; - self.date = ReactiveVar(); - self.now = ReactiveVar(moment()); - window.setInterval(() => { - self.now.set(moment()); - }, 60000); - - self.autorun(() => { - self.date.set(moment(self.data().value)); - }); - } - - showDate() { + onCreated() { + super.onCreated(); + const self = this; + self.date = ReactiveVar(); + self.now = ReactiveVar(moment()); + window.setInterval(() => { + self.now.set(moment()); + }, 60000); + + self.autorun(() => { + self.date.set(moment(self.data().value)); + }); + } + + showDate() { // this will start working once mquandalle:moment // is updated to at least moment.js 2.10.5 // until then, the date is displayed in the "L" format - return this.date.get().calendar(null, { - sameElse: 'llll', - }); - } + return this.date.get().calendar(null, { + sameElse: 'llll', + }); + } - showISODate() { - return this.date.get().toISOString(); - } + showISODate() { + return this.date.get().toISOString(); + } - classes() { - if (this.date.get().isBefore(this.now.get(), 'minute') && + classes() { + if (this.date.get().isBefore(this.now.get(), 'minute') && this.now.get().isBefore(this.data().value)) { - return 'current'; - } - return ''; + return 'current'; } + return ''; + } - showTitle() { - return `${TAPi18n.__('card-start-on')} ${this.date.get().format('LLLL')}`; - } + showTitle() { + return `${TAPi18n.__('card-start-on')} ${this.date.get().format('LLLL')}`; + } - events() { - return [{ - 'click .js-edit-date': Popup.open('cardCustomField-date'), - }]; - } + events() { + return [{ + 'click .js-edit-date': Popup.open('cardCustomField-date'), + }]; + } }).register('cardCustomField-date'); // cardCustomField-datePopup (class extends DatePicker { - onCreated() { - super.onCreated(); - const self = this; - self.card = Cards.findOne(Session.get('currentCard')); - self.customFieldId = this.data()._id; - this.data().value && this.date.set(moment(this.data().value)); - } - - _storeDate(date) { - this.card.setCustomField(this.customFieldId, date); - } - - _deleteDate() { - this.card.setCustomField(this.customFieldId, ''); - } + onCreated() { + super.onCreated(); + const self = this; + self.card = Cards.findOne(Session.get('currentCard')); + self.customFieldId = this.data()._id; + this.data().value && this.date.set(moment(this.data().value)); + } + + _storeDate(date) { + this.card.setCustomField(this.customFieldId, date); + } + + _deleteDate() { + this.card.setCustomField(this.customFieldId, ''); + } }).register('cardCustomField-datePopup'); // cardCustomField-dropdown (class extends CardCustomField { - onCreated() { - super.onCreated(); - this._items = this.data().definition.settings.dropdownItems; - this.items = this._items.slice(0); - this.items.unshift({ - _id: "", - name: TAPi18n.__('custom-field-dropdown-none') - }); - } - - selectedItem() { - const selected = this._items.find((item) => { - return item._id == this.data().value; - }); - return (selected) ? selected.name : TAPi18n.__('custom-field-dropdown-unknown'); - } - - events() { - return [{ - 'submit .js-card-customfield-dropdown'(evt) { - evt.preventDefault(); - const value = this.find('select').value; - this.card.setCustomField(this.customFieldId, value); - }, - }]; - } + onCreated() { + super.onCreated(); + this._items = this.data().definition.settings.dropdownItems; + this.items = this._items.slice(0); + this.items.unshift({ + _id: '', + name: TAPi18n.__('custom-field-dropdown-none'), + }); + } + + selectedItem() { + const selected = this._items.find((item) => { + return item._id === this.data().value; + }); + return (selected) ? selected.name : TAPi18n.__('custom-field-dropdown-unknown'); + } + + events() { + return [{ + 'submit .js-card-customfield-dropdown'(evt) { + evt.preventDefault(); + const value = this.find('select').value; + this.card.setCustomField(this.customFieldId, value); + }, + }]; + } -}).register('cardCustomField-dropdown');
\ No newline at end of file +}).register('cardCustomField-dropdown'); diff --git a/client/components/lists/listBody.js b/client/components/lists/listBody.js index 24e5cf5d..4bf7b369 100644 --- a/client/components/lists/listBody.js +++ b/client/components/lists/listBody.js @@ -36,9 +36,9 @@ BlazeComponent.extendComponent({ const members = formComponent.members.get(); const labelIds = formComponent.labels.get(); const customFields = formComponent.customFields.get(); - console.log("members", members); - console.log("labelIds", labelIds); - console.log("customFields", customFields); + //console.log('members', members); + //console.log('labelIds', labelIds); + //console.log('customFields', customFields); const boardId = this.data().board()._id; let swimlaneId = ''; diff --git a/client/components/sidebar/sidebarCustomFields.js b/client/components/sidebar/sidebarCustomFields.js index cfa21beb..9fed163c 100644 --- a/client/components/sidebar/sidebarCustomFields.js +++ b/client/components/sidebar/sidebarCustomFields.js @@ -27,11 +27,11 @@ const CreateCustomFieldPopup = BlazeComponent.extendComponent({ types() { const currentType = this.data().type; return this._types. - map(type => {return { + map((type) => {return { value: type, - name: TAPi18n.__('custom-field-' + type), - selected: type == currentType, - }}); + name: TAPi18n.__('custom-field-${type}'), + selected: type === currentType, + };}); }, isTypeNotSelected(type) { @@ -39,7 +39,7 @@ const CreateCustomFieldPopup = BlazeComponent.extendComponent({ }, getDropdownItems() { - var items = this.dropdownItems.get(); + const items = this.dropdownItems.get(); Array.from(this.findAll('.js-field-settings-dropdown input')).forEach((el, index) => { //console.log('each item!', index, el.value); if (!items[index]) items[index] = { @@ -51,12 +51,13 @@ const CreateCustomFieldPopup = BlazeComponent.extendComponent({ }, getSettings() { - let settings = {}; + const settings = {}; switch (this.type.get()) { - case 'dropdown': - let dropdownItems = this.getDropdownItems().filter(item => !!item.name.trim()); - settings.dropdownItems = dropdownItems; - break; + case 'dropdown': { + const dropdownItems = this.getDropdownItems().filter((item) => !!item.name.trim()); + settings.dropdownItems = dropdownItems; + break; + } } return settings; }, @@ -69,7 +70,7 @@ const CreateCustomFieldPopup = BlazeComponent.extendComponent({ }, 'keydown .js-dropdown-item.last'(evt) { if (evt.target.value.trim() && evt.keyCode === 13) { - let items = this.getDropdownItems(); + const items = this.getDropdownItems(); this.dropdownItems.set(items); evt.target.value = ''; } @@ -90,8 +91,8 @@ const CreateCustomFieldPopup = BlazeComponent.extendComponent({ name: this.find('.js-field-name').value.trim(), type: this.type.get(), 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 if (!this.data()._id) { diff --git a/client/lib/datepicker.js b/client/lib/datepicker.js index aac061cf..947970ee 100644 --- a/client/lib/datepicker.js +++ b/client/lib/datepicker.js @@ -1,86 +1,86 @@ DatePicker = BlazeComponent.extendComponent({ - template() { - return 'datepicker'; - }, + template() { + return 'datepicker'; + }, - onCreated() { - this.error = new ReactiveVar(''); - this.card = this.data(); - this.date = new ReactiveVar(moment.invalid()); - }, + onCreated() { + this.error = new ReactiveVar(''); + this.card = this.data(); + this.date = new ReactiveVar(moment.invalid()); + }, - onRendered() { - const $picker = this.$('.js-datepicker').datepicker({ - todayHighlight: true, - todayBtn: 'linked', - language: TAPi18n.getLanguage(), - }).on('changeDate', function(evt) { - this.find('#date').value = moment(evt.date).format('L'); - this.error.set(''); - this.find('#time').focus(); - }.bind(this)); + onRendered() { + const $picker = this.$('.js-datepicker').datepicker({ + todayHighlight: true, + todayBtn: 'linked', + language: TAPi18n.getLanguage(), + }).on('changeDate', function(evt) { + this.find('#date').value = moment(evt.date).format('L'); + this.error.set(''); + this.find('#time').focus(); + }.bind(this)); - if (this.date.get().isValid()) { - $picker.datepicker('update', this.date.get().toDate()); - } - }, + if (this.date.get().isValid()) { + $picker.datepicker('update', this.date.get().toDate()); + } + }, - showDate() { - if (this.date.get().isValid()) - return this.date.get().format('L'); - return ''; - }, - showTime() { - if (this.date.get().isValid()) - return this.date.get().format('LT'); - return ''; - }, - dateFormat() { - return moment.localeData().longDateFormat('L'); - }, - timeFormat() { - return moment.localeData().longDateFormat('LT'); - }, + showDate() { + if (this.date.get().isValid()) + return this.date.get().format('L'); + return ''; + }, + showTime() { + if (this.date.get().isValid()) + return this.date.get().format('LT'); + return ''; + }, + dateFormat() { + return moment.localeData().longDateFormat('L'); + }, + timeFormat() { + return moment.localeData().longDateFormat('LT'); + }, - events() { - return [{ - 'keyup .js-date-field'() { + events() { + return [{ + 'keyup .js-date-field'() { // parse for localized date format in strict mode - const dateMoment = moment(this.find('#date').value, 'L', true); - if (dateMoment.isValid()) { - this.error.set(''); - this.$('.js-datepicker').datepicker('update', dateMoment.toDate()); - } - }, - 'keyup .js-time-field'() { + const dateMoment = moment(this.find('#date').value, 'L', true); + if (dateMoment.isValid()) { + this.error.set(''); + this.$('.js-datepicker').datepicker('update', dateMoment.toDate()); + } + }, + 'keyup .js-time-field'() { // parse for localized time format in strict mode - const dateMoment = moment(this.find('#time').value, 'LT', true); - if (dateMoment.isValid()) { - this.error.set(''); - } - }, - 'submit .edit-date'(evt) { - evt.preventDefault(); + const dateMoment = moment(this.find('#time').value, 'LT', true); + if (dateMoment.isValid()) { + this.error.set(''); + } + }, + 'submit .edit-date'(evt) { + evt.preventDefault(); // 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 newDate = moment(dateString, 'L LT', true); - if (newDate.isValid()) { - this._storeDate(newDate.toDate()); - Popup.close(); - } - else { - this.error.set('invalid-date'); - evt.target.date.focus(); - } - }, - 'click .js-delete-date'(evt) { - evt.preventDefault(); - this._deleteDate(); - Popup.close(); - }, - }]; - }, -});
\ No newline at end of file + const dateString = `${evt.target.date.value} ${time}`; + const newDate = moment(dateString, 'L LT', true); + if (newDate.isValid()) { + this._storeDate(newDate.toDate()); + Popup.close(); + } + else { + this.error.set('invalid-date'); + evt.target.date.focus(); + } + }, + 'click .js-delete-date'(evt) { + evt.preventDefault(); + this._deleteDate(); + Popup.close(); + }, + }]; + }, +}); |