feat(browser): add counter in datalayer headline

This commit is contained in:
Yohan Boniface 2024-01-08 12:46:06 +01:00
parent cea5e30582
commit 2812431722
3 changed files with 10 additions and 1 deletions

View file

@ -62,6 +62,8 @@ L.U.Browser = L.Class.extend({
container.id = `browse_data_datalayer_${datalayer.umap_id}`
datalayer.renderToolbox(headline)
L.DomUtil.add('span', '', headline, datalayer.options.name)
const counter = L.DomUtil.add('span', 'datalayer-counter', headline, datalayer.count())
counter.title = L._('{count} features in this layer', {count: datalayer.count()})
const ul = L.DomUtil.create('ul', '', container)
L.DomUtil.classIf(container, 'off', !datalayer.isVisible())

View file

@ -1482,6 +1482,10 @@ L.U.DataLayer = L.Evented.extend({
return !!this.options.browsable && this.canBrowse() && this.isVisible()
},
count: function () {
return this._index.length
},
hasData: function () {
return !!this._index.length
},

View file

@ -1086,11 +1086,14 @@ a.add-datalayer:hover,
.umap-edit-enabled .show-on-edit.block {
display: block!important;
}
.umap-browse-description {
font-size: 0.9em;
margin-bottom: 14px;
}
.datalayer-counter {
float: right;
margin-right: 5px;
}
/* ********************************* */