Skip to content

Commit

Permalink
Merge pull request #1615 from frankrousseau/main
Browse files Browse the repository at this point in the history
[nav] Remember last production page visited
  • Loading branch information
frankrousseau authored Dec 17, 2024
2 parents e9c4e90 + fd61347 commit 78569f1
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 39 deletions.
30 changes: 19 additions & 11 deletions src/components/pages/Playlist.vue
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,10 @@ import { getPlaylistPath } from '@/lib/path'
import { updateModelFromList, removeModelFromList } from '@/lib/models'
import { sortShots } from '@/lib/sorting'
import assetStore from '@/store/modules/assets'
import shotStore from '@/store/modules/shots'
import sequenceStore from '@/store/modules/sequences'
import ButtonSimple from '@/components/widgets/ButtonSimple.vue'
import BuildFilterModal from '@/components/modals/BuildFilterModal.vue'
import Combobox from '@/components/widgets/Combobox.vue'
Expand Down Expand Up @@ -706,9 +710,13 @@ export default {
},
getTaskStatus(entity) {
let entityWithTasks = this.shotMap.get(entity.id)
if (!entityWithTasks) entityWithTasks = this.assetMap.get(entity.id)
if (!entityWithTasks) entityWithTasks = this.sequenceMap.get(entity.id)
let entityWithTasks = shotStore.cache.shotMap.get(entity.id)
if (!entityWithTasks) {
entityWithTasks = assetStore.cache.assetMap.get(entity.id)
}
if (!entityWithTasks) {
entityWithTasks = sequenceStore.cache.sequenceMap.get(entity.id)
}
if (!entityWithTasks) return {}
const taskId = entity.validations.get(this.currentPlaylist.task_type_id)
Expand Down Expand Up @@ -856,14 +864,14 @@ export default {
convertEntityToPlaylistFormat(entityInfo) {
let entity
if (this.isAssetPlaylist) {
entity = this.assetMap.get(entityInfo.id)
entity = assetStore.cache.assetMap.get(entityInfo.id)
} else if (this.isSequencePlaylist) {
entity = this.sequenceMap.get(entityInfo.id)
entity = sequenceStore.cache.sequenceMap.get(entityInfo.id)
if (this.currentEpisode) {
entity.episode_name = this.currentEpisode.name
}
} else {
entity = this.shotMap.get(entityInfo.id)
entity = shotStore.cache.shotMap.get(entityInfo.id)
}
if (entity) {
const playlistEntity = {
Expand Down Expand Up @@ -971,11 +979,11 @@ export default {
onNewEntityDropped(info) {
let entity = null
if (this.isAssetPlaylist) {
entity = this.assetMap.get(info.after)
entity = assetStore.cache.assetMap.get(info.after)
} else if (this.isSequencePlaylist) {
entity = this.sequenceMap.get(info.after)
entity = sequenceStore.cache.sequenceMap.get(info.after)
} else {
entity = this.shotMap.get(info.after)
entity = shotStore.cache.shotMap.get(info.after)
}
if (entity && !this.currentEntities[entity.id]) {
Expand Down Expand Up @@ -1021,7 +1029,7 @@ export default {
addSequence(sequenceShots) {
if (sequenceShots.length > 0) {
const sequenceId = sequenceShots[0].sequence_id
const shots = Array.from(this.shotMap.values())
const shots = Array.from(shotStore.cache.shotMap.values())
.filter(s => s.sequence_id === sequenceId)
.sort(firstBy('name'))
.reverse()
Expand Down Expand Up @@ -1068,7 +1076,7 @@ export default {
addMovie() {
this.loading.addMovie = true
this.$options.silent = true
const shots = sortShots(Array.from(this.shotMap.values()))
const shots = sortShots(Array.from(shotStore.cache.shotMap.values()))
this.addEntities(shots.reverse(), () => {
this.loading.addMovie = false
this.$options.silent = false
Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/playlists/PlaylistPlayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2079,7 +2079,7 @@ export default {
this.rebuildRevisionOptions()
}
this.$nextTick(() => {
if (this.isCurrentPreviewPicture) {
if (this.isCurrentPreviewPicture && !this.isPlaying) {
this.triggerResize()
this.resetHeight()
this.resetPictureCanvas()
Expand Down
32 changes: 5 additions & 27 deletions src/components/tops/Topbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
class="nav-item"
v-else-if="lastProduction && $route.path !== '/open-productions'"
>
<router-link :to="lastSectionPath" class="flexrow">
<router-link :to="lastProductionRoute" class="flexrow">
<chevron-left-icon />
{{ $t('main.go_productions') }}
</router-link>
Expand Down Expand Up @@ -282,7 +282,7 @@ export default {
'isSupportChat',
'isUserMenuHidden',
'isTVShow',
'lastProductionScreen',
'lastProductionRoute',
'lastProductionViewed',
'mainConfig',
'openProductions',
Expand Down Expand Up @@ -392,31 +392,6 @@ export default {
return production
},
lastSectionPath() {
const production = this.lastProduction
const section = this.lastProductionScreen
const route = {
name: section,
params: {
production_id: production.id
}
}
if (production.production_type === 'tvshow') {
if (section !== 'episodes') {
route.name = `episode-${section}`
}
if (
!['edits', 'episodes'].includes(section) &&
production.first_episode_id
) {
route.params.episode_id = production.first_episode_id
} else {
route.params.episode_id = 'all'
}
}
return route
},
sectionOptions() {
if (!this.currentProduction) return []
Expand Down Expand Up @@ -549,6 +524,7 @@ export default {
'loadEpisodes',
'incrementNotificationCounter',
'logout',
'saveLastProductionRoute',
'setProduction',
'setCurrentEpisode',
'setSupportChat',
Expand Down Expand Up @@ -774,6 +750,8 @@ export default {
$route() {
const productionId = this.$route.params.production_id
if (productionId) {
const route = this.$route
this.saveLastProductionRoute(route)
this.updateContext(productionId)
}
},
Expand Down
13 changes: 13 additions & 0 deletions src/store/modules/productions.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import {
DELETE_METADATA_DESCRIPTOR_END,
CLEAR_SHOTS,
CLEAR_ASSETS,
SAVE_LAST_PRODUCTION_ROUTE,
RESET_ALL
} from '@/store/mutation-types'

Expand All @@ -66,6 +67,8 @@ const initialState = {
isProductionsLoadingError: false,
isOpenProductionsLoading: false,

lastProductionRoute: { name: 'open-productions' },

assetsPath: { name: 'open-productions' },
assetTypesPath: { name: 'open-productions' },
shotsPath: { name: 'open-productions' },
Expand Down Expand Up @@ -161,6 +164,8 @@ const getters = {
playlistsPath: state => state.playlistsPath,
teamPath: state => state.teamPath,

lastProductionRoute: state => state.lastProductionRoute,

productionAssetTypes: (state, getters, rootState) => {
if (!state.currentProduction) return []
if (helpers.isEmptyArray(state.currentProduction, 'asset_types')) {
Expand Down Expand Up @@ -575,6 +580,10 @@ const actions = {

loadProductionStats() {
return productionsApi.getProductionStats()
},

saveLastProductionRoute({ commit }, route) {
this.commit(SAVE_LAST_PRODUCTION_ROUTE, route)
}
}

Expand Down Expand Up @@ -883,6 +892,10 @@ const mutations = {
}
},

[SAVE_LAST_PRODUCTION_ROUTE](state, route) {
state.lastProductionRoute = route
},

[RESET_ALL](state) {
Object.assign(state, { ...initialState })
}
Expand Down
2 changes: 2 additions & 0 deletions src/store/mutation-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ export const DELETE_METADATA_DESCRIPTOR_END = 'DELETE_METADATA_DESCRIPTOR_END'
export const ADD_ATTACHMENT_TO_COMMENT = 'ADD_ATTACHMENT_TO_COMMENT'
export const REMOVE_ATTACHMENT_FROM_COMMENT = 'REMOVE_ATTACHMENT_FROM_COMMENT'

export const SAVE_LAST_PRODUCTION_ROUTE = 'SAVE_LAST_PRODUCTION_ROUTE'

// Task types

export const LOAD_TASK_TYPES_START = 'LOAD_TASK_TYPES_START'
Expand Down

0 comments on commit 78569f1

Please sign in to comment.