Hide edit buttons when not logged in, css tweaks

This commit is contained in:
Pieter Vander Vennet 2020-07-13 16:18:04 +02:00
parent bedb55e25f
commit ff1690e307
11 changed files with 50 additions and 29 deletions

View file

@ -5,13 +5,14 @@ import {Statues} from "./Layouts/Statues";
import {Bookcases} from "./Layouts/Bookcases"; import {Bookcases} from "./Layouts/Bookcases";
import Cyclofix from "./Layouts/Cyclofix"; import Cyclofix from "./Layouts/Cyclofix";
import {All} from "./Layouts/All"; import {All} from "./Layouts/All";
import {Layout} from "./Layout";
export class AllKnownLayouts { export class AllKnownLayouts {
public static allSets: any = AllKnownLayouts.AllLayouts(); public static allSets: any = AllKnownLayouts.AllLayouts();
private static AllLayouts() { private static AllLayouts() : any{
const all = new All(); const all = new All();
const layouts = [ const layouts : Layout[] = [
new Groen(), new Groen(),
new GRB(), new GRB(),
new Cyclofix(), new Cyclofix(),

View file

@ -145,7 +145,7 @@ export class Bookcases extends LayerDefinition {
new TagRenderingOptions({ new TagRenderingOptions({
freeform: { freeform: {
key: "description", key: "description",
renderTemplate: "<b>Beschrijving door de uitbater</b><br>{description}", renderTemplate: "<b>Beschrijving door de uitbater:</b><br>{description}",
template: "$$$", template: "$$$",
} }
}) })

View file

@ -16,6 +16,7 @@ export class Layout {
public startLat: number; public startLat: number;
public welcomeTail: string; public welcomeTail: string;
public locationContains: string[];
constructor( constructor(
name: string, name: string,
@ -41,13 +42,5 @@ export class Layout {
this.welcomeTail = welcomeTail; this.welcomeTail = welcomeTail;
} }
/*
static statues = new Layout(
);
*/
} }

View file

@ -23,5 +23,6 @@ export class Bookcases extends Layout{
" </a> of door je " + " </a> of door je " +
" <span onclick=\"authOsm()\" class=\"activate-osm-authentication\">aan te melden</span>.</p>", " <span onclick=\"authOsm()\" class=\"activate-osm-authentication\">aan te melden</span>.</p>",
"Klik op een boekenruilkastje om vragen te beantwoorden"); "Klik op een boekenruilkastje om vragen te beantwoorden");
this.locationContains= ["Bookcases.html", "Bookcase.html","bookcase"]
} }
} }

View file

@ -47,5 +47,7 @@ export class Groen extends Layout {
"Als je inlogt, komt er een tweede cookie bij met je inloggegevens." + "Als je inlogt, komt er een tweede cookie bij met je inloggegevens." +
"</small>" "</small>"
); );
this.locationContains = ["buurtnatuur.be"]
} }
} }

View file

@ -11,6 +11,7 @@ import {UIRadioButtonWithOther} from "../UI/Base/UIRadioButtonWithOther";
import {VariableUiElement} from "../UI/Base/VariableUIElement"; import {VariableUiElement} from "../UI/Base/VariableUIElement";
import {TagDependantUIElement, TagDependantUIElementConstructor} from "./UIElementConstructor"; import {TagDependantUIElement, TagDependantUIElementConstructor} from "./UIElementConstructor";
import {OnlyShowIfConstructor} from "./OnlyShowIf"; import {OnlyShowIfConstructor} from "./OnlyShowIf";
import {UserDetails} from "../Logic/OsmConnection";
export class TagRenderingOptions implements TagDependantUIElementConstructor { export class TagRenderingOptions implements TagDependantUIElementConstructor {
@ -111,6 +112,7 @@ class TagRendering extends UIElement implements TagDependantUIElement {
private _priority: number; private _priority: number;
private _userDetails: UIEventSource<UserDetails>;
Priority(): number { Priority(): number {
return this._priority; return this._priority;
@ -162,6 +164,9 @@ class TagRendering extends UIElement implements TagDependantUIElement {
this.ListenTo(this._questionSkipped); this.ListenTo(this._questionSkipped);
this.ListenTo(this._editMode); this.ListenTo(this._editMode);
this._userDetails = changes.login.userDetails;
this.ListenTo(this._userDetails);
this._question = options.question; this._question = options.question;
this._priority = options.priority ?? 0; this._priority = options.priority ?? 0;
this._primer = options.primer ?? ""; this._primer = options.primer ?? "";
@ -397,8 +402,14 @@ class TagRendering extends UIElement implements TagDependantUIElement {
if (html == "") { if (html == "") {
return ""; return "";
} }
let editButton = "";
if(this._userDetails.data.loggedIn){
editButton = this._editButton.Render();
}
return "<span class='answer'>" + return "<span class='answer'>" +
"<span class='answer-text'>" + html + "</span>" + this._editButton.Render() + "<span class='answer-text'>" + html + "</span>" +
editButton +
"</span>"; "</span>";
} }

View file

@ -13,7 +13,7 @@ export class Changes {
private static _nextId = -1; // New assined ID's are negative private static _nextId = -1; // New assined ID's are negative
private readonly login: OsmConnection; public readonly login: OsmConnection;
public readonly _allElements: ElementStorage; public readonly _allElements: ElementStorage;
private _pendingChanges: { elementId: string, key: string, value: string }[] = []; // Gets reset on uploadAll private _pendingChanges: { elementId: string, key: string, value: string }[] = []; // Gets reset on uploadAll

View file

@ -7,6 +7,7 @@ import {VerticalCombine} from "../Base/VerticalCombine";
import {Changes} from "../../Logic/Changes"; import {Changes} from "../../Logic/Changes";
import {VariableUiElement} from "../Base/VariableUIElement"; import {VariableUiElement} from "../Base/VariableUIElement";
import {ConfirmDialog} from "../ConfirmDialog"; import {ConfirmDialog} from "../ConfirmDialog";
import {UserDetails} from "../../Logic/OsmConnection";
export class ImageCarousel extends UIElement { export class ImageCarousel extends UIElement {
@ -19,8 +20,11 @@ export class ImageCarousel extends UIElement {
private readonly _deleteButton: UIElement; private readonly _deleteButton: UIElement;
private readonly _isDeleted: UIElement; private readonly _isDeleted: UIElement;
private readonly _userDetails : UIEventSource<UserDetails>;
constructor(tags: UIEventSource<any>, changes: Changes) { constructor(tags: UIEventSource<any>, changes: Changes) {
super(tags); super(tags);
this._userDetails = changes.login.userDetails;
const self = this; const self = this;
this.searcher = new ImageSearcher(tags, changes); this.searcher = new ImageSearcher(tags, changes);
@ -40,8 +44,11 @@ export class ImageCarousel extends UIElement {
const showDeleteButton = this.slideshow._currentSlide.map((i) => { const showDeleteButton = this.slideshow._currentSlide.map((i) => {
if(!self._userDetails.data.loggedIn){
return false;
}
return self.searcher.IsDeletable(self.searcher.data[i]); return self.searcher.IsDeletable(self.searcher.data[i]);
}, [this.searcher]); }, [this.searcher, this._userDetails]);
this.slideshow._currentSlide.addCallback(() => { this.slideshow._currentSlide.addCallback(() => {
showDeleteButton.ping(); // This pings the showDeleteButton, which indicates that it has to hide it's subbuttons showDeleteButton.ping(); // This pings the showDeleteButton, which indicates that it has to hide it's subbuttons
}) })
@ -57,8 +64,7 @@ export class ImageCarousel extends UIElement {
"<span>Afbeelding verwijderen</span>", "<span>Afbeelding verwijderen</span>",
"<span>Terug</span>", "<span>Terug</span>",
deleteCurrent, deleteCurrent,
() => { () => { },
},
'delete-image-confirm', 'delete-image-confirm',
'delete-image-cancel'); 'delete-image-cancel');
@ -75,7 +81,6 @@ export class ImageCarousel extends UIElement {
this._isDeleted = new VariableUiElement( this._isDeleted = new VariableUiElement(
mapping mapping
) )
// .HideOnEmpty(true);
this.searcher._deletedImages.addCallback(() => { this.searcher._deletedImages.addCallback(() => {
this.slideshow._currentSlide.ping(); this.slideshow._currentSlide.ping();

View file

@ -573,7 +573,7 @@ form {
/***************** Info box (box containing features and questions ******************/ /***************** Info box (box containing features and questions ******************/
.leaflet-popup-content { .leaflet-popup-content {
width: 25vw !important; width: 40em !important;
} }
.featureinfobox { .featureinfobox {
@ -669,7 +669,6 @@ form {
background-color: #e5f5ff; background-color: #e5f5ff;
padding: 1em; padding: 1em;
border-radius: 1em; border-radius: 1em;
margin-right: 1em;
font-size: larger; font-size: larger;
} }

View file

@ -48,15 +48,6 @@
<script src="./index.ts"></script> <script src="./index.ts"></script>
<script src="vendor/Leaflet.AccuratePosition.js"></script> <script src="vendor/Leaflet.AccuratePosition.js"></script>
<!-- 3 dagen eerste protoype -->
<!-- 19 juni: eerste feedbackronde, foto's -->
<!-- 23 juni: wikimedia foto's laden -->
<!-- 24 juni: foto's via imgur -->
<!-- 26 restylen infobox -->
<!-- 27 restylen infobox, flow UI verbeteren, mobile, locate-me -->
<!-- 28: user testing, fixing issues and faults, lots of small useless features, add button vs 2.0 -->
<script data-goatcounter="https://pietervdvn.goatcounter.com/count" <script data-goatcounter="https://pietervdvn.goatcounter.com/count"
async src="//gc.zgo.at/count.js"></script> async src="//gc.zgo.at/count.js"></script>

View file

@ -21,6 +21,7 @@ import {VariableUiElement} from "./UI/Base/VariableUIElement";
import {SearchAndGo} from "./UI/SearchAndGo"; import {SearchAndGo} from "./UI/SearchAndGo";
import {CollapseButton} from "./UI/Base/CollapseButton"; import {CollapseButton} from "./UI/Base/CollapseButton";
import {AllKnownLayouts} from "./Customizations/AllKnownLayouts"; import {AllKnownLayouts} from "./Customizations/AllKnownLayouts";
import {All} from "./Customizations/Layouts/All";
@ -50,6 +51,23 @@ if (location.hostname === "localhost" || location.hostname === "127.0.0.1") {
let defaultQuest = "buurtnatuur" let defaultQuest = "buurtnatuur"
for (const k in AllKnownLayouts.allSets) {
const layout = AllKnownLayouts.allSets[k];
const possibleParts = layout.locationContains ?? [];
console.log(layout.locationContains)
for (const locationMatch of possibleParts) {
if(locationMatch === ""){
continue
}
console.log(layout.name," -> ", locationMatch, window.location.href.indexOf(locationMatch))
if(window.location.href.toLowerCase().indexOf(locationMatch.toLowerCase()) >= 0){
defaultQuest = layout.name;
console.log("Detected a default by URL: ", layout.name, "matches", locationMatch)
}
}
}
if (window.location.search) { if (window.location.search) {
const params = window.location.search.substr(1).split("&"); const params = window.location.search.substr(1).split("&");
const paramDict: any = {}; const paramDict: any = {};