Skip to content

Commit

Permalink
Add support for disabling items through keyboard commands
Browse files Browse the repository at this point in the history
Signed-off-by: Axel Boberg <[email protected]>
  • Loading branch information
axelboberg committed Feb 27, 2024
1 parent 58ced7c commit 3c26485
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 1 deletion.
4 changes: 4 additions & 0 deletions api/items.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ async function playItem (id) {
return
}

if (item?.data?.disabled) {
return
}

const type = await types.getType(item.type)
const clone = populateVariablesMutable(deepClone(item), type)
const delay = parseInt(clone?.data?.delay)
Expand Down
2 changes: 1 addition & 1 deletion plugins/rundown/app/components/RundownItem/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function RundownItem ({ index, item }) {
}, [item?.state, item?.didStartPlayingAt])

return (
<div className='RundownItem'>
<div className={`RundownItem ${item?.data?.disabled ? 'is-disabled' : ''}`}>
<Layout.Spread>
<div className='RundownItem-section'>
<div className='RundownItem-color' style={{ backgroundColor: item?.data?.color }} />
Expand Down
4 changes: 4 additions & 0 deletions plugins/rundown/app/components/RundownItem/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
padding: 1em;
}

.RundownItem.is-disabled {
opacity: 0.4;
}

.RundownItem-section {
display: flex;
width: 100%;
Expand Down
24 changes: 24 additions & 0 deletions plugins/rundown/app/components/RundownList/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,24 @@ async function stopSelection () {
selection.forEach(itemId => bridge.items.stopItem(itemId))
}

/**
* Toggle the disabled property
* of the currently selected items
* @returns { Promise.<void> }
*/
async function toggleDisableSelection () {
const selection = await bridge.client.getSelection()

for (const itemId of selection) {
const isDisabled = (await bridge.items.getItem(itemId))?.data?.disabled
bridge.items.applyItem(itemId, {
data: {
disabled: !isDisabled
}
})
}
}

export function RundownList ({
rundownId = '',
className = '',
Expand Down Expand Up @@ -201,6 +219,12 @@ export function RundownList ({
case 'bridge.rundown.previous':
select(-1)
break
case 'bridge.rundown.previous':
select(-1)
break
case 'toggleDisable':
toggleDisableSelection()
break
case 'delete':
deleteSelection()
break
Expand Down
6 changes: 6 additions & 0 deletions plugins/shortcuts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
"action": "delete",
"description": "Delete",
"trigger": ["CommandOrControl", "Backspace"]
},
{
"id": "toggleDisable",
"action": "toggleDisable",
"description": "Toggle disabled / enabled",
"trigger": ["CommandOrControl", "V"]
}
]
},
Expand Down

0 comments on commit 3c26485

Please sign in to comment.