Make collection id a property

Signed-off-by: Raimund Schlüßler <raimund.schluessler@mailbox.org>
This commit is contained in:
Raimund Schlüßler 2019-06-25 22:23:49 +02:00
parent 09823783ad
commit 18e2e9145b
No known key found for this signature in database
GPG key ID: 036FA7EB1A599178
3 changed files with 26 additions and 10 deletions

View file

@ -72,7 +72,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
<div class="task-status-container"> <div class="task-status-container">
<TaskStatusDisplay :task="task" /> <TaskStatusDisplay :task="task" />
</div> </div>
<div v-if="$route.params.collectionId=='week'" class="calendar"> <div v-if="collectionId=='week'" class="calendar">
<span :style="{'background-color': task.calendar.color}" class="calendar-indicator" /> <span :style="{'background-color': task.calendar.color}" class="calendar-indicator" />
<span class="calendar-name">{{ task.calendar.displayName }}</span> <span class="calendar-name">{{ task.calendar.displayName }}</span>
</div> </div>
@ -129,6 +129,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
<TaskBodyComponent v-for="subtask in filteredSubtasks" <TaskBodyComponent v-for="subtask in filteredSubtasks"
:key="subtask.uid" :key="subtask.uid"
:task="subtask" :task="subtask"
:collection-string="collectionString"
class="subtask" class="subtask"
/> />
</task-drag-container> </task-drag-container>
@ -174,13 +175,18 @@ export default {
task: { task: {
type: Object, type: Object,
required: true required: true
} },
collectionString: {
type: String,
default: null,
required: false
},
}, },
data() { data() {
return { return {
showSubtaskInput: false, showSubtaskInput: false,
newTaskName: '', newTaskName: '',
isAddingTask: false isAddingTask: false,
} }
}, },
computed: { computed: {
@ -190,6 +196,14 @@ export default {
searchQuery: 'searchQuery', searchQuery: 'searchQuery',
}), }),
collectionId: function() {
if (this.collectionString) {
return this.collectionString.split('-')[0]
} else {
return null
}
},
iconStar: function() { iconStar: function() {
if (+this.task.priority > 5) { if (+this.task.priority > 5) {
return 'icon-color icon-task-star-low' return 'icon-color icon-task-star-low'
@ -232,10 +246,10 @@ export default {
return !task.completed 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) { && this.$route.params.taskId !== this.task.uri) {
subTasks = subTasks.filter(task => { subTasks = subTasks.filter(task => {
return isTaskInList(task, this.$route.params.collectionId) return isTaskInList(task, this.collectionId)
}) })
} }
return sort([...subTasks], this.sortOrder, this.sortDirection) return sort([...subTasks], this.sortOrder, this.sortDirection)
@ -343,8 +357,8 @@ export default {
} }
if (this.$route.params.calendarId) { if (this.$route.params.calendarId) {
this.$router.push({ name: 'calendarsTask', params: { calendarId: this.$route.params.calendarId, taskId: this.task.uri } }) this.$router.push({ name: 'calendarsTask', params: { calendarId: this.$route.params.calendarId, taskId: this.task.uri } })
} else if (this.$route.params.collectionId) { } else if (this.collectionId) {
this.$router.push({ name: 'collectionsTask', params: { collectionId: this.$route.params.collectionId, taskId: this.task.uri } }) this.$router.push({ name: 'collectionsTask', params: { collectionId: this.collectionId, taskId: this.task.uri } })
} }
} }
}, },
@ -361,13 +375,13 @@ export default {
// If the task is created in a collection view, // If the task is created in a collection view,
// set the appropriate properties. // set the appropriate properties.
if (this.$route.params.collectionId === 'starred') { if (this.collectionId === 'starred') {
task.priority = '1' task.priority = '1'
} }
if (this.$route.params.collectionId === 'today') { if (this.collectionId === 'today') {
task.due = moment().startOf('day').format('YYYY-MM-DDTHH:mm:ss') 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') task.start = moment().format('YYYY-MM-DDTHH:mm:ss')
} }

View file

@ -55,6 +55,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
<Task v-for="task in sort(calendar.filteredTasks, sortOrder, sortDirection)" <Task v-for="task in sort(calendar.filteredTasks, sortOrder, sortDirection)"
:key="task.key" :key="task.key"
:task="task" :task="task"
:collection-string="collectionId"
/> />
</task-drag-container> </task-drag-container>
<LoadCompletedButton v-if="collectionId === 'completed'" :calendar="calendar" /> <LoadCompletedButton v-if="collectionId === 'completed'" :calendar="calendar" />

View file

@ -36,6 +36,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
<Task v-for="task in sort(day.tasks, sortOrder, sortDirection)" <Task v-for="task in sort(day.tasks, sortOrder, sortDirection)"
:key="task.key" :key="task.key"
:task="task" :task="task"
:collection-string="'week-' + day.diff"
/> />
</task-drag-container> </task-drag-container>
</div> </div>