Skip to content

Commit

Permalink
wip: update for types
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Sep 30, 2024
1 parent 27345ad commit 3248aec
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,46 +15,43 @@ export function RenderUserEditOperations(
isFormEditable: boolean,
rundownId: RundownId,
targetName: string,
userEdits: CoreUserEditingDefinition[] | undefined,
userEditStates: Record<string, boolean> | undefined,
userEditOperations: CoreUserEditingDefinition[] | undefined,
operationTarget: UserOperationTarget
): React.JSX.Element | null {
const t = i18nTranslator
if (!userEdits || userEdits.length === 0) return null
if (!userEditOperations || userEditOperations.length === 0) return null
return (
<>
<hr />
{userEdits.map((userEdit, i) => {
switch (userEdit.type) {
{userEditOperations.map((userEditOperation, i) => {
switch (userEditOperation.type) {
case UserEditingType.ACTION:
return (
<MenuItem
key={`${userEdit.id}_${i}`}
key={`${userEditOperation.id}_${i}`}
onClick={(e) => {
doUserAction(t, e, UserAction.EXECUTE_USER_OPERATION, (e, ts) =>
MeteorCall.userAction.executeUserChangeOperation(e, ts, rundownId, operationTarget, {
id: userEdit.id,
id: userEditOperation.id,
})
)
}}
>
{
// ToDo: use CSS to Style state instead of asterix
userEditStates && userEditStates[userEdit.id] ? (
<span className="action-protected">{userEditStates[userEdit.id].valueOf() ? '• ' : ''}</span>
) : null
userEditOperation.isActive ? <span className="action-protected">{'• '}</span> : null
}
<span>{translateMessage(userEdit.label, i18nTranslator)}</span>
<span>{translateMessage(userEditOperation.label, i18nTranslator)}</span>
</MenuItem>
)
case UserEditingType.FORM:
return (
<MenuItem
disabled={!isFormEditable}
key={`${userEdit.id}_${i}`}
key={`${userEditOperation.id}_${i}`}
onClick={(e) => {
const schema = JSONBlobParse(userEdit.schema)
const values = clone(userEdit.currentValues)
const schema = JSONBlobParse(userEditOperation.schema)
const values = clone(userEditOperation.currentValues)

// TODO:
doModalDialog({
Expand All @@ -63,7 +60,7 @@ export function RenderUserEditOperations(
<SchemaFormInPlace
schema={schema}
object={values}
translationNamespaces={userEdit.translationNamespaces}
translationNamespaces={userEditOperation.translationNamespaces}
/>
),
// acceptText: 'OK',
Expand All @@ -73,18 +70,18 @@ export function RenderUserEditOperations(
doUserAction(t, e, UserAction.EXECUTE_USER_OPERATION, (e, ts) =>
MeteorCall.userAction.executeUserChangeOperation(e, ts, rundownId, operationTarget, {
...values,
id: userEdit.id,
id: userEditOperation.id,
})
)
},
})
}}
>
<span>{translateMessage(userEdit.label, i18nTranslator)}</span>
<span>{translateMessage(userEditOperation.label, i18nTranslator)}</span>
</MenuItem>
)
default:
assertNever(userEdit)
assertNever(userEditOperation)
return null
}
})}
Expand Down
42 changes: 27 additions & 15 deletions packages/webui/src/client/ui/SegmentTimeline/SegmentTimeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { wrapPartToTemporaryInstance } from '@sofie-automation/meteor-lib/dist/c
import { SegmentTimelineSmallPartFlag } from './SmallParts/SegmentTimelineSmallPartFlag'
import { UIStateStorage } from '../../lib/UIStateStorage'
import { getPartInstanceTimingId, RundownTimingContext } from '../../lib/rundownTiming'
import { IOutputLayer, ISourceLayer, NoteSeverity } from '@sofie-automation/blueprints-integration'
import { IOutputLayer, ISourceLayer, NoteSeverity, UserEditingType } from '@sofie-automation/blueprints-integration'
import { SegmentTimelineZoomButtons } from './SegmentTimelineZoomButtons'
import { SegmentViewMode } from '../SegmentContainer/SegmentViewModes'
import { SwitchViewModeButton } from '../SegmentContainer/SwitchViewModeButton'
Expand All @@ -55,6 +55,7 @@ import {
import { SegmentTimeAnchorTime } from '../RundownView/RundownTiming/SegmentTimeAnchorTime'
import { logger } from '../../lib/logging'
import * as RundownResolver from '../../lib/RundownResolver'
import { DBSegment } from '@sofie-automation/corelib/dist/dataModel/Segment'

interface IProps {
id: string
Expand Down Expand Up @@ -1099,20 +1100,7 @@ export class SegmentTimelineClass extends React.Component<Translated<WithTiming<
))}
</div>
)}
<div className="segment-timeline__title__user-edit-states">
{this.props.segment.userEditStates &&
Object.keys(this.props.segment.userEditStates).map((key) =>
this.props.segment.userEditStates?.[key] ? (
<div
key={key}
className="segment-timeline__title__user-edit-state"
dangerouslySetInnerHTML={{
__html: this.props.segment.userEdits?.filter((i) => i.id === key)[0]?.svgIcon ?? '',
}}
></div>
) : null
)}
</div>
<HeaderEditStates userEditOperations={this.props.segment.userEditOperations} />
</ContextMenuTrigger>
<div className="segment-timeline__duration" tabIndex={0}>
{this.props.playlist &&
Expand Down Expand Up @@ -1245,3 +1233,27 @@ export const SegmentTimeline = withTranslation()(
}
})(SegmentTimelineClass)
)

interface HeaderEditStatesProps {
userEditOperations: DBSegment['userEditOperations']
}
function HeaderEditStates({ userEditOperations }: HeaderEditStatesProps) {
return (
<div className="segment-timeline__title__user-edit-states">
{userEditOperations &&
userEditOperations.map((operation) => {
if (operation.type === UserEditingType.FORM || !operation.svgIcon || !operation.isActive) return null

return (
<div
key={operation.id}
className="segment-timeline__title__user-edit-state"
dangerouslySetInnerHTML={{
__html: operation.svgIcon,
}}
></div>
)
})}
</div>
)
}

0 comments on commit 3248aec

Please sign in to comment.