Last active
January 27, 2024 10:55
-
-
Save svierk/ce6d65325187ba3f59ffbcee9480b9d4 to your computer and use it in GitHub Desktop.
JS Code for Content Document Table LWC | Columns & Data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class ContentDocumentTable extends NavigationMixin(LightningElement) { | |
@api recordId = null; | |
@api library = 'Documents'; | |
@api folder = null; | |
@api showCard = false; | |
@api cardIcon = 'standard:file'; | |
@api cardTitle = 'Document Table'; | |
@api showDownloadAction = false; | |
@api showViewAction = false; | |
@api showDeleteAction = false; | |
@track columns = COLUMNS; | |
@track documents = []; | |
@track wiredRecords = []; | |
isLoading = true; | |
@wire(getDocuments, { | |
library: '$library', | |
folder: '$folder', | |
recordId: '$recordId' | |
}) | |
wiredGetRecords(result) { | |
this.wiredRecords = result; | |
if (result.data) { | |
const documents = JSON.parse(result.data); | |
if (Array.isArray(documents)) { | |
documents.forEach((element) => { | |
element.icon = ICONS[element.FileExtension] ? ICONS[element.FileExtension] : ICONS.default; | |
element.preview = { | |
id: element.Id, | |
name: element.Title | |
}; | |
if (element.ContentSize) element.ContentSize = this.formatSize(element.ContentSize); | |
}); | |
this.documents = JSON.parse(JSON.stringify(documents)); | |
} | |
this.isLoading = false; | |
} | |
} | |
connectedCallback() { | |
this.columns = COLUMNS.slice(); | |
this.addRowActions(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment