@@ -14,6 +14,7 @@ import {
1414 CoreUserEditingDefinitionAction ,
1515 CoreUserEditingDefinitionForm ,
1616 CoreUserEditingDefinitionSourceLayerForm ,
17+ CoreUserEditingProperties ,
1718} from '@sofie-automation/corelib/dist/dataModel/UserEditingDefinitions'
1819import { DBSegment } from '@sofie-automation/corelib/dist/dataModel/Segment'
1920import { assertNever , clone , Complete , literal , omit } from '@sofie-automation/corelib/dist/lib'
@@ -58,6 +59,7 @@ import {
5859 UserEditingDefinitionAction ,
5960 UserEditingDefinitionForm ,
6061 UserEditingDefinitionSourceLayerForm ,
62+ UserEditingProperties ,
6163 UserEditingType ,
6264} from '@sofie-automation/blueprints-integration/dist/userEditing'
6365import type { PlayoutMutatablePart } from '../../playout/model/PlayoutPartInstanceModel'
@@ -121,6 +123,7 @@ export const IBlueprintMutatablePartSampleKeys = allKeysOfObject<IBlueprintMutat
121123 identifier : true ,
122124 hackListenToMediaObjectUpdates : true ,
123125 userEditOperations : true ,
126+ userEditProperties : true ,
124127} )
125128
126129/*
@@ -281,6 +284,7 @@ export function convertPartToBlueprints(part: ReadonlyDeep<DBPart>): IBlueprintP
281284 part . hackListenToMediaObjectUpdates
282285 ) ,
283286 userEditOperations : translateUserEditsToBlueprint ( part . userEditOperations ) ,
287+ userEditProperties : translateUserEditPropertiesToBlueprint ( part . userEditProperties ) ,
284288 }
285289
286290 return obj
@@ -349,6 +353,7 @@ export function convertSegmentToBlueprints(segment: ReadonlyDeep<DBSegment>): IB
349353 showShelf : segment . showShelf ,
350354 segmentTiming : segment . segmentTiming ,
351355 userEditOperations : translateUserEditsToBlueprint ( segment . userEditOperations ) ,
356+ userEditProperties : translateUserEditPropertiesToBlueprint ( segment . userEditProperties ) ,
352357 }
353358
354359 return obj
@@ -540,6 +545,30 @@ function translateUserEditsToBlueprint(
540545 )
541546}
542547
548+ function translateUserEditPropertiesToBlueprint (
549+ props : ReadonlyDeep < CoreUserEditingProperties > | undefined
550+ ) : UserEditingProperties | undefined {
551+ if ( ! props ) return undefined
552+
553+ return {
554+ globalProperties : props . globalProperties ,
555+ pieceTypeProperties : props . pieceTypeProperties ,
556+
557+ operations : props . operations ?. map (
558+ ( userEdit ) =>
559+ ( {
560+ type : UserEditingType . ACTION ,
561+ id : userEdit . id ,
562+ label : omit ( userEdit . label , 'namespaces' ) ,
563+ svgIcon : userEdit . svgIcon ,
564+ svgIconInactive : userEdit . svgIconInactive ,
565+ isActive : userEdit . isActive ,
566+ buttonType : userEdit . buttonType ,
567+ } satisfies Complete < UserEditingDefinitionAction > )
568+ ) ,
569+ }
570+ }
571+
543572export function translateUserEditsFromBlueprint (
544573 userEdits : UserEditingDefinition [ ] | undefined ,
545574 blueprintIds : BlueprintId [ ]
@@ -585,6 +614,33 @@ export function translateUserEditsFromBlueprint(
585614 )
586615}
587616
617+ export function translateUserEditPropertiesFromBlueprint (
618+ props : UserEditingProperties | undefined ,
619+ blueprintIds : BlueprintId [ ]
620+ ) : CoreUserEditingProperties | undefined {
621+ if ( ! props ) return undefined
622+
623+ return {
624+ globalProperties : clone ( props . globalProperties ) ,
625+ pieceTypeProperties : clone ( props . pieceTypeProperties ) ,
626+
627+ operations : props . operations ?. map (
628+ ( userEdit ) =>
629+ ( {
630+ type : UserEditingType . ACTION ,
631+ id : userEdit . id ,
632+ label : wrapTranslatableMessageFromBlueprints ( userEdit . label , blueprintIds ) ,
633+ svgIcon : userEdit . svgIcon ,
634+ svgIconInactive : userEdit . svgIconInactive ,
635+ isActive : userEdit . isActive ,
636+ buttonType : userEdit . buttonType ,
637+ } satisfies Complete < UserEditingDefinitionAction > )
638+ ) ,
639+
640+ translationNamespaces : blueprintIds . map ( ( id ) => `blueprint_${ id } ` ) ,
641+ }
642+ }
643+
588644export function convertPartialBlueprintMutablePartToCore (
589645 updatePart : Partial < IBlueprintMutatablePart > ,
590646 blueprintId : BlueprintId
@@ -602,5 +658,13 @@ export function convertPartialBlueprintMutablePartToCore(
602658 delete playoutUpdatePart . userEditOperations
603659 }
604660
661+ if ( 'userEditProperties' in updatePart ) {
662+ playoutUpdatePart . userEditProperties = translateUserEditPropertiesFromBlueprint ( updatePart . userEditProperties , [
663+ blueprintId ,
664+ ] )
665+ } else {
666+ delete playoutUpdatePart . userEditOperations
667+ }
668+
605669 return playoutUpdatePart
606670}
0 commit comments