summaryrefslogtreecommitdiffstats
path: root/client/components/cards/cardTime.js
diff options
context:
space:
mode:
authorThuan Pham Quoc <thuanpq.io@gmail.com>2017-11-20 22:26:31 +0700
committerThuan Pham Quoc <thuanpq.io@gmail.com>2017-11-20 22:26:31 +0700
commiteec3c301bc7b0f29d7a7fcfcf59d330ceb604985 (patch)
tree57000da1012bfdd24363b6449dd77dfddcefe6de /client/components/cards/cardTime.js
parentdfd0b2194746208c85b16fd485e7ca6f0cc34b57 (diff)
downloadwekan-eec3c301bc7b0f29d7a7fcfcf59d330ceb604985.tar.gz
wekan-eec3c301bc7b0f29d7a7fcfcf59d330ceb604985.tar.bz2
wekan-eec3c301bc7b0f29d7a7fcfcf59d330ceb604985.zip
Add card spent time to log time what can be overtime or not (will support filtering in future)
Diffstat (limited to 'client/components/cards/cardTime.js')
-rw-r--r--client/components/cards/cardTime.js77
1 files changed, 77 insertions, 0 deletions
diff --git a/client/components/cards/cardTime.js b/client/components/cards/cardTime.js
new file mode 100644
index 00000000..23331668
--- /dev/null
+++ b/client/components/cards/cardTime.js
@@ -0,0 +1,77 @@
+BlazeComponent.extendComponent({
+ template() {
+ return 'editCardSpentTime';
+ },
+ onCreated() {
+ this.error = new ReactiveVar('');
+ this.card = this.data();
+ },
+ toggleOvertime() {
+ this.card.isOvertime = !this.card.isOvertime;
+ $('#overtime .materialCheckBox').toggleClass('is-checked');
+
+ $('#overtime').toggleClass('is-checked');
+ },
+ storeTime(spentTime, isOvertime) {
+ this.card.setSpentTime(spentTime);
+ this.card.setOvertime(isOvertime);
+ },
+ deleteTime() {
+ this.card.unsetSpentTime();
+ },
+ events() {
+ return [{
+ //TODO : need checking this portion
+ 'submit .edit-time'(evt) {
+ evt.preventDefault();
+
+ const spentTime = parseFloat(evt.target.time.value);
+ const isOvertime = this.card.isOvertime;
+
+ if (spentTime >= 0) {
+ this.storeTime(spentTime, isOvertime);
+ Popup.close();
+ } else {
+ this.error.set('invalid-time');
+ evt.target.time.focus();
+ }
+ },
+ 'click .js-delete-time'(evt) {
+ evt.preventDefault();
+ this.deleteTime();
+ Popup.close();
+ },
+ 'click a.js-toggle-overtime': this.toggleOvertime,
+ }];
+ },
+}).register('editCardSpentTimePopup');
+
+BlazeComponent.extendComponent({
+ template() {
+ return 'timeBadge';
+ },
+ onCreated() {
+ const self = this;
+ self.time = ReactiveVar();
+ },
+ showTitle() {
+ return `${TAPi18n.__('card-spent')} ${this.data().spentTime}`;
+ },
+ showTime() {
+ return this.data().spentTime;
+ },
+ isOvertime() {
+ return this.data().isOvertime;
+ },
+ events() {
+ return [{
+ 'click .js-edit-time': Popup.open('editCardSpentTime'),
+ }];
+ },
+}).register('cardSpentTime');
+
+Template.timeBadge.helpers({
+ canModifyCard() {
+ return Meteor.user() && Meteor.user().isBoardMember() && !Meteor.user().isCommentOnly();
+ },
+});