diff --git a/Logic/Web/ImgurUploader.ts b/Logic/Web/ImgurUploader.ts index 851b9c53f..67392086d 100644 --- a/Logic/Web/ImgurUploader.ts +++ b/Logic/Web/ImgurUploader.ts @@ -26,7 +26,7 @@ export default class ImgurUploader { function (url) { console.log("File saved at", url); self.success.setData([...self.success.data, url]); - this. handleSuccessUrl(url); + self._handleSuccessUrl(url); }, function () { console.log("All uploads completed"); diff --git a/UI/Image/DeleteImage.ts b/UI/Image/DeleteImage.ts index 656b9160d..f49deeb1b 100644 --- a/UI/Image/DeleteImage.ts +++ b/UI/Image/DeleteImage.ts @@ -9,49 +9,47 @@ import {Tag} from "../../Logic/Tags/Tag"; import BaseUIElement from "../BaseUIElement"; -export default class DeleteImage extends UIElement { - private readonly key: string; - private readonly tags: UIEventSource; - - private readonly isDeletedBadge: BaseUIElement; - private readonly deleteDialog: BaseUIElement; +export default class DeleteImage extends Toggle { constructor(key: string, tags: UIEventSource) { - super(tags); - this.tags = tags; - this.key = key; - - this.isDeletedBadge = Translations.t.image.isDeleted; + const oldValue = tags.data[key] + const isDeletedBadge = Translations.t.image.isDeleted.Clone() + .SetClass("rounded-full p-1") + .SetStyle("color:white;background:#ff8c8c") + .onClick(() => { + State.state?.changes?.addTag(tags.data.id, new Tag(key, oldValue), tags); + }); const deleteButton = Translations.t.image.doDelete.Clone() .SetClass("block w-full pl-4 pr-4") .SetStyle("color:white;background:#ff8c8c; border-top-left-radius:30rem; border-top-right-radius: 30rem;") .onClick(() => { - State.state?.changes.addTag(tags.data.id, new Tag(key, "")); + State.state?.changes?.addTag(tags.data.id, new Tag(key, ""), tags); }); - const cancelButton = Translations.t.general.cancel.SetClass("bg-white pl-4 pr-4").SetStyle( "border-bottom-left-radius:30rem; border-bottom-right-radius: 30rem;"); - this.deleteDialog = new Toggle( + const cancelButton = Translations.t.general.cancel.Clone().SetClass("bg-white pl-4 pr-4").SetStyle("border-bottom-left-radius:30rem; border-bottom-right-radius: 30rem;"); + const openDelete = Svg.delete_icon_svg().SetStyle("width: 2em; height: 2em; display:block;") + const deleteDialog = new Toggle( new Combine([ deleteButton, cancelButton ]).SetClass("flex flex-col background-black"), - Svg.delete_icon_svg().SetStyle("width: 2em; height: 2em; display:block;") - ).ToggleOnClick() + openDelete + ) - } + cancelButton.onClick(() => deleteDialog.isEnabled.setData(false)) + openDelete.onClick(() => deleteDialog.isEnabled.setData(true)) - InnerRender() { - if(! State.state?.featureSwitchUserbadge?.data){ - return ""; - } - - const value = this.tags.data[this.key]; - if (value === undefined || value === "") { - return this.isDeletedBadge; - } - - return this.deleteDialog; + super( + new Toggle( + deleteDialog, + isDeletedBadge, + tags.map(tags => (tags[key] ?? "") !== "") + ), + undefined /*Login (and thus editing) is disabled*/, + State.state?.featureSwitchUserbadge ?? new UIEventSource(true) + ) + this.SetClass("cursor-pointer") } } \ No newline at end of file diff --git a/UI/Image/ImageUploadFlow.ts b/UI/Image/ImageUploadFlow.ts index 8de6ad4f9..cf5881f64 100644 --- a/UI/Image/ImageUploadFlow.ts +++ b/UI/Image/ImageUploadFlow.ts @@ -28,7 +28,7 @@ export class ImageUploadFlow extends Toggle { key = imagePrefix + ":" + freeIndex; } console.log("Adding image:" + key, url); - State.state.changes.addTag(tags.id, new Tag(key, url)); + State.state.changes.addTag(tags.id, new Tag(key, url), tagsSource); }) @@ -47,7 +47,7 @@ export class ImageUploadFlow extends Toggle { } console.log("Received images from the user, starting upload") - const license = licensePicker.GetValue().data ?? "CC0" + const license = licensePicker.GetValue()?.data ?? "CC0" const tags = tagsSource.data; diff --git a/UI/Image/SlideShow.ts b/UI/Image/SlideShow.ts index 01b6cbe5e..8c7fb1a2c 100644 --- a/UI/Image/SlideShow.ts +++ b/UI/Image/SlideShow.ts @@ -1,6 +1,5 @@ import {UIEventSource} from "../../Logic/UIEventSource"; import BaseUIElement from "../BaseUIElement"; -import $ from "jquery" export class SlideShow extends BaseUIElement { @@ -15,15 +14,29 @@ export class SlideShow extends BaseUIElement { protected InnerConstructElement(): HTMLElement { const el = document.createElement("div") el.classList.add("slic-carousel") + el.style.overflowX = "auto" + el.style.width = "min-content" + el.style.minWidth = "min-content" + el.style.display = "flex" this.embeddedElements.addCallbackAndRun(elements => { + while (el.firstChild) { + el.removeChild(el.lastChild) + } + for (const element of elements ?? []) { - element.SetClass("slick-carousel-content") + element.SetClass("block ml-1") + .SetStyle("width: 300px; max-height: var(--image-carousel-height); height: var(--image-carousel-height)") + el.appendChild(element.ConstructElement()) } }); - return el; + const wrapper = document.createElement("div") + wrapper.style.maxWidth = "100%" + wrapper.style.overflowX = "auto" + wrapper.appendChild(el) + return wrapper; } } \ No newline at end of file diff --git a/UI/Input/DropDown.ts b/UI/Input/DropDown.ts index 91f1d700e..fe8f8bc98 100644 --- a/UI/Input/DropDown.ts +++ b/UI/Input/DropDown.ts @@ -21,6 +21,8 @@ export class DropDown extends InputElement { } ) { super(); + value = value ?? new UIEventSource(undefined) + this._value = value this._values = values; if (values.length <= 1) { return; @@ -43,7 +45,7 @@ export class DropDown extends InputElement { el.appendChild(labelHtml) } } - + options = options ?? {} options.select_class = options.select_class ?? 'bg-indigo-100 p-1 rounded hover:bg-indigo-200' diff --git a/UI/Input/TextField.ts b/UI/Input/TextField.ts index 2071d7480..ff9101381 100644 --- a/UI/Input/TextField.ts +++ b/UI/Input/TextField.ts @@ -106,7 +106,7 @@ export class TextField extends InputElement { newCursorPos--; } // @ts-ignore - TextField.SetCursorPosition(newCursorPos); + TextField.SetCursorPosition(field, newCursorPos); }; diff --git a/UI/Popup/FeatureInfoBox.ts b/UI/Popup/FeatureInfoBox.ts index 64ffe59a2..7f375d298 100644 --- a/UI/Popup/FeatureInfoBox.ts +++ b/UI/Popup/FeatureInfoBox.ts @@ -53,7 +53,7 @@ export default class FeatureInfoBox extends ScrollableFullScreen { } let questionBoxIsUsed = false; - const renderings = layerConfig.tagRenderings.map(tr => { + const renderings : BaseUIElement[] = layerConfig.tagRenderings.map(tr => { if (tr.question === null) { // This is the question box! questionBoxIsUsed = true; diff --git a/UI/ShowDataLayer.ts b/UI/ShowDataLayer.ts index 6a2a8953d..d559b7cf2 100644 --- a/UI/ShowDataLayer.ts +++ b/UI/ShowDataLayer.ts @@ -126,22 +126,23 @@ export default class ShowDataLayer { closeButton: false }, leafletLayer); - leafletLayer.bindPopup(popup); - - let infobox : FeatureInfoBox = undefined; - + leafletLayer.bindPopup(popup); + + let infobox: FeatureInfoBox = undefined; + const id = `popup-${feature.properties.id}-${this._cleanCount}` - popup.setContent(`
Rendering
`) + popup.setContent(`
Rendering
`) leafletLayer.on("popupopen", () => { State.state.selectedElement.setData(feature) - if (infobox === undefined) { + if (infobox === undefined) { const tags = State.state.allElements.getEventSourceById(feature.properties.id); infobox = new FeatureInfoBox(tags, layer); infobox.isShown.addCallback(isShown => { if (!isShown) { State.state.selectedElement.setData(undefined); + leafletLayer.closePopup() } }); } @@ -162,7 +163,7 @@ export default class ShowDataLayer { leafletLayer.openPopup() } }) - + } private CreateGeojsonLayer(): L.Layer { diff --git a/Utils.ts b/Utils.ts index dc1d416a4..ba18b98d9 100644 --- a/Utils.ts +++ b/Utils.ts @@ -108,7 +108,7 @@ export class Utils { } public static EllipsesAfter(str: string, l: number = 100) { - if (str === undefined) { + if (str === undefined || str === null) { return undefined; } if (str.length <= l) { diff --git a/css/mobile.css b/css/mobile.css index 1d0b523eb..a9b321f2d 100644 --- a/css/mobile.css +++ b/css/mobile.css @@ -55,6 +55,10 @@ Contains tweaks for small screens .leaflet-control-attribution{ display: none; } + + .leaflet-popup { + display: none; + } } diff --git a/css/slideshow.css b/css/slideshow.css index 7fe59c113..c5ab215d6 100644 --- a/css/slideshow.css +++ b/css/slideshow.css @@ -1,22 +1,18 @@ -.slick-next { - top: unset; - bottom: -25px; - right: 15px; - z-index: 10000; + + +.slick-carousel-content { + width: 300px; + max-height: var(--image-carousel-height); + display: block; + margin-left: 10px; } -.slick-prev { - top: unset; - bottom: -25px; - left: 0; - z-index: 10000; +.slick-carousel-content img { + /** +Workaround to patch images within a slick carousel + */ + height: var(--image-carousel-height); + width: auto; } -.slick-next::before { - font-size: 35px; -} - -.slick-prev::before { - font-size: 35px; -} \ No newline at end of file diff --git a/index.css b/index.css index 10c8df5ee..afa2d28f9 100644 --- a/index.css +++ b/index.css @@ -65,21 +65,6 @@ --image-carousel-height: 400px; } -.slick-carousel-content { - width: 300px; - max-height: var(--image-carousel-height); - display: block; - margin-left: 10px; -} - -.slick-carousel-content img { - /** -Workaround to patch images within a slick carousel - */ - height: var(--image-carousel-height); - width: auto; -} - html, body { height: 100%; min-height: 100vh; diff --git a/index.html b/index.html index 1f9df50a6..e8354f59a 100644 --- a/index.html +++ b/index.html @@ -14,7 +14,6 @@ - diff --git a/package.json b/package.json index b62ffd445..40b378ec1 100644 --- a/package.json +++ b/package.json @@ -80,14 +80,12 @@ "postcss": "^7.0.35", "prompt-sync": "^4.2.0", "sharp": "^0.27.0", - "slick-carousel": "^1.8.1", "tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.0.2", "tslint": "^6.1.3" }, "devDependencies": { "@babel/polyfill": "^7.10.4", "@types/node": "^7.0.5", - "@types/slick-carousel": "^1.6.34", "assert": "^2.0.0", "fs": "0.0.1-security", "marked": "^2.0.0", diff --git a/test.ts b/test.ts index 46333efa3..ee47136d1 100644 --- a/test.ts +++ b/test.ts @@ -10,9 +10,9 @@ const tagsSource = new UIEventSource({ name:'name', surface:'asphalt', image: "https://i.imgur.com/kX3rl3v.jpg", - "image:1": "https://i.imgur.com/kX3rl3v.jpg", + "image:1": "https://i.imgur.com/oHAJqMB.jpg", + // "opening_hours":"mo-fr 09:00-18:00", _country:"be", - // "opening_hours":"mo-fr 09:00-18:00" }) const state = new State(undefined)