Skip to content

feat: add a back button in rules form #2673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions umap/static/umap/js/modules/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -213,10 +227,12 @@ export default class Rules {

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)
Expand Down
2 changes: 1 addition & 1 deletion umap/static/umap/js/modules/umap.js
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ export default class Umap {
}
this._advancedActions(container)

this.editPanel.open({
return this.editPanel.open({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it related to that PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it return the promise so someone calling open() can use this promise to run some code when the panel is opened (in this case we'll open a given fieldset) :)

content: container,
className: 'dark',
highlight: 'settings',
Expand Down