Skip to content

Commit

Permalink
Merge pull request #39 from ramarao9/feature/add-default-title
Browse files Browse the repository at this point in the history
bump version to 1.2.0.0 and add default note title feature
  • Loading branch information
ramarao9 authored Jan 29, 2025
2 parents eb273cb + 5a6e86f commit e91dcf1
Show file tree
Hide file tree
Showing 7 changed files with 5,218 additions and 3,515 deletions.
17 changes: 11 additions & 6 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
{
"env": {
"browser": true,
"es2021": true
"browser": true,
"es2020": true
},
"extends": [
"standard"
"eslint:recommended"
],
"globals": {
"ComponentFramework": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
"@microsoft/power-apps",
"@typescript-eslint"
],
"rules": {
"no-unused-vars": "off"
}
}
2 changes: 1 addition & 1 deletion AttachmentDragandDrop/Other/Solution.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<!-- Description of Cds Publisher in language code -->
<Description description="https://github.com/ramarao9/AttachmentUploader" languagecode="1033" />
</Descriptions>
<Version>1.0.1.0</Version>
<Version>1.2.0.0</Version>
<!-- Solution Package Type: Unmanaged(0)/Managed(1)/Both(2)-->
<Managed>2</Managed>
<Publisher>
Expand Down
9 changes: 7 additions & 2 deletions AttachmentUpload/AttachmentUploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface UploadProps {
uploadIcon: string;
useNoteAttachment: boolean;
context: ComponentFramework.Context<IInputs> | undefined;
defaultNoteTitle: string | null;
}

export interface FileInfo {
Expand Down Expand Up @@ -44,7 +45,7 @@ export const AttachmentUploader: React.FC<UploadProps> = (uploadProps: UploadPro
});

const uploadFileToRecord = async (id: string, entity: string, entitySetName: string,
fileInfo: FileInfo, context: ComponentFramework.Context<IInputs>) => {
fileInfo: FileInfo, context: ComponentFramework.Context<IInputs>, defaultNoteTitle: string|null) => {

let isActivityMimeAttachment = !uploadProps.useNoteAttachment && (entity.toLowerCase() === "email" || entity.toLowerCase() === "appointment");
let attachmentRecord: ComponentFramework.WebApi.Entity = {};
Expand All @@ -55,6 +56,10 @@ export const AttachmentUploader: React.FC<UploadProps> = (uploadProps: UploadPro
else {
attachmentRecord[`objectid_${entity}@odata.bind`] = `/${entitySetName}(${id})`;
attachmentRecord["documentbody"] = fileInfo.body;

if (defaultNoteTitle != null && defaultNoteTitle !== "") {
attachmentRecord["subject"] = defaultNoteTitle;
}
}

if (fileInfo.type && fileInfo.type !== "") {
Expand Down Expand Up @@ -90,7 +95,7 @@ export const AttachmentUploader: React.FC<UploadProps> = (uploadProps: UploadPro
entityName = currentPageContext.entityTypeName;
}

await uploadFileToRecord(entityId, entityName, uploadProps.entitySetName, fileInfo, uploadProps.context!!);
await uploadFileToRecord(entityId, entityName, uploadProps.entitySetName, fileInfo, uploadProps.context!!, uploadProps.defaultNoteTitle);
}
}
catch (e: any) {
Expand Down
35 changes: 21 additions & 14 deletions AttachmentUpload/ControlManifest.Input.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<manifest>
<control namespace="vij" constructor="AttachmentUpload" version="1.1.1" display-name-key="AttachmentUpload"
description-key="Upload attachments easily using drag and drop" control-type="standard">
<control namespace="vij" constructor="AttachmentUpload" version="1.1.3"
display-name-key="AttachmentUpload"
description-key="Upload attachments easily using drag and drop" control-type="standard">
<type-group name="flds">
<type>SingleLine.Text</type>
<type>SingleLine.Phone</type>
Expand All @@ -13,22 +14,28 @@
<type>FP</type>
<type>Decimal</type>
</type-group>
<property name="Attribute" display-name-key="Attribute" description-key="Select an Attribute" of-type-group="flds"
usage="bound" />

<property name="ControlNameForRefresh" display-name-key="ControlNameForRefresh" description-key="ControlNameForRefresh"
usage="input" of-type="SingleLine.Text"/>
<property name="Attribute" display-name-key="Attribute" description-key="Select an Attribute"
of-type-group="flds"
usage="bound" />

<property name="UseNoteAttachment" display-name-key="UseNoteAttachment" description-key="Upload as attachment on the Notes entity when Email or Appointment instead of Attachment(ActivityMimeAttachment)"
usage="input" of-type="Enum">
<value name="No" display-name-key="No" default="true">0</value>
<value name="Yes" display-name-key="Yes">1</value>
</property>
<property name="ControlNameForRefresh" display-name-key="ControlNameForRefresh"
description-key="ControlNameForRefresh"
usage="input" of-type="SingleLine.Text" />

<property name="DefaultNoteTitle" display-name-key="DefaultNoteTitle"
description-key="Sets the default title for the Note attachment"
usage="input" of-type="SingleLine.Text" />

<property name="UseNoteAttachment" display-name-key="UseNoteAttachment"
description-key="Upload as attachment on the Notes entity when Email or Appointment instead of Attachment(ActivityMimeAttachment)"
usage="input" of-type="Enum">
<value name="No" display-name-key="No" default="true">0</value>
<value name="Yes" display-name-key="Yes">1</value>
</property>


<resources>
<code path="index.ts" order="1"/>
<code path="index.ts" order="1" />
<css path="AttachmentUploader.css" order="2" />
<!-- Danish -->
<resx path="AttachmentUpload.1030.resx" version="1.0.0" />
Expand Down
4 changes: 3 additions & 1 deletion AttachmentUpload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export class AttachmentUpload implements ComponentFramework.StandardControl<IInp
controlToRefresh: "",
uploadIcon: "",
useNoteAttachment: false,
context: undefined
context: undefined,
defaultNoteTitle: ""
};
constructor() {

Expand All @@ -43,6 +44,7 @@ export class AttachmentUpload implements ComponentFramework.StandardControl<IInp
this.uploadProps.controlToRefresh = context.parameters.ControlNameForRefresh.raw;
this.uploadProps.uploadIcon = this.getImageBase64();
this.uploadProps.useNoteAttachment = context.parameters.UseNoteAttachment.raw === "1";
this.uploadProps.defaultNoteTitle = context.parameters.DefaultNoteTitle.raw;
this.uploadProps.context = context;
}
this.attachmentUploaderContainer = container;
Expand Down
Loading

0 comments on commit e91dcf1

Please sign in to comment.