Skip to content

Commit e62b1b8

Browse files
committed
Merge branch 'next' of github.com:devforth/adminforth into next
2 parents 976be8f + 3b21098 commit e62b1b8

File tree

5 files changed

+20
-19
lines changed

5 files changed

+20
-19
lines changed

adminforth/modules/configValidator.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ export default class ConfigValidator implements IConfigValidator {
458458
debounceTimeMs: 10,
459459
substringSearch: true,
460460
};
461-
if (col.enum || col.foreignResource) {
461+
if (col.enum || col.foreignResource || col.type === AdminForthDataTypes.BOOLEAN) {
462462
col.filterOptions.multiselect = true;
463463
}
464464
} else {
@@ -483,8 +483,8 @@ export default class ConfigValidator implements IConfigValidator {
483483
errors.push(`Resource "${res.resourceId}" column "${col.name}" has multiselectFilter in filterOptions that is not boolean`);
484484
}
485485

486-
if (!col.enum && !col.foreignResource) {
487-
errors.push(`Resource "${res.resourceId}" column "${col.name}" multiselectFilter in filterOptions should be set only for enum or foreign resource columns`);
486+
if (!col.enum && !col.foreignResource && col.type !== AdminForthDataTypes.BOOLEAN) {
487+
errors.push(`Resource "${res.resourceId}" column "${col.name}" multiselectFilter in filterOptions should be set only for enum, foreign resource or boolean columns`);
488488
}
489489
} else if (col.enum || col.foreignResource) {
490490
col.filterOptions.multiselect = true;

adminforth/spa/src/components/Filters.vue

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
class="w-full"
2929
:options="columnOptions[c.name] || []"
3030
@update:modelValue="onFilterInput[c.name]({ column: c, operator: c.filterOptions.multiselect ? 'in' : 'eq', value: c.filterOptions.multiselect ? ($event.length ? $event : undefined) : $event || undefined })"
31-
:modelValue="filtersStore.filters.find(f => f.field === c.name && f.operator === (c.filterOptions.multiselect ? 'in' : 'eq'))?.value || []"
31+
:modelValue="filtersStore.filters.find(f => f.field === c.name && f.operator === (c.filterOptions.multiselect ? 'in' : 'eq'))?.value || (c.filterOptions.multiselect ? [] : '')"
3232
/>
3333
<Select
34-
multiple
34+
:multiple="c.filterOptions.multiselect"
3535
class="w-full"
3636
v-else-if="c.type === 'boolean'"
3737
:options="[
@@ -40,8 +40,10 @@
4040
// if field is not required, undefined might be there, and user might want to filter by it
4141
...(c.required ? [] : [ { label: $t('Unset'), value: undefined } ])
4242
]"
43-
@update:modelValue="onFilterInput[c.name]({ column: c, operator: 'in', value: $event.length ? $event : undefined })"
44-
:modelValue="filtersStore.filters.find(f => f.field === c.name && f.operator === 'in')?.value || []"
43+
@update:modelValue="onFilterInput[c.name]({ column: c, operator: c.filterOptions.multiselect ? 'in' : 'eq', value: c.filterOptions.multiselect ? ($event.length ? $event : undefined) : $event })"
44+
:modelValue="filtersStore.filters.find(f => f.field === c.name && f.operator === (c.filterOptions.multiselect ? 'in' : 'eq'))?.value !== undefined
45+
? filtersStore.filters.find(f => f.field === c.name && f.operator === (c.filterOptions.multiselect ? 'in' : 'eq'))?.value
46+
: (c.filterOptions.multiselect ? [] : '')"
4547
/>
4648

4749
<Select
@@ -50,7 +52,7 @@
5052
v-else-if="c.enum"
5153
:options="c.enum"
5254
@update:modelValue="onFilterInput[c.name]({ column: c, operator: c.filterOptions.multiselect ? 'in' : 'eq', value: c.filterOptions.multiselect ? ($event.length ? $event : undefined) : $event || undefined })"
53-
:modelValue="filtersStore.filters.find(f => f.field === c.name && f.operator === (c.filterOptions.multiselect ? 'in' : 'eq'))?.value || []"
55+
:modelValue="filtersStore.filters.find(f => f.field === c.name && f.operator === (c.filterOptions.multiselect ? 'in' : 'eq'))?.value || (c.filterOptions.multiselect ? [] : '')"
5456
/>
5557

5658
<Input
@@ -165,12 +167,6 @@ const columnOptions = computedAsync(async () => {
165167
},
166168
});
167169
ret[column.name] = list.items;
168-
if (!column.filterOptions.multiselect) {
169-
ret[column.name].push({
170-
label: t('Unset'),
171-
value: '',
172-
});
173-
}
174170
}
175171
})
176172
);

adminforth/spa/src/components/ResourceListTable.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
{{ $t('Actions') }}
6060
</td>
6161
</tr>
62-
<tr v-for="c in tableBodyStartInjection" :key="c.id" class="align-top border-b border-lightListBorder dark:border-darkListTableBorder">
62+
<tr v-for="c in tableBodyStartInjection" :key="c.id" class="align-top border-b border-lightListBorder dark:border-darkListBorder dark:bg-darkListTable">
6363
<component :is="getCustomComponent(c)" :meta="c.meta" :resource="resource" :adminUser="coreStore.adminUser" />
6464
</tr>
6565
<!-- table header end -->

adminforth/spa/src/views/ListView.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,13 @@ const DEFAULT_PAGE_SIZE = 10;
178178
179179
const pageSize = computed(() => coreStore.resource?.options?.listPageSize || DEFAULT_PAGE_SIZE);
180180
181+
const isPageLoaded = ref(false);
181182
182183
async function getList() {
183184
rows.value = null;
185+
if (!isPageLoaded.value) {
186+
return;
187+
}
184188
const data = await callAdminForthApi({
185189
path: '/get_resource_data',
186190
method: 'POST',
@@ -434,9 +438,6 @@ watch([page], async () => {
434438
setQuery({ page: page.value });
435439
});
436440
437-
438-
439-
440441
watch([sort], async () => {
441442
if (!sort.value.length) {
442443
setQuery({ sort: undefined });
@@ -445,5 +446,8 @@ watch([sort], async () => {
445446
setQuery({ sort: SortQuerySerializer.serialize(sort.value) });
446447
});
447448
449+
watch(() => coreStore.resource, () => {
450+
isPageLoaded.value = true;
451+
});
448452
449453
</script>

dev-demo/resources/apartments.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import TextCompletePlugin from "../../plugins/adminforth-text-complete";
99
import UploadPlugin from "../../plugins/adminforth-upload";
1010
import ImportExportPlugin from "../../plugins/adminforth-import-export/index.js";
1111
import { v1 as uuid } from "uuid";
12+
import { admin } from '../index.js';
1213
import RichEditorPlugin from "../../plugins/adminforth-rich-editor";
1314
import { AdminForthResourceInput } from "../../adminforth";
1415
import CompletionAdapterOpenAIChatGPT from "../../adapters/adminforth-completion-adapter-open-ai-chat-gpt/index.js";
@@ -388,7 +389,7 @@ export default {
388389
confirm:
389390
"Are you sure you want to mark all selected apartments as listed?",
390391
action: async function ({ selectedIds, adminUser }: any) {
391-
const stmt = db.prepare(
392+
const stmt = admin.resource('aparts').dataConnector.client.prepare(
392393
`UPDATE apartments SET listed = 1 WHERE id IN (${selectedIds
393394
.map(() => "?")
394395
.join(",")})`

0 commit comments

Comments
 (0)