Skip to content

Commit 0b9cd82

Browse files
committed
feat(#67): select all users in a column in the calendar settings
1 parent 82fb54a commit 0b9cd82

File tree

5 files changed

+155
-36
lines changed

5 files changed

+155
-36
lines changed

Public/settings/index-BE6omVNY.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

Public/settings/index-BdWpO0Lz.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

Public/settings/index-BfxxJMoy.js

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Public/settings/index-CAvH96uA.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Resources/src/CalendarSettings/src/components/CalendarSettings.vue

Lines changed: 124 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup>
2-
import {onMounted, ref, watch} from 'vue';
2+
import {onMounted, ref, watch, computed} from 'vue';
33
import draggable from 'vuedraggable';
44
55
const props = defineProps({
@@ -27,6 +27,12 @@ const ljpccalendarmoduletranslations = window.ljpccalendarmoduletranslations
2727
const customFields = ref([]);
2828
const drag = ref(false);
2929
30+
// Select all toggles for permissions
31+
const selectAllDashboard = ref(false);
32+
const selectAllCalendar = ref(false);
33+
const selectAllCreate = ref(false);
34+
const selectAllEdit = ref(false);
35+
3036
const addCustomField = () => {
3137
customFields.value.push({
3238
id: Date.now(),
@@ -62,6 +68,31 @@ onMounted(() => {
6268
}
6369
});
6470
71+
// Functions to toggle all permissions
72+
const toggleAllDashboard = () => {
73+
Object.keys(permissions.value).forEach(key => {
74+
permissions.value[key].showInDashboard = selectAllDashboard.value;
75+
});
76+
};
77+
78+
const toggleAllCalendar = () => {
79+
Object.keys(permissions.value).forEach(key => {
80+
permissions.value[key].showInCalendar = selectAllCalendar.value;
81+
});
82+
};
83+
84+
const toggleAllCreate = () => {
85+
Object.keys(permissions.value).forEach(key => {
86+
permissions.value[key].createItems = selectAllCreate.value;
87+
});
88+
};
89+
90+
const toggleAllEdit = () => {
91+
Object.keys(permissions.value).forEach(key => {
92+
permissions.value[key].editItems = selectAllEdit.value;
93+
});
94+
};
95+
6596
6697
const handleSubmit = async (event) => {
6798
event.preventDefault();
@@ -182,10 +213,25 @@ onMounted(() => {
182213
permissions.value[user.id].userTeam = user.text;
183214
}
184215
});
216+
217+
// Initialize select all checkboxes based on existing permissions
218+
updateSelectAllStates();
185219
})
186220
.catch(error => console.error(error));
187221
});
188222
223+
// Function to update select all states based on current permissions
224+
const updateSelectAllStates = () => {
225+
const keys = Object.keys(permissions.value);
226+
if (keys.length === 0) return;
227+
228+
// Only set select all to true if ALL items have that permission
229+
selectAllDashboard.value = keys.every(key => permissions.value[key].showInDashboard);
230+
selectAllCalendar.value = keys.every(key => permissions.value[key].showInCalendar);
231+
selectAllCreate.value = keys.every(key => permissions.value[key].createItems);
232+
selectAllEdit.value = keys.every(key => permissions.value[key].editItems);
233+
};
234+
189235
</script>
190236
191237
<template>
@@ -335,10 +381,62 @@ onMounted(() => {
335381
<thead>
336382
<tr>
337383
<th>{{ ljpccalendarmoduletranslations.userTeam }}</th>
338-
<th>{{ ljpccalendarmoduletranslations.showInDashboardWidget }}</th>
339-
<th>{{ ljpccalendarmoduletranslations.showInCalendar }}</th>
340-
<th v-if="calendarType !== 'ics'">{{ ljpccalendarmoduletranslations.createEvents }}</th>
341-
<th v-if="calendarType !== 'ics'">{{ ljpccalendarmoduletranslations.editEvents }}</th>
384+
<th>
385+
<div class="permission-header">
386+
{{ ljpccalendarmoduletranslations.showInDashboardWidget }}
387+
<div class="select-all">
388+
<input
389+
type="checkbox"
390+
id="select-all-dashboard"
391+
v-model="selectAllDashboard"
392+
@change="toggleAllDashboard"
393+
>
394+
<label for="select-all-dashboard">{{ ljpccalendarmoduletranslations.all || 'All' }}</label>
395+
</div>
396+
</div>
397+
</th>
398+
<th>
399+
<div class="permission-header">
400+
{{ ljpccalendarmoduletranslations.showInCalendar }}
401+
<div class="select-all">
402+
<input
403+
type="checkbox"
404+
id="select-all-calendar"
405+
v-model="selectAllCalendar"
406+
@change="toggleAllCalendar"
407+
>
408+
<label for="select-all-calendar">{{ ljpccalendarmoduletranslations.all || 'All' }}</label>
409+
</div>
410+
</div>
411+
</th>
412+
<th v-if="calendarType !== 'ics'">
413+
<div class="permission-header">
414+
{{ ljpccalendarmoduletranslations.createEvents }}
415+
<div class="select-all">
416+
<input
417+
type="checkbox"
418+
id="select-all-create"
419+
v-model="selectAllCreate"
420+
@change="toggleAllCreate"
421+
>
422+
<label for="select-all-create">{{ ljpccalendarmoduletranslations.all || 'All' }}</label>
423+
</div>
424+
</div>
425+
</th>
426+
<th v-if="calendarType !== 'ics'">
427+
<div class="permission-header">
428+
{{ ljpccalendarmoduletranslations.editEvents }}
429+
<div class="select-all">
430+
<input
431+
type="checkbox"
432+
id="select-all-edit"
433+
v-model="selectAllEdit"
434+
@change="toggleAllEdit"
435+
>
436+
<label for="select-all-edit">{{ ljpccalendarmoduletranslations.all || 'All' }}</label>
437+
</div>
438+
</div>
439+
</th>
342440
</tr>
343441
</thead>
344442
<tbody>
@@ -449,4 +547,25 @@ small {
449547
.merge-tag:hover {
450548
text-decoration: underline;
451549
}
550+
551+
.permission-header {
552+
display: flex;
553+
flex-direction: column;
554+
}
555+
556+
.select-all {
557+
font-size: 0.85em;
558+
display: flex;
559+
align-items: center;
560+
margin-top: 3px;
561+
}
562+
563+
.select-all input {
564+
margin-right: 5px;
565+
}
566+
567+
.select-all label {
568+
margin-bottom: 0;
569+
cursor: pointer;
570+
}
452571
</style>

0 commit comments

Comments
 (0)