From 852b47ae0700fd67c39abc5a0f30634de7e16b92 Mon Sep 17 00:00:00 2001 From: underscope Date: Tue, 31 Mar 2026 08:48:44 +0200 Subject: [PATCH 1/3] Enable container presets & collapsible behaviour --- .../src/schemas/partner-training-v2.schema.ts | 7 + .../src/edit/StructuredSubcontainer.vue | 134 +++++++++++++----- .../structured-content/src/edit/config.js | 20 ++- .../structured-content/src/edit/index.vue | 90 +++++++++--- 4 files changed, 194 insertions(+), 57 deletions(-) diff --git a/config/src/schemas/partner-training-v2.schema.ts b/config/src/schemas/partner-training-v2.schema.ts index 62ce7566e..d74f62afe 100644 --- a/config/src/schemas/partner-training-v2.schema.ts +++ b/config/src/schemas/partner-training-v2.schema.ts @@ -137,6 +137,13 @@ const SectionContainer: ContentContainerConfig = { required: true, displayHeading: false, config: { + isCollapsible: true, + defaultSubcontainers: [ + { type: ActivityType.Section, data: { title: 'Intro' } }, + { type: ActivityType.Section, data: { title: 'Key Concepts' } }, + { type: ActivityType.Section, data: { title: 'Top Advisors' } }, + { type: ActivityType.Section, data: { title: 'Talking Points' } }, + ], [ActivityType.Section]: { label: 'Section', meta: () => [...sectionMeta], diff --git a/packages/core-extensions/content-containers/structured-content/src/edit/StructuredSubcontainer.vue b/packages/core-extensions/content-containers/structured-content/src/edit/StructuredSubcontainer.vue index a96530fd6..d70e85f58 100644 --- a/packages/core-extensions/content-containers/structured-content/src/edit/StructuredSubcontainer.vue +++ b/packages/core-extensions/content-containers/structured-content/src/edit/StructuredSubcontainer.vue @@ -1,52 +1,86 @@ @@ -71,6 +105,9 @@ const props = defineProps<{ layout?: boolean; contentElementConfig?: Array; disableContentElementList?: boolean; + isCollapsible?: boolean; + expandAll?: boolean; + collapsedPreviewKey?: string | null; }>(); const emit = defineEmits([ @@ -81,6 +118,30 @@ const emit = defineEmits([ 'delete:element', ]); +const elementCount = computed(() => { + return Object.values(props.elements).filter( + (el) => el.activityId === props.container.id, + ).length; +}); + +const isExpanded = ref(true); + +const collapsedPreviewText = computed(() => { + const key = props.collapsedPreviewKey || props.meta?.[0]?.key; + return key ? props.container?.data?.[key] || '' : ''; +}); + +const toggleExpanded = () => { + isExpanded.value = !isExpanded.value; +}; + +watch( + () => props.expandAll, + (expanded) => { + if (props.isCollapsible) isExpanded.value = !!expanded; + }, +); + const containerData = ref({ ...props.container?.data }) as any; const processedMeta = computed(() => @@ -102,4 +163,9 @@ watch(containerData, save, { deep: true }); .meta-container :deep(.v-messages) { text-align: left; } + +.subcontainer-header-collapsible { + cursor: pointer; + user-select: none; +} diff --git a/packages/core-extensions/content-containers/structured-content/src/edit/config.js b/packages/core-extensions/content-containers/structured-content/src/edit/config.js index b0d116e06..63d109406 100644 --- a/packages/core-extensions/content-containers/structured-content/src/edit/config.js +++ b/packages/core-extensions/content-containers/structured-content/src/edit/config.js @@ -14,10 +14,21 @@ const DEFAULT_CONFIG = { }; export const parseConfig = (repository, outlineActivity, container, config) => { - if (!config) return DEFAULT_CONFIG; - return reduce( + if (!config) return { subcontainers: DEFAULT_CONFIG, defaultSubcontainers: [], isCollapsible: false }; + // Container-level options (skipped by the sub-type reduce below): + // - isCollapsible: enable collapse/expand for subcontainers + // - collapsedPreviewKey: meta key to display in collapsed subcontainer header + // - defaultSubcontainers: initial subcontainers to create on mount + const CONTAINER_OPTIONS = ['isCollapsible', 'collapsedPreviewKey', 'defaultSubcontainers']; + const { + isCollapsible = false, + collapsedPreviewKey = null, + defaultSubcontainers = [], + } = config; + const subcontainers = reduce( config, (acc, val, key) => { + if (CONTAINER_OPTIONS.includes(key)) return acc; acc[key] = { ...val, icon: val.icon || 'mdi-text', @@ -28,9 +39,12 @@ export const parseConfig = (repository, outlineActivity, container, config) => { contentElementConfig: val.contentElementConfig, disableContentElementList: !!val.disableContentElementList, disableAi: !!val.disableAi, + isCollapsible: val.isCollapsible ?? isCollapsible, + collapsedPreviewKey: val.collapsedPreviewKey || collapsedPreviewKey, }; return acc; }, - {}, + {} as Record, ); + return { subcontainers, defaultSubcontainers, isCollapsible }; }; diff --git a/packages/core-extensions/content-containers/structured-content/src/edit/index.vue b/packages/core-extensions/content-containers/structured-content/src/edit/index.vue index 88cdaf1e8..0ef9cdde5 100644 --- a/packages/core-extensions/content-containers/structured-content/src/edit/index.vue +++ b/packages/core-extensions/content-containers/structured-content/src/edit/index.vue @@ -1,22 +1,45 @@