Skip to content

Commit 317f7bb

Browse files
author
Allan De Castro
authored
Merge pull request #18 from allandecastro/patch-duplicate-first-stage
Patch duplicate first stage
2 parents 7289a14 + a1c60ec commit 317f7bb

File tree

4 files changed

+28
-23
lines changed

4 files changed

+28
-23
lines changed

BusinessProcessFlowViewer/BusinessProcessFlowViewer/ControlManifest.Input.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest>
3-
<control namespace="BusinessProcessFlowViewer" constructor="BusinessProcessFlowViewer" version="1.0.19" display-name-key="BusinessProcessFlowViewer" description-key="BusinessProcessFlowViewer show BPF of any records type." control-type="standard" preview-image="img/preview.png">
3+
<control namespace="BusinessProcessFlowViewer" constructor="BusinessProcessFlowViewer" version="1.0.28" display-name-key="BusinessProcessFlowViewer" description-key="BusinessProcessFlowViewer show BPF of any records type." control-type="standard" preview-image="img/preview.png">
44
<data-set name="dataSet" display-name-key="DataSet View Used" cds-data-set-options="displayCommandBar:true;displayViewSelector:true;displayQuickFindSearch:true">
55
</data-set>
66
<property name="parametersBPF" display-name-key="parametersBPF" description-key="This parameter is used to retrieve the different BPFs used by the target entity." of-type="SingleLine.TextArea" usage="input" required="true" default-value="{&quot;bpfs&quot;:[{&quot;bpfEntitySchemaName&quot;:&quot;opportunitysalesprocess&quot;, &quot;lookupFieldSchemaName&quot;:&quot;_opportunityid_value&quot;}, {&quot;bpfEntitySchemaName&quot;:&quot;leadtoopportunitysalesprocess&quot;, &quot;lookupFieldSchemaName&quot;:&quot;_opportunityid_value&quot;}]}" />

BusinessProcessFlowViewer/BusinessProcessFlowViewer/index.ts

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
import { IInputs, IOutputs } from "./generated/ManifestTypes";
2-
interface Bpf {
2+
interface IBpf {
33
bpfEntitySchemaName: string;
44
lookupFieldSchemaName: string;
55
}
66

7-
interface BusinessProcessFlowJson {
8-
bpfs: Bpf[];
7+
interface IBusinessProcessFlowJson {
8+
bpfs: IBpf[];
9+
}
10+
11+
interface IStageData {
12+
id: string[],
13+
name: string[]
14+
}
15+
interface IStagesData {
16+
stage: IStageData
917
}
1018

1119
export class BusinessProcessFlowViewer implements ComponentFramework.StandardControl<IInputs, IOutputs> {
@@ -65,7 +73,7 @@ export class BusinessProcessFlowViewer implements ComponentFramework.StandardCon
6573
//We remove all items to make sure that if you perform a refresh, it will not add the records again.
6674
this.removeChildItems();
6775
//Parse the Parameters and make sure it contains datas.
68-
let jsonParametersBPF: BusinessProcessFlowJson = JSON.parse(this._parametersBPF);
76+
let jsonParametersBPF: IBusinessProcessFlowJson = JSON.parse(this._parametersBPF);
6977
if (!jsonParametersBPF || jsonParametersBPF.bpfs == null || jsonParametersBPF.bpfs.length == 0) {
7078
console.log("[BPFV][UPDATEVIEW] Error : JsonParameters is Empty, ensure to correctly enter the BPF parameters value.");
7179
return;
@@ -78,7 +86,7 @@ export class BusinessProcessFlowViewer implements ComponentFramework.StandardCon
7886
* Function to start the process for each records in the dataset.
7987
* @param jsonParametersBPF JsonObject with all parameters to be used.
8088
*/
81-
private processAllRecordsInDataSet(jsonParametersBPF: BusinessProcessFlowJson) {
89+
private processAllRecordsInDataSet(jsonParametersBPF: IBusinessProcessFlowJson) {
8290
var order: number = 1; // Used to keep the order of the records.
8391
this._numberOfRecords = this._context.parameters.dataSet.sortedRecordIds.length;
8492
this._context.parameters.dataSet.sortedRecordIds.forEach((currentRecordId) => {
@@ -109,7 +117,7 @@ export class BusinessProcessFlowViewer implements ComponentFramework.StandardCon
109117
* @param foundBPF
110118
* @param order Number to indicate initial records order
111119
*/
112-
private async processBusinessProcessFlowStageIdByCurrentRecordId(entityReference: ComponentFramework.EntityReference, currentRecordId: string, bpfEntitySchemaName: string, filterFieldSchemaName: string, bpfIteration: number, jsonParametersBPF: BusinessProcessFlowJson, foundBPF: boolean, order: number) {
120+
private async processBusinessProcessFlowStageIdByCurrentRecordId(entityReference: ComponentFramework.EntityReference, currentRecordId: string, bpfEntitySchemaName: string, filterFieldSchemaName: string, bpfIteration: number, jsonParametersBPF: IBusinessProcessFlowJson, foundBPF: boolean, order: number) {
113121

114122
let activeStage: string[] = new Array();
115123
let searchQuery: string = "?$select=_activestageid_value," + filterFieldSchemaName + ",_processid_value&$filter=" + filterFieldSchemaName + " eq " + currentRecordId;
@@ -171,16 +179,13 @@ export class BusinessProcessFlowViewer implements ComponentFramework.StandardCon
171179
* @param order Number to indicate initial records order.
172180
*/
173181
private async getAllBusinessProcessFlowStageByProcessId(processIdCurrentRecord: string, divContainer: HTMLDivElement, progresDiv: HTMLDivElement, activeStageIdCurrentRecord: string, order: number) {
174-
//Create Array to contain all Stage Name.
175-
let stage: string[] = new Array();
176-
//Create Array to contain all Stage Id.
177-
let processStageId: string[] = new Array();
178182
//Create an object to be returned, containing the two array.
179-
let datas = {
180-
stage: {
181-
id: processStageId,
182-
name: stage
183-
}
183+
let stageData:IStageData={
184+
id: new Array(),
185+
name: new Array()
186+
};
187+
let stagesData:IStagesData ={
188+
stage:stageData
184189
};
185190
try {
186191

@@ -195,21 +200,21 @@ export class BusinessProcessFlowViewer implements ComponentFramework.StandardCon
195200
result.entities.forEach(item => {
196201
var stagename: string = item[fieldToDisplay];
197202
var processStageid: string = item["processstageid"];
198-
stage.push(stagename);
199-
processStageId.push(processStageid);
203+
stageData.id.push(processStageid);
204+
stageData.name.push(stagename);
200205
})
201-
let jsonObjectStageId: string = JSON.stringify(datas.stage.id);
206+
202207
//Define a variable to know which step is active for this record and this BPF.
203208
let activeStageFound: boolean = false;
204209
//Parse all stage id and create cells with name and find the one active.
205-
JSON.parse(jsonObjectStageId, (key, value) => {
210+
for (var i = 0; i < stagesData.stage.id.length; i++) {
206211
let progresStageDiv: HTMLDivElement = document.createElement("div");
207212
progresStageDiv.classList.add("progress-step");
208213
progresStageDiv.classList.add("progress-step" + this._viewId);
209214
progresStageDiv.classList.add("is-notactive");
210215
progresStageDiv.classList.add("is-notactive" + this._viewId);
211216
//Test if this is the Active Stage.
212-
if (value === activeStageIdCurrentRecord) {
217+
if (stageData.id[i] === activeStageIdCurrentRecord) {
213218
activeStageFound = true;
214219
progresStageDiv.classList.add("is-active");
215220
progresStageDiv.classList.add("is-active" + this._viewId);
@@ -223,10 +228,10 @@ export class BusinessProcessFlowViewer implements ComponentFramework.StandardCon
223228
progresStageDiv.classList.remove("is-notactive");
224229
progresStageDiv.classList.remove("is-notactive" + this._viewId);
225230
}
226-
progresStageDiv.innerText = datas.stage.name[Number(key)];
231+
progresStageDiv.innerText = stageData.name[i];
227232
//We add the element to the Div.
228233
progresDiv.appendChild(progresStageDiv);
229-
});
234+
}
230235
divContainer.appendChild(progresDiv);
231236
//Add the element to the array.
232237
let elementToAdd: (number | HTMLDivElement)[] = [order, divContainer]
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)