Image selector errors
This commit is contained in:
		
							parent
							
								
									a9918cc2fb
								
							
						
					
					
						commit
						c5c773e82a
					
				|  | @ -11,6 +11,7 @@ function ImageSelector(form, maxFileSize, container, { | ||||||
| 	this.resetLink = container.querySelector(".imginput-reset-link"); | 	this.resetLink = container.querySelector(".imginput-reset-link"); | ||||||
| 	this.removeLink = container.querySelector(".imginput-remove-link"); | 	this.removeLink = container.querySelector(".imginput-remove-link"); | ||||||
| 	this.filenameText = container.querySelector(".imginput-filename"); | 	this.filenameText = container.querySelector(".imginput-filename"); | ||||||
|  | 	this.errorEl = container.querySelector(".error"); | ||||||
| 	this.originalImageUrl = this.imageEl.getAttribute("data-imginput-original"); | 	this.originalImageUrl = this.imageEl.getAttribute("data-imginput-original"); | ||||||
| 	this.originalImageFilename = this.imageEl.getAttribute("data-imginput-original-filename"); | 	this.originalImageFilename = this.imageEl.getAttribute("data-imginput-original-filename"); | ||||||
| 	this.currentImageUrl = this.originalImageUrl; | 	this.currentImageUrl = this.originalImageUrl; | ||||||
|  | @ -79,6 +80,8 @@ ImageSelector.prototype.updateSizeLimit = function(size) { | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| ImageSelector.prototype.setError = function(error) { | ImageSelector.prototype.setError = function(error) { | ||||||
|  | 	this.errorEl.textContent = error; | ||||||
|  | 	this.errorEl.hidden = !error; | ||||||
| 	this.fileInput.setCustomValidity(error); | 	this.fileInput.setCustomValidity(error); | ||||||
| 	this.fileInput.reportValidity(); | 	this.fileInput.reportValidity(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| {{/* NOTE(asaf): Make sure to include js/image_selector.js */}} | {{/* NOTE(asaf): Make sure to include js/image_selector.js */}} | ||||||
| <input {{ if .Required }}required{{ end }} class="imginput dn" type="file" accept="image/*" name="{{ .Name }}" /> | <input {{ if .Required }}required{{ end }} class="imginput dn" type="file" accept="image/*" name="{{ .Name }}" /> | ||||||
| <input class="imginput-remove" type="hidden" name="remove_{{ .Name }}" /> | <input class="imginput-remove" type="hidden" name="remove_{{ .Name }}" /> | ||||||
| <span class="error dn notice notice-failure mv2 mw6"></span> | <div class="error notice notice-failure pa2 b" hidden></div> | ||||||
| <div class="imginput-container pa3 flex g3 items-center"> | <div class="imginput-container pa3 flex g3 items-center"> | ||||||
| 	{{ $url := or (and .Asset .Asset.Url) "" }} | 	{{ $url := or (and .Asset .Asset.Url) "" }} | ||||||
| 	{{ $filename := or (and .Asset .Asset.Filename) "" }} | 	{{ $filename := or (and .Asset .Asset.Filename) "" }} | ||||||
|  |  | ||||||
|  | @ -639,7 +639,7 @@ type ProjectEditFormResult struct { | ||||||
| 
 | 
 | ||||||
| func ParseProjectEditForm(c *RequestContext) ProjectEditFormResult { | func ParseProjectEditForm(c *RequestContext) ProjectEditFormResult { | ||||||
| 	var res 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) | 	c.Req.Body = http.MaxBytesReader(c.Res, c.Req.Body, maxBodySize) | ||||||
| 	err := c.Req.ParseMultipartForm(maxBodySize) | 	err := c.Req.ParseMultipartForm(maxBodySize) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
|  |  | ||||||
|  | @ -16,6 +16,7 @@ | ||||||
|     - [ ] content |     - [ ] content | ||||||
|     - [ ] description |     - [ ] description | ||||||
|     - [ ] c--dim and friends |     - [ ] c--dim and friends | ||||||
|  |     - [ ] badge | ||||||
| - [x] Re-evaluate form styles | - [x] Re-evaluate form styles | ||||||
|     - [x] theme-color-light is used only for buttons |     - [x] theme-color-light is used only for buttons | ||||||
| - [x] center-layout vs. margin-center | - [x] center-layout vs. margin-center | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue