adminforth 1.4.3-next.7 → 1.4.3-next.9
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/dist/spa/src/afcl/Button.vue +21 -0
- package/dist/spa/src/afcl/Input.vue +32 -0
- package/dist/spa/src/afcl/Link.vue +9 -0
- package/dist/spa/src/afcl/Select.vue +205 -0
- package/dist/spa/src/afcl/index.ts +6 -0
- package/dist/spa/src/components/Filters.vue +11 -5
- package/dist/spa/src/components/GroupsTable.vue +23 -23
- package/dist/spa/src/views/LoginView.vue +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<button
|
|
3
|
+
v-bind="$attrs"
|
|
4
|
+
type="submit"
|
|
5
|
+
class="flex items-center justify-center gap-1 text-lightPrimaryContrast bg-lightPrimary dark:bg-darkPrimary hover:brightness-110
|
|
6
|
+
focus:ring-4 focus:outline-none focus:ring-lightPrimary focus:ring-opacity-50 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:focus:ring-darkPrimary dark:focus:ring-opacity-50"
|
|
7
|
+
>
|
|
8
|
+
<svg v-if="props.loader"
|
|
9
|
+
aria-hidden="true" class="w-4 h-4 text-gray-200 animate-spin dark:text-gray-600 fill-lightPrimary dark:fill-darkPrimary"
|
|
10
|
+
viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/><path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/></svg>
|
|
11
|
+
<slot></slot>
|
|
12
|
+
</button>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script setup lang="ts">
|
|
16
|
+
|
|
17
|
+
const props = defineProps({
|
|
18
|
+
loader: Boolean,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
</script>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
|
|
3
|
+
<div class="flex">
|
|
4
|
+
<span
|
|
5
|
+
v-if="$slots.prefix"
|
|
6
|
+
class="inline-flex items-center px-3 text-sm text-gray-900 bg-gray-200 border border-s-0 border-gray-300 rounded-e-md dark:bg-gray-600 dark:text-gray-400 dark:border-gray-600">
|
|
7
|
+
<slot name="prefix"></slot>
|
|
8
|
+
</span>
|
|
9
|
+
<input
|
|
10
|
+
v-bind="$attrs"
|
|
11
|
+
:type="type"
|
|
12
|
+
aria-describedby="helper-text-explanation"
|
|
13
|
+
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-0 focus:ring-lightPrimary focus:border-lightPrimary dark:focus:ring-darkPrimary dark:focus:border-darkPrimary
|
|
14
|
+
blue-500 focus:border-blue-500 block w-20 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white z-10"
|
|
15
|
+
:class="{'rounded-l-md': !$slots.prefix, 'rounded-r-md': !$slots.suffix}"
|
|
16
|
+
>
|
|
17
|
+
<span
|
|
18
|
+
v-if="$slots.suffix"
|
|
19
|
+
class="inline-flex items-center px-3 text-sm text-gray-900 bg-gray-200 border border-s-0 border-gray-300 rounded-e-md dark:bg-gray-600 dark:text-gray-400 dark:border-gray-600">
|
|
20
|
+
<slot name="suffix"></slot>
|
|
21
|
+
</span>
|
|
22
|
+
</div>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<script setup lang="ts">
|
|
26
|
+
|
|
27
|
+
const props = defineProps({
|
|
28
|
+
type: String,
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
</script>
|
|
32
|
+
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="relative inline-block afcl-select">
|
|
3
|
+
<div class="relative">
|
|
4
|
+
<input
|
|
5
|
+
type="text"
|
|
6
|
+
v-model="search"
|
|
7
|
+
@click="inputClick"
|
|
8
|
+
@input="inputInput"
|
|
9
|
+
class="block w-full pl-3 pr-10 py-2 border border-gray-300 rounded-md leading-5 bg-white placeholder-gray-500 sm:text-sm transition duration-150 ease-in-out dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white focus:ring-lightPrimary focus:border-lightPrimary dark:focus:ring-darkPrimary dark:focus:border-darkPrimary"
|
|
10
|
+
:placeholder="
|
|
11
|
+
selectedItems.length && !multiple ? '' : (showDropdown ? 'Search' : placeholder || 'Select...')
|
|
12
|
+
"
|
|
13
|
+
/>
|
|
14
|
+
|
|
15
|
+
<div v-if="!multiple && selectedItems.length" class="absolute pointer-events-none inset-y-0 left-2 flex items-center pr-2 px-1">
|
|
16
|
+
<slot
|
|
17
|
+
name="selected-item"
|
|
18
|
+
:option="selectedItems[0]"
|
|
19
|
+
></slot>
|
|
20
|
+
<span v-if="!$slots['selected-item']" class="text-lightPrimary dark:text-white font-medium ">
|
|
21
|
+
{{ selectedItems[0]?.label }}
|
|
22
|
+
</span>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<div class="absolute inset-y-0 right-2 flex items-center pointer-events-none">
|
|
26
|
+
<!-- triangle icon -->
|
|
27
|
+
<IconCaretDownSolid v-if="!showDropdown" class="h-5 w-5 text-lightPrimary dark:text-gray-400 opacity-50" />
|
|
28
|
+
<IconCaretUpSolid v-else class="h-5 w-5 text-lightPrimary dark:text-gray-400 opacity-50" />
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
<div v-if="showDropdown" class="absolute z-10 mt-1 w-full bg-white shadow-lg dark:shadow-black dark:bg-gray-700 dark:border-gray-600 rounded-md py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm">
|
|
32
|
+
<div
|
|
33
|
+
v-for="item in filteredItems"
|
|
34
|
+
:key="item.value"
|
|
35
|
+
class="px-4 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-400"
|
|
36
|
+
:class="{ 'bg-lightPrimaryOpacity dark:bg-darkPrimaryOpacity': selectedItems.includes(item) }"
|
|
37
|
+
@click="toogleItem(item)"
|
|
38
|
+
>
|
|
39
|
+
<slot name="item" :option="item"></slot>
|
|
40
|
+
<label v-if="!$slots.item" :for="item.value">{{ item.label }}</label>
|
|
41
|
+
</div>
|
|
42
|
+
<div v-if="!filteredItems.length" class="px-4 py-2 cursor-pointer text-gray-400 dark:text-gray-300">
|
|
43
|
+
No results found
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
<div v-if="multiple && selectedItems.length"
|
|
48
|
+
class="inset-y-0 left-2 flex items-center pr-2 flex-wrap gap-y-2 py-2"
|
|
49
|
+
>
|
|
50
|
+
<template v-for="item in selectedItems" :key="`afcl-select-${item.value}`">
|
|
51
|
+
<slot name="selected-item" :item="item"></slot>
|
|
52
|
+
<div v-if="!$slots['selected-item']"
|
|
53
|
+
class="bg-lightPrimaryOpacity text-lightPrimary text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-darkPrimaryOpacity dark:text-darkPrimary">
|
|
54
|
+
<span>{{ item.label }}</span>
|
|
55
|
+
<button
|
|
56
|
+
type="button"
|
|
57
|
+
@click="toogleItem(item)"
|
|
58
|
+
class="z-index-100 flex-shrink-0 ml-1 h-4 w-4 -mr-1 rounded-full inline-flex items-center justify-center text-gray-400 hover:text-gray-500 focus:outline-none focus:text-gray-500 focus:bg-gray-100"
|
|
59
|
+
>
|
|
60
|
+
<span class="sr-only">Remove item</span>
|
|
61
|
+
<svg class="h-2 w-2" stroke="currentColor" fill="none" viewBox="0 0 8 8">
|
|
62
|
+
<path
|
|
63
|
+
stroke-linecap="round"
|
|
64
|
+
stroke-linejoin="round"
|
|
65
|
+
stroke-width="1.5"
|
|
66
|
+
d="M1 1l6 6m0-6L1 7"
|
|
67
|
+
/>
|
|
68
|
+
</svg>
|
|
69
|
+
</button>
|
|
70
|
+
</div>
|
|
71
|
+
</template>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</template>
|
|
75
|
+
|
|
76
|
+
<script setup lang="ts">
|
|
77
|
+
import { ref, computed, onMounted, onUnmounted, watch } from 'vue';
|
|
78
|
+
import { IconCaretDownSolid, IconCaretUpSolid } from '@iconify-prerendered/vue-flowbite';
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
const props = defineProps({
|
|
82
|
+
options: Array,
|
|
83
|
+
modelValue: {
|
|
84
|
+
default: undefined,
|
|
85
|
+
},
|
|
86
|
+
multiple: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
default: false,
|
|
89
|
+
},
|
|
90
|
+
placeholder: {
|
|
91
|
+
type: String,
|
|
92
|
+
default: '',
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const emit = defineEmits(['update:modelValue']);
|
|
97
|
+
|
|
98
|
+
const search = ref('');
|
|
99
|
+
const showDropdown = ref(false);
|
|
100
|
+
|
|
101
|
+
const selectedItems = ref([]);
|
|
102
|
+
|
|
103
|
+
function inputInput() {
|
|
104
|
+
if (!props.multiple && selectedItems.value.length) {
|
|
105
|
+
selectedItems.value = [];
|
|
106
|
+
emit('update:modelValue', null);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function updateFromProps() {
|
|
111
|
+
if (props.modelValue !== undefined) {
|
|
112
|
+
if (!props.multiple) {
|
|
113
|
+
const el = props.options.find(item => item.value === props.modelValue);
|
|
114
|
+
if (el) {
|
|
115
|
+
selectedItems.value = [el];
|
|
116
|
+
} else {
|
|
117
|
+
selectedItems.value = [];
|
|
118
|
+
}
|
|
119
|
+
} else {
|
|
120
|
+
selectedItems.value = props.options.filter(item => props.modelValue.includes(item.value));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function inputClick() {
|
|
126
|
+
if (!showDropdown.value) {
|
|
127
|
+
showDropdown.value = true;
|
|
128
|
+
} else {
|
|
129
|
+
if (!search.value) {
|
|
130
|
+
showDropdown.value = false;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
onMounted(() => {
|
|
136
|
+
updateFromProps();
|
|
137
|
+
|
|
138
|
+
watch(() => props.modelValue, (value) => {
|
|
139
|
+
updateFromProps();
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
watch(() => props.options, () => {
|
|
143
|
+
updateFromProps();
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
addClickListener();
|
|
147
|
+
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
const filteredItems = computed(() => {
|
|
151
|
+
return props.options.filter(item =>
|
|
152
|
+
item.label.toLowerCase().includes(search.value.toLowerCase())
|
|
153
|
+
);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
const handleClickOutside = (event) => {
|
|
157
|
+
if (!event.target.closest('.afcl-select')) {
|
|
158
|
+
showDropdown.value = false;
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const addClickListener = () => {
|
|
163
|
+
document.addEventListener('click', handleClickOutside);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const removeClickListener = () => {
|
|
167
|
+
document.removeEventListener('click', handleClickOutside);
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const toogleItem = (item) => {
|
|
171
|
+
if (selectedItems.value.includes(item)) {
|
|
172
|
+
selectedItems.value = selectedItems.value.filter(i => i !== item);
|
|
173
|
+
} else {
|
|
174
|
+
if (!props.multiple) {
|
|
175
|
+
selectedItems.value = [item];
|
|
176
|
+
} else {
|
|
177
|
+
selectedItems.value = [...selectedItems.value, item];
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (!props.multiple) {
|
|
181
|
+
showDropdown.value = false;
|
|
182
|
+
}
|
|
183
|
+
if (!props.multiple && search.value) {
|
|
184
|
+
search.value = '';
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const list = selectedItems.value.map(item => item.value);
|
|
188
|
+
const updValue = list.length ? list : null;
|
|
189
|
+
let emitValue;
|
|
190
|
+
if (!props.multiple) {
|
|
191
|
+
emitValue = updValue ? updValue[0] : null;
|
|
192
|
+
} else {
|
|
193
|
+
emitValue = updValue;
|
|
194
|
+
}
|
|
195
|
+
emit('update:modelValue', emitValue);
|
|
196
|
+
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
onUnmounted(() => {
|
|
201
|
+
removeClickListener();
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
</script>
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<h5 id="drawer-navigation-label" class="text-base font-semibold text-gray-500 uppercase dark:text-gray-400">
|
|
12
12
|
Filters
|
|
13
13
|
|
|
14
|
-
<button type="button"
|
|
14
|
+
<button type="button" @click="$emit('hide')" class="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm p-1.5 absolute end-2.5 inline-flex items-center dark:hover:bg-gray-600 dark:hover:text-white" >
|
|
15
15
|
<svg aria-hidden="true" class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg>
|
|
16
16
|
<span class="sr-only">Close menu</span>
|
|
17
17
|
</button>
|
|
@@ -22,23 +22,28 @@
|
|
|
22
22
|
<li v-for="c in columnsWithFilter" :key="c">
|
|
23
23
|
<p class="dark:text-gray-400">{{ c.label }}</p>
|
|
24
24
|
|
|
25
|
-
<
|
|
25
|
+
<Select
|
|
26
26
|
v-if="c.foreignResource"
|
|
27
|
+
multiple
|
|
28
|
+
class="w-full"
|
|
27
29
|
:options="columnOptions[c.name] || []"
|
|
28
30
|
@update:modelValue="setFilterItem({ column: c, operator: 'in', value: $event || undefined })"
|
|
29
31
|
:modelValue="filtersStore.filters.find(f => f.field === c.name && f.operator === 'in')?.value || []"
|
|
30
32
|
/>
|
|
31
|
-
<
|
|
33
|
+
<Select
|
|
34
|
+
multiple
|
|
35
|
+
class="w-full"
|
|
32
36
|
v-else-if="c.type === 'boolean'"
|
|
33
37
|
:options="[{ label: 'Yes', value: true }, { label: 'No', value: false }, { label: 'Unset', value: undefined }]"
|
|
34
38
|
@update:modelValue="setFilterItem({ column: c, operator: 'in', value: $event || undefined })"
|
|
35
39
|
:modelValue="filtersStore.filters.find(f => f.field === c.name && f.operator === 'in')?.value || []"
|
|
36
40
|
/>
|
|
37
41
|
|
|
38
|
-
<
|
|
42
|
+
<Select
|
|
43
|
+
multiple
|
|
44
|
+
class="w-full"
|
|
39
45
|
v-else-if="c.enum"
|
|
40
46
|
:options="c.enum"
|
|
41
|
-
:allowCustom="c.allowCustom"
|
|
42
47
|
@update:modelValue="setFilterItem({ column: c, operator: 'in', value: $event || undefined })"
|
|
43
48
|
:modelValue="filtersStore.filters.find(f => f.field === c.name && f.operator === 'in')?.value || []"
|
|
44
49
|
/>
|
|
@@ -123,6 +128,7 @@ import { useRouter } from 'vue-router';
|
|
|
123
128
|
import { computedAsync } from '@vueuse/core'
|
|
124
129
|
import CustomRangePicker from "@/components/CustomRangePicker.vue";
|
|
125
130
|
import { useFiltersStore } from '@/stores/filters';
|
|
131
|
+
import Select from '@/afcl/Select.vue';
|
|
126
132
|
|
|
127
133
|
const filtersStore = useFiltersStore();
|
|
128
134
|
|
|
@@ -55,28 +55,28 @@
|
|
|
55
55
|
/>
|
|
56
56
|
</template>
|
|
57
57
|
<template v-else>
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
></
|
|
66
|
-
<
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
<
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
58
|
+
<Select
|
|
59
|
+
class="w-full"
|
|
60
|
+
v-if="column.foreignResource"
|
|
61
|
+
:options="columnOptions[column.name] || []"
|
|
62
|
+
:placeholder = "columnOptions[column.name]?.length ?'Select...': 'There are no options available'"
|
|
63
|
+
:modelValue="currentValues[column.name]"
|
|
64
|
+
@update:modelValue="setCurrentValue(column.name, $event)"
|
|
65
|
+
></Select>
|
|
66
|
+
<Select
|
|
67
|
+
class="w-full"
|
|
68
|
+
v-else-if="column.enum"
|
|
69
|
+
:options="column.enum"
|
|
70
|
+
:modelValue="currentValues[column.name]"
|
|
71
|
+
@update:modelValue="setCurrentValue(column.name, $event)"
|
|
72
|
+
></Select>
|
|
73
|
+
<Select
|
|
74
|
+
class="w-full"
|
|
75
|
+
v-else-if="column.type === 'boolean'"
|
|
76
|
+
:options="[{ label: 'Yes', value: true }, { label: 'No', value: false }, { label: 'Unset', value: null }]"
|
|
77
|
+
:modelValue="currentValues[column.name]"
|
|
78
|
+
@update:modelValue="setCurrentValue(column.name, $event)"
|
|
79
|
+
></Select>
|
|
80
80
|
<input
|
|
81
81
|
v-else-if="['integer'].includes(column.type)"
|
|
82
82
|
type="number"
|
|
@@ -153,7 +153,7 @@
|
|
|
153
153
|
<script setup>
|
|
154
154
|
import { IconExclamationCircleSolid, IconEyeSlashSolid, IconEyeSolid } from '@iconify-prerendered/vue-flowbite';
|
|
155
155
|
import CustomDatePicker from "@/components/CustomDatePicker.vue";
|
|
156
|
-
import
|
|
156
|
+
import Select from '@/afcl/Select.vue';
|
|
157
157
|
import AfTooltip from "./AfTooltip.vue";
|
|
158
158
|
import { getCustomComponent } from '@/utils';
|
|
159
159
|
|
|
@@ -123,7 +123,7 @@ import { useUserStore } from '@/stores/user';
|
|
|
123
123
|
import { IconEyeSolid, IconEyeSlashSolid } from '@iconify-prerendered/vue-flowbite';
|
|
124
124
|
import { callAdminForthApi, loadFile } from '@/utils';
|
|
125
125
|
import { useRouter } from 'vue-router';
|
|
126
|
-
import Button from '@/
|
|
126
|
+
import Button from '@/afcl/Button.vue';
|
|
127
127
|
|
|
128
128
|
const passwordInput = ref(null);
|
|
129
129
|
const usernameInput = ref(null);
|