From aadc79810b2604a28f731fa053e5ad59eca96f6c Mon Sep 17 00:00:00 2001 From: Frank Rousseau Date: Mon, 1 Jul 2024 20:24:36 +0200 Subject: [PATCH] [shots] Allow to set frames from previews --- .../SetFramesFromTaskTypePreviewsModal.vue | 121 ++++++++++++++++++ src/components/pages/Shots.vue | 38 ++++++ src/components/widgets/ComboboxTaskType.vue | 6 +- src/locales/en.js | 4 + src/store/api/shots.js | 8 ++ src/store/modules/shots.js | 15 +++ 6 files changed, 191 insertions(+), 1 deletion(-) create mode 100644 src/components/modals/SetFramesFromTaskTypePreviewsModal.vue diff --git a/src/components/modals/SetFramesFromTaskTypePreviewsModal.vue b/src/components/modals/SetFramesFromTaskTypePreviewsModal.vue new file mode 100644 index 0000000000..202569b12c --- /dev/null +++ b/src/components/modals/SetFramesFromTaskTypePreviewsModal.vue @@ -0,0 +1,121 @@ + + + + + diff --git a/src/components/pages/Shots.vue b/src/components/pages/Shots.vue index fcdb20b4e2..018aaaf613 100644 --- a/src/components/pages/Shots.vue +++ b/src/components/pages/Shots.vue @@ -45,6 +45,13 @@ icon="import-files" @click="showAddThumbnailsModal" /> + + + { this.loading.importing = false }) + }, + + async confirmSetFrames(taskTypeId) { + this.loading.getFrames = true + try { + await this.setNbFramesFromTaskTypePreviews({ + taskTypeId, + productionId: this.currentProduction.id, + episodeId: this.currentEpisode ? this.currentEpisode.id : null + }) + this.modals.isSetFramesDisplayed = false + } catch (err) { + console.error(err) + this.errors.getFrames = true + } finally { + this.loading.getFrames = false + } } }, diff --git a/src/components/widgets/ComboboxTaskType.vue b/src/components/widgets/ComboboxTaskType.vue index d616d6a9e4..e2a53c85f9 100644 --- a/src/components/widgets/ComboboxTaskType.vue +++ b/src/components/widgets/ComboboxTaskType.vue @@ -80,6 +80,10 @@ export default { default: false, type: Boolean }, + placeholder: { + default: '+ Task Type', + type: String + }, openTop: { default: false, type: Boolean @@ -95,7 +99,7 @@ export default { if (this.value) { return this.taskTypeMap.get(this.value) } else if (this.addPlaceholder) { - return { name: '+ Task Type', color: '#E5E5E5', id: '' } + return { name: this.placeholder, color: '#E5E5E5', id: '' } } else { return this.taskTypeList[0] } diff --git a/src/locales/en.js b/src/locales/en.js index e6fbeb5a70..2503b1bdb7 100644 --- a/src/locales/en.js +++ b/src/locales/en.js @@ -1234,6 +1234,7 @@ export default { new_task_type: 'Add a task type', no_task_types: 'There is no task type for this entity type', number: 'task type | task types', + select_task_type: 'Select a task type...', title: 'Task Types', fields: { dedicated_to: 'For', @@ -1359,6 +1360,9 @@ export default { empty_list: 'There is no shot in the production. What about creating some?', empty_list_client: 'There is no shot in this production.', episodes: 'Episodes', + get_frames_from_previews: 'Set frame numbers from previews', + get_frames_from_previews_description: 'Select a task type to extract the frame numbers from the latest published movie previews.', + get_frames_from_previews_error: 'There was an error while extracting the frame numbers from the task type previews. Please contact our support team.', history: 'Shot values history', multiple_delete_error: 'An error occurred while deleting a shot. There is probably some data linked to a shot. Are you sure there is no task linked to a selected shot?', new_shot: 'Add a shot', diff --git a/src/store/api/shots.js b/src/store/api/shots.js index 8f04be7d47..0835dad0c1 100644 --- a/src/store/api/shots.js +++ b/src/store/api/shots.js @@ -191,5 +191,13 @@ export default { `/api/data/projects/${productionId}/quotas/` + `${taskTypeId}?detail=${detailLevel}&weighted=${weighted}` ) + }, + + setNbFramesFromTaskTypePreviews(taskTypeId, productionId, episodeId) { + let path = + `/api/actions/projects/${productionId}/task-types/` + + `${taskTypeId}/set-shot-nb-frames` + if (episodeId) path += `?episode_id=${episodeId}` + return client.ppost(path) } } diff --git a/src/store/modules/shots.js b/src/store/modules/shots.js index 46e0ad7fb8..389bdbb8e9 100644 --- a/src/store/modules/shots.js +++ b/src/store/modules/shots.js @@ -759,6 +759,21 @@ const actions = { } ) }) + }, + + async setNbFramesFromTaskTypePreviews( + { commit, rootGetters }, + { taskTypeId, productionId, episodeId } + ) { + const shotNbFrames = await shotsApi.setNbFramesFromTaskTypePreviews( + taskTypeId, + productionId, + episodeId + ) + shotNbFrames.forEach(shot => { + commit(UPDATE_SHOT, shot) + }) + return shotNbFrames } }