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
<template> | |
<lightning-icon class="slds-current-color" icon-name={icon} size="small"></lightning-icon> | |
</template> |
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
<template> | |
<template lwc:if={isLoading}> | |
<lightning-spinner alternative-text="Loading" variant="brand"></lightning-spinner> | |
</template> | |
<template lwc:if={showCard}> | |
<lightning-card icon-name={cardIcon} title={cardTitle}> | |
<c-content-document-table-extension | |
key-field="id" | |
columns={columns} | |
data={documents} |
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
<template> | |
<a onclick={showPreview}>{preview.name}</a> | |
</template> |
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
import { CurrentPageReference, NavigationMixin } from 'lightning/navigation'; | |
import { LightningElement, api, wire } from 'lwc'; | |
export default class ContentDocumentPreview extends NavigationMixin(LightningElement) { | |
@wire(CurrentPageReference) pageRef; | |
@api preview; | |
showPreview() { | |
this[NavigationMixin.Navigate]({ | |
type: 'standard__namedPage', |
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
import LightningDatatable from 'lightning/datatable'; | |
import contentDocumentIcon from './contentDocumentIcon.html'; | |
import contentDocumentPreview from './contentDocumentPreview.html'; | |
export default class ContentDocumentTableExtension extends LightningDatatable { | |
static customTypes = { | |
contentDocumentIcon: { | |
template: contentDocumentIcon, | |
standardCellLayout: true, | |
typeAttributes: ['icon'] |
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
@AuraEnabled | |
public static string getLatestVersion(Id recordId) { | |
return [ | |
SELECT Id, IsLatest, Title, ContentDocumentId | |
FROM ContentVersion | |
WHERE ContentDocumentId = :recordId AND isLatest = TRUE | |
WITH USER_MODE | |
LIMIT 1 | |
] | |
.Id; |
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
@AuraEnabled(cacheable=true) | |
public static String getDocuments(String library, String folder, Id recordId) { | |
try { | |
String folderName = folder != null ? folder : recordId.getSObjectType().getDescribe().getName(); | |
// get workspace library | |
ContentWorkspace cw = [ | |
SELECT Id, Name | |
FROM ContentWorkspace | |
WHERE Name LIKE :library |
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
@TestSetup | |
static void makeData() { | |
User u = new User(); | |
u.FirstName = 'Test'; | |
u.LastName = 'User'; | |
u.Username = '[email protected]'; | |
u.Alias = '123test'; | |
u.Email = '[email protected]'; | |
u.ProfileId = [SELECT Id FROM Profile WHERE Name = 'System Administrator' LIMIT 1].Id; | |
u.TimeZoneSidKey = 'America/Chicago'; |
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
private static Id createContentSetup(Id recordId) { | |
ContentWorkspace cw = getContentWorkspace('Test Documents'); | |
insert cw; | |
ContentFolderLink cfl = [ | |
SELECT Id, ContentFolderId, ParentEntityId | |
FROM ContentFolderLink | |
WHERE ParentEntityId = :cw.Id | |
]; | |
ContentFolder cf = getContentFolder(recordId.getSObjectType().getDescribe().getName(), cfl.ContentFolderId); | |
insert cf; |
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
handleDragStart(event) { | |
event.dataTransfer.setData('id', event.target.dataset.id); | |
event.dataTransfer.setData('label', event.target.dataset.name); | |
} | |
handleDragOver(event) { | |
event.preventDefault(); | |
event.currentTarget.style = 'background-color: pink; border-color:red;'; | |
} |