adminforth 1.3.55-next.0 → 1.3.55
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/.eslintrc.cjs +14 -0
- package/dist/spa/README.md +39 -0
- package/dist/spa/env.d.ts +1 -0
- package/dist/spa/index.html +23 -0
- package/dist/spa/package-lock.json +4659 -0
- package/dist/spa/package.json +52 -0
- package/dist/spa/postcss.config.js +6 -0
- package/dist/spa/public/assets/favicon.png +0 -0
- package/dist/spa/src/App.vue +418 -0
- package/dist/spa/src/assets/base.css +2 -0
- package/dist/spa/src/assets/logo.svg +19 -0
- package/dist/spa/src/components/AcceptModal.vue +45 -0
- package/dist/spa/src/components/Breadcrumbs.vue +41 -0
- package/dist/spa/src/components/BreadcrumbsWithButtons.vue +26 -0
- package/dist/spa/src/components/CustomDatePicker.vue +176 -0
- package/dist/spa/src/components/CustomDateRangePicker.vue +218 -0
- package/dist/spa/src/components/CustomRangePicker.vue +156 -0
- package/dist/spa/src/components/Dropdown.vue +168 -0
- package/dist/spa/src/components/Filters.vue +222 -0
- package/dist/spa/src/components/HelloWorld.vue +17 -0
- package/dist/spa/src/components/MenuLink.vue +27 -0
- package/dist/spa/src/components/ResourceForm.vue +325 -0
- package/dist/spa/src/components/ResourceListTable.vue +466 -0
- package/dist/spa/src/components/SingleSkeletLoader.vue +13 -0
- package/dist/spa/src/components/SkeleteLoader.vue +23 -0
- package/dist/spa/src/components/ThreeDotsMenu.vue +43 -0
- package/dist/spa/src/components/Toast.vue +78 -0
- package/dist/spa/src/components/ValueRenderer.vue +141 -0
- package/dist/spa/src/components/icons/IconCalendar.vue +5 -0
- package/dist/spa/src/components/icons/IconCommunity.vue +7 -0
- package/dist/spa/src/components/icons/IconDocumentation.vue +7 -0
- package/dist/spa/src/components/icons/IconEcosystem.vue +7 -0
- package/dist/spa/src/components/icons/IconSupport.vue +7 -0
- package/dist/spa/src/components/icons/IconTime.vue +5 -0
- package/dist/spa/src/components/icons/IconTooling.vue +19 -0
- package/dist/spa/src/composables/useFrontendApi.ts +26 -0
- package/dist/spa/src/composables/useStores.ts +131 -0
- package/dist/spa/src/index.scss +31 -0
- package/dist/spa/src/main.ts +18 -0
- package/dist/spa/src/renderers/CompactUUID.vue +48 -0
- package/dist/spa/src/renderers/CountryFlag.vue +69 -0
- package/dist/spa/src/router/index.ts +59 -0
- package/dist/spa/src/spa_types/core.ts +53 -0
- package/dist/spa/src/stores/core.ts +148 -0
- package/dist/spa/src/stores/filters.ts +27 -0
- package/dist/spa/src/stores/modal.ts +48 -0
- package/dist/spa/src/stores/toast.ts +31 -0
- package/dist/spa/src/stores/user.ts +72 -0
- package/dist/spa/src/types/AdminForthConfig.ts +1762 -0
- package/dist/spa/src/types/FrontendAPI.ts +143 -0
- package/dist/spa/src/utils.ts +160 -0
- package/dist/spa/src/views/CreateView.vue +167 -0
- package/dist/spa/src/views/EditView.vue +170 -0
- package/dist/spa/src/views/ListView.vue +352 -0
- package/dist/spa/src/views/LoginView.vue +192 -0
- package/dist/spa/src/views/ResourceParent.vue +17 -0
- package/dist/spa/src/views/ShowView.vue +194 -0
- package/dist/spa/tailwind.config.js +17 -0
- package/dist/spa/tsconfig.app.json +14 -0
- package/dist/spa/tsconfig.json +11 -0
- package/dist/spa/tsconfig.node.json +19 -0
- package/dist/spa/vite.config.ts +56 -0
- package/package.json +2 -2
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<div class="grid w-40 gap-4 mb-2">
|
|
4
|
+
<div>
|
|
5
|
+
<label for="start-time" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">{{ label }}</label>
|
|
6
|
+
|
|
7
|
+
<div class="relative">
|
|
8
|
+
<div class="absolute inset-y-0 end-0 top-0 flex items-center pe-3.5 pointer-events-none">
|
|
9
|
+
<IconCalendar class="w-4 h-4 text-gray-500 dark:text-gray-400"/>
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
<input ref="datepickerStartEl" type="text"
|
|
13
|
+
class="bg-gray-50 border leading-none border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
|
14
|
+
placeholder="Select date">
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<div>
|
|
20
|
+
<div class="grid w-40 gap-4 mb-2" :class="{hidden: !showTimeInputs}">
|
|
21
|
+
<div>
|
|
22
|
+
<div class="relative">
|
|
23
|
+
<div class="absolute inset-y-0 end-0 top-0 flex items-center pe-3.5 pointer-events-none">
|
|
24
|
+
<IconTime class="w-4 h-4 text-gray-500 dark:text-gray-400 bg-white dark:bg-gray-700"/>
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
<input v-model="startTime" type="time" id="start-time" onfocus="this.showPicker()" onclick="this.showPicker()" step="1"
|
|
28
|
+
class="bg-gray-50 border leading-none border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
|
29
|
+
value="00:00" required/>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
<button type="button"
|
|
35
|
+
class="text-lightPrimary dark:text-darkPrimary text-base font-medium hover:underline p-0 inline-flex items-center mb-2"
|
|
36
|
+
@click="toggleTimeInputs">{{ showTimeInputs ? 'Hide time' : 'Show time' }}
|
|
37
|
+
<svg class="w-8 h-8 ms-0.5" :class="{'rotate-180': showTimeInputs}" aria-hidden="true"
|
|
38
|
+
xmlns="http://www.w3.org/2000/svg" width="24" height="24"
|
|
39
|
+
fill="none" viewBox="0 0 24 24">
|
|
40
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
41
|
+
d="m8 10 4 4 4-4"/>
|
|
42
|
+
</svg>
|
|
43
|
+
</button>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
</template>
|
|
47
|
+
<script setup>
|
|
48
|
+
import {ref, computed, onMounted, watch, onBeforeUnmount} from 'vue';
|
|
49
|
+
import dayjs from 'dayjs';
|
|
50
|
+
import utc from 'dayjs/plugin/utc';
|
|
51
|
+
|
|
52
|
+
import {useCoreStore} from '@/stores/core';
|
|
53
|
+
|
|
54
|
+
import Datepicker from "flowbite-datepicker/Datepicker";
|
|
55
|
+
import IconCalendar from "@/components/icons/IconCalendar.vue";
|
|
56
|
+
import IconTime from "@/components/icons/IconTime.vue";
|
|
57
|
+
|
|
58
|
+
const coreStore = useCoreStore();
|
|
59
|
+
dayjs.extend(utc)
|
|
60
|
+
|
|
61
|
+
const props = defineProps({
|
|
62
|
+
valueStart: {
|
|
63
|
+
default: undefined
|
|
64
|
+
},
|
|
65
|
+
column: {
|
|
66
|
+
type: Object,
|
|
67
|
+
},
|
|
68
|
+
label: {
|
|
69
|
+
type: String,
|
|
70
|
+
},
|
|
71
|
+
autoHide: {
|
|
72
|
+
type: Boolean,
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const emit = defineEmits(['update:valueStart']);
|
|
77
|
+
|
|
78
|
+
const datepickerStartEl = ref();
|
|
79
|
+
|
|
80
|
+
const showTimeInputs = ref(false);
|
|
81
|
+
|
|
82
|
+
const startDate = ref('');
|
|
83
|
+
|
|
84
|
+
const startTime = ref('');
|
|
85
|
+
|
|
86
|
+
const datepickerObject = ref('')
|
|
87
|
+
|
|
88
|
+
const start = computed(() => {
|
|
89
|
+
if (!startDate.value) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
let date = dayjs(startDate.value);
|
|
94
|
+
|
|
95
|
+
if (startTime.value) {
|
|
96
|
+
date = addTimeToDate(formatTime(startTime.value), date)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return date.utc().toISOString();
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
async function updateFromProps() {
|
|
103
|
+
if (!props.valueStart) {
|
|
104
|
+
datepickerStartEl.value.value = '';
|
|
105
|
+
startTime.value = '';
|
|
106
|
+
} else {
|
|
107
|
+
// wait ref to initialize
|
|
108
|
+
await (new Promise(resolve => setTimeout(resolve, 0)));
|
|
109
|
+
datepickerObject.value.setDate(dayjs(props.valueStart).format('DD MMM YYYY'));
|
|
110
|
+
startTime.value = dayjs(props.valueStart).format('HH:mm:ss')
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
onMounted(() => {
|
|
115
|
+
updateFromProps();
|
|
116
|
+
|
|
117
|
+
watch(() => [props.valueStart], (value) => {
|
|
118
|
+
updateFromProps();
|
|
119
|
+
});
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
watch(start, () => {
|
|
123
|
+
//console.log('⚡ emit', start.value)
|
|
124
|
+
emit('update:valueStart', start.value)
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
function initDatepickers() {
|
|
128
|
+
const options = {format: 'dd M yyyy'};
|
|
129
|
+
|
|
130
|
+
if (props.autoHide) {
|
|
131
|
+
options.autohide = true;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
datepickerObject.value = new Datepicker(datepickerStartEl.value, options);
|
|
135
|
+
|
|
136
|
+
addChangeDateListener();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function addChangeDateListener() {
|
|
140
|
+
datepickerStartEl.value.addEventListener('changeDate', setStartDate)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function removeChangeDateListener() {
|
|
144
|
+
datepickerStartEl.value.removeEventListener('changeDate', setStartDate);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function destroyDatepickerElement() {
|
|
148
|
+
datepickerObject.value.destroy();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function setStartDate(event) {
|
|
152
|
+
startDate.value = event.detail.date
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function formatTime(time) {
|
|
156
|
+
return time.split(':').map(Number).length === 2 ? time + ':00' : time;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function addTimeToDate(time, date) {
|
|
160
|
+
const [hours, minutes, seconds] = time.split(':').map(Number)
|
|
161
|
+
return date.hour(hours).minute(minutes).second(seconds)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const toggleTimeInputs = () => {
|
|
165
|
+
showTimeInputs.value = !showTimeInputs.value
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
onMounted(() => {
|
|
169
|
+
initDatepickers();
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
onBeforeUnmount(() => {
|
|
173
|
+
removeChangeDateListener();
|
|
174
|
+
destroyDatepickerElement();
|
|
175
|
+
});
|
|
176
|
+
</script>
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<div class="mx-auto grid grid-cols-2 gap-4 mb-2">
|
|
4
|
+
<div class="relative">
|
|
5
|
+
<div class="absolute inset-y-0 end-0 top-0 flex items-center pe-3.5 pointer-events-none">
|
|
6
|
+
<IconCalendar class="w-4 h-4 text-gray-500 dark:text-gray-400"/>
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
<input ref="datepickerStartEl" type="text"
|
|
10
|
+
class="bg-gray-50 border leading-none border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
|
11
|
+
placeholder="From">
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
<div class="relative">
|
|
15
|
+
<div class="absolute inset-y-0 end-0 top-0 flex items-center pe-3.5 pointer-events-none">
|
|
16
|
+
<IconCalendar class="w-4 h-4 text-gray-500 dark:text-gray-400"/>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<input ref="datepickerEndEl" type="text"
|
|
20
|
+
class="bg-gray-50 border leading-none border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
|
21
|
+
placeholder="To">
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<div>
|
|
26
|
+
<div class="mx-auto grid grid-cols-2 gap-4 mb-2" :class="{hidden: !showTimeInputs}">
|
|
27
|
+
<div>
|
|
28
|
+
<div class="relative">
|
|
29
|
+
<div class="absolute inset-y-0 end-0 top-0 flex items-center pe-3.5 pointer-events-none">
|
|
30
|
+
<IconTime class="w-4 h-4 text-gray-500 dark:text-gray-400 bg-white dark:bg-gray-700"/>
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<input v-model="startTime" type="time" id="start-time"
|
|
34
|
+
class="bg-gray-50 border leading-none border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
|
35
|
+
value="00:00" required/>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
<div>
|
|
40
|
+
<div class="relative">
|
|
41
|
+
<div class="absolute inset-y-0 end-0 top-0 flex items-center pe-3.5 pointer-events-none">
|
|
42
|
+
<IconTime class="w-4 h-4 text-gray-500 dark:text-gray-400 bg-white dark:bg-gray-700"/>
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
<input v-model="endTime" type="time" id="end-time"
|
|
46
|
+
class="bg-gray-50 border leading-none border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
|
47
|
+
value="00:00" required/>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
<button type="button"
|
|
53
|
+
class="text-lightPrimary dark:text-darkPrimary text-base font-medium hover:underline p-0 inline-flex items-center mb-2"
|
|
54
|
+
@click="toggleTimeInputs">{{ showTimeInputs ? 'Hide time' : 'Show time' }}
|
|
55
|
+
<svg class="w-8 h-8 ms-0.5 relative top-px" :class="{'rotate-180': showTimeInputs}" aria-hidden="true"
|
|
56
|
+
xmlns="http://www.w3.org/2000/svg" width="24" height="24"
|
|
57
|
+
fill="none" viewBox="0 0 24 24">
|
|
58
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
59
|
+
d="m8 10 4 4 4-4"/>
|
|
60
|
+
</svg>
|
|
61
|
+
</button>
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
</template>
|
|
65
|
+
<script setup>
|
|
66
|
+
import {ref, computed, onMounted, watch, onBeforeUnmount} from 'vue';
|
|
67
|
+
import dayjs from 'dayjs';
|
|
68
|
+
import utc from 'dayjs/plugin/utc';
|
|
69
|
+
|
|
70
|
+
import {useCoreStore} from '@/stores/core';
|
|
71
|
+
|
|
72
|
+
import Datepicker from "flowbite-datepicker/Datepicker";
|
|
73
|
+
import IconCalendar from "@/components/icons/IconCalendar.vue";
|
|
74
|
+
import IconTime from "@/components/icons/IconTime.vue";
|
|
75
|
+
|
|
76
|
+
const coreStore = useCoreStore();
|
|
77
|
+
dayjs.extend(utc)
|
|
78
|
+
|
|
79
|
+
const props = defineProps({
|
|
80
|
+
valueStart: {
|
|
81
|
+
default: undefined
|
|
82
|
+
},
|
|
83
|
+
valueEnd: {
|
|
84
|
+
default: undefined
|
|
85
|
+
},
|
|
86
|
+
column: {
|
|
87
|
+
type: Object,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const emit = defineEmits(['update:valueStart', 'update:valueEnd']);
|
|
92
|
+
|
|
93
|
+
const datepickerStartEl = ref();
|
|
94
|
+
const datepickerEndEl = ref();
|
|
95
|
+
|
|
96
|
+
const showTimeInputs = ref(false);
|
|
97
|
+
|
|
98
|
+
const startDate = ref('');
|
|
99
|
+
const endDate = ref('');
|
|
100
|
+
|
|
101
|
+
const startTime = ref('');
|
|
102
|
+
const endTime = ref('');
|
|
103
|
+
|
|
104
|
+
const datepickerStartObject = ref('')
|
|
105
|
+
const datepickerEndObject = ref('')
|
|
106
|
+
|
|
107
|
+
const start = computed(() => {
|
|
108
|
+
if (!startDate.value) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
let date = dayjs(startDate.value);
|
|
113
|
+
|
|
114
|
+
if (startTime.value) {
|
|
115
|
+
date = addTimeToDate(formatTime(startTime.value), date)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return date.utc().toISOString();
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
const end = computed(() => {
|
|
122
|
+
if (!endDate.value) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
let date = dayjs(endDate.value);
|
|
127
|
+
|
|
128
|
+
if (endTime.value) {
|
|
129
|
+
date = addTimeToDate(formatTime(endTime.value), date)
|
|
130
|
+
} else {
|
|
131
|
+
date = addTimeToDate('23:59:59', date)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return date.utc().toISOString();
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
function updateFromProps() {
|
|
138
|
+
if (!props.valueStart) {
|
|
139
|
+
datepickerStartEl.value.value = '';
|
|
140
|
+
startTime.value = '';
|
|
141
|
+
}
|
|
142
|
+
if (!props.valueEnd) {
|
|
143
|
+
datepickerEndEl.value.value = '';
|
|
144
|
+
endTime.value = '';
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
onMounted(() => {
|
|
149
|
+
updateFromProps();
|
|
150
|
+
|
|
151
|
+
watch(() => [props.valueStart, props.valueEnd], (value) => {
|
|
152
|
+
updateFromProps();
|
|
153
|
+
});
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
watch(start, () => {
|
|
157
|
+
//console.log('⚡ emit', start.value)
|
|
158
|
+
emit('update:valueStart', start.value)
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
watch(end, () => {
|
|
162
|
+
//console.log('⚡ emit', end.value)
|
|
163
|
+
emit('update:valueEnd', end.value)
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
function initDatepickers() {
|
|
167
|
+
|
|
168
|
+
datepickerStartObject.value = new Datepicker(datepickerStartEl.value, {format: 'dd M yyyy'});
|
|
169
|
+
|
|
170
|
+
datepickerEndObject.value = new Datepicker(datepickerEndEl.value, {format: 'dd M yyyy'});
|
|
171
|
+
addChangeDateListener();
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function addChangeDateListener() {
|
|
175
|
+
datepickerStartEl.value.addEventListener('changeDate', setStartDate)
|
|
176
|
+
datepickerEndEl.value.addEventListener('changeDate', setEndDate)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function removeChangeDateListener() {
|
|
180
|
+
datepickerStartEl.value.removeEventListener('changeDate', setStartDate);
|
|
181
|
+
datepickerEndEl.value.removeEventListener('changeDate', setEndDate);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function destroyDatepickerElement() {
|
|
185
|
+
datepickerStartObject.value.destroy();
|
|
186
|
+
datepickerEndObject.value.destroy();
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function setStartDate(event) {
|
|
190
|
+
startDate.value = event.detail.date
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function setEndDate(event) {
|
|
194
|
+
endDate.value = event.detail.date
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function formatTime(time) {
|
|
198
|
+
return time.split(':').map(Number).length === 2 ? time + ':00' : time;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function addTimeToDate(time, date) {
|
|
202
|
+
const [hours, minutes, seconds] = time.split(':').map(Number)
|
|
203
|
+
return date.hour(hours).minute(minutes).second(seconds)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const toggleTimeInputs = () => {
|
|
207
|
+
showTimeInputs.value = !showTimeInputs.value
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
onMounted(() => {
|
|
211
|
+
initDatepickers();
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
onBeforeUnmount(() => {
|
|
215
|
+
removeChangeDateListener();
|
|
216
|
+
destroyDatepickerElement();
|
|
217
|
+
})
|
|
218
|
+
</script>
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="flex flex-wrap gap-2">
|
|
3
|
+
<input
|
|
4
|
+
:min="minFormatted"
|
|
5
|
+
:max="maxFormatted"
|
|
6
|
+
type="number" aria-describedby="helper-text-explanation"
|
|
7
|
+
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-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 dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
|
8
|
+
placeholder="From"
|
|
9
|
+
v-model="start"
|
|
10
|
+
>
|
|
11
|
+
|
|
12
|
+
<input
|
|
13
|
+
:min="minFormatted"
|
|
14
|
+
:max="maxFormatted"
|
|
15
|
+
type="number" aria-describedby="helper-text-explanation"
|
|
16
|
+
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-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 dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
|
17
|
+
placeholder="To"
|
|
18
|
+
v-model="end"
|
|
19
|
+
>
|
|
20
|
+
|
|
21
|
+
<button
|
|
22
|
+
v-if="isChanged"
|
|
23
|
+
type="button"
|
|
24
|
+
class="flex items-center p-0.5 ml-auto px-3 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded border border-gray-300 hover:bg-gray-100 hover:text-lightPrimary focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed"
|
|
25
|
+
@click="clear">Clear
|
|
26
|
+
</button>
|
|
27
|
+
|
|
28
|
+
<div v-if="min && max" class="w-full px-2.5">
|
|
29
|
+
<vue-slider
|
|
30
|
+
class="custom-slider"
|
|
31
|
+
:dot-size="20"
|
|
32
|
+
height="7.99px"
|
|
33
|
+
:min="minFormatted"
|
|
34
|
+
:max="maxFormatted"
|
|
35
|
+
v-model="sliderValue"
|
|
36
|
+
@update:model-value="updateFromSlider($event)"
|
|
37
|
+
/>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
</template>
|
|
41
|
+
<script setup lang="ts">
|
|
42
|
+
import VueSlider from 'vue-slider-component';
|
|
43
|
+
import 'vue-slider-component/theme/antd.css'
|
|
44
|
+
import {computed, onMounted, ref, watch} from "vue";
|
|
45
|
+
import debounce from 'debounce'
|
|
46
|
+
|
|
47
|
+
const props = defineProps({
|
|
48
|
+
valueStart: {
|
|
49
|
+
default: '',
|
|
50
|
+
},
|
|
51
|
+
valueEnd: {
|
|
52
|
+
default: '',
|
|
53
|
+
},
|
|
54
|
+
min: {},
|
|
55
|
+
max: {},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const emit = defineEmits(['update:valueStart', 'update:valueEnd']);
|
|
59
|
+
|
|
60
|
+
const minFormatted = computed(() => Math.floor(props.min));
|
|
61
|
+
const maxFormatted = computed(() => Math.ceil(props.max));
|
|
62
|
+
|
|
63
|
+
const isChanged = computed(() => {
|
|
64
|
+
return start.value && start.value !== minFormatted.value || end.value && end.value !== maxFormatted.value;
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const start = ref(props.valueStart);
|
|
68
|
+
const end = ref(props.valueEnd);
|
|
69
|
+
|
|
70
|
+
const sliderValue = ref([minFormatted.value, maxFormatted.value]);
|
|
71
|
+
|
|
72
|
+
const updateFromSlider =
|
|
73
|
+
debounce((value: [number, number]) => {
|
|
74
|
+
start.value = value[0] === minFormatted.value ? '': value[0];
|
|
75
|
+
end.value = value[1] === maxFormatted.value ? '': value[1];
|
|
76
|
+
}, 500);
|
|
77
|
+
|
|
78
|
+
onMounted(() => {
|
|
79
|
+
updateStartFromProps();
|
|
80
|
+
updateEndFromProps();
|
|
81
|
+
|
|
82
|
+
watch(() => props.valueStart, (value) => {
|
|
83
|
+
updateStartFromProps();
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
watch(() => props.valueEnd, (value) => {
|
|
87
|
+
updateEndFromProps();
|
|
88
|
+
});
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
function updateStartFromProps() {
|
|
92
|
+
start.value = props.valueStart;
|
|
93
|
+
setSliderValues(start.value, end.value)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function updateEndFromProps() {
|
|
97
|
+
end.value = props.valueEnd;
|
|
98
|
+
setSliderValues(start.value, end.value)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
watch(start, () => {
|
|
102
|
+
console.log('⚡ emit', start.value)
|
|
103
|
+
emit('update:valueStart', start.value)
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
watch(end, () => {
|
|
107
|
+
console.log('⚡ emit', end.value)
|
|
108
|
+
emit('update:valueEnd', end.value);
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
watch([minFormatted,maxFormatted], () => {
|
|
112
|
+
setSliderValues(minFormatted.value, maxFormatted.value)
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
const clear = () => {
|
|
116
|
+
start.value = ''
|
|
117
|
+
end.value = ''
|
|
118
|
+
setSliderValues('', '')
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function setSliderValues(start, end) {
|
|
122
|
+
sliderValue.value = [start || minFormatted.value, end || maxFormatted.value];
|
|
123
|
+
}
|
|
124
|
+
</script>
|
|
125
|
+
|
|
126
|
+
<style lang="scss" scoped>
|
|
127
|
+
.custom-slider {
|
|
128
|
+
&:deep(.vue-slider-rail) {
|
|
129
|
+
background-color: rgb(229 231 235);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
&:deep(.vue-slider-dot-handle) {
|
|
133
|
+
// apply bg-blue-500 to the handle when active
|
|
134
|
+
@apply bg-lightPrimary;
|
|
135
|
+
border: none;
|
|
136
|
+
box-shadow: none;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
&:deep(.vue-slider-dot-handle:hover) {
|
|
140
|
+
@apply bg-lightPrimary;
|
|
141
|
+
filter: brightness(1.1);
|
|
142
|
+
border: none;
|
|
143
|
+
box-shadow: none;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
&:deep(.vue-slider-process) {
|
|
147
|
+
@apply bg-lightPrimaryOpacity;
|
|
148
|
+
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
&:deep(.vue-slider-process:hover) {
|
|
152
|
+
filter: brightness(1.1);
|
|
153
|
+
@apply bg-lightPrimaryOpacity;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
</style>
|