Skip to content

Commit

Permalink
improve selector behaviour, replace last button by selected action item
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Veyssier <[email protected]>
  • Loading branch information
julien-nc committed Sep 25, 2023
1 parent 77da67c commit 9c981a5
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions src/components/TaskTypeSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,31 +64,28 @@ export default {
computed: {
buttonTypes() {
const types = this.options.slice(0, this.inline)
/*
// TODO delete next line
types.push(...[
{
id: 'plop1',
name: 'DummyTask1',
},
{
id: 'plop2',
name: 'DummyTask2',
},
{
id: 'plop3',
name: 'DummyTask3',
},
])
*/
// extra button replaces the last one
if (this.extraButtonType !== null) {
const types = this.options.slice(0, this.inline - 1)
types.push(this.extraButtonType)
return types
} else {
return this.options.slice(0, this.inline)
}
return types
},
actionTypes() {
return this.options.slice(this.inline)
if (this.extraButtonType !== null) {
// the extra button replaces the last one so we need the last one as an action
// take all non-inline options that are not selected and that are not the extra button
const types = this.options.slice(this.inline).filter(t => t.id !== this.value && t.id !== this.extraButtonType.id)
// add the one that was a button and that has been replaced
if (this.extraButtonType.id !== this.options[this.inline - 1].id) {
types.unshift(this.options[this.inline - 1])
}
return types
} else {
return this.options.slice(this.inline)
}
},
},
Expand Down

0 comments on commit 9c981a5

Please sign in to comment.