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