Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: simplify priority handling #2687

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/components/AppSidebar/MultiselectOption.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
-->

<template>
<div :class="optionClass" class="multiselect-picker-option">
<div :style="{'color': color}" :class="optionClass" class="multiselect-picker-option">
<span class="multiselect-picker-option__icon">
<component :is="icon" :size="20" />
</span>
Expand All @@ -49,6 +49,10 @@ export default {
type: String,
default: null,
},
color: {
type: String,
default: null,
},
},
}
</script>
Expand Down
2 changes: 2 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import Delete from 'vue-material-design-icons/Delete.vue'
import Eye from 'vue-material-design-icons/Eye.vue'
import EyeOff from 'vue-material-design-icons/EyeOff.vue'
import Pulse from 'vue-material-design-icons/Pulse.vue'
import Star from 'vue-material-design-icons/Star.vue'
import TrendingUp from 'vue-material-design-icons/TrendingUp.vue'

import { createApp } from 'vue'
Expand All @@ -59,6 +60,7 @@ const Tasks = createApp(App)
.component('IconEye', Eye)
.component('IconEyeOff', EyeOff)
.component('IconPulse', Pulse)
.component('IconStar', Star)
.component('IconTrendingUp', TrendingUp)
.provide('$OCA', OCA)
.provide('$appVersion', appVersion)
Expand Down
6 changes: 5 additions & 1 deletion src/store/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,12 @@ const mutations = {
* @param {Task} task The task
*/
toggleStarred(state, task) {
if (+task.priority < 1 || +task.priority > 4) {
if (task.priority === 0) {
task.priority = 1
} else if (task.priority < 5) {
task.priority = 5
} else if (task.priority === 5) {
task.priority = 9
} else {
task.priority = 0
}
Expand Down
83 changes: 51 additions & 32 deletions src/views/AppSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -166,19 +166,13 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
:placeholder="t('tasks', 'Select a status')"
icon="IconPulse"
@change-value="changeStatus" />
<SliderItem v-show="!readOnly || task.priority"
:value="task.priority"
:property-string="priorityString"
:read-only="readOnly"
:min-value="0"
:max-value="9"
:color="priorityColor"
:task="task"
@set-value="({task, value}) => setPriority({ task, priority: value })">
<template #icon>
<Star :size="20" />
</template>
</SliderItem>
<MultiselectItem v-show="!readOnly || priority"
:value="priorityOptions.find( _ => _.value === priority )"
:options="priorityOptions"
:disabled="readOnly"
:placeholder="t('tasks', 'Select a priority')"
icon="IconStar"
@change-value="changePriority" />
<SliderItem v-show="!readOnly || task.complete"
:value="task.complete"
:property-string="completeString"
Expand Down Expand Up @@ -300,7 +294,6 @@ import Pencil from 'vue-material-design-icons/Pencil.vue'
import Percent from 'vue-material-design-icons/Percent.vue'
import Pin from 'vue-material-design-icons/Pin.vue'
import PinOff from 'vue-material-design-icons/PinOff.vue'
import Star from 'vue-material-design-icons/Star.vue'
import TextBoxOutline from 'vue-material-design-icons/TextBoxOutline.vue'
import Undo from 'vue-material-design-icons/Undo.vue'
import Web from 'vue-material-design-icons/Web.vue'
Expand Down Expand Up @@ -328,7 +321,6 @@ export default {
Percent,
Pin,
PinOff,
Star,
TextBoxOutline,
Undo,
Web,
Expand Down Expand Up @@ -612,29 +604,17 @@ export default {
showAllDayToggle() {
return !this.readOnly && (this.task.due || this.task.start || this.editingStart || this.editingDue)
},
priorityColor() {
if (+this.task.priority > 5) {
return '#4271a6'
}
if (+this.task.priority === 5) {
return '#fd0'
}
if (+this.task.priority > 0) {
return '#b3312d'
}
return null
},
priorityString() {
priority() {
if (+this.task.priority > 5) {
return t('tasks', 'Priority {priority}: low', { priority: this.task.priority })
return 9
}
if (+this.task.priority === 5) {
return t('tasks', 'Priority {priority}: medium', { priority: this.task.priority })
return 5
}
if (+this.task.priority > 0) {
return t('tasks', 'Priority {priority}: high', { priority: this.task.priority })
return 1
}
return t('tasks', 'No priority assigned')
return 0
},
priorityClass() {
if (+this.task.priority > 5) {
Expand All @@ -648,6 +628,41 @@ export default {
}
return null
},
priorityOptions() {
const priorityOptions = [
{
displayName: t('tasks', 'High'),
value: 1,
icon: 'IconStar',
optionClass: 'active',
color: '#b3312d',
},
{
displayName: t('tasks', 'Medium'),
value: 5,
icon: 'IconStar',
optionClass: 'active',
color: '#fd0',
},
{
displayName: t('tasks', 'Low'),
value: 9,
icon: 'IconStar',
optionClass: 'active',
color: '#4271a6',
},
]
if (this.task.priority) {
return priorityOptions.concat([{
displayName: t('tasks', 'Clear priority'),
value: null,
icon: 'IconDelete',
optionClass: 'center',
color: null,
}])
}
return priorityOptions
},
completeString() {
return t('tasks', '{percent} % completed', { percent: this.task.complete })
},
Expand Down Expand Up @@ -825,6 +840,10 @@ export default {
this.setStatus({ task: this.task, status: status.type })
},

changePriority(priority) {
this.setPriority({ task: this.task, priority: priority.value })
},

/**
* Sets the tags of a task
*
Expand Down