Skip to content

Commit a738545

Browse files
Toggle action buttons when finished editing drawing
1 parent 0383aff commit a738545

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

src/client/javascripts/geospatial-map.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,8 @@ function onDrawEditedFactory(context) {
469469
getActiveFeature,
470470
listContainer,
471471
geospatialInput,
472-
resetActiveFeature
472+
resetActiveFeature,
473+
toggleActionButtons
473474
} = context
474475

475476
/**
@@ -494,6 +495,7 @@ function onDrawEditedFactory(context) {
494495
}
495496

496497
resetActiveFeature()
498+
toggleActionButtons(false)
497499
}
498500
}
499501

test/client/javascripts/map.test.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,14 +663,16 @@ describe('Maps Client JS', () => {
663663
/**
664664
* Initialise geospatial maps helper
665665
*/
666-
function initialiseGeospatialMaps() {
666+
function initialiseGeospatialMaps(prefillFeatures = true) {
667667
const input = document.body.querySelector('textarea.govuk-textarea')
668668
expect(input).toBeDefined()
669669

670670
const geospatialInput = /** @type {HTMLInputElement} */ (input)
671671

672672
// Set some initial values prior to initMaps
673-
geospatialInput.value = JSON.stringify(features, null, 2)
673+
geospatialInput.value = prefillFeatures
674+
? JSON.stringify(features, null, 2)
675+
: ''
674676

675677
expect(() => initMaps()).not.toThrow()
676678
expect(onMock).toHaveBeenCalledTimes(6)
@@ -812,6 +814,15 @@ describe('Maps Client JS', () => {
812814
expect(addMarkerMock).toHaveBeenCalledOnce()
813815
})
814816

817+
test('initMaps with no initial value', () => {
818+
initialiseGeospatialMaps(false)
819+
820+
expect(interactPlugin).toHaveBeenCalledWith(expect.any(Object))
821+
expect(addPanelMock).toHaveBeenCalledWith('info', expect.any(Object))
822+
expect(addButtonMock).toHaveBeenCalledTimes(3)
823+
expect(interactPluginEnable).not.toHaveBeenCalled()
824+
})
825+
815826
test('drawing created', () => {
816827
const { geospatialInput } = initialiseGeospatialMaps()
817828

@@ -935,6 +946,8 @@ describe('Maps Client JS', () => {
935946
2
936947
)
937948
)
949+
950+
expectToggleButtons(false, 3)
938951
})
939952

940953
test('drawing deleted', () => {

0 commit comments

Comments
 (0)