From 2eff2c075f724eb8d2d8e1ce247d1322b3b08835 Mon Sep 17 00:00:00 2001 From: Suraj Pillai <85.suraj@gmail.com> Date: Wed, 22 Apr 2020 00:20:50 -0400 Subject: [PATCH] Add file upload --- config/project-scratch-def.json | 2 +- .../default/classes/GetFilesController.cls | 19 ++++-- .../filesRelatedList/filesRelatedList.html | 9 ++- .../lwc/filesRelatedList/filesRelatedList.js | 64 +++++++++++++++++-- 4 files changed, 81 insertions(+), 13 deletions(-) diff --git a/config/project-scratch-def.json b/config/project-scratch-def.json index 198a1f1..2ad5a6d 100755 --- a/config/project-scratch-def.json +++ b/config/project-scratch-def.json @@ -1,7 +1,7 @@ { "orgName": "Demo company", "edition": "Developer", - "features": [], + "features": ["AuthorApex"], "settings":{ "lightningExperienceSettings":{ "enableS1DesktopEnabled": true diff --git a/force-app/main/default/classes/GetFilesController.cls b/force-app/main/default/classes/GetFilesController.cls index c0e9a32..c250681 100755 --- a/force-app/main/default/classes/GetFilesController.cls +++ b/force-app/main/default/classes/GetFilesController.cls @@ -44,8 +44,8 @@ public with sharing class GetFilesController { public static FileVersionWrapper[] getFileVersionDetails(Id fileId) { /*{{{*/ FileVersionWrapper[] contentversions = new List{}; - for (ContentVersion cv : [SELECT title, createddate, createdby.name FROM ContentVersion WHERE ContentDocumentId = :fileId]) { - contentVersions.add(new FileVersionWrapper(cv.Id, cv.title, cv.createdby.name, Date.valueOf(cv.createddate))); + for (ContentVersion cv : [SELECT title, createddate, createdby.name, VersionReason FROM ContentVersion WHERE ContentDocumentId = :fileId]) { + contentVersions.add(new FileVersionWrapper(cv.Id, cv.title, cv.createdby.name, Date.valueOf(cv.createddate), cv.VersionReason)); } return contentVersions; } /*}}}*/ @@ -68,11 +68,12 @@ public with sharing class GetFilesController { } public FilesWrapper() { + /*{{{*/ this.title = ''; this.createdBy = ''; this.createdDate = null; this.id = ''; - } + } /*}}}*/ public FilesWrapper(String id, String title, String createdBy, Date createdDate) { this.id = id; @@ -92,6 +93,8 @@ public with sharing class GetFilesController { @AuraEnabled public Date createdDate { get; set; } @AuraEnabled + public String versionReason { get; set; } + @AuraEnabled public String url { get { return '/' + this.id; @@ -100,17 +103,21 @@ public with sharing class GetFilesController { } public FileVersionWrapper() { + /*{{{*/ this.title = ''; this.createdBy = ''; this.createdDate = null; this.id = ''; - } + this.versionReason = ''; + } /*}}}*/ - public FileVersionWrapper(String id, String title, String createdBy, Date createdDate) { + public FileVersionWrapper(String id, String title, String createdBy, Date createdDate, String versionReason) { + /*{{{*/ this.id = id; this.title = title; this.createdBy = createdBy; this.createdDate = createdDate; - } + this.versionReason = versionReason; + } /*}}}*/ } /*}}}*/ } diff --git a/force-app/main/default/lwc/filesRelatedList/filesRelatedList.html b/force-app/main/default/lwc/filesRelatedList/filesRelatedList.html index 5adfd48..fdf168c 100755 --- a/force-app/main/default/lwc/filesRelatedList/filesRelatedList.html +++ b/force-app/main/default/lwc/filesRelatedList/filesRelatedList.html @@ -1,4 +1,5 @@