refactor: small ux improvements

- rename dissolve > ungroup
- prevent ondrag when clicking
- add untitled as block title fallback
- move block action to context menu
This commit is contained in:
Carlos Valente
2025-05-23 13:06:48 +02:00
committed by arc-alex
parent 2546159a94
commit 17deeddb87
9 changed files with 47 additions and 53 deletions
@@ -11,7 +11,7 @@ import {
deleteAllEntries,
deleteEvent,
editEvent,
dissolveBlock,
ungroupEntries,
groupEntries,
reorderEntry,
swapEvents,
@@ -139,9 +139,9 @@ export async function rundownCloneEntry(req: Request, res: Response<Rundown | Er
}
}
export async function rundownDissolveBlock(req: Request, res: Response<Rundown | ErrorResponse>) {
export async function rundownUngroupEntries(req: Request, res: Response<Rundown | ErrorResponse>) {
try {
const newRundown = await dissolveBlock(req.params.entryId);
const newRundown = await ungroupEntries(req.params.entryId);
res.status(200).send(newRundown);
} catch (error) {
const message = getErrorMessage(error);
@@ -7,7 +7,7 @@ import {
rundownBatchPut,
rundownCloneEntry,
rundownDelete,
rundownDissolveBlock,
rundownUngroupEntries,
rundownGetAll,
rundownGetById,
rundownGetCurrent,
@@ -41,7 +41,7 @@ router.patch('/reorder/', rundownReorderValidator, rundownReorder);
router.patch('/swap', rundownSwapValidator, rundownSwap);
router.patch('/applydelay/:entryId', paramsMustHaveEntryId, rundownApplyDelay);
router.post('/clone/:entryId', paramsMustHaveEntryId, rundownCloneEntry);
router.post('/dissolve/:entryId', paramsMustHaveEntryId, rundownDissolveBlock);
router.post('/ungroup/:entryId', paramsMustHaveEntryId, rundownUngroupEntries);
router.post('/group', rundownArrayOfIds, rundownAddToBlock);
router.delete('/', rundownArrayOfIds, deletesEventById);
@@ -244,8 +244,8 @@ export async function cloneEntry(entryId: EntryId) {
/**
* Deletes a block from the rundown and moves all its children to the top level
*/
export async function dissolveBlock(blockId: EntryId) {
const scopedMutation = cache.mutateCache(cache.dissolveBlock);
export async function ungroupEntries(blockId: EntryId) {
const scopedMutation = cache.mutateCache(cache.ungroup);
const { newRundown } = await scopedMutation({ blockId });
// notify runtime that rundown has changed
@@ -15,7 +15,7 @@ import {
editCustomField,
removeCustomField,
customFieldChangelog,
dissolveBlock,
ungroup,
groupEntries,
clone,
} from '../rundownCache.js';
@@ -870,7 +870,7 @@ describe('clone() mutation', () => {
});
});
describe('dissolveBlock() mutation', () => {
describe('ungroup() mutation', () => {
it('should correctly dissolve a block into its events', () => {
const rundown = makeRundown({
order: ['1', '2'],
@@ -883,7 +883,7 @@ describe('dissolveBlock() mutation', () => {
},
});
const { newRundown } = dissolveBlock({
const { newRundown } = ungroup({
rundown,
blockId: '2',
});
@@ -594,7 +594,7 @@ export function clone({ rundown, entryId }: CloneEntryArgs): MutatingReturn {
const flatIndex = rundown.flatOrder.indexOf(lastNestedIdInOriginal) + 1;
newBlock.events = nestedIds;
newBlock.title = `${entry.title} (copy)`;
newBlock.title = `${entry.title || 'Untitled'} (copy)`;
rundown.entries[newBlock.id] = newBlock;
rundown.order = insertAtIndex(atIndex, newBlock.id, rundown.order);
@@ -606,13 +606,13 @@ export function clone({ rundown, entryId }: CloneEntryArgs): MutatingReturn {
}
}
type DissolveBlockArgs = MutationParams<{ blockId: EntryId }>;
type UngroupArgs = MutationParams<{ blockId: EntryId }>;
/**
* Deletes a block and moves all its children to the top level order
* Mutates the given rundown
* @throws if block ID not found
*/
export function dissolveBlock({ rundown, blockId }: DissolveBlockArgs): MutatingReturn {
export function ungroup({ rundown, blockId }: UngroupArgs): MutatingReturn {
const block = rundown.entries[blockId];
if (!isOntimeBlock(block)) {
throw new Error('Block with ID not found');