forked from MapComplete/MapComplete
Remove empty elements
This commit is contained in:
parent
ea61e17268
commit
40a0e7931d
3 changed files with 23 additions and 15 deletions
|
@ -45,6 +45,7 @@ export default abstract class BaseUIElement {
|
||||||
* Adds all the relevant classes, space separated
|
* Adds all the relevant classes, space separated
|
||||||
*/
|
*/
|
||||||
public SetClass(clss: string) {
|
public SetClass(clss: string) {
|
||||||
|
if(clss == undefined){return }
|
||||||
const all = clss.split(" ").map(clsName => clsName.trim());
|
const all = clss.split(" ").map(clsName => clsName.trim());
|
||||||
let recordedChange = false;
|
let recordedChange = false;
|
||||||
for (let c of all) {
|
for (let c of all) {
|
||||||
|
|
|
@ -16,7 +16,10 @@ export default class EditableTagRendering extends Toggle {
|
||||||
constructor(tags: UIEventSource<any>,
|
constructor(tags: UIEventSource<any>,
|
||||||
configuration: TagRenderingConfig,
|
configuration: TagRenderingConfig,
|
||||||
units: Unit [],
|
units: Unit [],
|
||||||
editMode = new UIEventSource<boolean>(false)
|
options:{
|
||||||
|
editMode? : UIEventSource<boolean> ,
|
||||||
|
innerElementClasses?: string
|
||||||
|
}
|
||||||
) {
|
) {
|
||||||
|
|
||||||
// The tagrendering is hidden if:
|
// The tagrendering is hidden if:
|
||||||
|
@ -27,7 +30,12 @@ export default class EditableTagRendering extends Toggle {
|
||||||
(configuration?.condition?.matchesProperties(tags) ?? true))
|
(configuration?.condition?.matchesProperties(tags) ?? true))
|
||||||
|
|
||||||
super(
|
super(
|
||||||
new Lazy(() => EditableTagRendering.CreateRendering(tags, configuration, units, editMode)),
|
new Lazy(() => {
|
||||||
|
const editMode = options.editMode ?? new UIEventSource<boolean>(false)
|
||||||
|
const rendering = EditableTagRendering.CreateRendering(tags, configuration, units, editMode);
|
||||||
|
rendering.SetClass(options.innerElementClasses)
|
||||||
|
return rendering
|
||||||
|
}),
|
||||||
undefined,
|
undefined,
|
||||||
renderingIsShown
|
renderingIsShown
|
||||||
)
|
)
|
||||||
|
|
|
@ -68,7 +68,8 @@ export default class FeatureInfoBox extends ScrollableFullScreen {
|
||||||
const groupName = allGroupNames[i];
|
const groupName = allGroupNames[i];
|
||||||
|
|
||||||
const trs = layerConfig.tagRenderings.filter(tr => tr.group === groupName)
|
const trs = layerConfig.tagRenderings.filter(tr => tr.group === groupName)
|
||||||
const renderingsForGroup: BaseUIElement[] = []
|
const renderingsForGroup: (EditableTagRendering | BaseUIElement)[] = []
|
||||||
|
const innerClasses = "block w-full break-word text-default m-1 p-1 border-b border-gray-200 mb-2 pb-2";
|
||||||
for (const tr of trs) {
|
for (const tr of trs) {
|
||||||
if (tr.question === null || tr.id === "questions") {
|
if (tr.question === null || tr.id === "questions") {
|
||||||
// This is a question box!
|
// This is a question box!
|
||||||
|
@ -76,21 +77,19 @@ export default class FeatureInfoBox extends ScrollableFullScreen {
|
||||||
questionBoxes.delete(tr.group)
|
questionBoxes.delete(tr.group)
|
||||||
renderingsForGroup.push(questionBox)
|
renderingsForGroup.push(questionBox)
|
||||||
} else {
|
} else {
|
||||||
const etr = new EditableTagRendering(tags, tr, layerConfig.units).SetClass("editable-tag-rendering")
|
let classes = innerClasses
|
||||||
|
if(renderingsForGroup.length === 0 && i > 0){
|
||||||
|
// This is the first element of a group!
|
||||||
|
// It should act as header and be sticky
|
||||||
|
classes= "sticky top-0"
|
||||||
|
}
|
||||||
|
|
||||||
|
const etr = new EditableTagRendering(tags, tr, layerConfig.units,{
|
||||||
|
innerElementClasses: innerClasses
|
||||||
|
})
|
||||||
renderingsForGroup.push(etr)
|
renderingsForGroup.push(etr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let j = 0
|
|
||||||
if (i !== 0) {
|
|
||||||
renderingsForGroup[0]?.SetStyle("position: sticky; top: -5px")
|
|
||||||
j = 1
|
|
||||||
}
|
|
||||||
for (/* j = 0 or 1 */; j < renderingsForGroup.length; j++) {
|
|
||||||
renderingsForGroup[j].SetClass("block w-full break-word text-default m-1 p-1 border-b border-gray-200 mb-2 pb-2")
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
allRenderings.push(...renderingsForGroup)
|
allRenderings.push(...renderingsForGroup)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue