Merge branch 'develop'

This commit is contained in:
Pieter Vander Vennet 2020-10-23 01:23:34 +02:00
commit 93e16b0aa8
9 changed files with 153 additions and 38 deletions

1
.gitignore vendored
View file

@ -3,3 +3,4 @@ node_modules
.cache/*
.idea/*
scratch
assets/editor-layer-index.json

View file

@ -18,7 +18,7 @@ export class PersonalLayout extends Layout {
);
this.description = "The personal theme allows to select one or more layers from all the layouts, creating a truly personal editor"
this.icon = "./assets/star.svg"
this.icon = "./assets/add.svg"
}
}

View file

@ -85,6 +85,8 @@ To develop:
0. Make a fork and clone the repository.
1. Install `npm`. Linux: `sudo apt install npm` (or your favourite package manager), windows: install nodeJS: https://nodejs.org/en/download/
2. Run `npm install` to install the dependencies
3. Download the editor layer index: `cd assets/ && wget https://osmlab.github.io/editor-layer-index/imagery.geojson --output-document=editor-layer-index.json`
3. Run `npm run start` to build and host a local testversion
4. By default, the 'bookcases'-theme is loaded. In order to load another theme, use `layout=themename` or `userlayout=true#<layout configuration>`. Note that the custom URLs (e.g. `bookcases.html`, `aed.html`, ...) _don't_ exist on the development version. (These are automatically generated from a template on the server).

View file

@ -4,6 +4,7 @@ import {UIEventSource} from "../../../Logic/UIEventSource";
import {Utils} from "../../../Utils";
import {UIElement} from "../../UIElement";
import Translations from "../../i18n/Translations";
import {Browser} from "leaflet";
/**
* This is the base-table which is selectable by hovering over it.
@ -48,9 +49,9 @@ export default class OpeningHoursPickerTable extends InputElement<OpeningHour[]>
rows += `<tr><td rowspan="2" class="oh-left-col oh-timecell-full">${hs}:00</td>` +
Utils.Times(weekday => `<td id="${this.id}-timecell-${weekday}-${h}" class="oh-timecell oh-timecell-full"></td>`, 7) +
Utils.Times(weekday => `<td id="${this.id}-timecell-${weekday}-${h}" class="oh-timecell oh-timecell-full oh-timecell-${weekday}"></td>`, 7) +
'</tr><tr>' +
Utils.Times(id => `<td id="${this.id}-timecell-${id}-${h}-30" class="oh-timecell oh-timecell-half"></td>`, 7) +
Utils.Times(id => `<td id="${this.id}-timecell-${id}-${h}-30" class="oh-timecell oh-timecell-half oh-timecell-${id}"></td>`, 7) +
'</tr>';
}
let days = OpeningHoursPickerTable.days.map((day, i) => {
@ -63,6 +64,7 @@ export default class OpeningHoursPickerTable extends InputElement<OpeningHour[]>
protected InnerUpdate() {
const self = this;
const table = (document.getElementById(`oh-table-${this.id}`) as HTMLTableElement);
console.log("Inner update!")
if (table === undefined || table === null) {
return;
}
@ -118,11 +120,16 @@ export default class OpeningHoursPickerTable extends InputElement<OpeningHour[]>
self.source.ping();
// Clear the highlighting
let header = table.rows[0];
for (let j = 1; j < header.cells.length; j++) {
header.cells[j].classList?.remove("oh-timecol-selected")
}
for (let i = 1; i < table.rows.length; i++) {
let row = table.rows[i]
for (let j = 0; j < row.cells.length; j++) {
let cell = row.cells[j]
cell?.classList?.remove("oh-timecell-selected")
cell?.classList?.remove("oh-timecell-selected");
row.classList?.remove("oh-timerow-selected");
}
}
}
@ -134,7 +141,15 @@ export default class OpeningHoursPickerTable extends InputElement<OpeningHour[]>
endSelection();
};
let lastSelectionIend, lastSelectionJEnd;
function selectAllBetween(iEnd, jEnd) {
if (lastSelectionIend === iEnd && lastSelectionJEnd === jEnd) {
return; // We already did this
}
lastSelectionIend = iEnd;
lastSelectionJEnd = jEnd;
let iStart = selectionStart[0];
let jStart = selectionStart[1];
@ -149,8 +164,34 @@ export default class OpeningHoursPickerTable extends InputElement<OpeningHour[]>
jEnd = h;
}
let header = table.rows[0];
for (let j = 1; j < header.cells.length; j++) {
let cell = header.cells[j]
cell.classList?.remove("oh-timecol-selected-round-left");
cell.classList?.remove("oh-timecol-selected-round-right");
if (jStart + 1 <= j && j <= jEnd + 1) {
cell.classList?.add("oh-timecol-selected")
if (jStart + 1 == j) {
cell.classList?.add("oh-timecol-selected-round-left");
}
if (jEnd + 1 == j) {
cell.classList?.add("oh-timecol-selected-round-right");
}
} else {
cell.classList?.remove("oh-timecol-selected")
}
}
for (let i = 1; i < table.rows.length; i++) {
let row = table.rows[i]
let row = table.rows[i];
if (iStart <= i && i <= iEnd) {
row.classList?.add("oh-timerow-selected")
} else {
row.classList?.remove("oh-timerow-selected")
}
for (let j = 0; j < row.cells.length; j++) {
let cell = row.cells[j]
if (cell === undefined) {
@ -159,10 +200,13 @@ export default class OpeningHoursPickerTable extends InputElement<OpeningHour[]>
let offset = 0;
if (i % 2 == 1) {
if (j == 0) {
// This is the first column of a full hour -> This is the time indication (skip)
continue;
}
offset = -1;
}
if (iStart <= i && i <= iEnd &&
jStart <= j + offset && j + offset <= jEnd) {
cell?.classList?.add("oh-timecell-selected")
@ -170,6 +214,7 @@ export default class OpeningHoursPickerTable extends InputElement<OpeningHour[]>
cell?.classList?.remove("oh-timecell-selected")
}
}
}

View file

@ -153,13 +153,20 @@ export default class OpeningHoursVisualization extends UIElement {
if (tags._country === undefined) {
return "Loading...";
}
const oh = new opening_hours(tags[this._key], {
let oh = null;
try {
oh = new opening_hours(tags[this._key], {
lat: tags._lat,
lon: tags._lon,
address: {
country_code: tags._country
}
}, {tag_key: this._key});
} catch (e) {
console.log(e);
return "Error: could not visualize these opening hours"
}
if (!oh.getState() && !oh.getUnknown()) {
// POI is currently closed

File diff suppressed because one or more lines are too long

View file

@ -1,8 +1,25 @@
.oh-table {
border-collapse: collapse;
width: 100%;
height: 100%;
text-align: center;
}
.oh-table th {
padding: 0;
margin: 0;
}
.oh-table, .oh-table td {
border-collapse: collapse;
background-clip: padding-box;
border-right: 1px solid #ccc;
}
.oh-timecell {
background-color: white;
position: relative;
box-sizing: border-box;
}
.oh-table th {
@ -16,39 +33,76 @@
}
.oh-timecell:hover {
background-color: #ffd1be !important;
background-color: #92b1ff !important;
}
.oh-timecell {
background-color: white;
border-left: 1px solid #eee;
border-right: 1px solid #ccc;
position: relative;
box-sizing: border-box;
}
.oh-timecell-selected {
background-color: orange;
background-color: #0048ff;
}
.oh-timecell-half {
border-bottom: 1px solid #ddd;
background-color: aliceblue;
}
.oh-timecell-half.oh-timecell-selected {
background-color: lightsalmon;
background-color: #0048ff;
}
.oh-table tr {
background: #ddd;
}
.oh-left-col {
border-bottom: 1px solid #aaa;
margin: 0;
margin-left: 10px;
width: 0.5em;
font-size: large;
padding: 0;
padding-right: 0.2em;
background: #ddd;
}
.oh-timecell-0 {
border-left: 10px solid rgba(0, 0, 0, 0);
}
.oh-timecell-6 {
border-right: 10px solid rgba(0, 0, 0, 0);
}
.oh-timecol-selected {
border-right: #0048ff;
}
.oh-timecol-selected > span {
background-color: #0048ff;
color: white;
width: 100%;
display: block;
}
.oh-timecol-selected-round-left > span {
border-top-left-radius: 5em;
border-bottom-left-radius: 5em;
}
.oh-timecol-selected-round-right > span {
border-top-right-radius: 5em;
border-bottom-right-radius: 5em;
}
.oh-timerow-selected .oh-timecell-0 {
border-left: 10px solid #0048ff !important;
}
.oh-timerow-selected .oh-timecell-6 {
border-right: 10px solid #0048ff !important;
}
.oh-draggable-header {
background-color: blue;
height: 0.5em;
@ -56,23 +110,25 @@
.oh-timerange {
border-radius: 0.5em;
margin: 2px;
margin-left: 2px;
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
background: orange;
width: calc(100% - 4px);
background: #0048ff;
z-index: 1;
box-sizing: border-box
box-sizing: border-box;
}
.oh-timerange-inner {
display: flex;
flex-direction: column;
overflow-x: hidden;
justify-content: space-between;
align-content: center;
height: 100%;
overflow-y: hidden;
}
.oh-timerange-inner input {

View file

@ -1,7 +1,6 @@
#! /bin/bash
cd assets/
wget https://osmlab.github.io/editor-layer-index/imagery.geojson --output-document=editor-layer-index.json
cd assets/ && wget https://osmlab.github.io/editor-layer-index/imagery.geojson --output-document=editor-layer-index.json
cd ..
mkdir -p assets/generated

10
test.ts
View file

@ -1,8 +1,14 @@
//*
import SpecialVisualizations from "./UI/SpecialVisualizations";
SpecialVisualizations.HelpMessage.AttachTo("maindiv")
import OpeningHoursPickerTable from "./UI/Input/OpeningHours/OpeningHoursPickerTable";
import {UIElement} from "./UI/UIElement";
import {UIEventSource} from "./Logic/UIEventSource";
import {OpeningHour} from "./Logic/OpeningHours";
new OpeningHoursPickerTable(new UIEventSource<UIElement[]>([]), new UIEventSource<OpeningHour[]>([]))
.AttachTo("maindiv")
/*/