2222
2323<template >
2424 <div >
25- <NcMultiselect :value =" currentValue"
25+ <NcSelect :value =" currentValue"
2626 :placeholder =" t('workflowengine', 'Select a file type')"
2727 label =" label"
28- track-by =" pattern"
2928 :options =" options"
30- :multiple =" false"
31- :tagging =" false"
29+ :clearable =" false"
3230 @input =" setValue" >
33- <template slot="singleLabel" slot-scope="props">
34- <span v-if =" props.option.icon" class =" option__icon" :class =" props.option.icon" />
35- <img v-else
36- class =" option__icon-img"
37- :src =" props.option.iconUrl"
38- alt =" " >
39- <span class =" option__title option__title_single" >{{ props.option.label }}</span >
31+ <template #option =" option " >
32+ <span v-if =" option.icon" class =" option__icon" :class =" option.icon" />
33+ <span v-else class =" option__icon-img" >
34+ <img :src =" option.iconUrl" alt =" " >
35+ </span >
36+ <span class =" option__title" >
37+ <NcEllipsisedOption :name =" String(option.label)" />
38+ </span >
4039 </template >
41- <template slot="option" slot-scope="props">
42- <span v-if =" props.option.icon" class =" option__icon" :class =" props.option.icon" />
43- <img v-else
44- class =" option__icon-img"
45- :src =" props.option.iconUrl"
46- alt =" " >
47- <span class =" option__title" >{{ props.option.label }}</span >
40+ <template #selected-option =" selectedOption " >
41+ <span v-if =" selectedOption.icon" class =" option__icon" :class =" selectedOption.icon" />
42+ <span v-else class =" option__icon-img" >
43+ <img :src =" selectedOption.iconUrl" alt =" " >
44+ </span >
45+ <span class =" option__title" >
46+ <NcEllipsisedOption :name =" String(selectedOption.label)" />
47+ </span >
4848 </template >
49- </NcMultiselect >
49+ </NcSelect >
5050 <input v-if =" !isPredefined"
5151 type =" text"
52- :value =" currentValue.pattern "
52+ :value =" currentValue.id "
5353 :placeholder =" t('workflowengine', 'e.g. httpd/unix-directory')"
5454 @input =" updateCustom" >
5555 </div >
5656</template >
5757
5858<script >
59- import NcMultiselect from ' @nextcloud/vue/dist/Components/NcMultiselect'
59+ import NcEllipsisedOption from ' @nextcloud/vue/dist/Components/NcEllipsisedOption.js'
60+ import NcSelect from ' @nextcloud/vue/dist/Components/NcSelect.js'
6061import valueMixin from ' ./../../mixins/valueMixin'
6162import { imagePath } from ' @nextcloud/router'
6263
6364export default {
6465 name: ' FileMimeType' ,
6566 components: {
66- NcMultiselect,
67+ NcEllipsisedOption,
68+ NcSelect,
6769 },
6870 mixins: [
6971 valueMixin,
@@ -74,22 +76,22 @@ export default {
7476 {
7577 icon: ' icon-folder' ,
7678 label: t (' workflowengine' , ' Folder' ),
77- pattern : ' httpd/unix-directory' ,
79+ id : ' httpd/unix-directory' ,
7880 },
7981 {
8082 icon: ' icon-picture' ,
8183 label: t (' workflowengine' , ' Images' ),
82- pattern : ' /image\\ /.*/' ,
84+ id : ' /image\\ /.*/' ,
8385 },
8486 {
8587 iconUrl: imagePath (' core' , ' filetypes/x-office-document' ),
8688 label: t (' workflowengine' , ' Office documents' ),
87- pattern : ' /(vnd\\ .(ms-|openxmlformats-|oasis\\ .opendocument).*)$/' ,
89+ id : ' /(vnd\\ .(ms-|openxmlformats-|oasis\\ .opendocument).*)$/' ,
8890 },
8991 {
9092 iconUrl: imagePath (' core' , ' filetypes/application-pdf' ),
9193 label: t (' workflowengine' , ' PDF documents' ),
92- pattern : ' application/pdf' ,
94+ id : ' application/pdf' ,
9395 },
9496 ],
9597 }
@@ -99,7 +101,7 @@ export default {
99101 return [... this .predefinedTypes , this .customValue ]
100102 },
101103 isPredefined () {
102- const matchingPredefined = this .predefinedTypes .find ((type ) => this .newValue === type .pattern )
104+ const matchingPredefined = this .predefinedTypes .find ((type ) => this .newValue === type .id )
103105 if (matchingPredefined) {
104106 return true
105107 }
@@ -109,18 +111,18 @@ export default {
109111 return {
110112 icon: ' icon-settings-dark' ,
111113 label: t (' workflowengine' , ' Custom MIME type' ),
112- pattern : ' ' ,
114+ id : ' ' ,
113115 }
114116 },
115117 currentValue () {
116- const matchingPredefined = this .predefinedTypes .find ((type ) => this .newValue === type .pattern )
118+ const matchingPredefined = this .predefinedTypes .find ((type ) => this .newValue === type .id )
117119 if (matchingPredefined) {
118120 return matchingPredefined
119121 }
120122 return {
121123 icon: ' icon-settings-dark' ,
122124 label: t (' workflowengine' , ' Custom mimetype' ),
123- pattern : this .newValue ,
125+ id : this .newValue ,
124126 }
125127 },
126128 },
@@ -132,7 +134,7 @@ export default {
132134 },
133135 setValue (value ) {
134136 if (value !== null ) {
135- this .newValue = value .pattern
137+ this .newValue = value .id
136138 this .$emit (' input' , this .newValue )
137139 }
138140 },
@@ -144,24 +146,30 @@ export default {
144146}
145147 </script >
146148<style scoped lang="scss">
147- .multiselect , input [type = ' text' ] {
148- width : 100% ;
149- }
150- .multiselect >>> .multiselect__content-wrapper li >span ,
151- .multiselect >>> .multiselect__single {
152- display : flex ;
153- white-space : nowrap ;
154- overflow : hidden ;
155- text-overflow : ellipsis ;
156- }
149+ .v-select ,
150+ input [type = ' text' ] {
151+ width : 100% ;
152+ }
153+
154+ input [type = text ] {
155+ min-height : 48px ;
156+ }
157157
158- .option__icon {
159- display : inline-block ;
160- min-width : 30px ;
161- background-position : left ;
162- }
158+ .option__icon ,
159+ .option__icon-img {
160+ display : inline-block ;
161+ min-width : 30px ;
162+ background-position : center ;
163+ vertical-align : middle ;
164+ }
163165
164- .option__icon-img {
165- margin-right : 14px ;
166- }
166+ .option__icon-img {
167+ text-align : center ;
168+ }
169+
170+ .option__title {
171+ display : inline-flex ;
172+ width : calc (100% - 36px );
173+ vertical-align : middle ;
174+ }
167175 </style >
0 commit comments