Skip to content

Commit

Permalink
Only 1 open task displayed within case task lists issue fixed (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
tumms2021389 committed Oct 3, 2023
1 parent 42a864f commit ccad23d
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ export class AutoCompleteComponent implements OnInit {
this.listType = 'datapage';
datasource = datasourceMetadata.datasource.name;
this.parameters = this.flattenParameters(datasourceMetadata?.datasource?.parameters);
const displayProp = datasourceMetadata.datasource.propertyForDisplayText.startsWith('@P')
const displayProp = datasourceMetadata.datasource.propertyForDisplayText?.startsWith('@P')
? datasourceMetadata.datasource.propertyForDisplayText.substring(3)
: datasourceMetadata.datasource.propertyForDisplayText;
const valueProp = datasourceMetadata.datasource.propertyForValue.startsWith('@P')
const valueProp = datasourceMetadata.datasource.propertyForValue?.startsWith('@P')
? datasourceMetadata.datasource.propertyForValue.substring(3)
: datasourceMetadata.datasource.propertyForValue;
columns = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@
<div class="psdk-todo-assignment">
<div class="psdk-avatar">{{ this.currentUserInitials$ }}</div>
<div class="psdk-todo-card">
<div class="psdk-todo-assignment-title">{{ assignment.stepName }}</div>
<div class="psdk-todo-assignment-title">{{ getAssignmentName(assignment) }}</div>
<div class="psdk-todo-assignment-data">
<div class="psdk-todo-assignment-task" (click)="clickGo([assignment])">
<div class="psdk-todo-assignment-task" (click)="clickGo(assignment)">
Task in <span class="psdk-todo-id">{{ assignment.name }} {{ getID(assignment) }}</span>
<span *ngIf="assignment.status != undefined">
&bull; <span class="psdk-todo-assignment-status">{{ assignment?.status }}</span>
</span>
&bull; Priority {{ assignment?.priority }}
&bull; Urgency {{ getPriority(assignment) }}
</div>
</div>
</div>
<div class="psdk-todo-assignment-action">
<button mat-flat-button color="primary" (click)="clickGo([assignment])">Go</button>
<button mat-flat-button color="primary" (click)="clickGo(assignment)">Go</button>
</div>
</div>
<div class="psdk-display-divider"></div>
</div>
</div>

<div *ngIf="showTodoList$">
<div *ngIf="assignmentCount$ > 3">
<div *ngIf="bShowMore$; else showLess" class="psdk-todo-show-more">
<button mat-stroked-button (click)="_showMore()">Show more</button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export class TodoComponent implements OnInit {
bShowMore$: boolean = true;
arAssignments$: Array<any>;
assignmentsSource$: any;
CONSTS: any;
bLogging = true;

constructor(private psService: ProgressSpinnerService, private ngZone: NgZone, private utils: Utils) {}

Expand All @@ -44,6 +46,7 @@ export class TodoComponent implements OnInit {
this.PCore$ = window.PCore;
}

this.CONSTS = this.PCore$.getConstants();
const { CREATE_STAGE_SAVED, CREATE_STAGE_DELETED } = this.PCore$.getEvents().getCaseEvent();

this.PCore$.getPubSubUtils().subscribe(
Expand Down Expand Up @@ -138,57 +141,56 @@ export class TodoComponent implements OnInit {
}

getID(assignment: any) {
let sID = '';
if (assignment.value) {
let refKey = assignment.value;
sID = refKey.substring(refKey.lastIndexOf(' ') + 1);
const refKey = assignment.value;
return refKey.substring(refKey.lastIndexOf(' ') + 1);
} else {
let refKey = assignment.ID;
let arKeys = refKey.split('!')[0].split(' ');

sID = arKeys[2];
const refKey = assignment.ID;
const arKeys = refKey.split('!')[0].split(' ');
return arKeys[2];
}

return sID;
}

topThreeAssignments(arList: Array<any>) {
let arList3: Array<any> = new Array<any>();
topThreeAssignments(assignmentsSource: Array<any>): Array<any> {
return Array.isArray(assignmentsSource) ? assignmentsSource.slice(0, 3) : [];
}

if (arList && typeof arList == 'object') {
let len = arList.length;
if (len > 3) len = 3;
getAssignmentId(assignment) {
return this.type$ === this.CONSTS.TODO ? assignment.ID : assignment.id;
}

for (let i = 0; i < len; i++) {
arList3.push(arList[i]);
}
}
getPriority(assignment) {
return this.type$ === this.CONSTS.TODO ? assignment.urgency : assignment.priority;
}

return arList3;
getAssignmentName(assignment) {
return this.type$ === this.CONSTS.TODO ? assignment.name : assignment.stepName;
}

getCaseInfoAssignment(arList: Array<any>, caseInfoID: string) {
let arList1: Array<any> = new Array<any>();
for (var aIndex in arList) {
if (arList[aIndex].ID.indexOf(caseInfoID) >= 0) {
let listRow = JSON.parse(JSON.stringify(arList[aIndex]));
initAssignments(): Array<any> {
if (this.assignmentsSource$) {
this.assignmentCount$ = this.assignmentsSource$.length;
return this.topThreeAssignments(this.assignmentsSource$);
} else {
// turn off todolist
return [];
}
}

getCaseInfoAssignment(assignmentsSource: Array<any>, caseInfoID: string) {
const result: Array<any> = [];
for (const source of assignmentsSource) {
if (source.ID.indexOf(caseInfoID) >= 0) {
const listRow = JSON.parse(JSON.stringify(source));
// urgency becomes priority
if (listRow.urgency) {
listRow['priority'] = listRow.urgency;
}

if (listRow.ID) {
// mimic regular list
listRow['id'] = listRow['ID'];
}

arList1.push(listRow);
break;
listRow['priority'] = listRow.urgency || undefined;
// mimic regular list
listRow['id'] = listRow['ID'] || undefined;
result.push(listRow);
}
}

return arList1;
return result;
}

_showMore() {
Expand All @@ -206,40 +208,42 @@ export class TodoComponent implements OnInit {
});
}

clickGo(assignment: any) {
let { id, classname } = assignment[0];

// capture className, as seem to loose it when
if (classname == null || classname == '') {
classname = this.pConn$.getCaseInfo().getClassName();
}
isChildCase(assignment) {
return assignment.isChild;
}

let sTarget = this.pConn$.getContainerName();
let sTargetContainerName = sTarget;
let sIsActionFromTodoList = 'todo';
clickGo(assignment) {
const id = this.getAssignmentId(assignment);
let { classname = '' } = assignment;
const sTarget = this.pConn$.getContainerName();
const sTargetContainerName = sTarget;

let options = { containerName: sTarget };
const options = { containerName: sTargetContainerName };

if (classname == null || classname == '') {
if (classname === null || classname === '') {
classname = this.pConn$.getCaseInfo().getClassName();
}

if (sTarget === 'workarea') {
options['isActionFromToDoList'] = true;
options['target'] = '';
options['context'] = this.context$;
options['isChild'] = undefined;
options['context'] = null;
options['isChild'] = this.isChildCase(assignment);
} else {
options['isActionFromToDoList'] = false;
options['target'] = sTarget;
options['context'] = '';
}

this.psService.sendMessage(true);

this.pConn$
.getActionsApi()
.openAssignment(id, classname, options)
.then(() => {});
.then(() => {
if (this.bLogging) {
console.log(`openAssignment completed`);
}
})
.catch(() => {
alert(`Submit failed!`);
});
}
}

0 comments on commit ccad23d

Please sign in to comment.