fix: task default color should be set and evaluated properly

This commit is contained in:
kolaente 2022-06-16 18:11:42 +02:00
parent 7ef0d8c4ea
commit 37c36560fb
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
2 changed files with 7 additions and 4 deletions

View file

@ -4,9 +4,9 @@
:class="{ :class="{
'is-loading': loadingInternal || loading, 'is-loading': loadingInternal || loading,
'draggable': !(loadingInternal || loading), 'draggable': !(loadingInternal || loading),
'has-light-text': !colorIsDark(task.hexColor) && task.hexColor !== `#${task.defaultColor}` && task.hexColor !== task.defaultColor, 'has-light-text': task.getHexColor() !== TASK_DEFAULT_COLOR && !colorIsDark(task.getHexColor()),
}" }"
:style="{'background-color': task.hexColor !== '#' && task.hexColor !== `#${task.defaultColor}` ? task.hexColor : false}" :style="{'background-color': task.hexColor !== '#' && task.hexColor !== '' ? task.hexColor : false}"
@click.exact="openTaskDetail()" @click.exact="openTaskDetail()"
@click.ctrl="() => toggleTaskDone(task)" @click.ctrl="() => toggleTaskDone(task)"
@click.meta="() => toggleTaskDone(task)" @click.meta="() => toggleTaskDone(task)"
@ -74,6 +74,7 @@ import User from '../../../components/misc/user'
import Done from '@/components/misc/Done.vue' import Done from '@/components/misc/Done.vue'
import Labels from '../../../components/tasks/partials/labels' import Labels from '../../../components/tasks/partials/labels'
import ChecklistSummary from './checklist-summary' import ChecklistSummary from './checklist-summary'
import {TASK_DEFAULT_COLOR} from '@/models/task'
import {colorIsDark} from '@/helpers/color/colorIsDark' import {colorIsDark} from '@/helpers/color/colorIsDark'
@ -89,6 +90,7 @@ export default defineComponent({
data() { data() {
return { return {
loadingInternal: false, loadingInternal: false,
TASK_DEFAULT_COLOR,
} }
}, },
props: { props: {

View file

@ -8,6 +8,7 @@ import SubscriptionModel from '@/models/subscription'
import {parseDateOrNull} from '@/helpers/parseDateOrNull' import {parseDateOrNull} from '@/helpers/parseDateOrNull'
const SUPPORTS_TRIGGERED_NOTIFICATION = 'Notification' in window && 'showTrigger' in Notification.prototype const SUPPORTS_TRIGGERED_NOTIFICATION = 'Notification' in window && 'showTrigger' in Notification.prototype
export const TASK_DEFAULT_COLOR = '#1973ff'
export default class TaskModel extends AbstractModel { export default class TaskModel extends AbstractModel {
constructor(data) { constructor(data) {
@ -187,8 +188,8 @@ export default class TaskModel extends AbstractModel {
} }
getHexColor() { getHexColor() {
if (this.hexColor === '') { if (this.hexColor === '' || this.hexColor === '#') {
return `#${this.defaultColor}` return TASK_DEFAULT_COLOR
} }
return this.hexColor return this.hexColor