From c5c773e82a4448cdf31ae54980db894119a2976b Mon Sep 17 00:00:00 2001 From: Asaf Gartner Date: Wed, 3 Jul 2024 10:59:40 +0300 Subject: [PATCH] Image selector errors --- public/js/image_selector.js | 3 +++ src/templates/src/include/image_selector.html | 2 +- src/website/projects.go | 2 +- todo-styles.md | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/public/js/image_selector.js b/public/js/image_selector.js index a07aedbb..4bc4d6c1 100644 --- a/public/js/image_selector.js +++ b/public/js/image_selector.js @@ -11,6 +11,7 @@ function ImageSelector(form, maxFileSize, container, { this.resetLink = container.querySelector(".imginput-reset-link"); this.removeLink = container.querySelector(".imginput-remove-link"); this.filenameText = container.querySelector(".imginput-filename"); + this.errorEl = container.querySelector(".error"); this.originalImageUrl = this.imageEl.getAttribute("data-imginput-original"); this.originalImageFilename = this.imageEl.getAttribute("data-imginput-original-filename"); this.currentImageUrl = this.originalImageUrl; @@ -79,6 +80,8 @@ ImageSelector.prototype.updateSizeLimit = function(size) { }; ImageSelector.prototype.setError = function(error) { + this.errorEl.textContent = error; + this.errorEl.hidden = !error; this.fileInput.setCustomValidity(error); this.fileInput.reportValidity(); } diff --git a/src/templates/src/include/image_selector.html b/src/templates/src/include/image_selector.html index 84bbd2a4..884891be 100644 --- a/src/templates/src/include/image_selector.html +++ b/src/templates/src/include/image_selector.html @@ -1,7 +1,7 @@ {{/* NOTE(asaf): Make sure to include js/image_selector.js */}} - +
{{ $url := or (and .Asset .Asset.Url) "" }} {{ $filename := or (and .Asset .Asset.Filename) "" }} diff --git a/src/website/projects.go b/src/website/projects.go index 6bd43101..64501267 100644 --- a/src/website/projects.go +++ b/src/website/projects.go @@ -639,7 +639,7 @@ type ProjectEditFormResult struct { func ParseProjectEditForm(c *RequestContext) ProjectEditFormResult { var res ProjectEditFormResult - maxBodySize := int64(ProjectLogoMaxFileSize*2 + 1024*1024) + maxBodySize := int64(ProjectLogoMaxFileSize + ProjectHeaderMaxFileSize + 1024*1024) c.Req.Body = http.MaxBytesReader(c.Res, c.Req.Body, maxBodySize) err := c.Req.ParseMultipartForm(maxBodySize) if err != nil { diff --git a/todo-styles.md b/todo-styles.md index 92d0a380..9a4c954f 100644 --- a/todo-styles.md +++ b/todo-styles.md @@ -16,6 +16,7 @@ - [ ] content - [ ] description - [ ] c--dim and friends + - [ ] badge - [x] Re-evaluate form styles - [x] theme-color-light is used only for buttons - [x] center-layout vs. margin-center