|
133 | 133 | > |
134 | 134 | This is a required field. |
135 | 135 | </b-form-invalid-feedback> |
| 136 | + <b-form-text |
| 137 | + v-if="isDuplicateNewCue" |
| 138 | + class="text-warning" |
| 139 | + > |
| 140 | + ⚠️ A cue with this identifier already exists for this cue type |
| 141 | + </b-form-text> |
136 | 142 | </b-form-group> |
137 | 143 | </b-form> |
138 | 144 | </b-modal> |
|
182 | 188 | > |
183 | 189 | This is a required field. |
184 | 190 | </b-form-invalid-feedback> |
| 191 | + <b-form-text |
| 192 | + v-if="isDuplicateEditCue" |
| 193 | + class="text-warning" |
| 194 | + > |
| 195 | + ⚠️ A cue with this identifier already exists for this cue type |
| 196 | + </b-form-text> |
185 | 197 | </b-form-group> |
186 | 198 | </b-form> |
187 | 199 | <template #modal-footer="{ ok, cancel }"> |
@@ -308,7 +320,7 @@ export default { |
308 | 320 | }, |
309 | 321 | }, |
310 | 322 | computed: { |
311 | | - ...mapGetters(['IS_CUE_EDITOR', 'RBAC_ROLES', 'CURRENT_USER_RBAC', 'IS_ADMIN_USER']), |
| 323 | + ...mapGetters(['IS_CUE_EDITOR', 'RBAC_ROLES', 'CURRENT_USER_RBAC', 'IS_ADMIN_USER', 'SCRIPT_CUES']), |
312 | 324 | cueTypeOptions() { |
313 | 325 | if (this.IS_ADMIN_USER) { |
314 | 326 | return [ |
@@ -385,6 +397,24 @@ export default { |
385 | 397 | } |
386 | 398 | return style; |
387 | 399 | }, |
| 400 | + flatScriptCues() { |
| 401 | + return Object.keys(this.SCRIPT_CUES).map((key) => this.SCRIPT_CUES[key]).flat(); |
| 402 | + }, |
| 403 | + isDuplicateNewCue() { |
| 404 | + if (this.newFormState.ident == null || this.newFormState.cueType == null) { |
| 405 | + return false; |
| 406 | + } |
| 407 | + return this.flatScriptCues.some((cue) => cue.cue_type_id === this.newFormState.cueType |
| 408 | + && cue.ident === this.newFormState.ident); |
| 409 | + }, |
| 410 | + isDuplicateEditCue() { |
| 411 | + if (this.editFormState.ident == null || this.editFormState.cueType == null) { |
| 412 | + return false; |
| 413 | + } |
| 414 | + return this.flatScriptCues.some((cue) => cue.cue_type_id === this.editFormState.cueType |
| 415 | + && cue.ident === this.editFormState.ident |
| 416 | + && cue.id !== this.editFormState.cueId); |
| 417 | + }, |
388 | 418 | }, |
389 | 419 | methods: { |
390 | 420 | contrastColor, |
|
0 commit comments