forked from MapComplete/MapComplete
Refactored out 'layout.ts'
This commit is contained in:
parent
36f5e896df
commit
73f32e0ecf
30 changed files with 465 additions and 400 deletions
|
@ -246,7 +246,12 @@ export default class MetaTagging {
|
|||
static addMetatags(features: any[]) {
|
||||
|
||||
for (const metatag of MetaTagging.metatags) {
|
||||
metatag.addMetaTags(features);
|
||||
try {
|
||||
metatag.addMetaTags(features);
|
||||
} catch (e) {
|
||||
console.error("Could not calculate metatag ", metatag.keys.join(","), ":", e)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import {OsmConnection, UserDetails} from "./OsmConnection";
|
||||
import {UIEventSource} from "../UIEventSource";
|
||||
import {ElementStorage} from "../ElementStorage";
|
||||
import {Layout} from "../../Customizations/Layout";
|
||||
import State from "../../State";
|
||||
import Locale from "../../UI/i18n/Locale";
|
||||
import LayoutConfig from "../../Customizations/JSON/LayoutConfig";
|
||||
|
||||
export class ChangesetHandler {
|
||||
|
||||
|
@ -26,7 +26,7 @@ export class ChangesetHandler {
|
|||
|
||||
|
||||
public UploadChangeset(
|
||||
layout: Layout,
|
||||
layout: LayoutConfig,
|
||||
allElements: ElementStorage,
|
||||
generateChangeXML: (csid: string) => string,
|
||||
continuation: () => void) {
|
||||
|
@ -85,10 +85,10 @@ export class ChangesetHandler {
|
|||
|
||||
|
||||
private OpenChangeset(
|
||||
layout : Layout,
|
||||
layout : LayoutConfig,
|
||||
continuation: (changesetId: string) => void) {
|
||||
|
||||
const commentExtra = layout.changesetMessage !== undefined ? " - " + layout.changesetMessage : "";
|
||||
const commentExtra = layout.changesetmessage !== undefined ? " - " + layout.changesetmessage : "";
|
||||
|
||||
let surveySource = "";
|
||||
if (State.state.currentGPSLocation.data !== undefined) {
|
||||
|
|
|
@ -3,10 +3,10 @@ import osmAuth from "osm-auth";
|
|||
import {UIEventSource} from "../UIEventSource";
|
||||
import {OsmPreferences} from "./OsmPreferences";
|
||||
import {ChangesetHandler} from "./ChangesetHandler";
|
||||
import {Layout} from "../../Customizations/Layout";
|
||||
import {ElementStorage} from "../ElementStorage";
|
||||
import {Img} from "../../UI/Img";
|
||||
import Svg from "../../Svg";
|
||||
import LayoutConfig from "../../Customizations/JSON/LayoutConfig";
|
||||
|
||||
export class UserDetails {
|
||||
|
||||
|
@ -97,7 +97,7 @@ export class OsmConnection {
|
|||
|
||||
|
||||
public UploadChangeset(
|
||||
layout: Layout,
|
||||
layout: LayoutConfig,
|
||||
allElements: ElementStorage,
|
||||
generateChangeXML: (csid: string) => string,
|
||||
continuation: () => void = () => {}) {
|
||||
|
|
|
@ -5,12 +5,12 @@ import {UIEventSource} from "./UIEventSource";
|
|||
import {AllKnownLayouts} from "../Customizations/AllKnownLayouts";
|
||||
import Combine from "../UI/Base/Combine";
|
||||
import CheckBox from "../UI/Input/CheckBox";
|
||||
import {PersonalLayout} from "./PersonalLayout";
|
||||
import {Layout} from "../Customizations/Layout";
|
||||
import * as personal from "../assets/themes/personalLayout/personalLayout.json";
|
||||
import {SubtleButton} from "../UI/Base/SubtleButton";
|
||||
import {FixedUiElement} from "../UI/Base/FixedUiElement";
|
||||
import {Img} from "../UI/Img";
|
||||
import Svg from "../Svg";
|
||||
import LayoutConfig from "../Customizations/JSON/LayoutConfig";
|
||||
|
||||
export class PersonalLayersPanel extends UIElement {
|
||||
private checkboxes: UIElement[] = [];
|
||||
|
@ -22,19 +22,19 @@ export class PersonalLayersPanel extends UIElement {
|
|||
this.UpdateView([]);
|
||||
const self = this;
|
||||
State.state.installedThemes.addCallback(extraThemes => {
|
||||
self.UpdateView(extraThemes.map(layout => layout.layout));
|
||||
self.UpdateView(extraThemes.map(layout => layout.layout.layoutConfig));
|
||||
self.Update();
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
private UpdateView(extraThemes: Layout[]) {
|
||||
private UpdateView(extraThemes: LayoutConfig[]) {
|
||||
this.checkboxes = [];
|
||||
const favs = State.state.favouriteLayers.data ?? [];
|
||||
const controls = new Map<string, UIEventSource<boolean>>();
|
||||
const allLayouts = AllKnownLayouts.layoutsList.concat(extraThemes);
|
||||
for (const layout of allLayouts) {
|
||||
if (layout.id === PersonalLayout.NAME) {
|
||||
if (layout.id === personal.id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -44,11 +44,15 @@ export class PersonalLayersPanel extends UIElement {
|
|||
"<b>",
|
||||
layout.title,
|
||||
"</b><br/>",
|
||||
layout.description ?? ""
|
||||
layout.shortDescription ?? ""
|
||||
]).SetStyle("background: #eee; display: block; padding: 0.5em; border-radius:0.5em; overflow:auto;")
|
||||
this.checkboxes.push(header);
|
||||
|
||||
for (const layer of layout.layers) {
|
||||
if(layer === undefined){
|
||||
console.warn("Undefined layer for ",layout.id)
|
||||
continue;
|
||||
}
|
||||
if (typeof layer === "string") {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
import {Layout} from "../Customizations/Layout";
|
||||
import Translations from "../UI/i18n/Translations";
|
||||
import {Img} from "../UI/Img";
|
||||
import Svg from "../Svg";
|
||||
|
||||
export class PersonalLayout extends Layout {
|
||||
|
||||
public static NAME: string = "personal";
|
||||
|
||||
constructor() {
|
||||
super(
|
||||
PersonalLayout.NAME,
|
||||
["en"],
|
||||
Translations.t.favourite.title,
|
||||
[],
|
||||
12,
|
||||
0,
|
||||
0,
|
||||
Translations.t.favourite.description,
|
||||
);
|
||||
this.maintainer = "MapComplete"
|
||||
this.description = "The personal theme allows to select one or more layers from all the layouts, creating a truly personal editor"
|
||||
this.icon = Img.AsData(Svg.add)
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue