88 <template #list >
99 <NcAppNavigationItem v-for =" creator in creators"
1010 :key =" creator.app + '-' + creator.extension"
11- :name =" creator.label "
11+ :name =" categoryName( creator) "
1212 :active =" activeCreator === creator"
13- @click =" setCreator(creator)" />
13+ @click =" setCreator(creator)" >
14+ <template #icon >
15+ <!-- eslint-disable-next-line vue/no-v-html -->
16+ <span class =" office-overview__nav-icon" v-html =" creator.iconSvgInline" />
17+ </template >
18+ </NcAppNavigationItem >
1419 </template >
1520 </NcAppNavigation >
1621
2833 <template v-else >
2934 <div class =" office-overview__search" >
3035 <NcTextField v-model =" searchQuery"
31- :label =" t('richdocuments', 'Search {category}', { category: activeCreator.label })"
36+ :label =" t('richdocuments', 'Search {category}', { category: categoryName( activeCreator) })"
3237 type =" search" />
3338 </div >
3439
7378
7479 <!-- Create from template dialog -->
7580 <NcDialog v-if =" showCreateDialog"
76- :name =" t('richdocuments', 'New {type}', { type: pendingCreator ? pendingCreator.label : '' }) "
81+ :name =" pendingCreator ? pendingCreator.label : ''"
7782 :open =" showCreateDialog"
7883 close-on-click-outside
7984 @update:open =" showCreateDialog = false" >
8691 <NcTextField ref =" createInput"
8792 v-model =" newFileName"
8893 :label =" t('richdocuments', 'Filename')"
94+ :error =" !!createError"
95+ :helper-text =" createError"
8996 :disabled =" creating" />
9097 </form >
9198 </NcDialog >
@@ -138,6 +145,7 @@ export default {
138145 pendingCreator: null ,
139146 pendingTemplate: null ,
140147 creating: false ,
148+ createError: ' ' ,
141149 }
142150 },
143151
@@ -169,6 +177,12 @@ export default {
169177 },
170178
171179 methods: {
180+ categoryName (creator ) {
181+ const base = creator .label .replace (/ ^ new\s + / i , ' ' ).trim ()
182+ const capitalized = base .charAt (0 ).toUpperCase () + base .slice (1 )
183+ return capitalized .endsWith (' s' ) ? capitalized : capitalized + ' s'
184+ },
185+
172186 setCreator (creator ) {
173187 this .activeCreator = creator
174188 },
@@ -191,6 +205,7 @@ export default {
191205 this .pendingCreator = creator
192206 this .pendingTemplate = template
193207 this .newFileName = creator .label .replace (/ ^ New\s + / i , ' ' ) + creator .extension
208+ this .createError = ' '
194209 this .showCreateDialog = true
195210 this .$nextTick (() => {
196211 const input = this .$refs .createInput ? .$el ? .querySelector (' input' )
@@ -206,28 +221,33 @@ export default {
206221 return
207222 }
208223 this .creating = true
224+ this .createError = ' '
209225 try {
210226 const filePath = ' /' + this .newFileName .trim ()
211227 const templatePath = this .pendingTemplate ? .filename ?? ' '
212228 const templateType = this .pendingTemplate ? ' user' : ' user_system'
213229 await createFromTemplate (filePath, templatePath, templateType)
214230 this .showCreateDialog = false
231+ const previousCreator = this .activeCreator
215232 invalidateOfficeFilesCache ()
216- await this .fetchAll ()
233+ await this .fetchAll (previousCreator )
217234 } catch (e) {
218- this .error = t (' richdocuments' , ' Failed to create file ' )
235+ this .createError = t (' richdocuments' , ' A file with that name already exists ' )
219236 } finally {
220237 this .creating = false
221238 }
222239 },
223240
224- async fetchAll () {
241+ async fetchAll (restoreCreator = null ) {
225242 this .loading = true
226243 this .error = null
227244
228245 try {
229246 this .creators = await getTemplates ()
230- this .activeCreator = this .creators [0 ] ?? null
247+ const match = restoreCreator
248+ ? this .creators .find (c => c .app === restoreCreator .app && c .extension === restoreCreator .extension )
249+ : null
250+ this .activeCreator = match ?? this .creators [0 ] ?? null
231251
232252 if (this .creators .length > 0 ) {
233253 const allMimes = this .creators .flatMap (c => c .mimetypes )
@@ -281,4 +301,15 @@ export default {
281301.office - overview__create- form {
282302 min- height: calc (2 * var (-- default- clickable- area));
283303}
304+
305+ .office - overview__nav- icon {
306+ display: flex;
307+ width: 20px ;
308+ height: 20px ;
309+
310+ : deep (svg ) {
311+ width: 100 % ;
312+ height: 100 % ;
313+ }
314+ }
284315< / style>
0 commit comments