From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Fri, 3 Oct 2025 22:50:05 +0000 (+0200) Subject: fix(webui): reset toggle button state after action completion (#1547) X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=cddc77d5fc797b1a1ac928fa18e9d65dbf1d1abb;p=e-mobility-charging-stations-simulator.git fix(webui): reset toggle button state after action completion (#1547) * Initial plan * Add resetToggleButtonState utility and reset toggle buttons on action completion Co-authored-by: jerome-benoit <6537332+jerome-benoit@users.noreply.github.com> * [autofix.ci] apply automated fixes * docs(webui): add JSDoc for resetToggleButtonState utility Co-authored-by: jerome-benoit <6537332+jerome-benoit@users.noreply.github.com> * [autofix.ci] apply automated fixes * fix(webui): reset toggle button state after action completion Co-authored-by: jerome-benoit <6537332+jerome-benoit@users.noreply.github.com> * [autofix.ci] apply automated fixes * Update ui/web/src/composables/Utils.ts * Update ui/web/src/composables/Utils.ts * Update ui/web/src/composables/Utils.ts * docs(webui): improve JSDoc formatting for resetToggleButtonState Co-authored-by: jerome-benoit <6537332+jerome-benoit@users.noreply.github.com> * [autofix.ci] apply automated fixes --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jerome-benoit <6537332+jerome-benoit@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Jérôme Benoit --- diff --git a/ui/web/src/components/actions/AddChargingStations.vue b/ui/web/src/components/actions/AddChargingStations.vue index ae2dc602..06733bf4 100644 --- a/ui/web/src/components/actions/AddChargingStations.vue +++ b/ui/web/src/components/actions/AddChargingStations.vue @@ -100,6 +100,7 @@ console.error('Error at adding charging stations:', error) }) .finally(() => { + resetToggleButtonState('add-charging-stations', true) $router.push({ name: 'charging-stations' }) }) } @@ -113,7 +114,7 @@ import { getCurrentInstance, ref, watch } from 'vue' import Button from '@/components/buttons/Button.vue' -import { convertToBoolean, randomUUID } from '@/composables' +import { convertToBoolean, randomUUID, resetToggleButtonState } from '@/composables' const state = ref<{ autoStart: boolean diff --git a/ui/web/src/components/actions/SetSupervisionUrl.vue b/ui/web/src/components/actions/SetSupervisionUrl.vue index ae62b05f..c7affb90 100644 --- a/ui/web/src/components/actions/SetSupervisionUrl.vue +++ b/ui/web/src/components/actions/SetSupervisionUrl.vue @@ -26,6 +26,7 @@ console.error('Error at setting supervision url:', error) }) .finally(() => { + resetToggleButtonState(`${props.hashId}-set-supervision-url`, true) $router.push({ name: 'charging-stations' }) }) } @@ -39,8 +40,9 @@ import { ref } from 'vue' import Button from '@/components/buttons/Button.vue' +import { resetToggleButtonState } from '@/composables' -defineProps<{ +const props = defineProps<{ chargingStationId: string hashId: string }>() diff --git a/ui/web/src/components/actions/StartTransaction.vue b/ui/web/src/components/actions/StartTransaction.vue index 901d97bf..a9390973 100644 --- a/ui/web/src/components/actions/StartTransaction.vue +++ b/ui/web/src/components/actions/StartTransaction.vue @@ -47,12 +47,17 @@ console.error('Error at starting transaction:', error) }) .finally(() => { + resetToggleButtonState( + `${props.hashId}-${props.connectorId}-start-transaction`, + true + ) $router.push({ name: 'charging-stations' }) }) }) .catch((error: Error) => { $toast.error('Error at authorizing RFID tag') console.error('Error at authorizing RFID tag:', error) + resetToggleButtonState(`${props.hashId}-${props.connectorId}-start-transaction`, true) $router.push({ name: 'charging-stations' }) }) } else { @@ -66,6 +71,7 @@ console.error('Error at starting transaction:', error) }) .finally(() => { + resetToggleButtonState(`${props.hashId}-${props.connectorId}-start-transaction`, true) $router.push({ name: 'charging-stations' }) }) } @@ -80,9 +86,9 @@ import { ref } from 'vue' import Button from '@/components/buttons/Button.vue' -import { convertToBoolean, convertToInt } from '@/composables' +import { convertToBoolean, convertToInt, resetToggleButtonState } from '@/composables' -defineProps<{ +const props = defineProps<{ chargingStationId: string connectorId: string hashId: string diff --git a/ui/web/src/composables/Utils.ts b/ui/web/src/composables/Utils.ts index fef01713..f490e8b7 100644 --- a/ui/web/src/composables/Utils.ts +++ b/ui/web/src/composables/Utils.ts @@ -54,6 +54,16 @@ export const getLocalStorage = (): Storage => { return localStorage } +/** + * Resets the state of a toggle button by removing its entry from localStorage. + * @param id - The identifier of the toggle button + * @param shared - Whether the toggle button is shared + */ +export const resetToggleButtonState = (id: string, shared = false): void => { + const key = shared ? `shared-toggle-button-${id}` : `toggle-button-${id}` + deleteFromLocalStorage(key) +} + export const randomUUID = (): `${string}-${string}-${string}-${string}-${string}` => { return crypto.randomUUID() } diff --git a/ui/web/src/composables/index.ts b/ui/web/src/composables/index.ts index f4a165a8..ab6d1799 100644 --- a/ui/web/src/composables/index.ts +++ b/ui/web/src/composables/index.ts @@ -6,6 +6,7 @@ export { getFromLocalStorage, getLocalStorage, randomUUID, + resetToggleButtonState, setToLocalStorage, useUIClient, } from './Utils'