-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add delete multiple files and file preview
Added ability to delete multiple files. Extended datatable to show file previews when hovering on a link on both files and version tables
- Loading branch information
Showing
18 changed files
with
154 additions
and
15 deletions.
There are no files selected for viewing
Empty file.
This file contains 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
1 change: 1 addition & 0 deletions
1
force-app/main/default/lwc/customDatatable/customDatatable.html
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<template> </template> |
11 changes: 11 additions & 0 deletions
11
force-app/main/default/lwc/customDatatable/customDatatable.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import LightningDataTable from "lightning/datatable"; | ||
import linkPreview from "./linkPreview.html"; | ||
|
||
export default class CustomDatatable extends LightningDataTable { | ||
static customTypes = { | ||
filePreview: { | ||
template: linkPreview, | ||
typeAttributes: ["anchorText", "versionId"] | ||
} | ||
}; | ||
} |
5 changes: 5 additions & 0 deletions
5
force-app/main/default/lwc/customDatatable/customDatatable.js-meta.xml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>48.0</apiVersion> | ||
<isExposed>false</isExposed> | ||
</LightningComponentBundle> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<template> | ||
<c-file-preview-col data-navigation="enable" file-id={value} label={typeAttributes.anchorText} version-id={typeAttributes.versionId}></c-file-preview-col> | ||
<!--<a href={value} data-link={typeAttributes.anchorText}>{typeAttributes.anchorText}</a> --> | ||
</template> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.overlay { | ||
position: fixed; | ||
z-index: 101; | ||
left: 30px; | ||
height: 5rem; | ||
} |
8 changes: 8 additions & 0 deletions
8
force-app/main/default/lwc/filePreviewCol/filePreviewCol.html
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<template> | ||
<a href={url} onmouseover={handleMouseOver} onmouseout={handleMouseOut}>{label}</a> | ||
<template if:true={showPreview}> | ||
<div class="overlay"> | ||
<c-file-preview-comp file-id={fileOrVersionId} height-in-rem="1.25"></c-file-preview-comp> | ||
</div> | ||
</template> | ||
</template> |
26 changes: 26 additions & 0 deletions
26
force-app/main/default/lwc/filePreviewCol/filePreviewCol.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { LightningElement, api } from "lwc"; | ||
import { baseNavigation } from "lightning/datatableKeyboardMixins"; | ||
import template from "./filePreviewCol.html"; | ||
|
||
export default class FilePreviewCol extends LightningElement { | ||
showPreview = false; | ||
@api fileId = ""; | ||
@api label = ""; | ||
@api versionId = ""; | ||
|
||
get url() { | ||
return this.fileId ? "/" + this.fileId : "#"; | ||
} | ||
|
||
get fileOrVersionId() { | ||
return this.versionId || this.fileId; | ||
} | ||
|
||
handleMouseOver() { | ||
this.showPreview = true; | ||
} | ||
|
||
handleMouseOut() { | ||
this.showPreview = false; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
force-app/main/default/lwc/filePreviewCol/filePreviewCol.js-meta.xml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>48.0</apiVersion> | ||
<isExposed>false</isExposed> | ||
</LightningComponentBundle> |
8 changes: 8 additions & 0 deletions
8
force-app/main/default/lwc/filePreviewComp/filePreviewComp.html
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<template> | ||
<template if:true={url}> | ||
<img src={url} onerror={fallback}></img> | ||
</template> | ||
<template if:false={url}> | ||
<lightning-card>No PDF File ID found. Please specify PDF File ID.</lightning-card> | ||
</template> | ||
</template> |
25 changes: 25 additions & 0 deletions
25
force-app/main/default/lwc/filePreviewComp/filePreviewComp.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { LightningElement, api } from "lwc"; | ||
import NOPREVIEWIMGURL from "@salesforce/resourceUrl/nopreviewimg"; | ||
|
||
export default class FilePreviewComp extends LightningElement { | ||
@api fileId; | ||
@api heightInRem; | ||
|
||
get baseUrl() { | ||
return `https://${ | ||
window.location.hostname.split(".")[0] | ||
}--c.documentforce.com`; | ||
} | ||
|
||
get url() { | ||
return `${this.baseUrl}/sfc/servlet.shepherd/version/renditionDownload?rendition=THUMB720BY480&versionId=${this.fileId}&operationContext=CHATTER&page=0`; | ||
} | ||
|
||
fallback(event) { | ||
if (event.target.src != NOPREVIEWIMGURL) { | ||
event.target.src = NOPREVIEWIMGURL; | ||
this.template.querySelector("img").style.width = "200px"; | ||
this.template.querySelector("img").style.height = "100px"; | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
force-app/main/default/lwc/filePreviewComp/filePreviewComp.js-meta.xml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>48.0</apiVersion> | ||
<isExposed>false</isExposed> | ||
</LightningComponentBundle> |
This file contains 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
This file contains 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions
5
force-app/main/default/staticresources/nopreviewimg.resource-meta.xml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<StaticResource xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<cacheControl>Private</cacheControl> | ||
<contentType>image/png</contentType> | ||
</StaticResource> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ | |
"namespace": "", | ||
"sfdcLoginUrl": "https://login.salesforce.com", | ||
"sourceApiVersion": "48.0" | ||
} | ||
} |
e0abff2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Closes #6