Fixed icon's src in d4s-storage-folder

This commit is contained in:
Vincenzo Cestone 2022-05-02 12:21:55 +02:00
parent cf2e4b4313
commit e8151b580f
1 changed files with 11 additions and 5 deletions

View File

@ -1,3 +1,5 @@
var D4S_STORAGE_SCRIPT = document.currentScript
/**
* Base class of <d4s-storage-tree> and <d4s-storage-folder>
*/
@ -243,15 +245,19 @@ window.customElements.define('d4s-storage-folder', class extends D4SStorageHtmlE
#d4sstorageTree = null
#selectedbgcolor = 'lightgray'
#srcbaseurl = null
constructor() {
super()
if (D4S_STORAGE_SCRIPT) {
const d4ssrc = D4S_STORAGE_SCRIPT.src
this.#srcbaseurl = (d4ssrc) ? d4ssrc.substring(0, d4ssrc.lastIndexOf('/')) : ""
}
}
connectedCallback() {
const shadowRoot = this.attachShadow({mode: 'open'})
this.appendStylesheets(shadowRoot)
const style = document.createElement('style')
style.innerHTML = `
span {
@ -334,13 +340,13 @@ window.customElements.define('d4s-storage-folder', class extends D4SStorageHtmlE
}
iconTag(item) {
var i = `<img src="/storage/img/file-earmark.svg"></img>`
var i = `<img src="${this.#srcbaseurl}/img/file-earmark.svg"></img>`
if (item['@class'].includes('FolderItem')) {
i = `<img src="/storage/img/folder.svg"></img>`
i = `<img src="${this.#srcbaseurl}/img/folder.svg"></img>`
} else if (item['@class'].includes('ImageFile')) {
i = `<img src="/storage/img/image.svg"></img>`
i = `<img src="${this.#srcbaseurl}/img/image.svg"></img>`
} else if (item['@class'].includes('PDFFileItem')) {
i = `<img src="/storage/img/filetype-pdf.svg"></img>`
i = `<img src="${this.#srcbaseurl}/img/filetype-pdf.svg"></img>`
}
return '<span class="px-2">' + i + '</span>'
}