diff options
author | RJevnikar <12701645+rjevnikar@users.noreply.github.com> | 2018-03-26 19:04:02 +0000 |
---|---|---|
committer | RJevnikar <12701645+rjevnikar@users.noreply.github.com> | 2018-03-26 20:51:24 +0000 |
commit | 07217d0e5142028bbe794bdd3611e47890ab4bfb (patch) | |
tree | df4747598115c2daf6813d004bcd48a7446a48ad /client/components/cards/cardDate.js | |
parent | 80941e57d39138338761311964dc32ad25fd34ad (diff) | |
download | wekan-07217d0e5142028bbe794bdd3611e47890ab4bfb.tar.gz wekan-07217d0e5142028bbe794bdd3611e47890ab4bfb.tar.bz2 wekan-07217d0e5142028bbe794bdd3611e47890ab4bfb.zip |
Add additional dates (received & end), default title of checklists to 'Checklist'
Remove translations
Add additional dates (received & end), default name checklists to Checklist
Diffstat (limited to 'client/components/cards/cardDate.js')
-rw-r--r-- | client/components/cards/cardDate.js | 126 |
1 files changed, 124 insertions, 2 deletions
diff --git a/client/components/cards/cardDate.js b/client/components/cards/cardDate.js index abf6a42b..7c0ad6ab 100644 --- a/client/components/cards/cardDate.js +++ b/client/components/cards/cardDate.js @@ -1,4 +1,4 @@ -// Edit start & due dates +// Edit received, start, due & end dates const EditCardDate = BlazeComponent.extendComponent({ template() { return 'editCardDate'; @@ -92,6 +92,23 @@ Template.dateBadge.helpers({ }, }); +// editCardReceivedDatePopup +(class extends EditCardDate { + onCreated() { + super.onCreated(); + this.data().receivedAt && this.date.set(moment(this.data().receivedAt)); + } + + _storeDate(date) { + this.card.setReceived(date); + } + + _deleteDate() { + this.card.unsetReceived(); + } +}).register('editCardReceivedDatePopup'); + + // editCardStartDatePopup (class extends EditCardDate { onCreated() { @@ -99,6 +116,13 @@ Template.dateBadge.helpers({ this.data().startAt && this.date.set(moment(this.data().startAt)); } + onRendered() { + super.onRendered(); + if (moment.isDate(this.card.receivedAt)) { + this.$('.js-datepicker').datepicker('setStartDate', this.card.receivedAt); + } + } + _storeDate(date) { this.card.setStart(date); } @@ -131,8 +155,31 @@ Template.dateBadge.helpers({ } }).register('editCardDueDatePopup'); +// editCardEndDatePopup +(class extends EditCardDate { + onCreated() { + super.onCreated(); + this.data().endAt && this.date.set(moment(this.data().endAt)); + } + + onRendered() { + super.onRendered(); + if (moment.isDate(this.card.startAt)) { + this.$('.js-datepicker').datepicker('setStartDate', this.card.startAt); + } + } + + _storeDate(date) { + this.card.setEnd(date); + } + + _deleteDate() { + this.card.unsetEnd(); + } +}).register('editCardEndDatePopup'); + -// Display start & due dates +// Display received, start, due & end dates const CardDate = BlazeComponent.extendComponent({ template() { return 'dateBadge'; @@ -161,6 +208,36 @@ const CardDate = BlazeComponent.extendComponent({ }, }); +class CardReceivedDate extends CardDate { + onCreated() { + super.onCreated(); + const self = this; + self.autorun(() => { + self.date.set(moment(self.data().receivedAt)); + }); + } + + classes() { + let classes = 'received-date' + ' '; + if (this.date.get().isBefore(this.now.get(), 'minute') && + this.now.get().isBefore(this.data().dueAt)) { + classes += 'current'; + } + return classes; + } + + showTitle() { + return `${TAPi18n.__('card-received-on')} ${this.date.get().format('LLLL')}`; + } + + events() { + return super.events().concat({ + 'click .js-edit-date': Popup.open('editCardReceivedDate'), + }); + } +} +CardReceivedDate.register('cardReceivedDate'); + class CardStartDate extends CardDate { onCreated() { super.onCreated(); @@ -223,6 +300,44 @@ class CardDueDate extends CardDate { } CardDueDate.register('cardDueDate'); +class CardEndDate extends CardDate { + onCreated() { + super.onCreated(); + const self = this; + self.autorun(() => { + self.date.set(moment(self.data().endAt)); + }); + } + + classes() { + let classes = 'end-date' + ' '; + if (this.data.dueAt.diff(this.date.get(), 'days') >= 2) + classes += 'long-overdue'; + else if (this.data.dueAt.diff(this.date.get(), 'days') >= 0) + classes += 'due'; + else if (this.data.dueAt.diff(this.date.get(), 'days') >= -2) + classes += 'almost-due'; + return classes; + } + + showTitle() { + return `${TAPi18n.__('card-end-on')} ${this.date.get().format('LLLL')}`; + } + + events() { + return super.events().concat({ + 'click .js-edit-date': Popup.open('editCardEndDate'), + }); + } +} +CardEndDate.register('cardEndDate'); + +(class extends CardReceivedDate { + showDate() { + return this.date.get().format('l'); + } +}).register('minicardReceivedDate'); + (class extends CardStartDate { showDate() { return this.date.get().format('l'); @@ -234,3 +349,10 @@ CardDueDate.register('cardDueDate'); return this.date.get().format('l'); } }).register('minicardDueDate'); + +(class extends CardEndDate { + showDate() { + return this.date.get().format('l'); + } +}).register('minicardEndDate'); + |