Skip to content

Commit 151cf93

Browse files
committed
feat: use segmentHeaderNotes
1 parent 466641d commit 151cf93

4 files changed

Lines changed: 58 additions & 4 deletions

File tree

packages/blueprints-integration/src/documents/part.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ export interface IBlueprintMutatablePart<TPrivateData = unknown, TPublicData = u
9191
/** User-facing identifier that can be used by the User to identify the contents of a segment in the Rundown source system */
9292
identifier?: string
9393

94+
/** User-facing notes shown in the segment header */
95+
segmentHeaderNotes?: ITranslatableMessage[]
96+
9497
/** MediaObjects that when created/updated, should cause the blueprint to be rerun for the Segment of this Part */
9598
hackListenToMediaObjectUpdates?: HackPartMediaObjectSubscription[]
9699

packages/job-worker/src/blueprints/context/lib.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import {
5151
IBlueprintShowStyleVariant,
5252
IOutputLayer,
5353
ISourceLayer,
54+
ITranslatableMessage,
5455
PieceAbSessionInfo,
5556
RundownPlaylistTiming,
5657
} from '@sofie-automation/blueprints-integration'
@@ -138,6 +139,7 @@ export const PlayoutMutatablePartSampleKeys = allKeysOfObject<PlayoutMutatablePa
138139
displayDurationGroup: true,
139140
displayDuration: true,
140141
identifier: true,
142+
segmentHeaderNotes: true,
141143
hackListenToMediaObjectUpdates: true,
142144
userEditOperations: true,
143145
userEditProperties: true,
@@ -326,6 +328,7 @@ export function convertPartToBlueprints(part: ReadonlyDeep<DBPart>): IBlueprintP
326328
displayDurationGroup: part.displayDurationGroup,
327329
displayDuration: part.displayDuration,
328330
identifier: part.identifier,
331+
segmentHeaderNotes: clone<ITranslatableMessage[] | undefined>(part.segmentHeaderNotes),
329332
hackListenToMediaObjectUpdates: clone<HackPartMediaObjectSubscription[] | undefined>(
330333
part.hackListenToMediaObjectUpdates
331334
),
@@ -705,7 +708,13 @@ export function convertPartialBlueprintMutablePartToCore(
705708
blueprintId,
706709
])
707710
} else {
708-
delete playoutUpdatePart.userEditOperations
711+
delete playoutUpdatePart.userEditProperties
712+
}
713+
714+
if ('segmentHeaderNotes' in updatePart) {
715+
playoutUpdatePart.segmentHeaderNotes = updatePart.segmentHeaderNotes?.map((note) =>
716+
wrapTranslatableMessageFromBlueprints(note, [blueprintId])
717+
)
709718
}
710719

711720
return playoutUpdatePart

packages/job-worker/src/ingest/generationSegment.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,9 @@ function updateModelWithGeneratedPart(
377377
]),
378378
}
379379
: undefined,
380+
segmentHeaderNotes: blueprintPart.part.segmentHeaderNotes?.map((note) =>
381+
wrapTranslatableMessageFromBlueprints(note, [blueprintId])
382+
),
380383
userEditOperations: translateUserEditsFromBlueprint(blueprintPart.part.userEditOperations, [blueprintId]),
381384
userEditProperties: translateUserEditPropertiesFromBlueprint(blueprintPart.part.userEditProperties, [
382385
blueprintId,

packages/webui/src/client/ui/SegmentHeader/SegmentHeaderNotes.tsx

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ import { PartInstance } from '@sofie-automation/meteor-lib/dist/collections/Part
1212
import { literal } from 'shuttle-webhid'
1313
import { Notifications } from '../../collections'
1414
import { getIgnorePieceContentStatus } from '../../lib/localStorage'
15-
import { UISegmentPartNotes, UIPieceContentStatuses, UIPartInstances } from '../Collections'
15+
import { UISegmentPartNotes, UIPieceContentStatuses, UIPartInstances, UIParts } from '../Collections'
1616
import { useTracker } from '../../lib/ReactMeteorData/ReactMeteorData'
1717
import type { ITranslatableMessage } from '@sofie-automation/corelib/dist/TranslatableMessage'
18+
import type { DBPart } from '@sofie-automation/corelib/dist/dataModel/Part'
1819

1920
export interface SegmentHeaderNotesProps {
2021
/** Override the classname of the root div */
@@ -77,7 +78,7 @@ function getReactivePieceNoteCountsForSegment(segmentId: SegmentId): SegmentNote
7778
const segmentNoteCounts: SegmentNoteCounts = {
7879
criticalNotes: 0,
7980
warningNotes: 0,
80-
headerNotes: [], // TODO - define
81+
headerNotes: [],
8182
}
8283

8384
const rawNotes = UISegmentPartNotes.find({ segmentId }, { fields: { note: 1 } }).fetch() as Pick<
@@ -144,9 +145,15 @@ function getReactivePieceNoteCountsForSegment(segmentId: SegmentId): SegmentNote
144145
{
145146
fields: {
146147
_id: 1,
148+
// @ts-expect-error deep property
149+
'part._id': 1,
150+
'part._rank': 1,
151+
'part.segmentHeaderNotes': 1,
147152
},
148153
}
149-
).fetch() as Array<Pick<PartInstance, '_id'>>
154+
).fetch() as Array<
155+
Pick<PartInstance, '_id'> & { part: Pick<PartInstance['part'], '_id' | '_rank' | 'segmentHeaderNotes'> }
156+
>
150157
const rawNotifications = Notifications.find(
151158
{
152159
$or: [
@@ -179,5 +186,37 @@ function getReactivePieceNoteCountsForSegment(segmentId: SegmentId): SegmentNote
179186
}
180187
}
181188

189+
const partsForSegment = UIParts.find(
190+
{ segmentId },
191+
{
192+
fields: {
193+
_id: 1,
194+
_rank: 1,
195+
segmentHeaderNotes: 1,
196+
},
197+
}
198+
).fetch() as Array<Pick<DBPart, '_id' | '_rank' | 'segmentHeaderNotes'>>
199+
200+
// Collect the segment header notes from the parts in part rank order, with partinstance taking priority over the part
201+
const partIdsWithInstance = new Set(partInstancesForSegment.map((pi) => pi.part._id))
202+
203+
const mergedNoteEntries: Array<{ rank: number; notes: ITranslatableMessage[] }> = []
204+
for (const partInstance of partInstancesForSegment) {
205+
if (partInstance.part.segmentHeaderNotes?.length) {
206+
mergedNoteEntries.push({ rank: partInstance.part._rank, notes: partInstance.part.segmentHeaderNotes })
207+
}
208+
}
209+
for (const part of partsForSegment) {
210+
if (partIdsWithInstance.has(part._id)) continue
211+
if (part.segmentHeaderNotes?.length) {
212+
mergedNoteEntries.push({ rank: part._rank, notes: part.segmentHeaderNotes })
213+
}
214+
}
215+
216+
mergedNoteEntries.sort((a, b) => a.rank - b.rank)
217+
for (const entry of mergedNoteEntries) {
218+
segmentNoteCounts.headerNotes.push(...entry.notes)
219+
}
220+
182221
return segmentNoteCounts
183222
}

0 commit comments

Comments
 (0)