Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frontend/src/components/assessment/ActivityAssetsManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,8 @@ onMounted(() => {
<component :is="getIconComponent(asset.icon)" :class="compact ? 'h-4 w-4 text-muted-foreground shrink-0' : 'h-6 w-6 text-muted-foreground mb-2'" />

<!-- Name -->
<span :class="[
compact ? 'text-xs font-medium truncate max-w-[100px]' : 'text-sm font-medium text-center line-clamp-2 leading-tight',
<span :title="asset.name" :class="[
compact ? 'text-xs font-medium truncate max-w-[100px]' : 'text-sm font-medium text-center line-clamp-2 leading-tight w-full min-w-0 break-words',
asset.deleted ? 'line-through text-muted-foreground' : ''
]">{{ asset.name }}</span>

Expand Down
33 changes: 22 additions & 11 deletions frontend/src/components/assessment/ActivityDetectionSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { computed } from 'vue';
import ActivityAssetsManager from '@/components/assessment/ActivityAssetsManager.vue';
import { Badge } from '@/components/ui/badge';
import DateTimePicker from '@/components/ui/DateTimePicker.vue';
import DateTimeField from '@/components/ui/DateTimeField.vue';
import { Label } from '@/components/ui/label';
import MarkdownEditor from '@/components/ui/MarkdownEditor.vue';
import {
Expand Down Expand Up @@ -32,6 +32,13 @@ const formData = defineModel<Partial<ActivityRead>>('formData', {
required: true,
});

// One width for every field in this section, so the time pickers (which carry
// their own Now button) and the severity selects line up on both edges
const FIELD_WIDTH = 'w-full max-w-md lg:max-w-lg xl:max-w-xl 2xl:max-w-2xl';
// Hands width control to the wrapper above: without clearing every breakpoint
// the picker keeps its own caps and drifts out of line if FIELD_WIDTH changes
const FIELD_FILL = 'max-w-none lg:max-w-none xl:max-w-none 2xl:max-w-none';

const severityOptions = zActivitySeverity.options;
const preferencesStore = usePreferencesStore();

Expand Down Expand Up @@ -142,13 +149,14 @@ const stakeholderNotificationCreated = computed({
</div>

<div v-if="logged" class="space-y-4 pt-2 border-t">
<div class="space-y-2 w-full sm:w-1/2 pr-2">
<div :class="['space-y-2', FIELD_WIDTH]">
<Label class="text-sm font-medium">Log Time</Label>
<template v-if="readonly">
<div class="text-sm px-3 py-2 rounded-md border bg-muted/30 min-h-[36px] flex items-center">{{ readonlyDate(formData.log_time) }}</div>
</template>
<template v-else>
<DateTimePicker
<DateTimeField
:class="FIELD_FILL"
:model-value="formData.log_time ?? undefined"
@update:model-value="formData.log_time = $event ?? null"
/>
Expand Down Expand Up @@ -197,13 +205,14 @@ const stakeholderNotificationCreated = computed({
</div>

<div v-if="prevented" class="space-y-4 pt-2 border-t">
<div class="space-y-2 w-full sm:w-1/2 pr-2">
<div :class="['space-y-2', FIELD_WIDTH]">
<Label class="text-sm font-medium">Prevention Time</Label>
<template v-if="readonly">
<div class="text-sm px-3 py-2 rounded-md border bg-muted/30 min-h-[36px] flex items-center">{{ readonlyDate(formData.prevent_time) }}</div>
</template>
<template v-else>
<DateTimePicker
<DateTimeField
:class="FIELD_FILL"
:model-value="formData.prevent_time ?? undefined"
@update:model-value="formData.prevent_time = $event ?? null"
/>
Expand Down Expand Up @@ -253,19 +262,20 @@ const stakeholderNotificationCreated = computed({

<div v-if="alerted" class="space-y-4 pt-2 border-t">
<div class="space-y-4">
<div class="space-y-2 w-full sm:w-1/2 pr-2">
<div :class="['space-y-2', FIELD_WIDTH]">
<Label class="text-sm font-medium">Alert Time</Label>
<template v-if="readonly">
<div class="text-sm px-3 py-2 rounded-md border bg-muted/30 min-h-[36px] flex items-center">{{ readonlyDate(formData.alert_time) }}</div>
</template>
<template v-else>
<DateTimePicker
<DateTimeField
:class="FIELD_FILL"
:model-value="formData.alert_time ?? undefined"
@update:model-value="formData.alert_time = $event ?? null"
/>
</template>
</div>
<div class="space-y-2 w-full sm:w-1/2 pr-2">
<div :class="['space-y-2', FIELD_WIDTH]">
<Label class="text-sm font-medium">Alert Severity</Label>
<template v-if="readonly">
<div class="text-sm px-3 py-2 rounded-md border bg-muted/30 min-h-[36px] flex items-center">{{ formData.alert_severity || '—' }}</div>
Expand Down Expand Up @@ -328,19 +338,20 @@ const stakeholderNotificationCreated = computed({

<div v-if="stakeholderNotificationCreated" class="space-y-4 pt-2 border-t">
<div class="space-y-4">
<div class="space-y-2 w-full sm:w-1/2 pr-2">
<div :class="['space-y-2', FIELD_WIDTH]">
<Label class="text-sm font-medium">Notification Time</Label>
<template v-if="readonly">
<div class="text-sm px-3 py-2 rounded-md border bg-muted/30 min-h-[36px] flex items-center">{{ readonlyDate(formData.stakeholder_notification_time) }}</div>
</template>
<template v-else>
<DateTimePicker
<DateTimeField
:class="FIELD_FILL"
:model-value="formData.stakeholder_notification_time ?? undefined"
@update:model-value="formData.stakeholder_notification_time = $event ?? null"
/>
</template>
</div>
<div class="space-y-2 w-full sm:w-1/2 pr-2">
<div :class="['space-y-2', FIELD_WIDTH]">
<Label class="text-sm font-medium">Notification Severity</Label>
<template v-if="readonly">
<div class="text-sm px-3 py-2 rounded-md border bg-muted/30 min-h-[36px] flex items-center">{{ formData.stakeholder_notification_severity || '—' }}</div>
Expand Down
26 changes: 21 additions & 5 deletions frontend/src/components/assessment/ActivityForm.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { BookOpen, Copy, History } from '@lucide/vue';
import { useElementSize } from '@vueuse/core';
import { useElementBounding, useElementSize } from '@vueuse/core';
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
import { toast } from 'vue-sonner';
import ActivityAssetsManager from '@/components/assessment/ActivityAssetsManager.vue';
Expand All @@ -13,7 +13,7 @@ import ConflictResolutionDialog from '@/components/assessment/ConflictResolution
import KnowledgeBaseModal from '@/components/assessment/KnowledgeBaseModal.vue';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import DateTimePicker from '@/components/ui/DateTimePicker.vue';
import DateTimeField from '@/components/ui/DateTimeField.vue';
import { Label } from '@/components/ui/label';
import MarkdownEditor from '@/components/ui/MarkdownEditor.vue';
import {
Expand Down Expand Up @@ -138,6 +138,16 @@ const { height: stickyHeaderHeight } = useElementSize(stickyHeader, undefined, {
box: 'border-box',
});

// Once the tab bar is stuck it sits flush under the header, and the header's
// divider would cut across the tabs' rounded tops. The border stays in place so
// the header keeps its height - only its colour goes - otherwise removing it
// would shrink the header, shift the tab bar up and flip this back and forth.
const sectionTabsEl = computed(() => sectionTabs.value?.$el ?? null);
const { top: sectionTabsTop } = useElementBounding(sectionTabsEl);
const sectionTabsStuck = computed(
() => sectionTabsTop.value <= stickyHeaderHeight.value,
);

// Clicking a tab while the bar is stuck jumps to the start of that section
function onSectionTabClicked() {
const tabsEl = sectionTabs.value?.$el;
Expand Down Expand Up @@ -602,7 +612,13 @@ defineExpose({ hasUnsavedChanges });
<template>
<div class="w-full px-4 mx-auto space-y-8 pb-24">
<!-- Sticky Header -->
<div ref="stickyHeader" class="sticky top-0 z-20 bg-background pb-4 border-b">
<div
ref="stickyHeader"
:class="[
'sticky top-0 z-20 bg-background pb-4 border-b',
sectionTabsStuck && 'border-b-transparent',
]"
>
<div class="flex justify-between items-start pt-2">
<div>
<h2 class="text-3xl font-bold tracking-tight">{{ formData.name || 'Activity Details' }}</h2>
Expand Down Expand Up @@ -740,7 +756,7 @@ defineExpose({ hasUnsavedChanges });
<div class="text-sm px-3 py-2 rounded-md border bg-muted/30 min-h-[36px] flex items-center">{{ readonlyDate(formData.activity_start_time) }}</div>
</template>
<template v-else>
<DateTimePicker
<DateTimeField
:model-value="formData.activity_start_time ?? undefined"
@update:model-value="formData.activity_start_time = $event ?? null"
/>
Expand All @@ -752,7 +768,7 @@ defineExpose({ hasUnsavedChanges });
<div class="text-sm px-3 py-2 rounded-md border bg-muted/30 min-h-[36px] flex items-center">{{ readonlyDate(formData.activity_end_time) }}</div>
</template>
<template v-else>
<DateTimePicker
<DateTimeField
:model-value="formData.activity_end_time ?? undefined"
@update:model-value="formData.activity_end_time = $event ?? null"
/>
Expand Down
Loading
Loading