fix: remove hardcoded task status/priority options and get from meta
This commit is contained in:
parent
a2bc12d58a
commit
c5bc6fe36b
@ -43,6 +43,7 @@
|
||||
clip-rule="evenodd"
|
||||
d="M8 15C11.866 15 15 11.866 15 8C15 4.13401 11.866 1 8 1C4.13401 1 1 4.13401 1 8C1 11.866 4.13401 15 8 15ZM5.14645 5.14645C4.95118 5.34171 4.95118 5.65829 5.14645 5.85355L7.29289 8L5.14645 10.1464C4.95118 10.3417 4.95118 10.6583 5.14645 10.8536C5.34171 11.0488 5.65829 11.0488 5.85355 10.8536L8 8.70711L10.1464 10.8536C10.3417 11.0488 10.6583 11.0488 10.8536 10.8536C11.0488 10.6583 11.0488 10.3417 10.8536 10.1464L8.70711 8L10.8536 5.85355C11.0488 5.65829 11.0488 5.34171 10.8536 5.14645C10.6583 4.95118 10.3417 4.95118 10.1464 5.14645L8 7.29289L5.85355 5.14645C5.65829 4.95118 5.34171 4.95118 5.14645 5.14645Z"
|
||||
/>
|
||||
<circle v-else-if="status" cx="8" cy="8" r="7" fill="currentColor" />
|
||||
</svg>
|
||||
</template>
|
||||
<script setup>
|
||||
|
||||
@ -3,6 +3,7 @@ import TaskPriorityIcon from '@/components/Icons/TaskPriorityIcon.vue'
|
||||
import { usersStore } from '@/stores/users'
|
||||
import { gemoji } from 'gemoji'
|
||||
import { useTimeAgo } from '@vueuse/core'
|
||||
import { getMeta } from '@/stores/meta'
|
||||
import { toast, dayjsLocal, dayjs } from 'frappe-ui'
|
||||
import { h } from 'vue'
|
||||
|
||||
@ -74,20 +75,39 @@ export function timeAgo(date) {
|
||||
return useTimeAgo(date).value
|
||||
}
|
||||
|
||||
const taskMeta = getMeta('CRM Task')
|
||||
|
||||
export function taskStatusOptions(action, data) {
|
||||
return ['Backlog', 'Todo', 'In Progress', 'Done', 'Canceled'].map(
|
||||
(status) => {
|
||||
return {
|
||||
icon: () => h(TaskStatusIcon, { status }),
|
||||
label: status,
|
||||
onClick: () => action && action(status, data),
|
||||
}
|
||||
},
|
||||
)
|
||||
let options = ['Backlog', 'Todo', 'In Progress', 'Done', 'Canceled']
|
||||
let statusMeta = taskMeta
|
||||
.getFields()
|
||||
?.find((field) => field.fieldname == 'status')
|
||||
if (statusMeta) {
|
||||
options = statusMeta.options
|
||||
.map((option) => option.value)
|
||||
.filter((option) => option)
|
||||
}
|
||||
return options.map((status) => {
|
||||
return {
|
||||
icon: () => h(TaskStatusIcon, { status }),
|
||||
label: status,
|
||||
onClick: () => action && action(status, data),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function taskPriorityOptions(action, data) {
|
||||
return ['Low', 'Medium', 'High'].map((priority) => {
|
||||
let options = ['Low', 'Medium', 'High']
|
||||
let priorityMeta = taskMeta
|
||||
.getFields()
|
||||
?.find((field) => field.fieldname == 'priority')
|
||||
if (priorityMeta) {
|
||||
options = priorityMeta.options
|
||||
.map((option) => option.value)
|
||||
.filter((option) => option)
|
||||
}
|
||||
|
||||
return options.map((priority) => {
|
||||
return {
|
||||
label: priority,
|
||||
icon: () => h(TaskPriorityIcon, { priority }),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user