Skip to content

Commit 28bc329

Browse files
committed
refactor(desk): improve UX in folder explorer
1 parent 73ab4c6 commit 28bc329

File tree

7 files changed

+229
-47
lines changed

7 files changed

+229
-47
lines changed

package-lock.json

Lines changed: 70 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/desktop/components/is-input.vue

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ export default {
55
</script>
66

77
<script setup lang="ts">
8-
import { computed, ref, useAttrs } from 'vue'
8+
import { createBindings } from '@/composables/binding'
9+
import { computed, ref, useAttrs, onMounted } from 'vue'
910
import { useVModel } from 'vue-wind/composables/v-model'
1011
1112
const props = defineProps({
@@ -49,6 +50,10 @@ const props = defineProps({
4950
type: String,
5051
default: '',
5152
},
53+
autofocus: {
54+
type: Boolean,
55+
default: false,
56+
},
5257
})
5358
5459
const emit = defineEmits(['update:modelValue'])
@@ -152,32 +157,15 @@ const labelClasses = computed(() => {
152157
153158
// input attrs
154159
155-
const bindings = computed(() => {
156-
const root = {}
157-
const label = {}
158-
const input = {}
159-
const wrapper = {}
160-
161-
Object.keys(attrs).forEach((key) => {
162-
if (key.startsWith('input:')) {
163-
input[key.replace('input:', '')] = attrs[key]
164-
return
165-
}
160+
const bindings = computed(() => createBindings(attrs, ['label', 'input', 'wrapper']))
166161
167-
if (key.startsWith('label:')) {
168-
label[key.replace('label:', '')] = attrs[key]
169-
return
170-
}
162+
// autofocus
163+
const inputRef = ref<HTMLInputElement>()
171164
172-
if (key.startsWith('wrapper:')) {
173-
wrapper[key.replace('wrapper:', '')] = attrs[key]
174-
return
175-
}
176-
177-
root[key] = attrs[key]
178-
})
179-
180-
return { root, wrapper, label, input }
165+
onMounted(() => {
166+
if (props.autofocus) {
167+
inputRef.value?.focus()
168+
}
181169
})
182170
</script>
183171
<template>
@@ -189,6 +177,7 @@ const bindings = computed(() => {
189177
<div :class="classes" v-bind="bindings.wrapper">
190178
<input
191179
:id="label"
180+
ref="inputRef"
192181
v-model="model"
193182
:type="type"
194183
:placeholder="placeholder"

packages/desktop/components/v-table.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ const visibleItems = computed(() => props.items.slice(0, pagination.value.limit)
101101
</thead>
102102

103103
<slot
104-
v-for="item in visibleItems"
105-
:key="item"
104+
v-for="(item, index) in visibleItems"
106105
name="item"
107106
:items="visibleItems"
108107
:columns="parsedColumns"
109108
:item="item"
109+
:index="index"
110110
>
111111
<v-tr>
112112
<slot

packages/desktop/modules/entry/store.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,39 +25,39 @@ export const useStore = defineStore('entry', () => {
2525
payload.workspaceId = workspace.currentId
2626
}
2727

28-
return useCase<ListDirectoryEntryDTO.Output>('list-directory-entry', payload)
28+
return useCase('list-directory-entry', payload as any)
2929
}
3030

3131
function show(payload: Partial<ShowDirectoryEntryDTO.Input>) {
3232
if (!payload.workspaceId && workspace.currentId) {
3333
payload.workspaceId = workspace.currentId
3434
}
3535

36-
return useCase<ShowDirectoryEntryDTO.Output>('show-directory-entry', payload)
36+
return useCase('show-directory-entry', payload as any)
3737
}
3838

3939
function create(payload: Partial<CreateDirectoryEntryDTO.Input>) {
4040
if (!payload.workspaceId && workspace.currentId) {
4141
payload.workspaceId = workspace.currentId
4242
}
4343

44-
return useCase<CreateDirectoryEntryDTO.Output>('create-directory-entry', payload)
44+
return useCase('create-directory-entry', payload as any)
4545
}
4646

4747
function update(payload: Partial<UpdateDirectionEntryDTO.Input>) {
4848
if (!payload.workspaceId && workspace.currentId) {
4949
payload.workspaceId = workspace.currentId
5050
}
5151

52-
return useCase<UpdateDirectionEntryDTO.Output>('update-directory-entry', payload)
52+
return useCase('update-directory-entry', payload as any)
5353
}
5454

5555
function destroy(payload: Partial<DeleteDirectoryEntryDTO.Input>) {
5656
if (!payload.workspaceId && workspace.currentId) {
5757
payload.workspaceId = workspace.currentId
5858
}
5959

60-
return useCase<DeleteDirectoryEntryDTO.Output>('delete-directory-entry', payload)
60+
return useCase('delete-directory-entry', payload as any)
6161
}
6262

6363
function read(payload: Partial<ReadDirectoryEntryDTO.Input>) {
@@ -73,7 +73,7 @@ export const useStore = defineStore('entry', () => {
7373
payload.workspaceId = workspace.currentId
7474
}
7575

76-
return useCase<void>('write-directory-entry', payload)
76+
return useCase('write-directory-entry', payload as any)
7777
}
7878

7979
return {

0 commit comments

Comments
 (0)