Skip to content

Commit

Permalink
Merge pull request #149 from SalesforceLabs/feature/mobile-upload-fix
Browse files Browse the repository at this point in the history
Feature/mobile upload fix
  • Loading branch information
cjrolfe authored Feb 19, 2024
2 parents fedef77 + 364332c commit 27699e1
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
<objects>
<object>animalshelters__Animal__c</object>
</objects>
<supportedFormFactors>
<supportedFormFactor type="Large" />
<supportedFormFactor type="Small" />
</supportedFormFactors>
</targetConfig>
</targetConfigs>
</LightningComponentBundle>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
<objects>
<object>animalshelters__Animal__c</object>
</objects>
<supportedFormFactors>
<supportedFormFactor type="Large" />
<supportedFormFactor type="Small" />
</supportedFormFactors>
</targetConfig>
</targetConfigs>
</LightningComponentBundle>
12 changes: 10 additions & 2 deletions force-app/main/default/lwc/recordImage/recordImage.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
<!--
@description :
@author : Stewart Anderson
@group :
@last modified on : 02-19-2024
@last modified by : Stewart Anderson
-->
<template>
<lightning-card>

Expand All @@ -10,8 +17,9 @@
</template>

<p slot="footer">
<lightning-file-upload label="Upload Photo" name="fileUploader" accept={acceptedFormats} record-id={recordId} onuploadfinished={handleUploadFinished}>
<lightning-file-upload label="Upload Photo" multiple="false" name="fileUploader" accept={acceptedFormats}
record-id={recordId} onuploadfinished={handleUploadFinished}>
</lightning-file-upload>
</p>
</lightning-card>
</template>
</template>
42 changes: 21 additions & 21 deletions force-app/main/default/lwc/recordImage/recordImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @description :
* @author : Stewart Anderson
* @group :
* @last modified on : 12-15-2023
* @last modified on : 02-19-2024
* @last modified by : Stewart Anderson
**/
import { LightningElement, wire, api } from 'lwc';
Expand Down Expand Up @@ -77,15 +77,15 @@ export default class recordImage extends LightningElement {

// Set Accepted Photo Formats
get acceptedFormats() {
return ['.png','.jpg','.jpeg'];
return ['.png', '.jpg', '.jpeg', '.webp', '.heic', '.heif', '.avif', '.bmp', '.gif'];
}

// Handle a Completed Upload of the Photo
handleUploadFinished(event) {
const uploadedFiles = event.detail.files;
this.photoId = uploadedFiles[0].contentVersionId;
this.updateRecord(this.photoId);
this.photoURL = '/sfc/servlet.shepherd/version/download/' + this.photoId;
this.photoURL = '/sfc/servlet.shepherd/version/download/' + this.photoId;
}

// Update the PhotoId Field on the Record
Expand All @@ -103,23 +103,23 @@ export default class recordImage extends LightningElement {

const recordInput = { fields };
updateRecord(recordInput)
.then(() => {
if (this.objectApiName == 'Contact') {
return refreshApex(this.Contact);
}
if (this.objectApiName == 'animalshelters__Animal__c') {
return refreshApex(this.animalshelters__Animal__c);
}
.then(() => {
if (this.objectApiName == 'Contact') {
return refreshApex(this.Contact);
}
if (this.objectApiName == 'animalshelters__Animal__c') {
return refreshApex(this.animalshelters__Animal__c);
}

})
.catch(error => {
this.dispatchEvent(
new ShowToastEvent({
title: 'Error Uploading Photo',
message: error.body.message,
variant: 'error'
})
);
});
})
.catch(error => {
this.dispatchEvent(
new ShowToastEvent({
title: 'Error Uploading Photo',
message: error.body.message,
variant: 'error'
})
);
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
<object>animalshelters__Animal__c</object>
<object>Contact</object>
</objects>
<supportedFormFactors>
<supportedFormFactor type="Large" />
<supportedFormFactor type="Small" />
</supportedFormFactors>
</targetConfig>
<targetConfig targets="lightningCommunity__Default">
<property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
<actionOverrides>
<actionName>View</actionName>
<comment>Action override updated by Lightning App Builder during activation.</comment>
<content>Animal_Record_Page1</content>
<content>Animal_Record_Page</content>
<formFactor>Small</formFactor>
<skipRecordTypeSelect>false</skipRecordTypeSelect>
<type>Flexipage</type>
Expand Down Expand Up @@ -174,8 +174,8 @@
<customTabListAdditionalFields>Species__c</customTabListAdditionalFields>
<customTabListAdditionalFields>Animal_Status__c</customTabListAdditionalFields>
<excludedStandardButtons>OpenListInQuip</excludedStandardButtons>
<excludedStandardButtons>Accept</excludedStandardButtons>
<excludedStandardButtons>NewFromDocument</excludedStandardButtons>
<excludedStandardButtons>Accept</excludedStandardButtons>
<lookupDialogsAdditionalFields>Animal_Name__c</lookupDialogsAdditionalFields>
<lookupDialogsAdditionalFields>TypeFromBreeds__c</lookupDialogsAdditionalFields>
<lookupDialogsAdditionalFields>Species__c</lookupDialogsAdditionalFields>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@
<protected>false</protected>
<showsLocation>false</showsLocation>
<showsStatus>false</showsStatus>
<url>
/animalshelters/lightningPrintViewApp.app?recordid={!animalshelters__Animal__c.Id}&amp;fieldSetName=animalshelters__Animal_Cage_Card_Field_Set&amp;sObjectTypeName=animalshelters__Animal__c&amp;badgefields=animalshelters__Behaviours__c</url>
<url>/animalshelters/lightningPrintViewApp.app?recordid={!Animal__c.Id}&amp;fieldSetName=animalshelters__Animal_Cage_Card_Field_Set&amp;sObjectTypeName=animalshelters__Animal__c&amp;badgefields=animalshelters__Behaviours__c</url>
</WebLink>

0 comments on commit 27699e1

Please sign in to comment.