@geogirafe/lib-geoportal
Version:
GeoGirafe is a flexible application to build online geoportals.
54 lines (53 loc) • 2.31 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
// SPDX-License-Identifier: Apache-2.0
import { BrainIgnoreClone } from '../../tools/state/brain/decorators.js';
import { v4 as uuidv4 } from 'uuid';
/*
* This class is a used in the state of the application, which will be accessed behind a javascript proxy.
* This means that each modification made to its properties must come from outside,
* because they have to be made through the proxy, so that the modification can be listen.
* Therefore, this class must not contain any method which is updating a value directly
* For example, any method doing <this.xxx = value> is forbidden here, because the modification be known from the proxy
*/
class BaseLayer {
id;
treeItemId;
name;
order;
isDefaultChecked;
disclaimer;
metadataUrl;
isVisible = true;
// The pinned state will bring layers to the top of their parent, independent of their order.
// Additionally, pinned themes will stay in the tree when switching between themes or emptying the tree.
isPinned = false;
// Flags to control button visibility in layer tree
isRemovable = true;
isSwipeable = true;
isDraggable = true;
hasError = false;
errorMessage = null;
get hasMetadata() {
return this.metadataUrl !== undefined;
}
isHighlighted = false;
parent;
constructor(id, name, order, options) {
this.id = id;
this.treeItemId = uuidv4();
this.name = name;
this.order = order;
this.isDefaultChecked = options?.isDefaultChecked || false;
this.disclaimer = options?.disclaimer;
this.metadataUrl = options?.metadataUrl;
}
}
__decorate([
BrainIgnoreClone
], BaseLayer.prototype, "parent", void 0);
export default BaseLayer;