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/* .cache/*
.idea/* .idea/*
scratch 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.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. 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/ 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 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 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). 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 {Utils} from "../../../Utils";
import {UIElement} from "../../UIElement"; import {UIElement} from "../../UIElement";
import Translations from "../../i18n/Translations"; import Translations from "../../i18n/Translations";
import {Browser} from "leaflet";
/** /**
* This is the base-table which is selectable by hovering over it. * 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>` + 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>' + '</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>'; '</tr>';
} }
let days = OpeningHoursPickerTable.days.map((day, i) => { let days = OpeningHoursPickerTable.days.map((day, i) => {
@ -63,6 +64,7 @@ export default class OpeningHoursPickerTable extends InputElement<OpeningHour[]>
protected InnerUpdate() { protected InnerUpdate() {
const self = this; const self = this;
const table = (document.getElementById(`oh-table-${this.id}`) as HTMLTableElement); const table = (document.getElementById(`oh-table-${this.id}`) as HTMLTableElement);
console.log("Inner update!")
if (table === undefined || table === null) { if (table === undefined || table === null) {
return; return;
} }
@ -109,7 +111,7 @@ export default class OpeningHoursPickerTable extends InputElement<OpeningHour[]>
endHour: h(timeEnd + 1), endHour: h(timeEnd + 1),
endMinutes: m(timeEnd + 1) endMinutes: m(timeEnd + 1)
} }
if(oh.endHour > 23){ if (oh.endHour > 23) {
oh.endHour = 24; oh.endHour = 24;
oh.endMinutes = 0; oh.endMinutes = 0;
} }
@ -118,11 +120,16 @@ export default class OpeningHoursPickerTable extends InputElement<OpeningHour[]>
self.source.ping(); self.source.ping();
// Clear the highlighting // 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++) { for (let i = 1; i < table.rows.length; i++) {
let row = table.rows[i] let row = table.rows[i]
for (let j = 0; j < row.cells.length; j++) { for (let j = 0; j < row.cells.length; j++) {
let cell = row.cells[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(); endSelection();
}; };
let lastSelectionIend, lastSelectionJEnd;
function selectAllBetween(iEnd, jEnd) { function selectAllBetween(iEnd, jEnd) {
if (lastSelectionIend === iEnd && lastSelectionJEnd === jEnd) {
return; // We already did this
}
lastSelectionIend = iEnd;
lastSelectionJEnd = jEnd;
let iStart = selectionStart[0]; let iStart = selectionStart[0];
let jStart = selectionStart[1]; let jStart = selectionStart[1];
@ -149,8 +164,34 @@ export default class OpeningHoursPickerTable extends InputElement<OpeningHour[]>
jEnd = h; 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++) { 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++) { for (let j = 0; j < row.cells.length; j++) {
let cell = row.cells[j] let cell = row.cells[j]
if (cell === undefined) { if (cell === undefined) {
@ -159,16 +200,20 @@ export default class OpeningHoursPickerTable extends InputElement<OpeningHour[]>
let offset = 0; let offset = 0;
if (i % 2 == 1) { if (i % 2 == 1) {
if (j == 0) { if (j == 0) {
// This is the first column of a full hour -> This is the time indication (skip)
continue; continue;
} }
offset = -1; offset = -1;
} }
if (iStart <= i && i <= iEnd && if (iStart <= i && i <= iEnd &&
jStart <= j + offset && j + offset <= jEnd) { jStart <= j + offset && j + offset <= jEnd) {
cell?.classList?.add("oh-timecell-selected") cell?.classList?.add("oh-timecell-selected")
} else { } else {
cell?.classList?.remove("oh-timecell-selected") cell?.classList?.remove("oh-timecell-selected")
} }
} }

View file

@ -150,16 +150,23 @@ export default class OpeningHoursVisualization extends UIElement {
nextSunday.setDate(nextSunday.getDate() + 7); nextSunday.setDate(nextSunday.getDate() + 7);
const tags = this._source.data; const tags = this._source.data;
if(tags._country === undefined){ if (tags._country === undefined) {
return "Loading..."; return "Loading...";
} }
const oh = new opening_hours(tags[this._key], { let oh = null;
lat: tags._lat,
lon: tags._lon, try {
address: { oh = new opening_hours(tags[this._key], {
country_code: tags._country lat: tags._lat,
} lon: tags._lon,
}, {tag_key: this._key}); 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()) { if (!oh.getState() && !oh.getUnknown()) {
// POI is currently closed // POI is currently closed

File diff suppressed because one or more lines are too long

View file

@ -1,8 +1,25 @@
.oh-table { .oh-table {
border-collapse: collapse;
width: 100%; width: 100%;
height: 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 { .oh-table th {
@ -16,39 +33,76 @@
} }
.oh-timecell:hover { .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 { .oh-timecell-selected {
background-color: orange; background-color: #0048ff;
} }
.oh-timecell-half{
.oh-timecell-half {
border-bottom: 1px solid #ddd;
background-color: aliceblue; background-color: aliceblue;
} }
.oh-timecell-half.oh-timecell-selected { .oh-timecell-half.oh-timecell-selected {
background-color: lightsalmon; background-color: #0048ff;
}
.oh-table tr {
background: #ddd;
} }
.oh-left-col { .oh-left-col {
border-bottom: 1px solid #aaa; border-bottom: 1px solid #aaa;
margin: 0; margin: 0;
margin-left: 10px;
width: 0.5em; width: 0.5em;
font-size: large; font-size: large;
padding: 0; padding: 0;
padding-right: 0.2em; 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 { .oh-draggable-header {
background-color: blue; background-color: blue;
height: 0.5em; height: 0.5em;
@ -56,23 +110,25 @@
.oh-timerange { .oh-timerange {
border-radius: 0.5em; border-radius: 0.5em;
margin: 2px; margin-left: 2px;
display: block; display: block;
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 0;
width: 100%; width: calc(100% - 4px);
background: orange; background: #0048ff;
z-index: 1; z-index: 1;
box-sizing: border-box box-sizing: border-box;
} }
.oh-timerange-inner { .oh-timerange-inner {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
overflow-x: hidden;
justify-content: space-between; justify-content: space-between;
align-content: center; align-content: center;
height: 100%; height: 100%;
overflow-y: hidden;
} }
.oh-timerange-inner input { .oh-timerange-inner input {

View file

@ -1,7 +1,6 @@
#! /bin/bash #! /bin/bash
cd assets/ cd assets/ && wget https://osmlab.github.io/editor-layer-index/imagery.geojson --output-document=editor-layer-index.json
wget https://osmlab.github.io/editor-layer-index/imagery.geojson --output-document=editor-layer-index.json
cd .. cd ..
mkdir -p assets/generated 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")
/*/ /*/