MT#56986 [CSC] Add possibility to select parent soundset when creating/editing a soundset

Change-Id: Id731c9e0464ccb88ca525c9437beaeb8d8488eff
mr11.4
Hugo Zigha 2 years ago
parent 79e15c91fb
commit 87d31b2145

@ -102,6 +102,10 @@ export function setSoundSetDescription (soundSetId, description) {
return setSoundSetProperty(soundSetId, 'description', description) return setSoundSetProperty(soundSetId, 'description', description)
} }
export function setSoundSetParent (soundSetId, parentId) {
return setSoundSetProperty(soundSetId, 'parent_id', parentId)
}
export function getSoundHandles (options) { export function getSoundHandles (options) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
options = options || {} options = options || {}

@ -20,6 +20,13 @@
{{ soundSet.description }} {{ soundSet.description }}
</csc-list-item-subtitle> </csc-list-item-subtitle>
</q-slide-transition> </q-slide-transition>
<q-slide-transition>
<csc-list-item-subtitle
v-if="!expanded && soundSet.parent_id && parent"
>
{{ $t('Parent') + ': ' + parent.name }}
</csc-list-item-subtitle>
</q-slide-transition>
<q-slide-transition> <q-slide-transition>
<csc-list-item-subtitle <csc-list-item-subtitle
v-if="!expanded" v-if="!expanded"
@ -76,6 +83,27 @@
/> />
</template> </template>
</q-input> </q-input>
<q-select
v-model="changes.parent_id"
v-if="(changes.parent_id && parent) || !changes.parent_id"
emit-value
map-options
:options="getParentOptions"
:label="$t('Parent')"
>
<template
v-if="hasParentChanged"
v-slot:append
>
<csc-input-button-save
@click.stop="save"
/>
<csc-input-button-reset
@click.stop="resetParent"
/>
</template>
</q-select>
<q-checkbox <q-checkbox
:label="$t('Default sound set for all seats and groups')" :label="$t('Default sound set for all seats and groups')"
:value="soundSet.contract_default" :value="soundSet.contract_default"
@ -117,6 +145,9 @@
</template> </template>
<script> <script>
import {
mapState
} from 'vuex'
import { import {
maxLength maxLength
} from 'vuelidate/lib/validators' } from 'vuelidate/lib/validators'
@ -207,11 +238,37 @@ export default {
} }
}, },
computed: { computed: {
...mapState('pbxSoundSets', [
'soundSetList'
]),
hasNameChanged () { hasNameChanged () {
return this.changes.name !== this.getDefaultData().name return this.changes.name !== this.getDefaultData().name
}, },
hasDescriptionChanged () { hasDescriptionChanged () {
return this.changes.description !== this.getDefaultData().description return this.changes.description !== this.getDefaultData().description
},
parent () {
return this.changes.parent_id ? this.soundSetList.find((soundSet) => this.changes.parent_id === soundSet.id) : null
},
getParentOptions () {
let parentOptions = [
{
label: this.$t('Unassigned'),
value: null
}
]
this.soundSetList.map((soundSet) => {
if (soundSet.id !== this.soundSet.id) {
parentOptions.push({
label: soundSet.name,
value: soundSet.id
})
}
})
return parentOptions
},
hasParentChanged () {
return this.changes.parent_id !== this.getDefaultData().parent_id
} }
}, },
watch: { watch: {
@ -245,7 +302,8 @@ export default {
return { return {
name: this.soundSet.name, name: this.soundSet.name,
description: this.soundSet.description, description: this.soundSet.description,
contract_default: this.soundSet.contract_default contract_default: this.soundSet.contract_default,
parent_id: this.soundSet.parent_id
} }
}, },
resetName () { resetName () {
@ -254,6 +312,9 @@ export default {
resetDescription () { resetDescription () {
this.changes.description = this.getDefaultData().description this.changes.description = this.getDefaultData().description
}, },
resetParent () {
this.changes.parent_id = this.getDefaultData().parent_id
},
playSoundFile (data) { playSoundFile (data) {
this.$emit('play-sound-file', data) this.$emit('play-sound-file', data)
}, },
@ -280,6 +341,12 @@ export default {
description: this.changes.description description: this.changes.description
}) })
} }
if (this.hasParentChanged) {
this.$emit('save-parent', {
soundSetId: this.soundSet.id,
parent_id: this.changes.parent_id
})
}
} }
} }
} }

@ -20,6 +20,15 @@
hide-bottom-space hide-bottom-space
@input="$v.data.description.$touch" @input="$v.data.description.$touch"
/> />
<q-select
v-model="data.parent_id"
emit-value
map-options
:disable="loading"
:readonly="loading"
:options="getParentOptions"
:label="$t('Parent')"
/>
<div <div
class="q-mb-sm q-mt-sm" class="q-mb-sm q-mt-sm"
> >
@ -90,6 +99,9 @@
</template> </template>
<script> <script>
import {
mapState
} from 'vuex'
import { import {
required, required,
maxLength maxLength
@ -147,6 +159,9 @@ export default {
} }
}, },
computed: { computed: {
...mapState('pbxSoundSets', [
'soundSetList'
]),
nameErrorMessage () { nameErrorMessage () {
if (!this.$v.data.name.required) { if (!this.$v.data.name.required) {
return this.$t('{field} is required', { return this.$t('{field} is required', {
@ -201,6 +216,21 @@ export default {
classes.push('csc-toggle-disabled') classes.push('csc-toggle-disabled')
} }
return classes return classes
},
getParentOptions () {
let parentOptions = [
{
label: this.$t('Unassigned'),
value: null
}
]
this.soundSetList.map((soundSet) => {
parentOptions.push({
label: soundSet.name,
value: soundSet.id
})
})
return parentOptions
} }
}, },
methods: { methods: {
@ -212,7 +242,8 @@ export default {
language: 'en', language: 'en',
contract_default: false, contract_default: false,
copy_from_default: false, copy_from_default: false,
description: '' description: '',
parent_id: null
} }
}, },
cancel () { cancel () {

@ -299,6 +299,7 @@
"Page Header": "Page Header", "Page Header": "Page Header",
"Page not found": "Page not found", "Page not found": "Page not found",
"Parallel Ringing": "Parallel Ringing", "Parallel Ringing": "Parallel Ringing",
"Parent": "Parent",
"Password": "Password", "Password": "Password",
"Password Retype": "Password Retype", "Password Retype": "Password Retype",
"Password changed successfully": "Password changed successfully", "Password changed successfully": "Password changed successfully",
@ -543,6 +544,7 @@
"office hours are ...": "office hours are ...", "office hours are ...": "office hours are ...",
"page": "page", "page": "page",
"pages": "pages", "pages": "pages",
"parent": "parent",
"ring": "ring", "ring": "ring",
"second": "second", "second": "second",
"seconds": "seconds", "seconds": "seconds",

@ -67,6 +67,7 @@
@save-as-default="setAsDefaultSoundSet" @save-as-default="setAsDefaultSoundSet"
@save-name="setSoundSetName" @save-name="setSoundSetName"
@save-description="setSoundSetDescription" @save-description="setSoundSetDescription"
@save-parent="setSoundSetParent"
@expand="expandSoundSet(soundSet.id)" @expand="expandSoundSet(soundSet.id)"
@collapse="collapseSoundSet" @collapse="collapseSoundSet"
@play-sound-file="playSoundFile" @play-sound-file="playSoundFile"
@ -212,6 +213,7 @@ export default {
'setAsDefaultSoundSet', 'setAsDefaultSoundSet',
'setSoundSetName', 'setSoundSetName',
'setSoundSetDescription', 'setSoundSetDescription',
'setSoundSetParent',
'loadSoundSetResources', 'loadSoundSetResources',
'playSoundFile', 'playSoundFile',
'uploadSoundFile', 'uploadSoundFile',

@ -12,6 +12,7 @@ import {
setAsDefault, setAsDefault,
setSoundSetName, setSoundSetName,
setSoundSetDescription, setSoundSetDescription,
setSoundSetParent,
getAllSoundHandles, getAllSoundHandles,
getAllSoundFilesBySoundSetId, getAllSoundFilesBySoundSetId,
getSoundFile, getSoundFile,
@ -415,6 +416,22 @@ export default {
context.commit('soundSetUpdateFailed', err.message) context.commit('soundSetUpdateFailed', err.message)
}) })
}, },
setSoundSetParent (context, options) {
context.commit('soundSetUpdateRequesting', {
soundSetId: options.soundSetId,
field: i18n.t('parent')
})
setSoundSetParent(options.soundSetId, options.parent_id).then(() => {
return context.dispatch('loadSoundSetList', {
listVisible: true,
page: context.state.soundSetListCurrentPage
})
}).then(() => {
context.commit('soundSetUpdateSucceeded')
}).catch((err) => {
context.commit('soundSetUpdateFailed', err.message)
})
},
loadSoundSetResources (context, soundSetId) { loadSoundSetResources (context, soundSetId) {
if (context.state.soundHandleListState !== RequestState.succeeded) { if (context.state.soundHandleListState !== RequestState.succeeded) {
context.commit('soundHandlesRequesting') context.commit('soundHandlesRequesting')

Loading…
Cancel
Save