Skip to content

Commit 5d5bb7f

Browse files
committed
add id on dropdown and datepicker for testing purpose
1 parent fd3444c commit 5d5bb7f

File tree

3 files changed

+30
-13
lines changed

3 files changed

+30
-13
lines changed

source/src/main/webapp/ReportingCampaignStatistics.jsp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@
163163
<div class="mt-6">
164164
<button
165165
class="w-full bg-blue-600 hover:bg-blue-700 text-white font-semibold py-2 px-4 rounded-md h-10"
166+
id="reportingCampaingStatisticsLoadButton"
166167
@click.prevent="$dispatch('load-stats')">
167168
Load
168169
</button>

source/src/main/webapp/include/templates/datepicker.html

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<!-- Bouton principal -->
55
<button type="button"
66
@click="toggle()"
7+
:id="id + '-mainbutton'"
78
class="flex h-10 items-center justify-between w-full rounded-md border px-3 py-2 text-sm
89
dark:bg-slate-800 dark:border-slate-600 dark:text-slate-300 dark:hover:bg-slate-700
910
bg-white border-slate-300 text-slate-900 hover:bg-slate-100 transition-all">
@@ -23,17 +24,17 @@
2324

2425
<!-- Tabs en haut -->
2526
<div class="w-full flex bg-slate-200 dark:bg-slate-700 p-1 rounded-lg shadow-sm mb-8 h-10">
26-
<button type="button" @click="goToTab('years')" class="flex-1 flex items-center justify-center gap-2 px-4 py-3 rounded-md transition-colors duration-200" :class="activeTab==='years' ? 'bg-slate-50 font-semibold dark:bg-slate-900' : 'bg-slate-200 dark:bg-slate-700 text-slate-700 hover:text-slate-900 dark:text-slate-300 dark:hover:text-white'">Année</button>
27-
<button type="button" @click="goToTab('months')" class="flex-1 flex items-center justify-center gap-2 px-4 py-3 rounded-md transition-colors duration-200" :class="activeTab==='months' ? 'bg-slate-50 font-semibold dark:bg-slate-900' : 'bg-slate-200 dark:bg-slate-700 text-slate-700 hover:text-slate-900 dark:text-slate-300 dark:hover:text-white'">Mois</button>
28-
<button type="button" @click="goToTab('days')" class="flex-1 flex items-center justify-center gap-2 px-4 py-3 rounded-md transition-colors duration-200" :class="activeTab==='days' ? 'bg-slate-50 font-semibold dark:bg-slate-900' : 'bg-slate-200 dark:bg-slate-700 text-slate-700 hover:text-slate-900 dark:text-slate-300 dark:hover:text-white'">Jour</button>
29-
<button type="button" @click="goToTab('hours')" class="flex-1 flex items-center justify-center gap-2 px-4 py-3 rounded-md transition-colors duration-200" :class="activeTab==='hours' ? 'bg-slate-50 font-semibold dark:bg-slate-900' : 'bg-slate-200 dark:bg-slate-700 text-slate-700 hover:text-slate-900 dark:text-slate-300 dark:hover:text-white'">Heure</button>
27+
<button type="button" :id="parent.id + '-years'" @click="goToTab('years')" class="flex-1 flex items-center justify-center gap-2 px-4 py-3 rounded-md transition-colors duration-200" :class="activeTab==='years' ? 'bg-slate-50 font-semibold dark:bg-slate-900' : 'bg-slate-200 dark:bg-slate-700 text-slate-700 hover:text-slate-900 dark:text-slate-300 dark:hover:text-white'">Année</button>
28+
<button type="button" :id="parent.id + '-months'" @click="goToTab('months')" class="flex-1 flex items-center justify-center gap-2 px-4 py-3 rounded-md transition-colors duration-200" :class="activeTab==='months' ? 'bg-slate-50 font-semibold dark:bg-slate-900' : 'bg-slate-200 dark:bg-slate-700 text-slate-700 hover:text-slate-900 dark:text-slate-300 dark:hover:text-white'">Mois</button>
29+
<button type="button" :id="parent.id + '-days'" @click="goToTab('days')" class="flex-1 flex items-center justify-center gap-2 px-4 py-3 rounded-md transition-colors duration-200" :class="activeTab==='days' ? 'bg-slate-50 font-semibold dark:bg-slate-900' : 'bg-slate-200 dark:bg-slate-700 text-slate-700 hover:text-slate-900 dark:text-slate-300 dark:hover:text-white'">Jour</button>
30+
<button type="button" :id="parent.id + '-hours'" @click="goToTab('hours')" class="flex-1 flex items-center justify-center gap-2 px-4 py-3 rounded-md transition-colors duration-200" :class="activeTab==='hours' ? 'bg-slate-50 font-semibold dark:bg-slate-900' : 'bg-slate-200 dark:bg-slate-700 text-slate-700 hover:text-slate-900 dark:text-slate-300 dark:hover:text-white'">Heure</button>
3031
</div>
3132

3233
<!-- Header avec navigation < > -->
3334
<div class="flex items-center justify-between mb-2">
34-
<button @click="previous()" class="p-2 hover:bg-gray-100 rounded-lg">&lt;</button>
35+
<button :id="parent.id + '-previous'" @click="previous()" class="p-2 hover:bg-gray-100 rounded-lg">&lt;</button>
3536
<div class="font-bold" x-text="headerText"></div>
36-
<button @click="next()" class="p-2 hover:bg-gray-100 rounded-lg">&gt;</button>
37+
<button :id="parent.id + '-next'" @click="next()" class="p-2 hover:bg-gray-100 rounded-lg">&gt;</button>
3738
</div>
3839

3940
<!-- Contenu principal selon tab -->
@@ -57,6 +58,7 @@
5758
<div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-2 w-full max-w-[500px]">
5859
<template x-for="(month, index) in monthNames" :key="index">
5960
<button type="button"
61+
:id="parent.id + '-month-' + index"
6062
@click.stop="selectedMonth = index; goToTab('days')"
6163
:class="{'bg-blue-500 text-white': index===selectedMonth, 'hover:bg-gray-100': index!==selectedMonth}"
6264
class="aspect-square flex items-center justify-center rounded-lg text-sm transition"
@@ -79,6 +81,7 @@
7981
<div class="grid grid-cols-7 gap-1">
8082
<template x-for="day in calendarDays" :key="day.day+'-'+day.isCurrentMonth">
8183
<button type="button"
84+
:id="parent.id + '-day-' + day.day+'-'+day.isCurrentMonth"
8285
@click="selectDate(day)"
8386
x-text="day.day"
8487
:class="{
@@ -115,6 +118,7 @@
115118
<script>
116119
function dateTimePicker(config = {}) {
117120
return {
121+
id: config.id || 'datepicker',
118122
open: false,
119123
model: config.model,
120124
modelField: config.modelField,

source/src/main/webapp/include/templates/selectMultipleDropdown.html

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
<div class="flex gap-1 items-center" @click.stop>
1818
<!-- Select all items -->
1919
<button @click="selectAll()" x-show="open" type="button"
20+
:id="id + '-all'"
2021
class="text-[10px] px-2 py-0.5 bg-slate-200 hover:bg-slate-300 dark:bg-slate-700 dark:text-slate-200 rounded">
2122
<span x-text="$store.labels.getLabel('common','all')">All</span>
2223
</button>
2324

2425
<!-- Clear all selections -->
2526
<button @click="clearAll()" x-show="open" type="button"
27+
:id="id + '-none'"
2628
class="text-[10px] px-2 py-0.5 bg-slate-200 hover:bg-slate-300 dark:bg-slate-700 dark:text-slate-200 rounded">
2729
<span x-text="$store.labels.getLabel('common','none')">None</span>
2830
</button>
@@ -32,19 +34,20 @@
3234
<!-- Dropdown content, teleported to <body> to avoid overflow clipping -->
3335
<template x-teleport="body">
3436
<div x-show="open"
35-
@click.outside="open = false"
3637
x-transition
3738
class="absolute rounded-md border shadow-lg z-50
3839
dark:bg-slate-800 dark:border-slate-600 dark:text-slate-300
3940
bg-white border-slate-300 text-slate-900"
40-
:style="{ top: `${top}px`, left: `${left}px`, minWidth: `${width}px` }">
41+
:style="{ top: `${top}px`, left: `${left}px`, minWidth: `${width}px` }"
42+
:id="id + '-dropdown'">
4143

4244
<div class="bg-white dark:bg-slate-800 max-h-64 overflow-hidden rounded-md dark:border-slate-600">
4345

4446
<!-- Search bar -->
45-
<div class="p-2 border-b dark:border-slate-700">
46-
<input type="text" x-model="search" :placeholder="$store.labels.getLabel('common','search')"
47-
class="w-full text-sm border rounded px-2 py-1 dark:bg-slate-700 dark:border-slate-600">
47+
<div class="p-2 border-b dark:border-slate-700 border-slate-300">
48+
<input type="text" x-model="search" :placeholder="$store.labels.getLabel('common','search')" :id="id + '-search'"
49+
class="w-full text-sm border rounded px-2 py-1 dark:bg-slate-800 dark:border-slate-600 dark:text-slate-300 dark:hover:bg-slate-700
50+
bg-white border-slate-300 text-slate-900 hover:bg-slate-100">
4851
</div>
4952

5053
<!-- Selectable list of items -->
@@ -102,7 +105,7 @@
102105
this.$el.appendChild(tpl);
103106

104107
// Load dropdown items using the provided loader function
105-
this.items = this.loader();
108+
this.items = await this.loader();
106109

107110
// Set preselected values (if any)
108111
if (this.preselected.length) {
@@ -114,7 +117,16 @@
114117

115118
// Close dropdown when clicking outside of it
116119
document.addEventListener('click', e => {
117-
if (this.open && !this.$el.contains(e.target)) this.open = false;
120+
const dropdown = document.getElementById(this.id + '-dropdown');
121+
122+
if (
123+
this.open &&
124+
!this.$el.contains(e.target) &&
125+
dropdown &&
126+
!dropdown.contains(e.target)
127+
) {
128+
this.open = false;
129+
}
118130
});
119131

120132
// Listen to external refresh event for dynamic updates

0 commit comments

Comments
 (0)