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)
}
export function setSoundSetParent (soundSetId, parentId) {
return setSoundSetProperty(soundSetId, 'parent_id', parentId)
}
export function getSoundHandles (options) {
return new Promise((resolve, reject) => {
options = options || {}

@ -20,6 +20,13 @@
{{ soundSet.description }}
</csc-list-item-subtitle>
</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>
<csc-list-item-subtitle
v-if="!expanded"
@ -76,6 +83,27 @@
/>
</template>
</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
:label="$t('Default sound set for all seats and groups')"
:value="soundSet.contract_default"
@ -117,6 +145,9 @@
</template>
<script>
import {
mapState
} from 'vuex'
import {
maxLength
} from 'vuelidate/lib/validators'
@ -207,11 +238,37 @@ export default {
}
},
computed: {
...mapState('pbxSoundSets', [
'soundSetList'
]),
hasNameChanged () {
return this.changes.name !== this.getDefaultData().name
},
hasDescriptionChanged () {
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: {
@ -245,7 +302,8 @@ export default {
return {
name: this.soundSet.name,
description: this.soundSet.description,
contract_default: this.soundSet.contract_default
contract_default: this.soundSet.contract_default,
parent_id: this.soundSet.parent_id
}
},
resetName () {
@ -254,6 +312,9 @@ export default {
resetDescription () {
this.changes.description = this.getDefaultData().description
},
resetParent () {
this.changes.parent_id = this.getDefaultData().parent_id
},
playSoundFile (data) {
this.$emit('play-sound-file', data)
},
@ -280,6 +341,12 @@ export default {
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
@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
class="q-mb-sm q-mt-sm"
>
@ -90,6 +99,9 @@
</template>
<script>
import {
mapState
} from 'vuex'
import {
required,
maxLength
@ -147,6 +159,9 @@ export default {
}
},
computed: {
...mapState('pbxSoundSets', [
'soundSetList'
]),
nameErrorMessage () {
if (!this.$v.data.name.required) {
return this.$t('{field} is required', {
@ -201,6 +216,21 @@ export default {
classes.push('csc-toggle-disabled')
}
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: {
@ -212,7 +242,8 @@ export default {
language: 'en',
contract_default: false,
copy_from_default: false,
description: ''
description: '',
parent_id: null
}
},
cancel () {

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

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

@ -12,6 +12,7 @@ import {
setAsDefault,
setSoundSetName,
setSoundSetDescription,
setSoundSetParent,
getAllSoundHandles,
getAllSoundFilesBySoundSetId,
getSoundFile,
@ -415,6 +416,22 @@ export default {
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) {
if (context.state.soundHandleListState !== RequestState.succeeded) {
context.commit('soundHandlesRequesting')

Loading…
Cancel
Save