Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[shots] Allow to set frames from previews #1474

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions src/components/modals/SetFramesFromTaskTypePreviewsModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<template>
<div
:class="{
modal: true,
'is-active': active
}"
>
<div class="modal-background" @click="$emit('cancel')"></div>

<div class="modal-content">
<div class="box content">
<h1 class="title">
{{ $t('shots.get_frames_from_previews') }}
</h1>

<p class="description">
{{ $t('shots.get_frames_from_previews_description') }}
</p>

<combobox-task-type
:task-type-list="productionShotTaskTypes"
:placeholder="$t('task_types.select_task_type')"
add-placeholder
v-model="taskTypeId"
/>

<modal-footer
:error-text="$t('shots.get_frames_from_previews_error')"
:is-error="isError"
:is-loading="isLoading"
:is-disabled="!isFormFilled"
@confirm="confirm"
@cancel="$emit('cancel')"
/>
</div>
</div>
</div>
</template>

<script>
import { mapGetters, mapActions } from 'vuex'
import { modalMixin } from '@/components/modals/base_modal'

import ComboboxTaskType from '@/components/widgets/ComboboxTaskType'
import ModalFooter from '@/components/modals/ModalFooter'

export default {
name: 'set-frames-from-task-type-previews-modal',
mixins: [modalMixin],

components: {
ComboboxTaskType,
ModalFooter
},

props: {
active: {
type: Boolean,
default: false
},
isLoading: {
type: Boolean,
default: false
},
isError: {
type: Boolean,
default: false
},
errorText: {
type: String,
default: ''
}
},

data() {
return {
taskTypeId: null
}
},

mounted() {
this.reset()
},

computed: {
...mapGetters(['productionShotTaskTypes']),

isFormFilled() {
return this.taskTypeId !== null && this.taskTypeId !== ''
}
},

methods: {
...mapActions([]),

confirm() {
return this.$emit('confirm', this.taskTypeId)
},

reset() {
this.taskType = null
}
},

watch: {
active() {
if (this.active) {
this.reset()
}
}
}
}
</script>

<style lang="scss" scoped>
p.description {
font-size: 1.2rem;
}
</style>
38 changes: 38 additions & 0 deletions src/components/pages/Shots.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@
icon="import-files"
@click="showAddThumbnailsModal"
/>
<button-simple
class="flexrow-item"
icon="film"
:title="$t('shots.get_frames_from_previews')"
@click="() => (modals.isSetFramesDisplayed = true)"
v-if="isCurrentUserManager"
/>
<button-simple
class="flexrow-item"
:title="$t('main.edl.import_file')"
Expand Down Expand Up @@ -257,6 +264,14 @@
@confirm="confirmAddMetadata"
/>

<set-frames-from-task-type-previews-modal
:active="modals.isSetFramesDisplayed"
:is-loading="loading.getFrames"
:is-error="errors.getFrames"
@cancel="modals.isSetFramesDisplayed = false"
@confirm="confirmSetFrames"
/>

<add-thumbnails-modal
ref="add-thumbnails-modal"
entity-type="Shot"
Expand Down Expand Up @@ -312,6 +327,7 @@ import HardDeleteModal from '@/components/modals/HardDeleteModal'
import ManageShotsModal from '@/components/modals/ManageShotsModal'
import SearchField from '@/components/widgets/SearchField'
import SearchQueryList from '@/components/widgets/SearchQueryList'
import SetFramesFromTaskTypePreviewsModal from '@/components/modals/SetFramesFromTaskTypePreviewsModal'
import SortingInfo from '@/components/widgets/SortingInfo'
import ShowAssignationsButton from '@/components/widgets/ShowAssignationsButton'
import ShowInfosButton from '@/components/widgets/ShowInfosButton'
Expand Down Expand Up @@ -341,6 +357,7 @@ export default {
InfoQuestionMark,
SearchField,
SearchQueryList,
SetFramesFromTaskTypePreviewsModal,
SortingInfo,
ShotHistoryModal,
ShowAssignationsButton,
Expand Down Expand Up @@ -384,6 +401,7 @@ export default {
isDeleteDisplayed: false,
isDeleteMetadataDisplayed: false,
isDeleteAllTasksDisplayed: false,
isSetFramesDisplayed: false,
isImportRenderDisplayed: false,
isImportDisplayed: false,
isEDLImportDisplayed: false,
Expand All @@ -401,6 +419,7 @@ export default {
deleteMetadata: false,
edit: false,
del: false,
getFrames: false,
importing: false,
restore: false,
savingSearch: false,
Expand All @@ -412,6 +431,7 @@ export default {
deleteMetadata: false,
creatingTasks: false,
deleteAllTasks: false,
getFrames: false,
importing: false,
importingError: null
}
Expand Down Expand Up @@ -564,6 +584,7 @@ export default {
'hideAssignations',
'loadEpisodes',
'loadShots',
'setNbFramesFromTaskTypePreviews',
'newEpisode',
'newSequence',
'newShot',
Expand Down Expand Up @@ -1097,6 +1118,23 @@ export default {
.finally(() => {
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
}
}
},

Expand Down
8 changes: 7 additions & 1 deletion src/components/widgets/ComboboxTaskType.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ export default {
default: false,
type: Boolean
},
placeholder: {
default: function () {
return this.$t('task_types.add_task_type_placeholder')
},
type: String
},
openTop: {
default: false,
type: Boolean
Expand All @@ -95,7 +101,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]
}
Expand Down
5 changes: 5 additions & 0 deletions src/locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -1232,13 +1232,15 @@ export default {
},

task_types: {
add_task_type_placeholder: '+ Task type',
delete_text: 'Are you sure you want to remove {name} from your database?',
delete_error: 'An error occurred while deleting this task type. There are probably data linked to it. Are you sure this task type has no task linked to it?',
edit_title: 'Edit task type',
create_error: 'An error occurred while creating the task type. Please, check that there is no task type with a similar name.',
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',
Expand Down Expand Up @@ -1366,6 +1368,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',
Expand Down
8 changes: 8 additions & 0 deletions src/store/api/shots.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
15 changes: 15 additions & 0 deletions src/store/modules/shots.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down