Skip to content

Commit

Permalink
refactor: address pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
AlitaBernachot committed Dec 18, 2024
1 parent d0c1114 commit e338d47
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 13 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/legends/legends.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ describe('Legends', () => {
'/getMetadata?lang=fr&uid=de5373d6-340f-4203-a065-da7550a03cc4_2050',
{ fixture: 'legends_parcelles.html' }
).as('mockedMetadataParcelles')

cy.intercept(
'GET',
'/legends/get_html?lang=fr&name=pcn_parcelles%3Ashow&id=359',
Expand Down Expand Up @@ -98,6 +97,7 @@ describe('Legends', () => {
})

it('displays the legends for both layers having legend', () => {
cy.wait('@mockedMetadataParcelles', { timeout: 10000 })
cy.wait('@parcel-fixture')
cy.wait('@solaire-fixture')
cy.get('[data-cy="legendLayer"]').its('length').should('be.equal', 2)
Expand Down
3 changes: 2 additions & 1 deletion src/components/draw/feature-edit-style-symbol.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const shapeComponents = {
cross: Cross,
triangle: Triangle,
}
type ShapeKey = keyof typeof shapeComponents
</script>
<template>
Expand Down Expand Up @@ -53,7 +54,7 @@ const shapeComponents = {
{{ t('Symbole') }}
<component
v-if="feature.featureStyle.shape"
:is="shapeComponents[feature.featureStyle.shape]"
:is="shapeComponents[feature.featureStyle.shape as ShapeKey]"
:fillColor="feature.featureStyle.color"
/>
</button>
Expand Down
22 changes: 18 additions & 4 deletions src/components/draw/feature-edit-style.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,34 @@ function onClickChangeLineStyle(style: string) {
feature.featureStyle = { ...feature.featureStyle, linestyle: style }
}
function onChangeSymbolShape(shape: DrawnFeatureStyleShape) {
function onChangeSymbolShape(
shape: DrawnFeatureStyleShape,
callBack?: Function
) {
feature.featureStyle = {
...feature.featureStyle,
shape,
symbolId: undefined,
symboltype: undefined,
}
callBack && callBack()
}
function onChangeSymbolIcon(symbolId: string, symboltype: Symboltype) {
function onChangeSymbolIcon(
symbolId: string,
symboltype: Symboltype,
callBack?: Function
) {
feature.featureStyle = {
...feature.featureStyle,
symbolId,
symboltype,
size: 100,
shape: undefined,
}
callBack && callBack()
}
</script>

Expand Down Expand Up @@ -198,8 +209,11 @@ function onChangeSymbolIcon(symbolId: string, symboltype: Symboltype) {

<template #symbolIcon="{ closeEditIcon }">
<FeatureEditSymbolIcon
@changeSymbolIcon="(symbolId: string, symboltype: Symboltype) => { onChangeSymbolIcon(symbolId, symboltype); closeEditIcon()}"
@changeSymbolShape="(shape: DrawnFeatureStyleShape) => { onChangeSymbolShape(shape); closeEditIcon()}"
@changeSymbolIcon="
(symbolId, symboltype) =>
onChangeSymbolIcon(symbolId, symboltype, closeEditIcon)
"
@changeSymbolShape="shape => onChangeSymbolShape(shape, closeEditIcon)"
@close="closeEditIcon"
>
<template v-slot:symbolcolor>
Expand Down
9 changes: 6 additions & 3 deletions src/components/draw/feature-edit-symbol-icon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { AlertNotificationType } from '@/stores/alert-notifications.store.model'
import FeatureEditSymbolList from './feature-edit-symbol-list.vue'
defineEmits<{
const emit = defineEmits<{
(e: 'close'): void
(e: 'changeSymbolIcon', symbolId: string, symboltype: Symboltype): void
(e: 'changeSymbolShape', shape: DrawnFeatureStyleShape): void
Expand Down Expand Up @@ -90,6 +90,10 @@ async function onSelectMySymbol() {
}
}
}
function onClickShape(shape: DrawnFeatureStyleShape) {
emit('changeSymbolShape', shape)
}
</script>

<template>
Expand Down Expand Up @@ -119,7 +123,7 @@ async function onSelectMySymbol() {
v-for="shape in Object.keys(shapeComponents)"
:key="shape"
class="lux-btn p-2 rounded-sm border-gray-600"
@click="() => $emit('changeSymbolShape', shape as keyof typeof shapeComponents)"
@click="onClickShape(shape as DrawnFeatureStyleShape)"
:data-cy="`featStyleSymbol_${shape}`"
>
<component
Expand Down Expand Up @@ -147,7 +151,6 @@ async function onSelectMySymbol() {
ref="fileInput"
type="file"
id="file"
multiple
hidden
@change="onSelectMySymbol"
/>
Expand Down
5 changes: 2 additions & 3 deletions src/services/draw/drawn-feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,16 +375,15 @@ export class DrawnFeature extends Feature {
rotation: feature.featureStyle.angle,
})
image = new StyleRegularShape(imageOptions as RegularShapeOptions)
} /*else if (shape === 'star') {
// TODO: star still used????
} else if (shape === 'star') {
Object.assign(imageOptions, {
points: 5,
angle: Math.PI / 4,
rotation: feature.featureStyle.angle,
radius2: featureSize,
})
image = new StyleRegularShape(imageOptions as RegularShapeOptions)
}*/ else if (shape === 'cross') {
} else if (shape === 'cross') {
Object.assign(imageOptions, {
points: 4,
angle: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/stores/draw.store.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export type DrawnFeatureStyleShape =
| 'square'
| 'cross'
| 'triangle'
// | 'star' // TODO: see if star option is used (look like it is not...)
| 'star' // TODO: see if star option is used (look like it is not...)
| undefined

export type Symboltype = 'us' | 'public'
Expand Down

0 comments on commit e338d47

Please sign in to comment.