Skip to content

Commit

Permalink
Make collection id a property
Browse files Browse the repository at this point in the history
  • Loading branch information
raimund-schluessler committed Jul 14, 2019
1 parent d1126da commit 366454b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
34 changes: 24 additions & 10 deletions src/components/Task.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
<span :class="{overdue: overdue(task.due)}" class="duedate">
{{ task.due | formatDate }}
</span>
<span v-if="$route.params.collectionId=='week'" class="listname">
<span v-if="collectionId=='week'" class="listname">
<span :style="{'background-color': task.calendar.color}" class="calendar-indicator" />
<span>{{ task.calendar.displayName }}</span>
</span>
Expand Down Expand Up @@ -120,6 +120,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
<TaskBodyComponent v-for="subtask in filteredSubtasks"
:key="subtask.uid"
:task="subtask"
:collection-string="collectionString"
class="subtask"
/>
</task-drag-container>
Expand Down Expand Up @@ -165,13 +166,18 @@ export default {
task: {
type: Object,
required: true
}
},
collectionString: {
type: String,
default: null,
required: false
},
},
data() {
return {
showSubtaskInput: false,
newTaskName: '',
isAddingTask: false
isAddingTask: false,
}
},
computed: {
Expand All @@ -181,6 +187,14 @@ export default {
searchQuery: 'searchQuery',
}),
collectionId: function() {
if (this.collectionString) {
return this.collectionString.split('-')[0]
} else {
return null
}
},
iconStar: function() {
if (+this.task.priority > 5) {
return 'icon-color icon-task-star-low'
Expand Down Expand Up @@ -223,10 +237,10 @@ export default {
return !task.completed
})
}
if (['today', 'week', 'starred', 'current'].indexOf(this.$route.params.collectionId) > -1
if (['today', 'week', 'starred', 'current'].indexOf(this.collectionId) > -1
&& this.$route.params.taskId !== this.task.uri) {
subTasks = subTasks.filter(task => {
return isTaskInList(task, this.$route.params.collectionId)
return isTaskInList(task, this.collectionId)
})
}
return sort([...subTasks], this.sortOrder, this.sortDirection)
Expand Down Expand Up @@ -327,8 +341,8 @@ export default {
}
if (this.$route.params.calendarId) {
this.$router.push({ name: 'calendarsTask', params: { calendarId: this.$route.params.calendarId, taskId: this.task.uri } })
} else if (this.$route.params.collectionId) {
this.$router.push({ name: 'collectionsTask', params: { collectionId: this.$route.params.collectionId, taskId: this.task.uri } })
} else if (this.collectionId) {
this.$router.push({ name: 'collectionsTask', params: { collectionId: this.collectionId, taskId: this.task.uri } })
}
}
},
Expand All @@ -345,13 +359,13 @@ export default {
// If the task is created in a collection view,
// set the appropriate properties.
if (this.$route.params.collectionId === 'starred') {
if (this.collectionId === 'starred') {
task.priority = '1'
}
if (this.$route.params.collectionId === 'today') {
if (this.collectionId === 'today') {
task.due = moment().startOf('day').format('YYYY-MM-DDTHH:mm:ss')
}
if (this.$route.params.collectionId === 'current') {
if (this.collectionId === 'current') {
task.start = moment().format('YYYY-MM-DDTHH:mm:ss')
}
Expand Down
1 change: 1 addition & 0 deletions src/components/TheCollections/General.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
<TaskBody v-for="task in sort(calendar.filteredTasks, sortOrder, sortDirection)"
:key="task.id"
:task="task"
:collection-string="collectionId"
/>
</task-drag-container>
<LoadCompletedButton v-if="collectionId === 'completed'" :calendar="calendar" />
Expand Down
1 change: 1 addition & 0 deletions src/components/TheCollections/Week.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
<TaskBody v-for="task in sort(day.tasks, sortOrder, sortDirection)"
:key="task.id"
:task="task"
:collection-string="'week-' + day.diff"
/>
</task-drag-container>
</div>
Expand Down

0 comments on commit 366454b

Please sign in to comment.