mapcomplete/Customizations/Layout.ts

65 lines
2.5 KiB
TypeScript
Raw Normal View History

2020-07-05 18:59:47 +02:00
import {LayerDefinition} from "./LayerDefinition";
2020-07-20 12:39:43 +02:00
import { UIElement } from "../UI/UIElement";
import { FixedUiElement } from "../UI/Base/FixedUiElement";
2020-07-05 18:59:47 +02:00
/**
* A layout is a collection of settings of the global view (thus: welcome text, title, selection of layers).
*/
export class Layout {
public name: string;
2020-07-20 12:39:43 +02:00
public title: UIElement;
2020-07-05 18:59:47 +02:00
public layers: LayerDefinition[];
2020-07-20 12:39:43 +02:00
public welcomeMessage: UIElement;
2020-07-05 18:59:47 +02:00
public gettingStartedPlzLogin: string;
public welcomeBackMessage: string;
public startzoom: number;
2020-07-21 00:07:04 +02:00
public supportedLanguages: string[];
2020-07-05 18:59:47 +02:00
public startLon: number;
public startLat: number;
public welcomeTail: string;
public locationContains: string[];
2020-07-15 11:23:35 +02:00
/**
*
* @param name: The name used in the query string. If in the query "quests=<name>" is defined, it will select this layout
* @param title: Will be used in the <title> of the page
* @param layers: The layers to show, a list of LayerDefinitions
* @param startzoom: The initial starting zoom of the map
* @param startLat:The initial starting latitude of the map
* @param startLon: the initial starting longitude of the map
* @param welcomeMessage: This message is shown in the collapsable box on the left
* @param gettingStartedPlzLogin: This is shown below the welcomemessage and wrapped in a login link.
* @param welcomeBackMessage: This is shown when the user is logged in
* @param welcomeTail: This text is shown below the login message. It is ideal for extra help
*/
2020-07-05 18:59:47 +02:00
constructor(
name: string,
2020-07-21 00:07:04 +02:00
supportedLanguages: string[],
2020-07-20 12:39:43 +02:00
title: UIElement | string,
2020-07-05 18:59:47 +02:00
layers: LayerDefinition[],
startzoom: number,
startLat: number,
startLon: number,
2020-07-20 12:39:43 +02:00
welcomeMessage: UIElement | string,
2020-07-15 11:23:35 +02:00
gettingStartedPlzLogin: string = "Please login to get started",
welcomeBackMessage: string = "You are logged in. Welcome back!",
2020-07-05 18:59:47 +02:00
welcomeTail: string = ""
) {
2020-07-21 00:07:04 +02:00
this.supportedLanguages = supportedLanguages;
2020-07-20 12:39:43 +02:00
this.title = typeof(title) === 'string' ? new FixedUiElement(title) : title;
2020-07-05 18:59:47 +02:00
this.startLon = startLon;
this.startLat = startLat;
this.startzoom = startzoom;
this.name = name;
this.layers = layers;
2020-07-20 12:39:43 +02:00
this.welcomeMessage = typeof(welcomeMessage) === 'string' ? new FixedUiElement(welcomeMessage) : welcomeMessage;
2020-07-05 18:59:47 +02:00
this.gettingStartedPlzLogin = gettingStartedPlzLogin;
this.welcomeBackMessage = welcomeBackMessage;
this.welcomeTail = welcomeTail;
}
}