const PlannerGrid = { components: { 'agent-row': AgentRow }, template: `
EOD TARGETS
94%
COVERAGE STATUS
Jump to Date
Go to Date
{{ date.toLocaleDateString('en-US', {weekday: 'short'}) }}
{{ date.getDate() }}
{{ dept }} DIVISION
`, setup() { const { ref, computed, nextTick } = Vue; const viewport = ref(null); // Connect to store const dates = computed(() => store.dates); const settings = store.viewSettings; const search = computed({ get: () => settings.searchQuery, set: (val) => settings.searchQuery = val }); // Filter Logic const agents = computed(() => store.filteredAgents); const shouldShowDept = (dept) => { if (settings.activeDept !== 'All' && settings.activeDept !== dept) return false; // If checking if any agents in this dept exist after filter return agents.value.some(a => a.dept === dept); }; const getAgentsByDept = (dept) => { return agents.value.filter(a => a.dept === dept); }; // Date Picker Logic // Date Picker Logic const tempPickedDate = ref(null); const initDateSelection = () => { // Initialize with current store start date const current = new Date(settings.startDate); // Format as YYYY-MM-DD const y = current.getFullYear(); const m = String(current.getMonth() + 1).padStart(2, '0'); const d = String(current.getDate()).padStart(2, '0'); tempPickedDate.value = `${y}-${m}-${d}`; }; const applyDateSelection = () => { if (!tempPickedDate.value) return; const val = tempPickedDate.value; const target = new Date(val); const targetStr = target.toDateString(); // Re-calculate store dates based on current view settings // incase user changed start date previously // Check if date is visible in current range? // Actually, requirements say "jumps to that date". // If date is outside current range, we should move the range start? // Existing logic: const index = dates.value.findIndex(d => d.toDateString() === targetStr); if (index === -1) { // Not in current view -> Move view directly store.setStartDate(val); nextTick(() => { if (viewport.value) viewport.value.scrollLeft = 0; }); } else { // In current view -> Scroll to it if (viewport.value) viewport.value.scrollLeft = index * 100; // 100 is cell width } }; const getTextColorClass = (date) => { const isWeekend = ValidationUtils.isWeekend(date); if (isWeekend && !settings.weekendsAreWorkingDays) { return ValidationUtils.isSat(date) ? 'text-sat' : 'text-sun'; } return 'text-grey-9'; // default }; return { viewport, dates, settings, search, depts: store.consts.DEPARTMENTS, tempPickedDate, initDateSelection, applyDateSelection, shouldShowDept, getAgentsByDept, ValidationUtils, getTextColorClass } } };