@@ -20,6 +20,7 @@ export default {
2020 micAllocations : [ ] ,
2121 noLeaderToast : null ,
2222 scriptModes : [ ] ,
23+ sessionTags : [ ] ,
2324 } ,
2425 mutations : {
2526 SET_CAST_LIST ( state , castList ) {
@@ -45,6 +46,7 @@ export default {
4546 state . characterList = [ ] ;
4647 state . actList = [ ] ;
4748 state . sceneList = [ ] ;
49+ state . sessionTags = [ ] ;
4850 } ,
4951 SET_SESSIONS_LIST ( state , sessions ) {
5052 state . sessions = sessions ;
@@ -70,6 +72,9 @@ export default {
7072 UPDATE_SCRIPT_MODES ( state , modes ) {
7173 state . scriptModes = modes ;
7274 } ,
75+ SET_SESSION_TAGS ( state , tags ) {
76+ state . sessionTags = tags ;
77+ } ,
7378 } ,
7479 actions : {
7580 async GET_CAST_LIST ( context ) {
@@ -98,12 +103,14 @@ export default {
98103 }
99104 } ,
100105 async DELETE_CAST_MEMBER ( context , castID ) {
101- const response = await fetch ( `${ makeURL ( '/api/v1/show/cast' ) } ` , {
106+ const searchParams = new URLSearchParams ( {
107+ id : castID ,
108+ } ) ;
109+ const response = await fetch ( `${ makeURL ( '/api/v1/show/cast' ) } ?${ searchParams } ` , {
102110 method : 'DELETE' ,
103111 headers : {
104112 'Content-Type' : 'application/json' ,
105113 } ,
106- body : JSON . stringify ( { id : castID } ) ,
107114 } ) ;
108115 if ( response . ok ) {
109116 context . dispatch ( 'GET_CAST_LIST' ) ;
@@ -155,12 +162,14 @@ export default {
155162 }
156163 } ,
157164 async DELETE_CHARACTER ( context , characterID ) {
158- const response = await fetch ( `${ makeURL ( '/api/v1/show/character' ) } ` , {
165+ const searchParams = new URLSearchParams ( {
166+ id : characterID ,
167+ } ) ;
168+ const response = await fetch ( `${ makeURL ( '/api/v1/show/character' ) } ?${ searchParams } ` , {
159169 method : 'DELETE' ,
160170 headers : {
161171 'Content-Type' : 'application/json' ,
162172 } ,
163- body : JSON . stringify ( { id : characterID } ) ,
164173 } ) ;
165174 if ( response . ok ) {
166175 context . dispatch ( 'GET_CHARACTER_LIST' ) ;
@@ -213,12 +222,14 @@ export default {
213222 }
214223 } ,
215224 async DELETE_CHARACTER_GROUP ( context , characterGroupID ) {
216- const response = await fetch ( `${ makeURL ( '/api/v1/show/character/group' ) } ` , {
225+ const searchParams = new URLSearchParams ( {
226+ id : characterGroupID ,
227+ } ) ;
228+ const response = await fetch ( `${ makeURL ( '/api/v1/show/character/group' ) } ?${ searchParams } ` , {
217229 method : 'DELETE' ,
218230 headers : {
219231 'Content-Type' : 'application/json' ,
220232 } ,
221- body : JSON . stringify ( { id : characterGroupID } ) ,
222233 } ) ;
223234 if ( response . ok ) {
224235 context . dispatch ( 'GET_CHARACTER_GROUP_LIST' ) ;
@@ -270,12 +281,14 @@ export default {
270281 }
271282 } ,
272283 async DELETE_ACT ( context , actID ) {
273- const response = await fetch ( `${ makeURL ( '/api/v1/show/act' ) } ` , {
284+ const searchParams = new URLSearchParams ( {
285+ id : actID ,
286+ } ) ;
287+ const response = await fetch ( `${ makeURL ( '/api/v1/show/act' ) } ?${ searchParams } ` , {
274288 method : 'DELETE' ,
275289 headers : {
276290 'Content-Type' : 'application/json' ,
277291 } ,
278- body : JSON . stringify ( { id : actID } ) ,
279292 } ) ;
280293 if ( response . ok ) {
281294 context . dispatch ( 'GET_ACT_LIST' ) ;
@@ -344,12 +357,14 @@ export default {
344357 }
345358 } ,
346359 async DELETE_SCENE ( context , sceneID ) {
347- const response = await fetch ( `${ makeURL ( '/api/v1/show/scene' ) } ` , {
360+ const searchParams = new URLSearchParams ( {
361+ id : sceneID ,
362+ } ) ;
363+ const response = await fetch ( `${ makeURL ( '/api/v1/show/scene' ) } ?${ searchParams } ` , {
348364 method : 'DELETE' ,
349365 headers : {
350366 'Content-Type' : 'application/json' ,
351367 } ,
352- body : JSON . stringify ( { id : sceneID } ) ,
353368 } ) ;
354369 if ( response . ok ) {
355370 context . dispatch ( 'GET_SCENE_LIST' ) ;
@@ -403,12 +418,14 @@ export default {
403418 }
404419 } ,
405420 async DELETE_CUE_TYPE ( context , cueTypeID ) {
406- const response = await fetch ( `${ makeURL ( '/api/v1/show/cues/types' ) } ` , {
421+ const searchParams = new URLSearchParams ( {
422+ id : cueTypeID ,
423+ } ) ;
424+ const response = await fetch ( `${ makeURL ( '/api/v1/show/cues/types' ) } ?${ searchParams } ` , {
407425 method : 'DELETE' ,
408426 headers : {
409427 'Content-Type' : 'application/json' ,
410428 } ,
411- body : JSON . stringify ( { id : cueTypeID } ) ,
412429 } ) ;
413430 if ( response . ok ) {
414431 context . dispatch ( 'GET_CUE_TYPES' ) ;
@@ -493,12 +510,14 @@ export default {
493510 }
494511 } ,
495512 async DELETE_MICROPHONE ( context , microphoneId ) {
496- const response = await fetch ( `${ makeURL ( '/api/v1/show/microphones' ) } ` , {
513+ const searchParams = new URLSearchParams ( {
514+ id : microphoneId ,
515+ } ) ;
516+ const response = await fetch ( `${ makeURL ( '/api/v1/show/microphones' ) } ?${ searchParams } ` , {
497517 method : 'DELETE' ,
498518 headers : {
499519 'Content-Type' : 'application/json' ,
500520 } ,
501- body : JSON . stringify ( { id : microphoneId } ) ,
502521 } ) ;
503522 if ( response . ok ) {
504523 context . dispatch ( 'GET_MICROPHONE_LIST' ) ;
@@ -558,6 +577,83 @@ export default {
558577 log . error ( 'Unable to fetch script modes' ) ;
559578 }
560579 } ,
580+ async GET_SESSION_TAGS ( context ) {
581+ const response = await fetch ( `${ makeURL ( '/api/v1/show/session/tags' ) } ` ) ;
582+ if ( response . ok ) {
583+ const data = await response . json ( ) ;
584+ context . commit ( 'SET_SESSION_TAGS' , data . tags ) ;
585+ } else {
586+ log . error ( 'Unable to get session tags' ) ;
587+ }
588+ } ,
589+ async ADD_SESSION_TAG ( context , tag ) {
590+ const response = await fetch ( `${ makeURL ( '/api/v1/show/session/tags' ) } ` , {
591+ method : 'POST' ,
592+ headers : {
593+ 'Content-Type' : 'application/json' ,
594+ } ,
595+ body : JSON . stringify ( tag ) ,
596+ } ) ;
597+ if ( response . ok ) {
598+ context . dispatch ( 'GET_SESSION_TAGS' ) ;
599+ Vue . $toast . success ( 'Added new session tag!' ) ;
600+ } else {
601+ log . error ( 'Unable to add session tag' ) ;
602+ Vue . $toast . error ( 'Unable to add session tag' ) ;
603+ }
604+ } ,
605+ async UPDATE_SESSION_TAG ( context , tag ) {
606+ const response = await fetch ( `${ makeURL ( '/api/v1/show/session/tags' ) } ` , {
607+ method : 'PATCH' ,
608+ headers : {
609+ 'Content-Type' : 'application/json' ,
610+ } ,
611+ body : JSON . stringify ( tag ) ,
612+ } ) ;
613+ if ( response . ok ) {
614+ context . dispatch ( 'GET_SESSION_TAGS' ) ;
615+ Vue . $toast . success ( 'Updated session tag!' ) ;
616+ } else {
617+ log . error ( 'Unable to edit session tag' ) ;
618+ Vue . $toast . error ( 'Unable to edit session tag' ) ;
619+ }
620+ } ,
621+ async DELETE_SESSION_TAG ( context , tagId ) {
622+ const response = await fetch ( `${ makeURL ( '/api/v1/show/session/tags' ) } ?id=${ tagId } ` , {
623+ method : 'DELETE' ,
624+ headers : {
625+ 'Content-Type' : 'application/json' ,
626+ } ,
627+ } ) ;
628+ if ( response . ok ) {
629+ context . dispatch ( 'GET_SESSION_TAGS' ) ;
630+ Vue . $toast . success ( 'Deleted session tag!' ) ;
631+ } else {
632+ log . error ( 'Unable to delete session tag' ) ;
633+ Vue . $toast . error ( 'Unable to delete session tag' ) ;
634+ }
635+ } ,
636+ async UPDATE_SESSION_TAGS ( context , { sessionId, tagIds } ) {
637+ const response = await fetch ( `${ makeURL ( '/api/v1/show/sessions/assign-tags' ) } ` , {
638+ method : 'PATCH' ,
639+ headers : {
640+ 'Content-Type' : 'application/json' ,
641+ } ,
642+ body : JSON . stringify ( {
643+ session_id : sessionId ,
644+ tag_ids : tagIds ,
645+ } ) ,
646+ } ) ;
647+ if ( response . ok ) {
648+ await context . dispatch ( 'GET_SHOW_SESSION_DATA' ) ;
649+ Vue . $toast . success ( 'Updated session tags!' ) ;
650+ } else {
651+ const errorData = await response . json ( ) . catch ( ( ) => ( { } ) ) ;
652+ log . error ( 'Unable to update session tags:' , errorData ) ;
653+ Vue . $toast . error ( errorData . message || 'Unable to update session tags' ) ;
654+ throw new Error ( 'Failed to update session tags' ) ;
655+ }
656+ } ,
561657 } ,
562658 getters : {
563659 CAST_LIST ( state ) {
@@ -741,5 +837,21 @@ export default {
741837 SCRIPT_MODES ( state ) {
742838 return state . scriptModes ;
743839 } ,
840+ SESSION_TAGS ( state ) {
841+ return state . sessionTags ;
842+ } ,
843+ SESSION_TAGS_DICT ( state ) {
844+ return Object . fromEntries ( state . sessionTags . map ( ( tag ) => [ tag . id , tag ] ) ) ;
845+ } ,
846+ SESSION_TAG_BY_ID : ( state , getters ) => ( tagId ) => {
847+ if ( tagId == null ) {
848+ return null ;
849+ }
850+ const tagStr = tagId . toString ( ) ;
851+ if ( Object . keys ( getters . SESSION_TAGS_DICT ) . includes ( tagStr ) ) {
852+ return getters . SESSION_TAGS_DICT [ tagStr ] ;
853+ }
854+ return null ;
855+ } ,
744856 } ,
745857} ;
0 commit comments