Skip to content

Commit

Permalink
Merge pull request 3liz#3957 from nboisteault/fix-permalink
Browse files Browse the repository at this point in the history
Fix permalink
  • Loading branch information
nboisteault authored Nov 6, 2023
2 parents 168dac5 + 50a43a7 commit a0b5172
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
8 changes: 5 additions & 3 deletions assets/src/modules/Permalink.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,12 @@ export default class Permalink {
if(itemsInURL && itemsInURL.includes(encodeURIComponent(item.name))){
const itemIndex = itemsInURL.indexOf(encodeURIComponent(item.name));
item.checked = true;
if(item.type === 'layer'){
if (item.type === 'layer' && stylesInURL[itemIndex]) {
item.wmsSelectedStyleName = decodeURIComponent(stylesInURL[itemIndex]);
}
item.opacity = parseFloat(opacitiesInURL[itemIndex]);
if (opacitiesInURL[itemIndex]) {
item.opacity = parseFloat(opacitiesInURL[itemIndex]);
}
} else {
item.checked = false;
}
Expand Down Expand Up @@ -213,7 +215,7 @@ export default class Permalink {

for (const item of lizMap.mainLizmap.state.rootMapGroup.findMapLayersAndGroups()) {
if (item.checked){
itemsVisibility.push(item.name);
itemsVisibility.push(encodeURIComponent(item.name));
itemsStyle.push(item.wmsSelectedStyleName);
itemsOpacity.push(item.opacity);
}
Expand Down
12 changes: 6 additions & 6 deletions tests/end2end/playwright/permalink.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ test.describe('Permalink', () => {
await expect(page.locator('#sub-dock .btn-opacity-layer.active')).toHaveText('60');
});

test('Permalink parameters error: not enough styles', async ({ page }) => {
test('Permalink parameters error: not enough styles -> No errors', async ({ page }) => {
const baseUrl = '/index.php/view/map?repository=testsrepository&project=permalink'
const bbox = '3.7980645260916805,43.59756940064654,3.904383263124536,43.672963842067254'
const layers = 'sousquartiers,Les%20quartiers%20%C3%A0%20Montpellier'
Expand All @@ -388,11 +388,11 @@ test.describe('Permalink', () => {
await page.goto(url, { waitUntil: 'networkidle' });

// Errors
await expect(page.locator('p.error-msg')).toHaveCount(1);
await expect(page.locator('#switcher lizmap-treeview ul li')).toHaveCount(0);
await expect(page.locator('p.error-msg')).toHaveCount(0);
await expect(page.locator('#switcher lizmap-treeview ul li')).not.toHaveCount(0);
});

test('Permalink parameters error: not enough opacities', async ({ page }) => {
test('Permalink parameters error: not enough opacities -> No errors', async ({ page }) => {
const baseUrl = '/index.php/view/map?repository=testsrepository&project=permalink'
const bbox = '3.7980645260916805,43.59756940064654,3.904383263124536,43.672963842067254'
const layers = 'sousquartiers,Les%20quartiers%20%C3%A0%20Montpellier'
Expand All @@ -402,7 +402,7 @@ test.describe('Permalink', () => {
await page.goto(url, { waitUntil: 'networkidle' });

// Errors
await expect(page.locator('p.error-msg')).toHaveCount(1);
await expect(page.locator('#switcher lizmap-treeview ul li')).toHaveCount(0);
await expect(page.locator('p.error-msg')).toHaveCount(0);
await expect(page.locator('#switcher lizmap-treeview ul li')).not.toHaveCount(0);
});
});

0 comments on commit a0b5172

Please sign in to comment.