2020-07-22 15:00:22 +00:00
|
|
|
// Copyright 2020 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2020-11-26 14:07:19 +00:00
|
|
|
import {FocusEvent} from '../events.mjs';
|
2021-06-16 13:06:08 +00:00
|
|
|
import {ExpandableText} from '../helper.mjs';
|
2020-11-03 08:01:33 +00:00
|
|
|
import {DOM, V8CustomElement} from '../helper.mjs';
|
2020-07-22 15:00:22 +00:00
|
|
|
|
2020-11-02 09:27:28 +00:00
|
|
|
DOM.defineCustomElement(
|
2020-11-18 15:51:07 +00:00
|
|
|
'./view/map-panel/map-details',
|
2020-11-03 08:01:33 +00:00
|
|
|
(templateText) => class MapDetails extends V8CustomElement {
|
2020-11-10 13:21:40 +00:00
|
|
|
_map;
|
|
|
|
|
2020-08-13 12:55:19 +00:00
|
|
|
constructor() {
|
|
|
|
super(templateText);
|
|
|
|
}
|
2020-11-10 13:21:40 +00:00
|
|
|
|
|
|
|
get _mapDetails() {
|
2020-11-03 08:01:33 +00:00
|
|
|
return this.$('#mapDetails');
|
2020-08-13 12:55:19 +00:00
|
|
|
}
|
2020-07-22 15:00:22 +00:00
|
|
|
|
2021-06-16 13:06:08 +00:00
|
|
|
get _mapProperties() {
|
|
|
|
return this.$('#mapProperties');
|
2020-08-28 14:41:56 +00:00
|
|
|
}
|
|
|
|
|
2020-11-10 13:21:40 +00:00
|
|
|
set map(map) {
|
|
|
|
if (this._map === map) return;
|
|
|
|
this._map = map;
|
2021-05-03 12:50:10 +00:00
|
|
|
this.requestUpdate();
|
2020-08-13 12:55:19 +00:00
|
|
|
}
|
2020-07-22 15:00:22 +00:00
|
|
|
|
2020-11-10 13:21:40 +00:00
|
|
|
_update() {
|
2021-06-16 13:06:08 +00:00
|
|
|
this._mapProperties.innerText = '';
|
2020-11-10 13:21:40 +00:00
|
|
|
if (this._map) {
|
2021-06-16 13:06:08 +00:00
|
|
|
let clickableDetailsTable = DOM.table('properties');
|
|
|
|
|
|
|
|
{
|
|
|
|
const row = clickableDetailsTable.insertRow();
|
|
|
|
row.insertCell().innerText = 'ID';
|
|
|
|
row.insertCell().innerText = `${this._map.id}`;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
const row = clickableDetailsTable.insertRow();
|
|
|
|
row.insertCell().innerText = 'Source location';
|
|
|
|
const sourceLocation = row.insertCell();
|
|
|
|
new ExpandableText(sourceLocation, `${this._map.sourcePosition}`);
|
|
|
|
sourceLocation.className = 'clickable';
|
|
|
|
sourceLocation.onclick = e => this._handleSourcePositionClick(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
this._mapProperties.appendChild(clickableDetailsTable);
|
|
|
|
this._mapDetails.innerText = this._map.description;
|
|
|
|
} else {
|
|
|
|
this._mapDetails.innerText = '';
|
2020-08-13 12:55:19 +00:00
|
|
|
}
|
|
|
|
}
|
2020-07-22 15:00:22 +00:00
|
|
|
|
2021-06-16 13:06:08 +00:00
|
|
|
_handleSourcePositionClick(event) {
|
2020-11-10 13:21:40 +00:00
|
|
|
this.dispatchEvent(new FocusEvent(this._map.sourcePosition));
|
2020-08-13 12:55:19 +00:00
|
|
|
}
|
2020-11-03 08:01:33 +00:00
|
|
|
});
|