55<template >
66 <div ref =" taskTypeSelect"
77 class =" task-type-select" >
8- <NcActions v-for =" variants in buttonTypes "
8+ <NcActions v-for =" variants in buttonTypesByInlineStatus . inline "
99 :key =" variants .id "
10- :menu-name =" variants .text "
1110 :force-menu =" true "
11+ :menu-name =" variants .text "
1212 :container =" $refs .taskTypeSelect "
1313 :primary =" selectedCategory (variants )"
1414 @click =" onMenuCategorySelected (variants .id , variants .tasks )" >
2727 <component :is =" variants.icon" />
2828 </template >
2929 </NcActions >
30+ <NcActions
31+ :force-menu =" true "
32+ :container =" $refs .taskTypeSelect "
33+ @close =" categorySubmenu = null " >
34+ <template v-if =" ! categorySubMenuTaskType " >
35+ <NcActionButton v-for =" variant in buttonTypesByInlineStatus .overflow "
36+ :key =" variant .id "
37+ :is-menu =" variant .tasks .length > 1 || variant .id === ' other' "
38+ :title =" variant .text "
39+ @click =" onMenuCategorySelected (variant .id , variant .tasks )" >
40+ <template #icon >
41+ <component :is =" variant.icon" />
42+ </template >
43+ {{ variant.text }}
44+ </NcActionButton >
45+ </template >
46+ <template v-else >
47+ <NcActionButton v-for =" t in categorySubMenuTaskType .tasks "
48+ :key =" t .id "
49+ :disabled =" selectedTask (t )"
50+ :title =" t .description "
51+ :close-after-click =" true "
52+ @click =" onTaskSelected (t )" >
53+ <template #icon >
54+ <div style =" width : 16px " />
55+ </template >
56+ {{ t.name }}
57+ </NcActionButton >
58+ </template >
59+ </NcActions >
3060 </div >
3161</template >
3262
@@ -60,6 +90,14 @@ export default {
6090 type: Array ,
6191 required: true ,
6292 },
93+ /**
94+ * Number of inline elements
95+ * All elements are inline if this prop is null
96+ */
97+ inline: {
98+ type: [Number , null ],
99+ default: null ,
100+ },
63101 },
64102
65103 emits: [
@@ -68,11 +106,14 @@ export default {
68106
69107 data () {
70108 return {
71- extraButtonType : null ,
109+ categorySubmenu : null ,
72110 }
73111 },
74112
75113 computed: {
114+ onlyInline () {
115+ return this .inline === null
116+ },
76117 buttonTypes () {
77118 const taskTypes = {}
78119 for (const task of this .options ) {
@@ -105,19 +146,27 @@ export default {
105146 }
106147 return result
107148 },
108- actionTypes () {
109- if (this .extraButtonType !== null ) {
110- // the extra button replaces the last one so we need the last one as an action
111- // take all non-inline options that are not selected and that are not the extra button
112- const types = this .options .slice (this .inline ).filter (t => t .id !== this .modelValue && t .id !== this .extraButtonType .id )
113- // add the one that was a button and that has been replaced
114- if (this .extraButtonType .id !== this .options [this .inline - 1 ].id ) {
115- types .unshift (this .options [this .inline - 1 ])
149+ buttonTypesByInlineStatus () {
150+ if (this .onlyInline ) {
151+ return { inline: this .buttonTypes , overflow: [] }
152+ }
153+ const inline = this .buttonTypes .slice (0 , this .inline )
154+ let overflow = this .buttonTypes .slice (this .inline )
155+
156+ // Ensure that the selection is never inline otherwise swap with the last uninlined category
157+ const selection = overflow .find (t => this .selectedCategory (t))
158+ if (selection) {
159+ const removal = inline .pop ()
160+ inline .push (selection)
161+ overflow = overflow .filter (t => t .id !== selection .id )
162+ if (removal) {
163+ overflow .unshift (removal)
116164 }
117- return types
118- } else {
119- return this .options .slice (this .inline )
120165 }
166+ return { overflow, inline }
167+ },
168+ categorySubMenuTaskType () {
169+ return this .buttonTypesByInlineStatus .overflow .find (t => t .id === this .categorySubmenu )
121170 },
122171 },
123172
@@ -135,9 +184,10 @@ export default {
135184 this .$emit (' update:model-value' , taskType .id )
136185 },
137186 onMenuCategorySelected (category , tasks ) {
138- if (tasks .length === 1 ) {
187+ if (tasks .length === 1 && category !== ' other ' ) {
139188 this .onTaskSelected (tasks[0 ])
140189 }
190+ this .categorySubmenu = category
141191 },
142192 getTaskCategory (id ) {
143193 if (id .startsWith (' chatty' )) {
0 commit comments