chore: change Panel.open signature

This commit is contained in:
Yohan Boniface 2024-04-18 17:45:24 +02:00
parent 9a46901795
commit 4ded52e3fc
11 changed files with 21 additions and 25 deletions

View file

@ -149,7 +149,7 @@ export default class Browser {
formContainer.appendChild(builder.build()) formContainer.appendChild(builder.build())
this.map.panel.open({ this.map.panel.open({
data: { html: container }, content: container,
className: 'umap-browser', className: 'umap-browser',
}) })

View file

@ -14,26 +14,22 @@ export class Panel {
DomEvent.on(this.container, 'MozMousePixelScroll', DomEvent.stopPropagation) DomEvent.on(this.container, 'MozMousePixelScroll', DomEvent.stopPropagation)
} }
open(e) { open({ content, className, actions = [] } = {}) {
this.container.className = `with-transition panel ${this.classname} ${this.mode}` this.container.className = `with-transition panel ${this.classname} ${this.mode}`
this.container.innerHTML = '' this.container.innerHTML = ''
const actionsContainer = DomUtil.create('ul', 'toolbox', this.container) const actionsContainer = DomUtil.create('ul', 'toolbox', this.container)
const body = DomUtil.create('div', 'body', this.container) const body = DomUtil.create('div', 'body', this.container)
if (e.data.html.nodeType && e.data.html.nodeType === 1) body.appendChild(content)
body.appendChild(e.data.html)
else body.innerHTML = e.data.html
const closeLink = DomUtil.create('li', 'umap-close-link', actionsContainer) const closeLink = DomUtil.create('li', 'umap-close-link', actionsContainer)
DomUtil.add('i', 'icon icon-16 icon-close', closeLink) DomUtil.add('i', 'icon icon-16 icon-close', closeLink)
closeLink.title = translate('Close') closeLink.title = translate('Close')
const resizeLink = DomUtil.create('li', 'umap-resize-link', actionsContainer) const resizeLink = DomUtil.create('li', 'umap-resize-link', actionsContainer)
DomUtil.add('i', 'icon icon-16 icon-resize', resizeLink) DomUtil.add('i', 'icon icon-16 icon-resize', resizeLink)
resizeLink.title = translate('Toggle size') resizeLink.title = translate('Toggle size')
if (e.actions) { for (let action of actions) {
for (let i = 0; i < e.actions.length; i++) { actionsContainer.appendChild(action)
actionsContainer.appendChild(e.actions[i])
}
} }
if (e.className) DomUtil.addClass(body, e.className) if (className) DomUtil.addClass(body, className)
const promise = new Promise((resolve, reject) => { const promise = new Promise((resolve, reject) => {
DomUtil.addClass(this.container, 'on') DomUtil.addClass(this.container, 'on')
resolve() resolve()

View file

@ -709,7 +709,7 @@ const ControlsMixin = {
}) })
container.appendChild(builder.build()) container.appendChild(builder.build())
this.panel.open({ data: { html: container } }) this.panel.open({ content: container })
}, },
displayCaption: function () { displayCaption: function () {
@ -789,7 +789,7 @@ const ControlsMixin = {
`, `,
urls urls
) )
this.panel.open({ data: { html: container } }) this.panel.open({ content: container })
}, },
renderEditToolbar: function () { renderEditToolbar: function () {
@ -976,7 +976,7 @@ const ControlsMixin = {
this this
) )
this.editPanel.open({ data: { html: container } }) this.editPanel.open({ content: container })
}, },
} }
@ -1051,7 +1051,7 @@ U.TileLayerChooser = L.Control.extend({
this._tilelayers_container = L.DomUtil.create('ul', '', container) this._tilelayers_container = L.DomUtil.create('ul', '', container)
this.buildList(options) this.buildList(options)
this.map.editPanel.open({ this.map.editPanel.open({
data: { html: container }, content: container,
className: options.className, className: options.className,
}) })
}, },
@ -1159,7 +1159,7 @@ U.Locate = L.Control.Locate.extend({
this._map = this.map this._map = this.map
L.Control.Locate.prototype._activate.call(this) L.Control.Locate.prototype._activate.call(this)
this._map = null this._map = null
} },
}) })
U.Search = L.PhotonSearch.extend({ U.Search = L.PhotonSearch.extend({
@ -1298,7 +1298,7 @@ U.SearchControl = L.Control.extend({
this.map.fire('dataload', { id: id }) this.map.fire('dataload', { id: id })
}) })
this.search.resultsContainer = resultsContainer this.search.resultsContainer = resultsContainer
this.map.panel.open({ data: { html: container } }).then(input.focus) this.map.panel.open({ content: container }).then(input.focus)
}, },
}) })

View file

@ -129,7 +129,7 @@ U.FeatureMixin = {
this.appendEditFieldsets(container) this.appendEditFieldsets(container)
const advancedActions = L.DomUtil.createFieldset(container, L._('Advanced actions')) const advancedActions = L.DomUtil.createFieldset(container, L._('Advanced actions'))
this.getAdvancedEditActions(advancedActions) this.getAdvancedEditActions(advancedActions)
const onLoad = this.map.editPanel.open({ data: { html: container } }) const onLoad = this.map.editPanel.open({ content: container })
onLoad.then(() => { onLoad.then(() => {
builder.helpers['properties.name'].input.focus() builder.helpers['properties.name'].input.focus()
}) })

View file

@ -107,7 +107,7 @@ U.Importer = L.Class.extend({
open: function () { open: function () {
if (!this.container) this.build() if (!this.container) this.build()
const onLoad = this.map.editPanel.open({ data: { html: this.container } }) const onLoad = this.map.editPanel.open({ content: this.container })
onLoad.then(() => { onLoad.then(() => {
this.fileInput.value = null this.fileInput.value = null
this.layerInput.innerHTML = '' this.layerInput.innerHTML = ''

View file

@ -1532,7 +1532,7 @@ U.Map = L.Map.extend({
] ]
const creditsBuilder = new U.FormBuilder(this, creditsFields) const creditsBuilder = new U.FormBuilder(this, creditsFields)
credits.appendChild(creditsBuilder.build()) credits.appendChild(creditsBuilder.build())
this.editPanel.open({ data: { html: container } }) this.editPanel.open({ content: container })
}, },
edit: function () { edit: function () {
@ -1550,7 +1550,7 @@ U.Map = L.Map.extend({
this._editSlideshow(container) this._editSlideshow(container)
this._advancedActions(container) this._advancedActions(container)
this.editPanel.open({ data: { html: container }, className: 'dark' }) this.editPanel.open({ content: container, className: 'dark' })
}, },
enableEdit: function () { enableEdit: function () {

View file

@ -1385,7 +1385,7 @@ U.DataLayer = L.Evented.extend({
) )
} }
this.map.editPanel.open({ this.map.editPanel.open({
data: { html: container }, content: container,
actions: [U.Browser.backButton(this.map)], actions: [U.Browser.backButton(this.map)],
}) })
}, },

View file

@ -126,7 +126,7 @@ U.MapPermissions = L.Class.extend({
this.map.eachDataLayer((datalayer) => { this.map.eachDataLayer((datalayer) => {
datalayer.permissions.edit(container) datalayer.permissions.edit(container)
}) })
this.map.editPanel.open({ data: { html: container }, className: 'dark' }) this.map.editPanel.open({ content: container, className: 'dark' })
}, },
attach: async function () { attach: async function () {

View file

@ -56,7 +56,7 @@ U.Popup.Panel = U.Popup.extend({
onAdd: function (map) { onAdd: function (map) {
map.panel.open({ map.panel.open({
data: { html: this._content }, content: this._content,
actions: [U.Browser.backButton(map)], actions: [U.Browser.backButton(map)],
}) })

View file

@ -159,7 +159,7 @@ U.Share = L.Class.extend({
open: function () { open: function () {
if (!this.container) this.build() if (!this.container) this.build()
this.map.panel.open({ data: { html: this.container } }) this.map.panel.open({ content: this.container })
}, },
format: function (mode) { format: function (mode) {

View file

@ -110,7 +110,7 @@ U.TableEditor = L.Class.extend({
} }
L.DomEvent.on(addButton, 'click', addProperty, this) L.DomEvent.on(addButton, 'click', addProperty, this)
this.datalayer.map.fullPanel.open({ this.datalayer.map.fullPanel.open({
data: { html: this.table }, content: this.table,
className: 'umap-table-editor', className: 'umap-table-editor',
actions: [addButton], actions: [addButton],
}) })