mirror of
				https://github.com/KevinMidboe/leifsopplevelser.git
				synced 2025-10-29 17:50:21 +00:00 
			
		
		
		
	Files uploaded in sessions will be appended to the end of the existing elements.
This commit is contained in:
		| @@ -2,7 +2,7 @@ | |||||||
|   <div class="form-item"> |   <div class="form-item"> | ||||||
|     <label class="title">last opp bilder</label> |     <label class="title">last opp bilder</label> | ||||||
|  |  | ||||||
|     <input id="file-upload" type="file" @change="processFile" multiple> |     <input id="file-upload" type="file" @change="processFiles" multiple> | ||||||
|     <div class="previewWindow" v-if="files.length"> |     <div class="previewWindow" v-if="files.length"> | ||||||
|       <p class="previewWindow--title">{{ files.length }} bilder lagt til</p> |       <p class="previewWindow--title">{{ files.length }} bilder lagt til</p> | ||||||
|       <div class="previewWindow--image"> |       <div class="previewWindow--image"> | ||||||
| @@ -33,17 +33,22 @@ export default { | |||||||
|     setPopoverAlbumIndex: (index) => store.dispatch('setPopoverAlbumIndex', index), |     setPopoverAlbumIndex: (index) => store.dispatch('setPopoverAlbumIndex', index), | ||||||
|     showPopover: () => store.dispatch('showPopover'), |     showPopover: () => store.dispatch('showPopover'), | ||||||
|  |  | ||||||
|     processFile(event) { |     processFiles(event) { | ||||||
|       const files = event.target.files; |       const files = event.target.files; | ||||||
|       let album = [] |       let mappedFiles = [] | ||||||
|  |       let album = this.files; | ||||||
|  |  | ||||||
|  |       // Files is a object with index keys so we need to map to a list | ||||||
|       for (var i = files.length - 1; i >= 0; i--) { |       for (var i = files.length - 1; i >= 0; i--) { | ||||||
|         album.push({ |         mappedFiles.push({ | ||||||
|           url: URL.createObjectURL(files[i]), |           url: URL.createObjectURL(files[i]), | ||||||
|           index: i, |           index: i, | ||||||
|         }) |         }) | ||||||
|       } |       } | ||||||
|       album.reverse() |  | ||||||
|  |       mappedFiles.reverse(); | ||||||
|  |       album = [...album, ...files] | ||||||
|  |       console.log('Packed uploaded album:', album) | ||||||
|  |  | ||||||
|       this.setPopoverAlbum(album) |       this.setPopoverAlbum(album) | ||||||
|       this.files = album; |       this.files = album; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user