offer heavy spread placement

This commit is contained in:
Yisroel Baum 2026-08-20 08:24:26 +03:00
parent 0a7848a342
commit d2aad964d2
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
2 changed files with 11 additions and 29 deletions

View file

@ -42,7 +42,8 @@ Attainly then distributes the selected elements across the available days.
When there are fewer assignments than days, the user can spread them across
the full range or pack them into consecutive days at the start, middle, or
end. When an uneven schedule has more than one assignment per day, the user
can place the consecutive heavier days at the start, middle, or end.
can spread the heavier days across the full range or keep them together at
the start, middle, or end.
For example, a user could choose to schedule:

View file

@ -14,7 +14,6 @@ import { useSetLayoutStore } from '@/stores/setLayout'
type ScheduleField = 'levelId' | 'startDate' | 'targetDate'
type ScheduleFieldErrors = Partial<Record<ScheduleField, string>>
type PackedWorkloadPlacement = Exclude<WorkloadPlacement, 'spread'>
type PlacementContext = 'unavailable' | 'sparse' | 'heavy' | 'balanced'
const route = useRoute()
@ -30,17 +29,18 @@ const form = reactive({
targetDate: '',
})
const sparseWorkloadPlacement = ref<WorkloadPlacement>('spread')
const heavyWorkloadPlacement = ref<PackedWorkloadPlacement>('middle')
const heavyWorkloadPlacement = ref<WorkloadPlacement>('middle')
const fieldErrors = ref<ScheduleFieldErrors>({})
const levels = computed(() =>
(layout.value?.levels ?? []).filter((level) => level.elementCount > 0),
)
const selectedLevel = computed(() => levels.value.find((level) => level.id === form.levelId))
const packedWorkloadPlacementOptions: Array<{
value: PackedWorkloadPlacement
const workloadPlacementOptions: Array<{
value: WorkloadPlacement
label: string
}> = [
{ value: 'spread', label: 'Spread evenly' },
{ value: 'start', label: 'At the start' },
{ value: 'middle', label: 'In the middle' },
{ value: 'end', label: 'At the end' },
@ -78,15 +78,6 @@ const placementContext = computed<PlacementContext>(() => {
const showWorkloadPlacement = computed(
() => placementContext.value === 'sparse' || placementContext.value === 'heavy',
)
const workloadPlacementOptions = computed<Array<{ value: WorkloadPlacement; label: string }>>(
() => {
if (placementContext.value === 'sparse') {
return [{ value: 'spread', label: 'Spread evenly' }, ...packedWorkloadPlacementOptions]
}
return packedWorkloadPlacementOptions
},
)
const selectedWorkloadPlacement = computed<WorkloadPlacement>({
get() {
if (placementContext.value === 'sparse') {
@ -102,9 +93,7 @@ const selectedWorkloadPlacement = computed<WorkloadPlacement>({
return
}
if (value !== 'spread') {
heavyWorkloadPlacement.value = value
}
heavyWorkloadPlacement.value = value
},
})
@ -290,14 +279,10 @@ async function retry(): Promise<void> {
Spread assignments across the schedule or keep them on consecutive days.
</p>
<p v-else>
Some days need one extra assignment. Choose where those days appear in the schedule.
Spread heavier days across the schedule or keep them together at the start, middle, or
end.
</p>
<div
class="workload-placement__options"
:class="{
'workload-placement__options--sparse': placementContext === 'sparse',
}"
>
<div class="workload-placement__options">
<label
v-for="option in workloadPlacementOptions"
:key="option.value"
@ -433,12 +418,8 @@ h1 {
.workload-placement__options {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 0.65rem;
}
.workload-placement__options--sparse {
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 0.65rem;
}
.workload-placement__option {