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> * 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 #d4sstorageTree = null
#selectedbgcolor = 'lightgray' #selectedbgcolor = 'lightgray'
#srcbaseurl = null
constructor() { constructor() {
super() super()
if (D4S_STORAGE_SCRIPT) {
const d4ssrc = D4S_STORAGE_SCRIPT.src
this.#srcbaseurl = (d4ssrc) ? d4ssrc.substring(0, d4ssrc.lastIndexOf('/')) : ""
}
} }
connectedCallback() { connectedCallback() {
const shadowRoot = this.attachShadow({mode: 'open'}) const shadowRoot = this.attachShadow({mode: 'open'})
this.appendStylesheets(shadowRoot) this.appendStylesheets(shadowRoot)
const style = document.createElement('style') const style = document.createElement('style')
style.innerHTML = ` style.innerHTML = `
span { span {
@ -334,13 +340,13 @@ window.customElements.define('d4s-storage-folder', class extends D4SStorageHtmlE
} }
iconTag(item) { 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')) { 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')) { } 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')) { } 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>' return '<span class="px-2">' + i + '</span>'
} }