mirror of
https://github.com/umap-project/umap.git
synced 2025-04-28 19:42:36 +02:00
Compare commits
4 commits
07363fa5fe
...
6687cd53ba
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6687cd53ba | ||
![]() |
a708316604 | ||
![]() |
67ed6d5b44 | ||
![]() |
fad182c5f3 |
2 changed files with 23 additions and 5 deletions
|
@ -136,7 +136,21 @@ class Rule {
|
||||||
.map((str) => `${value}${str || ''}`)
|
.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) {
|
renderToolbox(ul) {
|
||||||
|
@ -194,6 +208,7 @@ export default class Rules {
|
||||||
}
|
}
|
||||||
|
|
||||||
onReorder(src, dst, initialIndex, finalIndex) {
|
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 moved = this.rules.find((rule) => stamp(rule) === +src.dataset.id)
|
||||||
const reference = this.rules.find((rule) => stamp(rule) === +dst.dataset.id)
|
const reference = this.rules.find((rule) => stamp(rule) === +dst.dataset.id)
|
||||||
const movedIdx = this.rules.indexOf(moved)
|
const movedIdx = this.rules.indexOf(moved)
|
||||||
|
@ -209,14 +224,17 @@ export default class Rules {
|
||||||
this.rules.splice(newIdx, 0, moved)
|
this.rules.splice(newIdx, 0, moved)
|
||||||
this._umap.render(['rules'])
|
this._umap.render(['rules'])
|
||||||
this.commit()
|
this.commit()
|
||||||
|
this._umap.sync.update('properties.rules', this._umap.properties.rules, oldRules)
|
||||||
}
|
}
|
||||||
|
|
||||||
edit(container) {
|
edit(container) {
|
||||||
const template = `
|
const template = `
|
||||||
<details>
|
<details id="rules">
|
||||||
<summary>${translate('Conditional style rules')}</summary>
|
<summary>${translate('Conditional style rules')}</summary>
|
||||||
<fieldset><ul data-ref=ul></ul></fieldset>
|
<fieldset>
|
||||||
<button class="umap-add" type="button" data-ref=add>${translate('Add rule')}</button>
|
<ul data-ref=ul></ul>
|
||||||
|
<button class="umap-add" type="button" data-ref=add>${translate('Add rule')}</button>
|
||||||
|
</fieldset>
|
||||||
</details>
|
</details>
|
||||||
`
|
`
|
||||||
const [body, { ul, add }] = Utils.loadTemplateWithRefs(template)
|
const [body, { ul, add }] = Utils.loadTemplateWithRefs(template)
|
||||||
|
|
|
@ -1181,7 +1181,7 @@ export default class Umap {
|
||||||
}
|
}
|
||||||
this._advancedActions(container)
|
this._advancedActions(container)
|
||||||
|
|
||||||
this.editPanel.open({
|
return this.editPanel.open({
|
||||||
content: container,
|
content: container,
|
||||||
className: 'dark',
|
className: 'dark',
|
||||||
highlight: 'settings',
|
highlight: 'settings',
|
||||||
|
|
Loading…
Reference in a new issue