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 Cyclofix from "./Layouts/Cyclofix";
import {All} from "./Layouts/All";
import {Layout} from "./Layout";
export class AllKnownLayouts {
public static allSets: any = AllKnownLayouts.AllLayouts();
private static AllLayouts() {
private static AllLayouts() : any{
const all = new All();
const layouts = [
const layouts : Layout[] = [
new Groen(),
new GRB(),
new Cyclofix(),

View file

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

View file

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

View file

@ -23,5 +23,6 @@ export class Bookcases extends Layout{
" </a> of door je " +
" <span onclick=\"authOsm()\" class=\"activate-osm-authentication\">aan te melden</span>.</p>",
"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." +
"</small>"
);
this.locationContains = ["buurtnatuur.be"]
}
}

View file

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

View file

@ -13,7 +13,7 @@ export class Changes {
private static _nextId = -1; // New assined ID's are negative
private readonly login: OsmConnection;
public readonly login: OsmConnection;
public readonly _allElements: ElementStorage;
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 {VariableUiElement} from "../Base/VariableUIElement";
import {ConfirmDialog} from "../ConfirmDialog";
import {UserDetails} from "../../Logic/OsmConnection";
export class ImageCarousel extends UIElement {
@ -18,10 +19,13 @@ export class ImageCarousel extends UIElement {
private readonly _deleteButton: UIElement;
private readonly _isDeleted: UIElement;
private readonly _userDetails : UIEventSource<UserDetails>;
constructor(tags: UIEventSource<any>, changes: Changes) {
super(tags);
this._userDetails = changes.login.userDetails;
const self = this;
this.searcher = new ImageSearcher(tags, changes);
@ -40,8 +44,11 @@ export class ImageCarousel extends UIElement {
const showDeleteButton = this.slideshow._currentSlide.map((i) => {
if(!self._userDetails.data.loggedIn){
return false;
}
return self.searcher.IsDeletable(self.searcher.data[i]);
}, [this.searcher]);
}, [this.searcher, this._userDetails]);
this.slideshow._currentSlide.addCallback(() => {
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>Terug</span>",
deleteCurrent,
() => {
},
() => { },
'delete-image-confirm',
'delete-image-cancel');
@ -75,7 +81,6 @@ export class ImageCarousel extends UIElement {
this._isDeleted = new VariableUiElement(
mapping
)
// .HideOnEmpty(true);
this.searcher._deletedImages.addCallback(() => {
this.slideshow._currentSlide.ping();

View file

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

View file

@ -48,15 +48,6 @@
<script src="./index.ts"></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"
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 {CollapseButton} from "./UI/Base/CollapseButton";
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"
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) {
const params = window.location.search.substr(1).split("&");
const paramDict: any = {};