Compare commits

...

4 Commits

6 changed files with 40 additions and 14 deletions

View File

@ -25,12 +25,18 @@ export function createDefaultViews(projectId) {
view_kind: 3,
bucket_configuration_mode: 1,
}, false)
const calendar = ProjectViewFactory.create(1, {
id: 5,
project_id: projectId,
view_kind: 4,
}, false)
return [
list[0],
gantt[0],
table[0],
kanban[0],
calendar[0],
]
}

View File

@ -147,6 +147,8 @@ function getViewTitle(view: IProjectView) {
return t('project.table.title')
case 'Kanban':
return t('project.kanban.title')
case 'Calendar':
return t('project.calendar.title')
}
return view.title

View File

@ -33,6 +33,7 @@ import { useAuthStore } from '@/stores/auth'
import TaskService from '@/services/task'
import TaskModel from '@/models/task'
import type { DateSelectArg, EventAddArg, EventChangeArg, EventClickArg, CustomContentGenerator, EventContentArg } from '@fullcalendar/core/index.js'
import router from '@/router'
const {
projectId,
@ -65,20 +66,23 @@ function is_midnight(time?: Date) {
return (time && time.getHours() == 0 && time.getMinutes() == 0)
}
watch(
allTasks,
() => {
console.log(allTasks.value)
for (const task of allTasks.value) {
const allDay = (task.startDate && is_midnight(task.startDate) && task.endDate && (is_midnight(task.endDate) || is_midnight(task.endDate)))
function isAllDay(task: ITask){
return (task.startDate && is_midnight(task.startDate) && task.endDate && (is_midnight(task.endDate) || is_midnight(task.endDate)))
}
watch(
[allTasks, calendar],
() => {
if(!calendar.value)
return
for (const task of allTasks.value) {
if (task.startDate)
calendar.value.calendar.addEvent({
id: task.id,
title: task.title,
start: task.startDate,
end: task.endDate,
allDay: allDay,
allDay: isAllDay(task),
color: task.hexColor,
extendedProps: {
exists: true,
@ -114,6 +118,12 @@ function handleDateSelect(selectInfo: DateSelectArg) {
}
function handleEventClick(clickInfo: EventClickArg) {
router.push({
name: 'task.detail',
params: {id: clickInfo.event.id},
//state: {backdropView: router.currentRoute.value.fullPath},
})
return
if (confirm(`Are you sure you want to delete the event '${clickInfo.event.title}'`)) {
clickInfo.event.extendedProps.task.done != clickInfo.event.extendedProps.task.done
console.log('here')
@ -136,7 +146,7 @@ function eventRender(info: CustomContentGenerator<EventContentArg>) {
if (event.end)
timeEl.innerHTML += ' - ' + parseTime(event.end)
if (event.extendedProps.task.done) {
if (event.extendedProps.task && event.extendedProps.task.done) {
const strikethroughEl = document.createElement('s')
strikethroughEl.innerHTML = titleEl.innerHTML
titleEl = strikethroughEl
@ -164,7 +174,18 @@ async function eventAddHandler(addEvent: EventAddArg) {
const createdTask = await taskService.create(task)
addEvent.event.id = createdTask.id
addEvent.event = {
id: String(createdTask.id),
title: createdTask.title,
start: createdTask.startDate,
end: createdTask.endDate,
allDay: isAllDay(createdTask) ?? false,
color: createdTask.hexColor,
extendedProps: {
exists: true,
task: createdTask,
},
}
eventGuid = createdTask.id + 1
}

View File

@ -1,7 +1,7 @@
import type {IAbstract} from './IAbstract'
import type {IProject} from '@/modelTypes/IProject'
export const PROJECT_VIEW_KINDS = ['list', 'gantt', 'table', 'kanban']
export const PROJECT_VIEW_KINDS = ['list', 'gantt', 'table', 'kanban', 'calendar']
export type ProjectViewKind = typeof PROJECT_VIEW_KINDS[number]
export const PROJECT_VIEW_BUCKET_CONFIGURATION_MODES = ['none', 'manual', 'filter']

View File

@ -31,12 +31,10 @@ const viewToEdit = ref<IProjectView | null>(null)
async function createView() {
if (!showCreateForm.value) {
showCreateForm.value = true
alert(1)
return
}
if (newView.value.title === '') {
alert(2)
return
}
@ -52,7 +50,6 @@ async function createView() {
projectStore.setProjectView(result)
newView.value = new ProjectViewModel({})
} catch (e) {
alert(e)
error(e)
}
}

View File

@ -61,7 +61,7 @@ func (p *ProjectViewKind) UnmarshalJSON(bytes []byte) error {
case "kanban":
*p = ProjectViewKindKanban
case "calendar":
*p = ProjectViewKindKanban
*p = ProjectViewKindCalendar
default:
return fmt.Errorf("unknown project view kind: %s", value)
}