mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-22 06:49:35 +00:00
build(dev): finished timeblocks rework
This commit is contained in:
1 parent
1b0a9d5fff
commit
90dd4ee4b6
15 files changed
+194
-166
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { useQuery } from '@tanstack/vue-query';
|
||||
import { computed, Ref, unref } from 'vue';
|
||||
import { computed, Ref, unref, watch } from 'vue';
|
||||
import axios from '@/plugins/w@custom/axios/models/axios';
|
||||
import moment from 'moment';
|
||||
import timelineUtils from '@/plugins/tm@dashboard/tasks/_utils/timeline.utils';
|
||||
@@ -130,7 +130,6 @@ export function useEmployeeTimeline(
|
||||
const scheduledTime = computed(() => {
|
||||
const tasks = unref(timelineTasks);
|
||||
const d = unref(date);
|
||||
const now = moment();
|
||||
|
||||
if (!tasks || !d) return 0;
|
||||
|
||||
@@ -145,25 +144,10 @@ export function useEmployeeTimeline(
|
||||
return;
|
||||
}
|
||||
|
||||
if (now.isAfter(moment(task._real_end))) {
|
||||
// Ignore elapsed tasks
|
||||
return;
|
||||
} else if (
|
||||
now.isAfter(moment(task._real_start)) &&
|
||||
now.isBefore(moment(task._real_end))
|
||||
) {
|
||||
// Task in progress
|
||||
totalMinutes += timelineUtils._getDifferenceInMinutes(
|
||||
task._real_end,
|
||||
new Date(),
|
||||
);
|
||||
} else {
|
||||
// Future task
|
||||
totalMinutes += timelineUtils._getDifferenceInMinutes(
|
||||
task._real_end,
|
||||
task._real_start,
|
||||
);
|
||||
}
|
||||
totalMinutes += timelineUtils._getDifferenceInMinutes(
|
||||
task._real_end,
|
||||
task._real_start,
|
||||
);
|
||||
});
|
||||
|
||||
return (totalMinutes / 60).toFixed(1);
|
||||
@@ -177,28 +161,9 @@ export function useEmployeeTimeline(
|
||||
|
||||
if (!emp || !d) return '0';
|
||||
|
||||
const now = moment();
|
||||
const dateObj = moment(d);
|
||||
const dailyCapacityHours = emp.work_end - emp.work_start;
|
||||
|
||||
if (dateObj.isBefore(now, 'days')) {
|
||||
// Past date
|
||||
return '0';
|
||||
} else if (dateObj.isSame(now, 'days')) {
|
||||
// Today - calculate remaining capacity
|
||||
const elapsedMinutes = now.diff(now.clone().startOf('day'), 'minutes');
|
||||
const workStart =
|
||||
emp.work_start * 60 > elapsedMinutes
|
||||
? emp.work_start
|
||||
: elapsedMinutes / 60;
|
||||
const todayCapacityHours = emp.work_end - workStart;
|
||||
const free = todayCapacityHours - scheduled;
|
||||
return free < 0 ? '0' : free.toFixed(1);
|
||||
} else {
|
||||
// Future date
|
||||
const free = dailyCapacityHours - scheduled;
|
||||
return free < 0 ? '0' : free.toFixed(1);
|
||||
}
|
||||
return (dailyCapacityHours - scheduled).toFixed(1);
|
||||
});
|
||||
|
||||
// Detect collisions with current timeblock
|
||||
@@ -237,6 +202,22 @@ export function useEmployeeTimeline(
|
||||
return calculateTimeblockDuration(timeblock);
|
||||
});
|
||||
|
||||
watch(
|
||||
scheduledTime,
|
||||
(newVal) => {
|
||||
console.log('scheduledTime', newVal);
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
watch(
|
||||
freeTime,
|
||||
(newVal) => {
|
||||
console.log('freeTime', newVal);
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
return {
|
||||
// Query states
|
||||
isLoading,
|
||||
|
||||
Reference in new issue
Block a user