Compare commits

..

4 commits

Author SHA1 Message Date
Yohan Boniface
6687cd53ba
feat: add a back button in rules form (#2673)
To go back in rules list.

fix #2631


![image](https://github.com/user-attachments/assets/d0ad67fe-90c1-45c5-8bca-5ac30ef8366a)
2025-04-23 17:43:22 +02:00
Yohan Boniface
a708316604
fix: make rules reordering syncable, savable and undoable (#2672) 2025-04-23 17:42:47 +02:00
Yohan Boniface
67ed6d5b44 feat: add a back button in rules form
To go back in rules list.

fix #2631
2025-04-23 10:55:39 +02:00
Yohan Boniface
fad182c5f3 fix: make rules reordering syncable, savable and undoable 2025-04-23 10:19:19 +02:00
2 changed files with 23 additions and 5 deletions

View file

@ -136,7 +136,21 @@ class Rule {
.map((str) => `${value}${str || ''}`)
}
})
this._umap.editPanel.open({ content: container, highlight: 'settings' })
const backButton = Utils.loadTemplate(`
<button class="flat" type="button" data-ref="add">
<i class="icon icon-16 icon-back" title="${translate('Back to list')}"></i>
</button>`)
backButton.addEventListener('click', () =>
this._umap.edit().then(() => {
this._umap.editPanel.container.querySelector('details#rules').open = true
})
)
this._umap.editPanel.open({
content: container,
highlight: 'settings',
actions: [backButton],
})
}
renderToolbox(ul) {
@ -194,6 +208,7 @@ export default class Rules {
}
onReorder(src, dst, initialIndex, finalIndex) {
const oldRules = Utils.CopyJSON(this._umap.properties.rules || {})
const moved = this.rules.find((rule) => stamp(rule) === +src.dataset.id)
const reference = this.rules.find((rule) => stamp(rule) === +dst.dataset.id)
const movedIdx = this.rules.indexOf(moved)
@ -209,14 +224,17 @@ export default class Rules {
this.rules.splice(newIdx, 0, moved)
this._umap.render(['rules'])
this.commit()
this._umap.sync.update('properties.rules', this._umap.properties.rules, oldRules)
}
edit(container) {
const template = `
<details>
<details id="rules">
<summary>${translate('Conditional style rules')}</summary>
<fieldset><ul data-ref=ul></ul></fieldset>
<button class="umap-add" type="button" data-ref=add>${translate('Add rule')}</button>
<fieldset>
<ul data-ref=ul></ul>
<button class="umap-add" type="button" data-ref=add>${translate('Add rule')}</button>
</fieldset>
</details>
`
const [body, { ul, add }] = Utils.loadTemplateWithRefs(template)

View file

@ -1181,7 +1181,7 @@ export default class Umap {
}
this._advancedActions(container)
this.editPanel.open({
return this.editPanel.open({
content: container,
className: 'dark',
highlight: 'settings',