Skip to content

Commit 92a855b

Browse files
committed
fix: clear input
1 parent d42cb9d commit 92a855b

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

frontend/src/modules/admin/modules/collections/components/lf-collection-add.vue

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
</lf-field>
5757
</article>
5858

59-
<!-- Description -->
59+
<!-- Category -->
6060
<article class="mb-5">
6161
<lf-field label-text="Category">
6262
<div class="flex">
@@ -65,6 +65,7 @@
6565
v-model="form.type"
6666
placeholder="Select type"
6767
class="w-full type-select"
68+
clearable
6869
>
6970
<el-option label="Industry" value="vertical" />
7071
<el-option label="Stack" value="horizontal" />
@@ -78,8 +79,12 @@
7879
filterable
7980
clearable
8081
remote
81-
:disabled="!form.type.length"
82+
:disabled="!form.type?.length"
8283
:remote-method="fetchCategories"
84+
@clear="() => {
85+
form.type = null
86+
form.categoryId = null
87+
}"
8388
>
8489
<el-option
8590
v-if="collection"
@@ -177,7 +182,7 @@ const form = reactive<CollectionFormModel>({
177182
name: '',
178183
description: '',
179184
type: '',
180-
categoryId: '',
185+
categoryId: null,
181186
projects: [],
182187
});
183188
@@ -209,7 +214,7 @@ const fillForm = (record?: CollectionModel) => {
209214
if (record) {
210215
Object.assign(form, record);
211216
form.type = record.category.categoryGroupType;
212-
form.categoryId = record.categoryId || '';
217+
form.categoryId = record.categoryId || null;
213218
}
214219
215220
formSnapshot();
@@ -291,7 +296,7 @@ const fetchCategories = (query: string) => {
291296
offset: 0,
292297
limit: 20,
293298
query,
294-
groupType: form.type,
299+
groupType: form.type || undefined,
295300
})
296301
.then((res) => {
297302
form.categoryId = !form.categoryId ? (props.collection?.categoryId || '') : form.categoryId;
@@ -302,7 +307,7 @@ const fetchCategories = (query: string) => {
302307
watch(
303308
() => form.type,
304309
() => {
305-
form.categoryId = '';
310+
form.categoryId = null;
306311
fetchCategories('');
307312
},
308313
);

frontend/src/modules/admin/modules/collections/models/collection.model.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface CollectionModel {
1515
export interface CollectionFormModel {
1616
name: string;
1717
description: string;
18-
type: string;
19-
categoryId: string;
18+
type: string | null;
19+
categoryId: string | null;
2020
projects: InsightsProjectModel[];
2121
}

0 commit comments

Comments
 (0)