11<template >
2- <div class =" sr-legend-box" v-if =" atl03CnfColorMapStore" >
3- <Fieldset
4- class =" sr-lb-fieldset"
5- legend =" Atl03 Cnf Colors"
6- :toggleable =" false"
7- :collapsed =" false"
8- >
9- <div v-for =" option in atl03CnfOptions" :key =" option.value" class =" legend-item" >
10- <div class =" color-box" :style =" { backgroundColor: atl03CnfColorMapStore.getColorForAtl03CnfValue(option.value) }" ></div >
11- <div class =" label" >{{ formatLabel(option.label) }} ({{ option.value }})</div >
12- </div >
13- </Fieldset >
14- </div >
15- <div v-else >
16- Loading atl03CnfColorMap...
17- </div >
2+ <div class =" sr-legend-box" v-if =" atl03CnfColorMapStore" >
3+ <Fieldset
4+ class =" sr-lb-fieldset"
5+ legend =" Atl03 Cnf Colors"
6+ :toggleable =" false"
7+ :collapsed =" false"
8+ >
9+ <div v-for =" option in atl03CnfOptions" :key =" option.value" class =" legend-item" >
10+ <div
11+ class =" color-box"
12+ :style =" { backgroundColor: atl03CnfColorMapStore.getColorForAtl03CnfValue(option.value) }"
13+ ></div >
14+ <div class =" label" >{{ formatLabel(option.label) }} ({{ option.value }})</div >
15+ </div >
16+ </Fieldset >
17+ </div >
18+ <div v-else >Loading atl03CnfColorMap...</div >
1819</template >
19-
20+
2021<script setup lang="ts">
21- import { onMounted , computed , watch , ref } from ' vue' ;
22- import Fieldset from ' primevue/fieldset' ;
23- import { useAtl03CnfColorMapStore } from ' @/stores/atl03CnfColorMapStore' ;
24- import { createLogger } from ' @/utils/logger' ;
22+ import { onMounted , computed , watch , ref } from ' vue'
23+ import Fieldset from ' primevue/fieldset'
24+ import { useAtl03CnfColorMapStore } from ' @/stores/atl03CnfColorMapStore'
25+ import { createLogger } from ' @/utils/logger'
2526
26- const logger = createLogger (' SrAtl03CnfColors' );
27+ const logger = createLogger (' SrAtl03CnfColors' )
2728
28- const emit = defineEmits ([' restore-atl03-color-defaults-click' , ' atl03CnfColorChanged' ]);
29+ const emit = defineEmits ([' restore-atl03-color-defaults-click' , ' atl03CnfColorChanged' ])
2930const props = defineProps ({
30- reqIdStr: {
31- type: String ,
32- required: true
33- }
34- });
31+ reqIdStr: {
32+ type: String ,
33+ required: true
34+ }
35+ })
3536
36- const atl03CnfColorMapStore = ref <any >(null );
37+ const atl03CnfColorMapStore = ref <any >(null )
3738
3839onMounted (async () => {
39- // Any initialization logic can go here
40- atl03CnfColorMapStore .value = await useAtl03CnfColorMapStore (props .reqIdStr );
41- });
40+ // Any initialization logic can go here
41+ atl03CnfColorMapStore .value = await useAtl03CnfColorMapStore (props .reqIdStr )
42+ })
4243
4344// Reactive options computed from the store
44- const atl03CnfOptions = computed (() => atl03CnfColorMapStore .value .atl03CnfOptions );
45+ const atl03CnfOptions = computed (() => atl03CnfColorMapStore .value .atl03CnfOptions )
4546
4647// Watch for changes in the color map and trigger reactivity
4748watch (
48- () => atl03CnfColorMapStore .value ?.atl03CnfColorMap ,
49- (newMap , _oldMap ) => {
50- // Emit an event or trigger any logic when the color map changes
51- emit (' atl03CnfColorChanged' , newMap );
52- logger .debug (' Color map changed' , { newMap });
53- },
54- { deep: true } // Deep watch for changes inside the object
55- );
49+ () => atl03CnfColorMapStore .value ?.atl03CnfColorMap ,
50+ (newMap , _oldMap ) => {
51+ // Emit an event or trigger any logic when the color map changes
52+ emit (' atl03CnfColorChanged' , newMap )
53+ logger .debug (' Color map changed' , { newMap })
54+ },
55+ { deep: true } // Deep watch for changes inside the object
56+ )
5657
5758// Formatting labels for better readability
5859const formatLabel = (label : string ): string => {
59- return label .replace (/ ^ atl03_/ , ' ' ).replace (/ _/ g , ' ' );
60- };
60+ if (! label ) return ' '
61+ return label .replace (/ ^ atl03_/ , ' ' ).replace (/ _/ g , ' ' )
62+ }
6163 </script >
62-
64+
6365<style scoped>
6466.sr-legend-box {
6567 display : flex ;
@@ -91,44 +93,43 @@ const formatLabel = (label: string): string => {
9193}
9294
9395.label {
94- font-size :smaller ;
96+ font-size : smaller ;
9597 line-height : 1.2 ; /* Adjust line height */
9698 color : var (--p-primary-color );
9799}
98100
99101.sr-lb-fieldset {
100- padding : 0.2rem ; /* 3.2px equivalent */
101- background-color : rgba (0 , 0 , 0 , 0.2 ); /* Black with 50% transparency */
102- border-radius : var (--p-border-radius );
103- position : relative ; /* Enable positioning for the legend */
102+ padding : 0.2rem ; /* 3.2px equivalent */
103+ background-color : rgba (0 , 0 , 0 , 0.2 ); /* Black with 50% transparency */
104+ border-radius : var (--p-border-radius );
105+ position : relative ; /* Enable positioning for the legend */
104106}
105107
106108/* Custom Fieldset legend style */
107109:deep(.sr-lb-fieldset .p-fieldset-legend ) {
108- white-space : nowrap ;
109- font-size : small ;
110- font-weight : normal ;
111- color : var (--p-primary-color );
112- padding : 0.2rem ;
113- text-align : center ;
114- position : absolute ;
115- top : 0.5rem ;
116- left : 50% ;
117- transform : translate (-50% , -50% );
118- background : transparent ;
119- border-radius : 0.25rem ;
120- border-color : transparent ;
121- box-shadow : 0 2px 4px rgba (0 , 0 , 0 , 0.3 );
122- z-index : 1 ;
123- margin : 0.5rem ;
124- padding-left : 0.5rem ;
125- padding-right :0.5rem ;
126- padding-top : 0.5rem ;
127- padding-bottom : 0.5rem ;
110+ white-space : nowrap ;
111+ font-size : small ;
112+ font-weight : normal ;
113+ color : var (--p-primary-color );
114+ padding : 0.2rem ;
115+ text-align : center ;
116+ position : absolute ;
117+ top : 0.5rem ;
118+ left : 50% ;
119+ transform : translate (-50% , -50% );
120+ background : transparent ;
121+ border-radius : 0.25rem ;
122+ border-color : transparent ;
123+ box-shadow : 0 2px 4px rgba (0 , 0 , 0 , 0.3 );
124+ z-index : 1 ;
125+ margin : 0.5rem ;
126+ padding-left : 0.5rem ;
127+ padding-right : 0.5rem ;
128+ padding-top : 0.5rem ;
129+ padding-bottom : 0.5rem ;
128130}
129131
130132:deep(.p-fieldset-content-container ) {
131- padding-top : 1.5rem ; /* Adjust padding to prevent overlap with the legend */
133+ padding-top : 1.5rem ; /* Adjust padding to prevent overlap with the legend */
132134}
133135 </style >
134-
0 commit comments