Skip to content

Commit 924bb58

Browse files
committed
refactor: update prop types for Input, Select, and CustomRangePicker components; enhance Filters and Back types
1 parent c37459d commit 924bb58

7 files changed

Lines changed: 98 additions & 78 deletions

File tree

adminforth/spa/src/afcl/Input.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const isIos = coreStore.isIos;
4444
const props = defineProps<{
4545
type: string,
4646
fullWidth?: boolean,
47-
modelValue: string,
47+
modelValue: string | number | null,
4848
suffix?: string,
4949
prefix?: string,
5050
readonly?: boolean,

adminforth/spa/src/afcl/Select.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ import { ref, computed, onMounted, onUnmounted, watch, nextTick,type PropType, t
119119
import { IconCaretDownSolid } from '@iconify-prerendered/vue-flowbite';
120120
import { useElementSize } from '@vueuse/core'
121121
122-
type ISingleSelectModelValue = string | number;
122+
type ISingleSelectModelValue = string | number | boolean;
123123
124124
const props = defineProps({
125125
options: Array,

adminforth/spa/src/components/CustomRangePicker.vue

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,21 @@ import {computed, onMounted, ref, watch} from "vue";
3535
import debounce from 'debounce'
3636
import RangePicker from './RangePicker.vue';
3737
38-
const props = defineProps({
39-
valueStart: {
40-
default: '',
41-
},
42-
valueEnd: {
43-
default: '',
44-
},
45-
min: {},
46-
max: {},
47-
});
38+
const props = defineProps<{
39+
valueStart: number | null,
40+
valueEnd: number | null,
41+
min: number,
42+
max: number,
43+
}>()
4844
4945
const emit = defineEmits(['update:valueStart', 'update:valueEnd']);
5046
5147
const minFormatted = computed(() => Math.floor(<number>props.min));
5248
const maxFormatted = computed(() => Math.ceil(<number>props.max));
5349
5450
55-
const start = ref<string | number>(props.valueStart);
56-
const end = ref<string | number>(props.valueEnd);
51+
const start = ref<number | null>(props.valueStart);
52+
const end = ref<number | null>(props.valueEnd);
5753
5854
const sliderValue = ref<[number, number]>([minFormatted.value, maxFormatted.value]);
5955
@@ -71,8 +67,8 @@ watch([start, end], () => {
7167
7268
const updateFromSlider =
7369
debounce((value: [number, number]) => {
74-
start.value = value[0] === minFormatted.value ? '': value[0];
75-
end.value = value[1] === maxFormatted.value ? '': value[1];
70+
start.value = value[0] === minFormatted.value ? null : value[0];
71+
end.value = value[1] === maxFormatted.value ? null : value[1];
7672
}, 500);
7773
7874
onMounted(() => {

adminforth/spa/src/components/Filters.vue

Lines changed: 69 additions & 58 deletions
Large diffs are not rendered by default.

adminforth/types/Back.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { ActionCheckSource, AdminForthFilterOperators, AdminForthSortDirections,
1313
type AdminForthConfigMenuItem,
1414
type AnnouncementBadgeResponse,
1515
type AdminForthResourceColumnInputCommon,
16+
type ColumnMinMaxValue,
1617
} from './Common.js';
1718

1819
export interface ICodeInjector {
@@ -256,7 +257,7 @@ export interface IAdminForthDataSourceConnector {
256257
*
257258
* Internally should call {@link IAdminForthDataSourceConnector.getFieldValue} for both min and max values.
258259
*/
259-
getMinMaxForColumnsWithOriginalTypes({ resource, columns }: { resource: AdminForthResource, columns: AdminForthResourceColumn[] }): Promise<{ [key: string]: { min: any, max: any } }>;
260+
getMinMaxForColumnsWithOriginalTypes({ resource, columns }: { resource: AdminForthResource, columns: AdminForthResourceColumn[] }): Promise<ColumnMinMaxValue>;
260261

261262

262263
/**
@@ -309,7 +310,7 @@ export interface IAdminForthDataSourceConnectorBase extends IAdminForthDataSourc
309310
newValues: any,
310311
}): Promise<{ok: boolean, error?: string}>;
311312

312-
getMinMaxForColumns({ resource, columns }: { resource: AdminForthResource, columns: AdminForthResourceColumn[] }): Promise<{ [key: string]: { min: any, max: any } }>;
313+
getMinMaxForColumns({ resource, columns }: { resource: AdminForthResource, columns: AdminForthResourceColumn[] }): Promise<ColumnMinMaxValue>;
313314

314315
deleteMany?({resource, recordIds}:{resource: AdminForthResource, recordIds: any[]}): Promise<number>;
315316
}

adminforth/types/Common.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,4 +1257,8 @@ export interface GetBaseConfigResponse {
12571257
config: AdminForthConfigForFrontend,
12581258
adminUser: AdminUser,
12591259
version: string,
1260+
}
1261+
1262+
export interface ColumnMinMaxValue {
1263+
[key: string]: { min: any, max: any }
12601264
}

dev-demo/custom/AfComponents.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@
8282
</Select>
8383

8484

85-
<Input type="number" class="w-full">
85+
<Input type="number" class="w-full" v-model="numberInput">
8686
<template #suffix>
8787
USD
8888
</template>
8989
</Input>
9090

91-
<Input type="text" class="w-full">
91+
<Input type="text" class="w-full" v-model="textInput">
9292
<template #rightIcon>
9393
<IconSearchOutline class="w-5 h-5 text-lightPrimary dark:text-darkPrimary "/>
9494
</template>
@@ -431,6 +431,8 @@ const selected = ref(null)
431431
const selected2 = ref([])
432432
const valueStart = ref()
433433
const dialogRef = ref()
434+
const numberInput = ref()
435+
const textInput = ref()
434436
435437
const deltaToColor = (delta: number) => {
436438
if (delta < -10) return '#B91C1C' // bright red
@@ -514,4 +516,10 @@ async function loadPageData(data) {
514516
}
515517
}
516518
519+
watch(numberInput, (newVal) => {
520+
console.log('Number input changed:', newVal, typeof newVal);
521+
});
522+
watch(textInput, (newVal) => {
523+
console.log('Text input changed:', newVal, typeof newVal);
524+
});
517525
</script>

0 commit comments

Comments
 (0)