-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Introduce schedule management and calendar components (#1327)
* feat: Introduce schedule management and calendar components - Add `WorksiteCalendar.vue` to manage worksite schedules with calendar, map, and upcoming view modes - Implement schedule exporting in CSV, PDF, and ICS formats - Integrate `@schedule-x` for calendar functionality - Enable schedule editing and creation for worksite assignments - Add detailed work type interfaces in `types` fix: Improve existing components for better integration - Modify `AjaxTable.vue` to emit `rowClick` and `selectionChanged` events - Update `WorksiteTable.vue` styling and support passing custom table body styles - Adjust incident handling in `AddFromList` and `List` components for more consistent query parameters chore: Update dependencies for calendar integration - Add `@schedule-x` dependencies to `package.json` * refactor: remove Vuex ORM integration and simplify team data fetching - Removed Vuex ORM and related dependencies in `AddScheduleDialog` test setup. - Replaced Vuex ORM team fetching with direct `axios` call in `AddScheduleDialog.vue`. - Cleaned up unused test code and adjusted mocking for consistency. These changes simplify dependencies by removing Vuex ORM, streamlining the team data fetching process, and improving test maintainability.
- Loading branch information
Showing
22 changed files
with
2,252 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<template> | ||
<div class="flex flex-col"> | ||
<div class="flex items-center justify-between p-2"> | ||
<div></div> | ||
<div class="flex gap-2 mr-2"> | ||
<ccu-icon | ||
:alt="$t('casesVue.map_view')" | ||
data-testid="testMapViewIcon" | ||
size="medium" | ||
class="cursor-pointer" | ||
:class="showingMap ? 'filter-yellow' : 'filter-gray'" | ||
type="map" | ||
ccu-event="user_ui-view-map" | ||
@click="() => showMap(true)" | ||
/> | ||
<ccu-icon | ||
:alt="$t('casesVue.table_view')" | ||
data-testid="testTableViewIcon" | ||
size="medium" | ||
class="cursor-pointer" | ||
:class="showingTable ? 'filter-yellow' : 'filter-gray'" | ||
type="table" | ||
ccu-event="user_ui-view-table" | ||
@click="showTable" | ||
/> | ||
</div> | ||
</div> | ||
<div class="relative flex-grow border-t"> | ||
<SimpleMap | ||
v-show="showingMap" | ||
:map-loading="false" | ||
data-testid="mapPopupTest" | ||
/> | ||
<WorksiteTable | ||
v-show="showingTable" | ||
:worksite-query="props.query" | ||
:body-style="{ height: '32rem' }" | ||
@row-click="onSelectWorksite" | ||
/> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import SimpleMap from '@/components/SimpleMap.vue'; | ||
import useWorksiteMap from '@/hooks/worksite/useWorksiteMap'; | ||
import CcuIcon from '@/components/BaseIcon.vue'; | ||
import WorksiteTable from '@/components/work/WorksiteTable.vue'; | ||
import { loadCasesCached } from '@/utils/worksite'; | ||
import BaseCheckbox from '@/components/BaseCheckbox.vue'; | ||
const props = defineProps<{ | ||
incidentId: number; | ||
query?: Record<string, any> | null; | ||
}>(); | ||
const emits = defineEmits(['selectWorksite']); | ||
let mapUtils: ReturnType<typeof useWorksiteMap> | null = null; | ||
const showingMap = ref(true); | ||
const showingTable = ref(false); | ||
const showMap = (show: boolean) => { | ||
showingMap.value = show; | ||
showingTable.value = !show; | ||
}; | ||
const showTable = () => { | ||
showingTable.value = true; | ||
showingMap.value = false; | ||
}; | ||
const onSelectWorksite = (worksite: any) => { | ||
emits('selectWorksite', worksite); | ||
}; | ||
async function getWorksites() { | ||
const response = await loadCasesCached(props.query); | ||
return response.results; | ||
} | ||
/** | ||
* Minimal example that fetches worksites for the given incident | ||
* and sets a default or custom center. | ||
*/ | ||
onMounted(async () => { | ||
try { | ||
// 1. Fetch worksites by incident | ||
const worksites = await getWorksites(props.incidentId); | ||
// 2. Initialize the map composable | ||
mapUtils = useWorksiteMap( | ||
worksites, | ||
worksites.map((ws) => ws.id), | ||
(w) => { | ||
onSelectWorksite(w); | ||
}, | ||
(_, map) => { | ||
// Map centering logic | ||
if (props.incidentCenter) { | ||
// incidentCenter is typically [longitude, latitude] | ||
map.setView([props.incidentCenter[1], props.incidentCenter[0]], 5); | ||
} else { | ||
// Fallback center if none is provided | ||
map.setView([35.7465, -96.4115], 5); | ||
} | ||
}, | ||
); | ||
} catch (error) { | ||
console.error('Error fetching worksites for popup map:', error); | ||
} | ||
}); | ||
</script> | ||
|
||
<style scoped> | ||
/* You can style your popup container here if needed */ | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.