@adminforth/quick-filters 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.woodpecker/buildRelease.sh +13 -0
- package/.woodpecker/buildSlackNotify.sh +44 -0
- package/.woodpecker/release.yml +40 -0
- package/LICENSE +21 -0
- package/build.log +11 -0
- package/custom/FiltersArea.vue +247 -0
- package/custom/tsconfig.json +30 -0
- package/dist/custom/FiltersArea.vue +247 -0
- package/dist/custom/tsconfig.json +30 -0
- package/dist/index.js +53 -0
- package/dist/types.js +1 -0
- package/index.ts +53 -0
- package/package.json +50 -0
- package/tsconfig.json +13 -0
- package/types.ts +5 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
#!/bin/bash
|
|
3
|
+
|
|
4
|
+
# write npm run output both to console and to build.log
|
|
5
|
+
npm run build 2>&1 | tee build.log
|
|
6
|
+
build_status=${PIPESTATUS[0]}
|
|
7
|
+
|
|
8
|
+
# if exist status from the npm run build is not 0
|
|
9
|
+
# then exit with the status code from the npm run build
|
|
10
|
+
if [ $build_status -ne 0 ]; then
|
|
11
|
+
echo "Build failed. Exiting with status code $build_status"
|
|
12
|
+
exit $build_status
|
|
13
|
+
fi
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
set -x
|
|
4
|
+
|
|
5
|
+
COMMIT_SHORT_SHA=$(echo $CI_COMMIT_SHA | cut -c1-8)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
if [ "$CI_PREV_PIPELINE_STATUS" = "success" ]; then
|
|
9
|
+
MESSAGE="Did a build without issues on \`$CI_REPO_NAME/$CI_COMMIT_BRANCH\`. Commit: _${CI_COMMIT_MESSAGE}_ (<$CI_COMMIT_URL|$COMMIT_SHORT_SHA>)"
|
|
10
|
+
|
|
11
|
+
curl -s -X POST -H "Content-Type: application/json" -d '{
|
|
12
|
+
"username": "'"$CI_COMMIT_AUTHOR"'",
|
|
13
|
+
"icon_url": "'"$CI_COMMIT_AUTHOR_AVATAR"'",
|
|
14
|
+
"attachments": [
|
|
15
|
+
{
|
|
16
|
+
"mrkdwn_in": ["text", "pretext"],
|
|
17
|
+
"color": "#36a64f",
|
|
18
|
+
"text": "'"$MESSAGE"'"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}' "$DEVELOPERS_SLACK_WEBHOOK"
|
|
22
|
+
exit 0
|
|
23
|
+
fi
|
|
24
|
+
export BUILD_LOG=$(cat ./build.log)
|
|
25
|
+
|
|
26
|
+
BUILD_LOG=$(echo $BUILD_LOG | sed 's/"/\\"/g')
|
|
27
|
+
|
|
28
|
+
MESSAGE="Broke \`$CI_REPO_NAME/$CI_COMMIT_BRANCH\` with commit _${CI_COMMIT_MESSAGE}_ (<$CI_COMMIT_URL|$COMMIT_SHORT_SHA>)"
|
|
29
|
+
CODE_BLOCK="\`\`\`$BUILD_LOG\n\`\`\`"
|
|
30
|
+
|
|
31
|
+
echo "Sending slack message to developers $MESSAGE"
|
|
32
|
+
# Send the message
|
|
33
|
+
curl -sS -X POST -H "Content-Type: application/json" -d '{
|
|
34
|
+
"username": "'"$CI_COMMIT_AUTHOR"'",
|
|
35
|
+
"icon_url": "'"$CI_COMMIT_AUTHOR_AVATAR"'",
|
|
36
|
+
"attachments": [
|
|
37
|
+
{
|
|
38
|
+
"mrkdwn_in": ["text", "pretext"],
|
|
39
|
+
"color": "#8A1C12",
|
|
40
|
+
"text": "'"$CODE_BLOCK"'",
|
|
41
|
+
"pretext": "'"$MESSAGE"'"
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}' "$DEVELOPERS_SLACK_WEBHOOK" 2>&1
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
clone:
|
|
2
|
+
git:
|
|
3
|
+
image: woodpeckerci/plugin-git
|
|
4
|
+
settings:
|
|
5
|
+
partial: false
|
|
6
|
+
depth: 5
|
|
7
|
+
|
|
8
|
+
steps:
|
|
9
|
+
init-secrets:
|
|
10
|
+
when:
|
|
11
|
+
- event: push
|
|
12
|
+
image: infisical/cli
|
|
13
|
+
environment:
|
|
14
|
+
INFISICAL_TOKEN:
|
|
15
|
+
from_secret: VAULT_TOKEN
|
|
16
|
+
commands:
|
|
17
|
+
- infisical export --domain https://vault.devforth.io/api --format=dotenv-export --env="prod" > /woodpecker/deploy.vault.env
|
|
18
|
+
|
|
19
|
+
release:
|
|
20
|
+
image: node:20
|
|
21
|
+
when:
|
|
22
|
+
- event: push
|
|
23
|
+
commands:
|
|
24
|
+
- apt update && apt install -y rsync
|
|
25
|
+
- export $(cat /woodpecker/deploy.vault.env | xargs)
|
|
26
|
+
- npm clean-install
|
|
27
|
+
- /bin/bash ./.woodpecker/buildRelease.sh
|
|
28
|
+
- npm audit signatures
|
|
29
|
+
- npx semantic-release
|
|
30
|
+
|
|
31
|
+
slack-on-failure:
|
|
32
|
+
when:
|
|
33
|
+
- event: push
|
|
34
|
+
status: [failure, success]
|
|
35
|
+
- event: push
|
|
36
|
+
image: curlimages/curl
|
|
37
|
+
commands:
|
|
38
|
+
- export $(cat /woodpecker/deploy.vault.env | xargs)
|
|
39
|
+
- /bin/sh ./.woodpecker/buildSlackNotify.sh
|
|
40
|
+
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Devforth.io
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/build.log
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
> @adminforth/quick-filters@1.0.1 build
|
|
3
|
+
> tsc && rsync -av --exclude 'node_modules' custom dist/
|
|
4
|
+
|
|
5
|
+
sending incremental file list
|
|
6
|
+
custom/
|
|
7
|
+
custom/FiltersArea.vue
|
|
8
|
+
custom/tsconfig.json
|
|
9
|
+
|
|
10
|
+
sent 11,566 bytes received 58 bytes 23,248.00 bytes/sec
|
|
11
|
+
total size is 11,351 speedup is 0.98
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="columnsWithFilter && columnsWithFilter.length > 0" class="flex flex-col w-full p-4 mb-4 rounded-lg border border-gray-100 dark:border-gray-700 shadow-sm dark:shadow-lg text-gray-900 dark:text-white">
|
|
3
|
+
<p
|
|
4
|
+
class="hover:underline cursor-pointer text-blue-700 dark:text-blue-500 text-end"
|
|
5
|
+
@click="isExpanded = !isExpanded"
|
|
6
|
+
>
|
|
7
|
+
{{ isExpanded ? 'Hide filters' : 'Show filters' }}
|
|
8
|
+
</p>
|
|
9
|
+
<div v-if="isExpanded" class="md:grid md:grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-6 gap-4 w-full">
|
|
10
|
+
<div class="flex flex-col" v-for="c in columnsWithFilter" :key="c">
|
|
11
|
+
<div class="min-w-48">
|
|
12
|
+
<p class="dark:text-gray-400">{{ c.label }}</p>
|
|
13
|
+
<Select
|
|
14
|
+
v-if="c.foreignResource"
|
|
15
|
+
:multiple="c.filterOptions.multiselect"
|
|
16
|
+
class="w-full"
|
|
17
|
+
:options="columnOptions[c.name] || []"
|
|
18
|
+
:searchDisabled="!c.foreignResource.searchableFields"
|
|
19
|
+
@scroll-near-end="loadMoreOptions(c.name)"
|
|
20
|
+
@search="(searchTerm) => {
|
|
21
|
+
if (c.foreignResource.searchableFields && onSearchInput[c.name]) {
|
|
22
|
+
onSearchInput[c.name](searchTerm);
|
|
23
|
+
}
|
|
24
|
+
}"
|
|
25
|
+
@update:modelValue="onFilterInput[c.name]({ column: c, operator: c.filterOptions.multiselect ? 'in' : 'eq', value: c.filterOptions.multiselect ? ($event.length ? $event : undefined) : $event || undefined })"
|
|
26
|
+
:modelValue="filtersStore.filters.find(f => f.field === c.name && f.operator === (c.filterOptions.multiselect ? 'in' : 'eq'))?.value || (c.filterOptions.multiselect ? [] : '')"
|
|
27
|
+
>
|
|
28
|
+
<template #extra-item v-if="columnLoadingState[c.name]?.loading">
|
|
29
|
+
<div class="text-center text-gray-400 dark:text-gray-300 py-2 flex items-center justify-center gap-2">
|
|
30
|
+
<Spinner class="w-4 h-4" />
|
|
31
|
+
{{ $t('Loading...') }}
|
|
32
|
+
</div>
|
|
33
|
+
</template>
|
|
34
|
+
</Select>
|
|
35
|
+
<Select
|
|
36
|
+
:multiple="c.filterOptions.multiselect"
|
|
37
|
+
class="w-full"
|
|
38
|
+
v-else-if="c.type === 'boolean'"
|
|
39
|
+
:options="[
|
|
40
|
+
{ label: $t('Yes'), value: true },
|
|
41
|
+
{ label: $t('No'), value: false },
|
|
42
|
+
// if field is not required, undefined might be there, and user might want to filter by it
|
|
43
|
+
...(c.required ? [] : [ { label: $t('Unset'), value: undefined } ])
|
|
44
|
+
]"
|
|
45
|
+
@update:modelValue="onFilterInput[c.name]({ column: c, operator: c.filterOptions.multiselect ? 'in' : 'eq', value: c.filterOptions.multiselect ? ($event.length ? $event : undefined) : $event })"
|
|
46
|
+
:modelValue="filtersStore.filters.find(f => f.field === c.name && f.operator === (c.filterOptions.multiselect ? 'in' : 'eq'))?.value !== undefined
|
|
47
|
+
? filtersStore.filters.find(f => f.field === c.name && f.operator === (c.filterOptions.multiselect ? 'in' : 'eq'))?.value
|
|
48
|
+
: (c.filterOptions.multiselect ? [] : '')"
|
|
49
|
+
/>
|
|
50
|
+
|
|
51
|
+
<Select
|
|
52
|
+
:multiple="c.filterOptions.multiselect"
|
|
53
|
+
class="w-full"
|
|
54
|
+
v-else-if="c.enum"
|
|
55
|
+
:options="c.enum"
|
|
56
|
+
@update:modelValue="onFilterInput[c.name]({ column: c, operator: c.filterOptions.multiselect ? 'in' : 'eq', value: c.filterOptions.multiselect ? ($event.length ? $event : undefined) : $event || undefined })"
|
|
57
|
+
:modelValue="filtersStore.filters.find(f => f.field === c.name && f.operator === (c.filterOptions.multiselect ? 'in' : 'eq'))?.value || (c.filterOptions.multiselect ? [] : '')"
|
|
58
|
+
/>
|
|
59
|
+
|
|
60
|
+
<Input
|
|
61
|
+
v-else-if="['string', 'text', 'json', 'richtext', 'unknown'].includes(c.type)"
|
|
62
|
+
type="text"
|
|
63
|
+
full-width
|
|
64
|
+
:placeholder="$t('Search')"
|
|
65
|
+
@update:modelValue="onFilterInput[c.name]({ column: c, operator: c.filterOptions?.substringSearch ? 'ilike' : 'eq', value: $event || undefined })"
|
|
66
|
+
:modelValue="getFilterItem({ column: c, operator: c.filterOptions?.substringSearch ? 'ilike' : 'eq' })"
|
|
67
|
+
/>
|
|
68
|
+
|
|
69
|
+
<CustomDateRangePicker
|
|
70
|
+
v-else-if="['datetime', 'date', 'time'].includes(c.type)"
|
|
71
|
+
:column="c"
|
|
72
|
+
:valueStart="filtersStore.filters.find(f => f.field === c.name && f.operator === 'gte')?.value || undefined"
|
|
73
|
+
@update:valueStart="onFilterInput[c.name]({ column: c, operator: 'gte', value: $event || undefined })"
|
|
74
|
+
:valueEnd="filtersStore.filters.find(f => f.field === c.name && f.operator === 'lte')?.value || undefined"
|
|
75
|
+
@update:valueEnd="onFilterInput[c.name]({ column: c, operator: 'lte', value: $event || undefined })"
|
|
76
|
+
/>
|
|
77
|
+
|
|
78
|
+
<CustomRangePicker
|
|
79
|
+
v-else-if="['integer', 'decimal', 'float'].includes(c.type) && c.allowMinMaxQuery"
|
|
80
|
+
:min="getFilterMinValue(c.name)"
|
|
81
|
+
:max="getFilterMaxValue(c.name)"
|
|
82
|
+
:valueStart="getFilterItem({ column: c, operator: 'gte' })"
|
|
83
|
+
@update:valueStart="onFilterInput[c.name]({ column: c, operator: 'gte', value: ($event !== '' && $event !== null) ? $event : undefined })"
|
|
84
|
+
:valueEnd="getFilterItem({ column: c, operator: 'lte' })"
|
|
85
|
+
@update:valueEnd="onFilterInput[c.name]({ column: c, operator: 'lte', value: ($event !== '' && $event !== null) ? $event : undefined })"
|
|
86
|
+
/>
|
|
87
|
+
|
|
88
|
+
<div v-else-if="['integer', 'decimal', 'float'].includes(c.type)" class="flex gap-2">
|
|
89
|
+
<Input
|
|
90
|
+
type="number"
|
|
91
|
+
full-width
|
|
92
|
+
aria-describedby="helper-text-explanation"
|
|
93
|
+
:placeholder="$t('From')"
|
|
94
|
+
@update:modelValue="onFilterInput[c.name]({ column: c, operator: 'gte', value: ($event !== '' && $event !== null) ? $event : undefined })"
|
|
95
|
+
:modelValue="getFilterItem({ column: c, operator: 'gte' })"
|
|
96
|
+
/>
|
|
97
|
+
<Input
|
|
98
|
+
type="number"
|
|
99
|
+
full-width
|
|
100
|
+
aria-describedby="helper-text-explanation"
|
|
101
|
+
:placeholder="$t('To')"
|
|
102
|
+
@update:modelValue="onFilterInput[c.name]({ column: c, operator: 'lte', value: ($event !== '' && $event !== null) ? $event : undefined })"
|
|
103
|
+
:modelValue="getFilterItem({ column: c, operator: 'lte' })"
|
|
104
|
+
/>
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
<div v-if="isExpanded" class="flex w-full justify-end">
|
|
110
|
+
<Button
|
|
111
|
+
class="mt-4 max-w-24"
|
|
112
|
+
@click="filtersStore.filters = [...filtersStore.filters.filter(f => filtersStore.shouldFilterBeHidden(f.field))]"
|
|
113
|
+
:disabled="filtersStore.filters.length === 0"
|
|
114
|
+
>
|
|
115
|
+
Clear all
|
|
116
|
+
</Button>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
</template>
|
|
120
|
+
|
|
121
|
+
<script lang="ts" setup>
|
|
122
|
+
import { onMounted, computed, ref, reactive } from 'vue';
|
|
123
|
+
import { useFiltersStore } from '@/stores/filters';
|
|
124
|
+
import { callAdminForthApi, loadMoreForeignOptions, searchForeignOptions, createSearchInputHandlers } from '@/utils';
|
|
125
|
+
import { useRouter } from 'vue-router';
|
|
126
|
+
import debounce from 'debounce';
|
|
127
|
+
import { Select, Input, Button } from '@/afcl';
|
|
128
|
+
import CustomRangePicker from "@/components/CustomRangePicker.vue";
|
|
129
|
+
import CustomDateRangePicker from '@/components/CustomDateRangePicker.vue';
|
|
130
|
+
import { useRoute } from 'vue-router';
|
|
131
|
+
|
|
132
|
+
const router = useRouter();
|
|
133
|
+
const route = useRoute();
|
|
134
|
+
const columnLoadingState = reactive({});
|
|
135
|
+
const columnOffsets = reactive({});
|
|
136
|
+
const columnEmptyResultsCount = reactive({});
|
|
137
|
+
const filtersStore = useFiltersStore();
|
|
138
|
+
const columnsMinMax = ref({});
|
|
139
|
+
const isExpanded = ref(false);
|
|
140
|
+
|
|
141
|
+
const props = defineProps<{
|
|
142
|
+
meta: any,
|
|
143
|
+
resource: any,
|
|
144
|
+
adminUser: any
|
|
145
|
+
}>();
|
|
146
|
+
|
|
147
|
+
const columnOptions = ref({});
|
|
148
|
+
const columnsWithFilter = computed(
|
|
149
|
+
() => props.resource.columns?.filter(column => column.showIn.filter && props.meta.options.columns.some(c => c.column === column.name)) || []
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
onMounted(async () => {
|
|
153
|
+
console.log('FiltersArea mounted', props.resource);
|
|
154
|
+
columnsMinMax.value = await callAdminForthApi({
|
|
155
|
+
path: '/get_min_max_for_columns',
|
|
156
|
+
method: 'POST',
|
|
157
|
+
body: {
|
|
158
|
+
resourceId: route.params.resourceId
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
console.log('Fetched columnsMinMax:', columnsMinMax.value);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
function getFilterItem({ column, operator }) {
|
|
165
|
+
const filterValue = filtersStore.filters.find(f => f.field === column.name && f.operator === operator)?.value;
|
|
166
|
+
return filterValue !== undefined ? filterValue : '';
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function getFilterMinValue(columnName) {
|
|
170
|
+
if(columnsMinMax.value && columnsMinMax.value[columnName]) {
|
|
171
|
+
return columnsMinMax.value[columnName]?.min
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function getFilterMaxValue(columnName) {
|
|
176
|
+
if(columnsMinMax.value && columnsMinMax.value[columnName]) {
|
|
177
|
+
return columnsMinMax.value[columnName]?.max
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
async function loadMoreOptions(columnName, searchTerm = '') {
|
|
181
|
+
return loadMoreForeignOptions({
|
|
182
|
+
columnName,
|
|
183
|
+
searchTerm,
|
|
184
|
+
columns: props.resource.columns,
|
|
185
|
+
resourceId: Array.isArray(router.currentRoute.value.params.resourceId)
|
|
186
|
+
? router.currentRoute.value.params.resourceId[0]
|
|
187
|
+
: router.currentRoute.value.params.resourceId,
|
|
188
|
+
columnOptions,
|
|
189
|
+
columnLoadingState,
|
|
190
|
+
columnOffsets,
|
|
191
|
+
columnEmptyResultsCount
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
async function searchOptions(columnName, searchTerm) {
|
|
196
|
+
return searchForeignOptions({
|
|
197
|
+
columnName,
|
|
198
|
+
searchTerm,
|
|
199
|
+
columns: props.resource.columns,
|
|
200
|
+
resourceId: Array.isArray(router.currentRoute.value.params.resourceId)
|
|
201
|
+
? router.currentRoute.value.params.resourceId[0]
|
|
202
|
+
: router.currentRoute.value.params.resourceId,
|
|
203
|
+
columnOptions,
|
|
204
|
+
columnLoadingState,
|
|
205
|
+
columnOffsets,
|
|
206
|
+
columnEmptyResultsCount
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const onSearchInput = computed(() => {
|
|
211
|
+
return createSearchInputHandlers(
|
|
212
|
+
props.resource.columns,
|
|
213
|
+
searchOptions,
|
|
214
|
+
(column) => column.filterOptions?.debounceTimeMs || 300
|
|
215
|
+
);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
const onFilterInput = computed(() => {
|
|
219
|
+
if (!props.resource.columns) return {};
|
|
220
|
+
|
|
221
|
+
return props.resource.columns.reduce((acc, c) => {
|
|
222
|
+
return {
|
|
223
|
+
...acc,
|
|
224
|
+
[c.name]: debounce(({ column, operator, value }) => {
|
|
225
|
+
setFilterItem({ column, operator, value });
|
|
226
|
+
}, c.filterOptions?.debounceTimeMs || 10),
|
|
227
|
+
};
|
|
228
|
+
}, {});
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
function setFilterItem({ column, operator, value }) {
|
|
232
|
+
|
|
233
|
+
const index = filtersStore.filters.findIndex(f => f.field === column.name && f.operator === operator);
|
|
234
|
+
if (value === undefined || value === '' || value === null) {
|
|
235
|
+
if (index !== -1) {
|
|
236
|
+
filtersStore.filters.splice(index, 1);
|
|
237
|
+
}
|
|
238
|
+
} else {
|
|
239
|
+
if (index === -1) {
|
|
240
|
+
filtersStore.setFilter({ field: column.name, value, operator });
|
|
241
|
+
} else {
|
|
242
|
+
filtersStore.setFilters([...filtersStore.filters.slice(0, index), { field: column.name, value, operator }, ...filtersStore.filters.slice(index + 1)])
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
</script>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"baseUrl": ".", // This should point to your project root
|
|
4
|
+
"paths": {
|
|
5
|
+
"@/*": [
|
|
6
|
+
// "node_modules/adminforth/dist/spa/src/*"
|
|
7
|
+
"../../../adminforth/spa/src/*"
|
|
8
|
+
],
|
|
9
|
+
"*": [
|
|
10
|
+
// "node_modules/adminforth/dist/spa/node_modules/*"
|
|
11
|
+
"../../../adminforth/spa/node_modules/*"
|
|
12
|
+
],
|
|
13
|
+
"@@/*": [
|
|
14
|
+
// "node_modules/adminforth/dist/spa/src/*"
|
|
15
|
+
"."
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"include": [
|
|
20
|
+
"./**/*.ts",
|
|
21
|
+
"./**/*.tsx",
|
|
22
|
+
"./**/*.vue",
|
|
23
|
+
"../**/*.ts",
|
|
24
|
+
"../**/*.tsx",
|
|
25
|
+
"../**/*.vue",
|
|
26
|
+
"../*.vue",
|
|
27
|
+
"../*.ts",
|
|
28
|
+
"../*.tsx"
|
|
29
|
+
]
|
|
30
|
+
}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="columnsWithFilter && columnsWithFilter.length > 0" class="flex flex-col w-full p-4 mb-4 rounded-lg border border-gray-100 dark:border-gray-700 shadow-sm dark:shadow-lg text-gray-900 dark:text-white">
|
|
3
|
+
<p
|
|
4
|
+
class="hover:underline cursor-pointer text-blue-700 dark:text-blue-500 text-end"
|
|
5
|
+
@click="isExpanded = !isExpanded"
|
|
6
|
+
>
|
|
7
|
+
{{ isExpanded ? 'Hide filters' : 'Show filters' }}
|
|
8
|
+
</p>
|
|
9
|
+
<div v-if="isExpanded" class="md:grid md:grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-6 gap-4 w-full">
|
|
10
|
+
<div class="flex flex-col" v-for="c in columnsWithFilter" :key="c">
|
|
11
|
+
<div class="min-w-48">
|
|
12
|
+
<p class="dark:text-gray-400">{{ c.label }}</p>
|
|
13
|
+
<Select
|
|
14
|
+
v-if="c.foreignResource"
|
|
15
|
+
:multiple="c.filterOptions.multiselect"
|
|
16
|
+
class="w-full"
|
|
17
|
+
:options="columnOptions[c.name] || []"
|
|
18
|
+
:searchDisabled="!c.foreignResource.searchableFields"
|
|
19
|
+
@scroll-near-end="loadMoreOptions(c.name)"
|
|
20
|
+
@search="(searchTerm) => {
|
|
21
|
+
if (c.foreignResource.searchableFields && onSearchInput[c.name]) {
|
|
22
|
+
onSearchInput[c.name](searchTerm);
|
|
23
|
+
}
|
|
24
|
+
}"
|
|
25
|
+
@update:modelValue="onFilterInput[c.name]({ column: c, operator: c.filterOptions.multiselect ? 'in' : 'eq', value: c.filterOptions.multiselect ? ($event.length ? $event : undefined) : $event || undefined })"
|
|
26
|
+
:modelValue="filtersStore.filters.find(f => f.field === c.name && f.operator === (c.filterOptions.multiselect ? 'in' : 'eq'))?.value || (c.filterOptions.multiselect ? [] : '')"
|
|
27
|
+
>
|
|
28
|
+
<template #extra-item v-if="columnLoadingState[c.name]?.loading">
|
|
29
|
+
<div class="text-center text-gray-400 dark:text-gray-300 py-2 flex items-center justify-center gap-2">
|
|
30
|
+
<Spinner class="w-4 h-4" />
|
|
31
|
+
{{ $t('Loading...') }}
|
|
32
|
+
</div>
|
|
33
|
+
</template>
|
|
34
|
+
</Select>
|
|
35
|
+
<Select
|
|
36
|
+
:multiple="c.filterOptions.multiselect"
|
|
37
|
+
class="w-full"
|
|
38
|
+
v-else-if="c.type === 'boolean'"
|
|
39
|
+
:options="[
|
|
40
|
+
{ label: $t('Yes'), value: true },
|
|
41
|
+
{ label: $t('No'), value: false },
|
|
42
|
+
// if field is not required, undefined might be there, and user might want to filter by it
|
|
43
|
+
...(c.required ? [] : [ { label: $t('Unset'), value: undefined } ])
|
|
44
|
+
]"
|
|
45
|
+
@update:modelValue="onFilterInput[c.name]({ column: c, operator: c.filterOptions.multiselect ? 'in' : 'eq', value: c.filterOptions.multiselect ? ($event.length ? $event : undefined) : $event })"
|
|
46
|
+
:modelValue="filtersStore.filters.find(f => f.field === c.name && f.operator === (c.filterOptions.multiselect ? 'in' : 'eq'))?.value !== undefined
|
|
47
|
+
? filtersStore.filters.find(f => f.field === c.name && f.operator === (c.filterOptions.multiselect ? 'in' : 'eq'))?.value
|
|
48
|
+
: (c.filterOptions.multiselect ? [] : '')"
|
|
49
|
+
/>
|
|
50
|
+
|
|
51
|
+
<Select
|
|
52
|
+
:multiple="c.filterOptions.multiselect"
|
|
53
|
+
class="w-full"
|
|
54
|
+
v-else-if="c.enum"
|
|
55
|
+
:options="c.enum"
|
|
56
|
+
@update:modelValue="onFilterInput[c.name]({ column: c, operator: c.filterOptions.multiselect ? 'in' : 'eq', value: c.filterOptions.multiselect ? ($event.length ? $event : undefined) : $event || undefined })"
|
|
57
|
+
:modelValue="filtersStore.filters.find(f => f.field === c.name && f.operator === (c.filterOptions.multiselect ? 'in' : 'eq'))?.value || (c.filterOptions.multiselect ? [] : '')"
|
|
58
|
+
/>
|
|
59
|
+
|
|
60
|
+
<Input
|
|
61
|
+
v-else-if="['string', 'text', 'json', 'richtext', 'unknown'].includes(c.type)"
|
|
62
|
+
type="text"
|
|
63
|
+
full-width
|
|
64
|
+
:placeholder="$t('Search')"
|
|
65
|
+
@update:modelValue="onFilterInput[c.name]({ column: c, operator: c.filterOptions?.substringSearch ? 'ilike' : 'eq', value: $event || undefined })"
|
|
66
|
+
:modelValue="getFilterItem({ column: c, operator: c.filterOptions?.substringSearch ? 'ilike' : 'eq' })"
|
|
67
|
+
/>
|
|
68
|
+
|
|
69
|
+
<CustomDateRangePicker
|
|
70
|
+
v-else-if="['datetime', 'date', 'time'].includes(c.type)"
|
|
71
|
+
:column="c"
|
|
72
|
+
:valueStart="filtersStore.filters.find(f => f.field === c.name && f.operator === 'gte')?.value || undefined"
|
|
73
|
+
@update:valueStart="onFilterInput[c.name]({ column: c, operator: 'gte', value: $event || undefined })"
|
|
74
|
+
:valueEnd="filtersStore.filters.find(f => f.field === c.name && f.operator === 'lte')?.value || undefined"
|
|
75
|
+
@update:valueEnd="onFilterInput[c.name]({ column: c, operator: 'lte', value: $event || undefined })"
|
|
76
|
+
/>
|
|
77
|
+
|
|
78
|
+
<CustomRangePicker
|
|
79
|
+
v-else-if="['integer', 'decimal', 'float'].includes(c.type) && c.allowMinMaxQuery"
|
|
80
|
+
:min="getFilterMinValue(c.name)"
|
|
81
|
+
:max="getFilterMaxValue(c.name)"
|
|
82
|
+
:valueStart="getFilterItem({ column: c, operator: 'gte' })"
|
|
83
|
+
@update:valueStart="onFilterInput[c.name]({ column: c, operator: 'gte', value: ($event !== '' && $event !== null) ? $event : undefined })"
|
|
84
|
+
:valueEnd="getFilterItem({ column: c, operator: 'lte' })"
|
|
85
|
+
@update:valueEnd="onFilterInput[c.name]({ column: c, operator: 'lte', value: ($event !== '' && $event !== null) ? $event : undefined })"
|
|
86
|
+
/>
|
|
87
|
+
|
|
88
|
+
<div v-else-if="['integer', 'decimal', 'float'].includes(c.type)" class="flex gap-2">
|
|
89
|
+
<Input
|
|
90
|
+
type="number"
|
|
91
|
+
full-width
|
|
92
|
+
aria-describedby="helper-text-explanation"
|
|
93
|
+
:placeholder="$t('From')"
|
|
94
|
+
@update:modelValue="onFilterInput[c.name]({ column: c, operator: 'gte', value: ($event !== '' && $event !== null) ? $event : undefined })"
|
|
95
|
+
:modelValue="getFilterItem({ column: c, operator: 'gte' })"
|
|
96
|
+
/>
|
|
97
|
+
<Input
|
|
98
|
+
type="number"
|
|
99
|
+
full-width
|
|
100
|
+
aria-describedby="helper-text-explanation"
|
|
101
|
+
:placeholder="$t('To')"
|
|
102
|
+
@update:modelValue="onFilterInput[c.name]({ column: c, operator: 'lte', value: ($event !== '' && $event !== null) ? $event : undefined })"
|
|
103
|
+
:modelValue="getFilterItem({ column: c, operator: 'lte' })"
|
|
104
|
+
/>
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
<div v-if="isExpanded" class="flex w-full justify-end">
|
|
110
|
+
<Button
|
|
111
|
+
class="mt-4 max-w-24"
|
|
112
|
+
@click="filtersStore.filters = [...filtersStore.filters.filter(f => filtersStore.shouldFilterBeHidden(f.field))]"
|
|
113
|
+
:disabled="filtersStore.filters.length === 0"
|
|
114
|
+
>
|
|
115
|
+
Clear all
|
|
116
|
+
</Button>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
</template>
|
|
120
|
+
|
|
121
|
+
<script lang="ts" setup>
|
|
122
|
+
import { onMounted, computed, ref, reactive } from 'vue';
|
|
123
|
+
import { useFiltersStore } from '@/stores/filters';
|
|
124
|
+
import { callAdminForthApi, loadMoreForeignOptions, searchForeignOptions, createSearchInputHandlers } from '@/utils';
|
|
125
|
+
import { useRouter } from 'vue-router';
|
|
126
|
+
import debounce from 'debounce';
|
|
127
|
+
import { Select, Input, Button } from '@/afcl';
|
|
128
|
+
import CustomRangePicker from "@/components/CustomRangePicker.vue";
|
|
129
|
+
import CustomDateRangePicker from '@/components/CustomDateRangePicker.vue';
|
|
130
|
+
import { useRoute } from 'vue-router';
|
|
131
|
+
|
|
132
|
+
const router = useRouter();
|
|
133
|
+
const route = useRoute();
|
|
134
|
+
const columnLoadingState = reactive({});
|
|
135
|
+
const columnOffsets = reactive({});
|
|
136
|
+
const columnEmptyResultsCount = reactive({});
|
|
137
|
+
const filtersStore = useFiltersStore();
|
|
138
|
+
const columnsMinMax = ref({});
|
|
139
|
+
const isExpanded = ref(false);
|
|
140
|
+
|
|
141
|
+
const props = defineProps<{
|
|
142
|
+
meta: any,
|
|
143
|
+
resource: any,
|
|
144
|
+
adminUser: any
|
|
145
|
+
}>();
|
|
146
|
+
|
|
147
|
+
const columnOptions = ref({});
|
|
148
|
+
const columnsWithFilter = computed(
|
|
149
|
+
() => props.resource.columns?.filter(column => column.showIn.filter && props.meta.options.columns.some(c => c.column === column.name)) || []
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
onMounted(async () => {
|
|
153
|
+
console.log('FiltersArea mounted', props.resource);
|
|
154
|
+
columnsMinMax.value = await callAdminForthApi({
|
|
155
|
+
path: '/get_min_max_for_columns',
|
|
156
|
+
method: 'POST',
|
|
157
|
+
body: {
|
|
158
|
+
resourceId: route.params.resourceId
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
console.log('Fetched columnsMinMax:', columnsMinMax.value);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
function getFilterItem({ column, operator }) {
|
|
165
|
+
const filterValue = filtersStore.filters.find(f => f.field === column.name && f.operator === operator)?.value;
|
|
166
|
+
return filterValue !== undefined ? filterValue : '';
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function getFilterMinValue(columnName) {
|
|
170
|
+
if(columnsMinMax.value && columnsMinMax.value[columnName]) {
|
|
171
|
+
return columnsMinMax.value[columnName]?.min
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function getFilterMaxValue(columnName) {
|
|
176
|
+
if(columnsMinMax.value && columnsMinMax.value[columnName]) {
|
|
177
|
+
return columnsMinMax.value[columnName]?.max
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
async function loadMoreOptions(columnName, searchTerm = '') {
|
|
181
|
+
return loadMoreForeignOptions({
|
|
182
|
+
columnName,
|
|
183
|
+
searchTerm,
|
|
184
|
+
columns: props.resource.columns,
|
|
185
|
+
resourceId: Array.isArray(router.currentRoute.value.params.resourceId)
|
|
186
|
+
? router.currentRoute.value.params.resourceId[0]
|
|
187
|
+
: router.currentRoute.value.params.resourceId,
|
|
188
|
+
columnOptions,
|
|
189
|
+
columnLoadingState,
|
|
190
|
+
columnOffsets,
|
|
191
|
+
columnEmptyResultsCount
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
async function searchOptions(columnName, searchTerm) {
|
|
196
|
+
return searchForeignOptions({
|
|
197
|
+
columnName,
|
|
198
|
+
searchTerm,
|
|
199
|
+
columns: props.resource.columns,
|
|
200
|
+
resourceId: Array.isArray(router.currentRoute.value.params.resourceId)
|
|
201
|
+
? router.currentRoute.value.params.resourceId[0]
|
|
202
|
+
: router.currentRoute.value.params.resourceId,
|
|
203
|
+
columnOptions,
|
|
204
|
+
columnLoadingState,
|
|
205
|
+
columnOffsets,
|
|
206
|
+
columnEmptyResultsCount
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const onSearchInput = computed(() => {
|
|
211
|
+
return createSearchInputHandlers(
|
|
212
|
+
props.resource.columns,
|
|
213
|
+
searchOptions,
|
|
214
|
+
(column) => column.filterOptions?.debounceTimeMs || 300
|
|
215
|
+
);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
const onFilterInput = computed(() => {
|
|
219
|
+
if (!props.resource.columns) return {};
|
|
220
|
+
|
|
221
|
+
return props.resource.columns.reduce((acc, c) => {
|
|
222
|
+
return {
|
|
223
|
+
...acc,
|
|
224
|
+
[c.name]: debounce(({ column, operator, value }) => {
|
|
225
|
+
setFilterItem({ column, operator, value });
|
|
226
|
+
}, c.filterOptions?.debounceTimeMs || 10),
|
|
227
|
+
};
|
|
228
|
+
}, {});
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
function setFilterItem({ column, operator, value }) {
|
|
232
|
+
|
|
233
|
+
const index = filtersStore.filters.findIndex(f => f.field === column.name && f.operator === operator);
|
|
234
|
+
if (value === undefined || value === '' || value === null) {
|
|
235
|
+
if (index !== -1) {
|
|
236
|
+
filtersStore.filters.splice(index, 1);
|
|
237
|
+
}
|
|
238
|
+
} else {
|
|
239
|
+
if (index === -1) {
|
|
240
|
+
filtersStore.setFilter({ field: column.name, value, operator });
|
|
241
|
+
} else {
|
|
242
|
+
filtersStore.setFilters([...filtersStore.filters.slice(0, index), { field: column.name, value, operator }, ...filtersStore.filters.slice(index + 1)])
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
</script>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"baseUrl": ".", // This should point to your project root
|
|
4
|
+
"paths": {
|
|
5
|
+
"@/*": [
|
|
6
|
+
// "node_modules/adminforth/dist/spa/src/*"
|
|
7
|
+
"../../../adminforth/spa/src/*"
|
|
8
|
+
],
|
|
9
|
+
"*": [
|
|
10
|
+
// "node_modules/adminforth/dist/spa/node_modules/*"
|
|
11
|
+
"../../../adminforth/spa/node_modules/*"
|
|
12
|
+
],
|
|
13
|
+
"@@/*": [
|
|
14
|
+
// "node_modules/adminforth/dist/spa/src/*"
|
|
15
|
+
"."
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"include": [
|
|
20
|
+
"./**/*.ts",
|
|
21
|
+
"./**/*.tsx",
|
|
22
|
+
"./**/*.vue",
|
|
23
|
+
"../**/*.ts",
|
|
24
|
+
"../**/*.tsx",
|
|
25
|
+
"../**/*.vue",
|
|
26
|
+
"../*.vue",
|
|
27
|
+
"../*.ts",
|
|
28
|
+
"../*.tsx"
|
|
29
|
+
]
|
|
30
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { AdminForthPlugin } from "adminforth";
|
|
11
|
+
export default class extends AdminForthPlugin {
|
|
12
|
+
constructor(options) {
|
|
13
|
+
super(options, import.meta.url);
|
|
14
|
+
this.options = options;
|
|
15
|
+
}
|
|
16
|
+
modifyResourceConfig(adminforth, resourceConfig) {
|
|
17
|
+
const _super = Object.create(null, {
|
|
18
|
+
modifyResourceConfig: { get: () => super.modifyResourceConfig }
|
|
19
|
+
});
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
_super.modifyResourceConfig.call(this, adminforth, resourceConfig);
|
|
22
|
+
// simply modify resourceConfig or adminforth.config. You can get access to plugin options via this.options;
|
|
23
|
+
if (!resourceConfig.options.pageInjections) {
|
|
24
|
+
resourceConfig.options.pageInjections = {};
|
|
25
|
+
}
|
|
26
|
+
if (!resourceConfig.options.pageInjections.list) {
|
|
27
|
+
resourceConfig.options.pageInjections.list = {};
|
|
28
|
+
}
|
|
29
|
+
if (!resourceConfig.options.pageInjections.list.afterBreadcrumbs) {
|
|
30
|
+
resourceConfig.options.pageInjections.list.afterBreadcrumbs = [];
|
|
31
|
+
}
|
|
32
|
+
resourceConfig.options.pageInjections.list.afterBreadcrumbs.push({ file: this.componentPath('FiltersArea.vue'), meta: { pluginInstanceId: this.pluginInstanceId, resourceId: this.resourceConfig.resourceId, options: this.options } });
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
validateConfigAfterDiscover(adminforth, resourceConfig) {
|
|
36
|
+
// optional method where you can safely check field types after database discovery was performed
|
|
37
|
+
}
|
|
38
|
+
instanceUniqueRepresentation(pluginOptions) {
|
|
39
|
+
// optional method to return unique string representation of plugin instance.
|
|
40
|
+
// Needed if plugin can have multiple instances on one resource
|
|
41
|
+
return `single`;
|
|
42
|
+
}
|
|
43
|
+
setupEndpoints(server) {
|
|
44
|
+
server.endpoint({
|
|
45
|
+
method: 'POST',
|
|
46
|
+
path: `/plugin/${this.pluginInstanceId}/example`,
|
|
47
|
+
handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body }) {
|
|
48
|
+
const { name } = body;
|
|
49
|
+
return { hey: `Hello ${name}` };
|
|
50
|
+
})
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/index.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { AdminForthPlugin } from "adminforth";
|
|
2
|
+
import type { IAdminForth, IHttpServer, AdminForthResourcePages, AdminForthResourceColumn, AdminForthDataTypes, AdminForthResource, AdminForthComponentDeclaration } from "adminforth";
|
|
3
|
+
import type { PluginOptions } from './types.js';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export default class extends AdminForthPlugin {
|
|
7
|
+
options: PluginOptions;
|
|
8
|
+
|
|
9
|
+
constructor(options: PluginOptions) {
|
|
10
|
+
super(options, import.meta.url);
|
|
11
|
+
this.options = options;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async modifyResourceConfig(adminforth: IAdminForth, resourceConfig: AdminForthResource) {
|
|
15
|
+
super.modifyResourceConfig(adminforth, resourceConfig);
|
|
16
|
+
|
|
17
|
+
// simply modify resourceConfig or adminforth.config. You can get access to plugin options via this.options;
|
|
18
|
+
if ( !resourceConfig.options.pageInjections ) {
|
|
19
|
+
resourceConfig.options.pageInjections = {};
|
|
20
|
+
}
|
|
21
|
+
if ( !resourceConfig.options.pageInjections.list ) {
|
|
22
|
+
resourceConfig.options.pageInjections.list = {};
|
|
23
|
+
}
|
|
24
|
+
if ( !resourceConfig.options.pageInjections.list.afterBreadcrumbs ) {
|
|
25
|
+
resourceConfig.options.pageInjections.list.afterBreadcrumbs = [];
|
|
26
|
+
}
|
|
27
|
+
(resourceConfig.options.pageInjections.list.afterBreadcrumbs as AdminForthComponentDeclaration[]).push(
|
|
28
|
+
{ file: this.componentPath('FiltersArea.vue'), meta: { pluginInstanceId: this.pluginInstanceId, resourceId: this.resourceConfig.resourceId, options: this.options } }
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
validateConfigAfterDiscover(adminforth: IAdminForth, resourceConfig: AdminForthResource) {
|
|
33
|
+
// optional method where you can safely check field types after database discovery was performed
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
instanceUniqueRepresentation(pluginOptions: any) : string {
|
|
37
|
+
// optional method to return unique string representation of plugin instance.
|
|
38
|
+
// Needed if plugin can have multiple instances on one resource
|
|
39
|
+
return `single`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
setupEndpoints(server: IHttpServer) {
|
|
43
|
+
server.endpoint({
|
|
44
|
+
method: 'POST',
|
|
45
|
+
path: `/plugin/${this.pluginInstanceId}/example`,
|
|
46
|
+
handler: async ({ body }) => {
|
|
47
|
+
const { name } = body;
|
|
48
|
+
return { hey: `Hello ${name}` };
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@adminforth/quick-filters",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc && rsync -av --exclude 'node_modules' custom dist/"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [],
|
|
14
|
+
"author": "",
|
|
15
|
+
"license": "ISC",
|
|
16
|
+
"description": "",
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/node": "latest",
|
|
19
|
+
"semantic-release": "^24.2.1",
|
|
20
|
+
"semantic-release-slack-bot": "^4.0.2",
|
|
21
|
+
"typescript": "^5.7.3"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"adminforth": "^2.4.0-next.254"
|
|
25
|
+
},
|
|
26
|
+
"release": {
|
|
27
|
+
"plugins": [
|
|
28
|
+
"@semantic-release/commit-analyzer",
|
|
29
|
+
"@semantic-release/release-notes-generator",
|
|
30
|
+
"@semantic-release/npm",
|
|
31
|
+
"@semantic-release/github",
|
|
32
|
+
[
|
|
33
|
+
"semantic-release-slack-bot",
|
|
34
|
+
{
|
|
35
|
+
"notifyOnSuccess": true,
|
|
36
|
+
"notifyOnFail": true,
|
|
37
|
+
"slackIcon": ":package:",
|
|
38
|
+
"markdownReleaseNotes": true
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
"branches": [
|
|
44
|
+
"main",
|
|
45
|
+
{
|
|
46
|
+
"name": "next",
|
|
47
|
+
"prerelease": true
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include*/
|
|
4
|
+
"module": "node16", /* Specify what module code is generated. */
|
|
5
|
+
"outDir": "./dist", /* Specify an output folder for all emitted files. */
|
|
6
|
+
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. */
|
|
7
|
+
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
|
8
|
+
"strict": false, /* Enable all strict type-checking options. */
|
|
9
|
+
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
|
|
10
|
+
},
|
|
11
|
+
"exclude": ["node_modules", "dist", "custom"], /* Exclude files from compilation. */
|
|
12
|
+
}
|
|
13
|
+
|