refactor: simplify handling of series status

This commit is contained in:
Gauthier Roebroeck 2020-03-12 15:46:26 +08:00
parent d4e888beed
commit 241b441c56

View file

@ -163,8 +163,11 @@ export default Vue.extend({
multiple (): boolean {
return Array.isArray(this.series)
},
seriesStatus (): string[] {
return Object.keys(SeriesStatus).map(x => capitalize(x))
seriesStatus (): any[] {
return Object.keys(SeriesStatus).map(x => ({
text: capitalize(x),
value: x
}))
},
dialogTitle (): string {
return this.multiple
@ -177,17 +180,11 @@ export default Vue.extend({
if (Array.isArray(series) && series.length === 0) return
if (Array.isArray(series) && series.length > 0) {
const status = this.$_.uniq(series.map(x => x.metadata.status))
this.form.status = status.length > 1 ? '' : capitalize(status[0])
this.form.status = status.length > 1 ? '' : status[0]
const statusLock = this.$_.uniq(series.map(x => x.metadata.statusLock))
this.form.statusLock = statusLock.length > 1 ? false : statusLock[0]
} else {
const s = series as SeriesDto
this.form.status = capitalize(s.metadata.status)
this.form.statusLock = s.metadata.statusLock
this.form.title = s.metadata.title
this.form.titleLock = s.metadata.titleLock
this.form.titleSort = s.metadata.titleSort
this.form.titleSortLock = s.metadata.titleSortLock
this.$_.merge(this.form, (series as SeriesDto).metadata)
}
},
dialogCancel () {
@ -211,7 +208,7 @@ export default Vue.extend({
return
}
const metadata = {
status: this.form.status.toUpperCase(),
status: this.form.status,
statusLock: this.form.statusLock
} as SeriesMetadataUpdateDto