[ADF-741] Add the create task attachment component to the demo shell (#1946)

* Add the create task attachment component to the demo shell

* Add translation keys

* Add return to methods
This commit is contained in:
Maurizio Vitale
2017-06-09 14:18:10 +01:00
committed by Eugenio Romano
parent cfb3c9b8ba
commit 33d5f66bd7
11 changed files with 102 additions and 49 deletions

View File

@@ -24,3 +24,17 @@
text-align: left; text-align: left;
margin-bottom: 5px; margin-bottom: 5px;
} }
.adf-no-form-container {
text-align: center;
font-weight: 600;
font-size: 18px;
font-family: Muli;
padding: 16px;
}
.action-header {
border: 1px solid rgb(224, 224, 224);
background: #fff;
text-align: left;
}

View File

@@ -73,10 +73,25 @@
</activiti-task-details> </activiti-task-details>
<hr> <hr>
<h5>Attachments</h5> <h5>Attachments</h5>
<adf-task-attachment-list *ngIf="currentTaskId" <div class="adf-no-form-container">
[taskId]="currentTaskId" <div class="action-header">
(attachmentClick)="onAttachmentClick($event)"> <button class="mdl-button mdl-js-button" (click)="toggleCreateTakAttach()">
</adf-task-attachment-list> Attach Document
<i class="material-icons">add</i>
</button>
</div>
<adf-task-attachment-list #taskAttach
*ngIf="currentTaskId"
[taskId]="currentTaskId"
(attachmentClick)="onAttachmentClick($event)">
</adf-task-attachment-list>
<div *ngIf="isCreateTaskAttachVisible()">
<adf-create-task-attachment *ngIf="currentTaskId"
[taskId]="currentTaskId"
(success)="onCreateTaskSuccess ()">
</adf-create-task-attachment>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -21,7 +21,8 @@ import {
ActivitiFilters, ActivitiFilters,
ActivitiTaskList, ActivitiTaskList,
FilterRepresentationModel, FilterRepresentationModel,
TaskDetailsEvent TaskDetailsEvent,
TaskAttachmentListComponent
} from 'ng2-activiti-tasklist'; } from 'ng2-activiti-tasklist';
import { import {
ActivitiProcessFilters, ActivitiProcessFilters,
@@ -60,6 +61,9 @@ export class ActivitiDemoComponent implements AfterViewInit {
@ViewChild(ActivitiTaskList) @ViewChild(ActivitiTaskList)
taskList: ActivitiTaskList; taskList: ActivitiTaskList;
@ViewChild(TaskAttachmentListComponent)
taskAttachList: TaskAttachmentListComponent;
@ViewChild(ActivitiProcessFilters) @ViewChild(ActivitiProcessFilters)
activitiprocessfilter: ActivitiProcessFilters; activitiprocessfilter: ActivitiProcessFilters;
@@ -100,6 +104,7 @@ export class ActivitiDemoComponent implements AfterViewInit {
sub: Subscription; sub: Subscription;
blobFile: any; blobFile: any;
flag: boolean = true; flag: boolean = true;
createTaskAttach: boolean = false;
dataTasks: ObjectDataTableAdapter; dataTasks: ObjectDataTableAdapter;
dataProcesses: ObjectDataTableAdapter; dataProcesses: ObjectDataTableAdapter;
@@ -157,15 +162,15 @@ export class ActivitiDemoComponent implements AfterViewInit {
this.sub.unsubscribe(); this.sub.unsubscribe();
} }
onTaskFilterClick(filter: FilterRepresentationModel) { onTaskFilterClick(filter: FilterRepresentationModel): void {
this.applyTaskFilter(filter); this.applyTaskFilter(filter);
} }
onReportClick(event: any) { onReportClick(event: any): void {
this.report = event; this.report = event;
} }
onSuccessTaskFilterList(event: any) { onSuccessTaskFilterList(event: any): void {
this.applyTaskFilter(this.activitifilter.getCurrentFilter()); this.applyTaskFilter(this.activitifilter.getCurrentFilter());
} }
@@ -176,7 +181,7 @@ export class ActivitiDemoComponent implements AfterViewInit {
} }
} }
onStartTaskSuccess(event: any) { onStartTaskSuccess(event: any): void {
this.activitifilter.selectFilterWithTask(event.id); this.activitifilter.selectFilterWithTask(event.id);
this.currentTaskId = event.id; this.currentTaskId = event.id;
} }
@@ -185,88 +190,88 @@ export class ActivitiDemoComponent implements AfterViewInit {
this.currentTaskId = this.taskList.getCurrentId(); this.currentTaskId = this.taskList.getCurrentId();
} }
onProcessFilterClick(event: FilterProcessRepresentationModel) { onProcessFilterClick(event: FilterProcessRepresentationModel): void {
this.currentProcessInstanceId = null; this.currentProcessInstanceId = null;
this.processFilter = event; this.processFilter = event;
} }
onSuccessProcessFilterList() { onSuccessProcessFilterList(): void {
this.processFilter = this.activitiprocessfilter.getCurrentFilter(); this.processFilter = this.activitiprocessfilter.getCurrentFilter();
} }
onSuccessProcessList(event: any) { onSuccessProcessList(event: any): void {
this.currentProcessInstanceId = this.processList.getCurrentId(); this.currentProcessInstanceId = this.processList.getCurrentId();
} }
onTaskRowClick(taskId) { onTaskRowClick(taskId): void {
this.currentTaskId = taskId; this.currentTaskId = taskId;
} }
onProcessRowClick(processInstanceId) { onProcessRowClick(processInstanceId): void {
this.currentProcessInstanceId = processInstanceId; this.currentProcessInstanceId = processInstanceId;
} }
onEditReport(name: string) { onEditReport(name: string): void {
this.analyticsreportlist.reload(); this.analyticsreportlist.reload();
} }
onReportSaved(reportId) { onReportSaved(reportId): void {
this.analyticsreportlist.reload(reportId); this.analyticsreportlist.reload(reportId);
} }
onReportDeleted() { onReportDeleted(): void {
this.analyticsreportlist.reload(); this.analyticsreportlist.reload();
this.analyticsreportlist.selectReport(null); this.analyticsreportlist.selectReport(null);
} }
navigateStartProcess() { navigateStartProcess(): void {
this.resetProcessFilters(); this.resetProcessFilters();
this.reloadProcessFilters(); this.reloadProcessFilters();
this.currentProcessInstanceId = currentProcessIdNew; this.currentProcessInstanceId = currentProcessIdNew;
} }
onStartProcessInstance(instance: ProcessInstance) { onStartProcessInstance(instance: ProcessInstance): void {
this.currentProcessInstanceId = instance.id; this.currentProcessInstanceId = instance.id;
this.activitiStartProcess.reset(); this.activitiStartProcess.reset();
this.resetProcessFilters(); this.resetProcessFilters();
} }
isStartProcessMode() { isStartProcessMode(): boolean {
return this.currentProcessInstanceId === currentProcessIdNew; return this.currentProcessInstanceId === currentProcessIdNew;
} }
processCancelled(data: any) { processCancelled(data: any): void {
this.currentProcessInstanceId = null; this.currentProcessInstanceId = null;
this.processList.reload(); this.processList.reload();
} }
onSuccessNewProcess(data: any) { onSuccessNewProcess(data: any): void {
this.processList.reload(); this.processList.reload();
} }
onFormCompleted(form) { onFormCompleted(form): void {
this.taskList.reload(); this.taskList.reload();
this.currentTaskId = null; this.currentTaskId = null;
} }
onFormContentClick(content: any) { onFormContentClick(content: any): void {
this.fileShowed = true; this.fileShowed = true;
this.content = content.contentBlob; this.content = content.contentBlob;
this.contentName = content.name; this.contentName = content.name;
} }
onAttachmentClick(content: any) { onAttachmentClick(content: any): void {
this.fileShowed = true; this.fileShowed = true;
this.content = content.contentBlob; this.content = content.contentBlob;
this.contentName = content.name; this.contentName = content.name;
} }
onTaskCreated(data: any) { onTaskCreated(data: any): void {
this.currentTaskId = data.parentTaskId; this.currentTaskId = data.parentTaskId;
this.taskList.reload(); this.taskList.reload();
} }
onTaskDeleted(data: any) { onTaskDeleted(data: any): void {
this.taskList.reload(); this.taskList.reload();
} }
@@ -290,11 +295,11 @@ export class ActivitiDemoComponent implements AfterViewInit {
}); });
} }
onShowProcessDiagram(event: any) { onShowProcessDiagram(event: any): void {
this.router.navigate(['/activiti/diagram/' + event.value]); this.router.navigate(['/activiti/diagram/' + event.value]);
} }
onProcessDetailsTaskClick(event: TaskDetailsEvent) { onProcessDetailsTaskClick(event: TaskDetailsEvent): void {
event.preventDefault(); event.preventDefault();
this.activeTab = 'tasks'; this.activeTab = 'tasks';
@@ -310,20 +315,33 @@ export class ActivitiDemoComponent implements AfterViewInit {
this.currentTaskId = taskId; this.currentTaskId = taskId;
} }
private resetProcessFilters() { private resetProcessFilters(): void {
this.processFilter = null; this.processFilter = null;
} }
private reloadProcessFilters() { private reloadProcessFilters(): void {
this.activitiprocessfilter.selectFilter(null); this.activitiprocessfilter.selectFilter(null);
} }
onRowClick(event) { onRowClick(event): void {
console.log(event); console.log(event);
} }
onRowDblClick(event) { onRowDblClick(event): void {
console.log(event); console.log(event);
} }
onCreateTaskSuccess(): void {
this.taskAttachList.reload();
this.toggleCreateTakAttach();
}
toggleCreateTakAttach(): void {
this.createTaskAttach = !this.createTaskAttach;
}
isCreateTaskAttachVisible(): boolean {
return this.createTaskAttach;
}
} }

View File

@@ -464,9 +464,9 @@ This component displays attached documents on a specified task
This component displays Upload Component(Drag and Click) to upload the attachment to a specified task This component displays Upload Component(Drag and Click) to upload the attachment to a specified task
```html ```html
<activiti-create-task-attachment [taskId]="YOUR_TASK_ID" <adf-create-task-attachment [taskId]="YOUR_TASK_ID"
(error)="YOUR_CREATE_ATTACHMENT_ERROR_HANDLER" (error)="YOUR_CREATE_ATTACHMENT_ERROR_HANDLER"
(success)="YOUR_CREATE_ATTACHMENT_SUCCESS_HANDLER"></activiti-create-task-attachment> (success)="YOUR_CREATE_ATTACHMENT_SUCCESS_HANDLER"></adf-create-task-attachment>
``` ```
![task-create-attachment](docs/assets/task-create-attachment.png) ![task-create-attachment](docs/assets/task-create-attachment.png)

View File

@@ -1,15 +1,15 @@
<div class="upload-attachment-container"> <div class="upload-attachment-container">
<div class="drag-area" <div class="drag-area"
(upload-files)="onFileUpload($event)" (upload-files)="onFileUpload($event)"
mode="['click', 'drop']" mode="['click', 'drop']"
[adf-upload]="true"> [adf-upload]="true">
Drop Files Here... {{ 'TASK_DETAILS.BUTTON.DRAG-ATTACHMENT' | translate }}
</div> </div>
<button class="mdl-button mdl-js-button mdl-button--raised" <button class="mdl-button mdl-js-button mdl-button--raised"
[adf-upload]="true" [adf-upload]="true"
mode="['click']" mode="['click']"
[multiple]="true" [multiple]="true"
(upload-files)="onFileUpload($event)"> (upload-files)="onFileUpload($event)">
Upload Attachment {{ 'TASK_DETAILS.BUTTON.UPLOAD-ATTACHMENT' | translate }}
</button> </button>
</div> </div>

View File

@@ -22,7 +22,7 @@ import { Observable } from 'rxjs/Rx';
import { AlfrescoTranslationService, CoreModule } from 'ng2-alfresco-core'; import { AlfrescoTranslationService, CoreModule } from 'ng2-alfresco-core';
import { ActivitiContentService } from 'ng2-activiti-form'; import { ActivitiContentService } from 'ng2-activiti-form';
import { ActivitiCreateTaskAttachmentComponent } from './activiti-create-task-attachment.component'; import { ActivitiCreateTaskAttachmentComponent } from './adf-create-task-attachment.component';
describe('Activiti Task Create Attachment', () => { describe('Activiti Task Create Attachment', () => {

View File

@@ -20,9 +20,9 @@ import { AlfrescoTranslationService } from 'ng2-alfresco-core';
import { ActivitiContentService } from 'ng2-activiti-form'; import { ActivitiContentService } from 'ng2-activiti-form';
@Component({ @Component({
selector: 'activiti-create-task-attachment', selector: 'adf-create-task-attachment',
styleUrls: ['./activiti-create-task-attachment.component.css'], styleUrls: ['./adf-create-task-attachment.component.css'],
templateUrl: './activiti-create-task-attachment.component.html' templateUrl: './adf-create-task-attachment.component.html'
}) })
export class ActivitiCreateTaskAttachmentComponent implements OnChanges { export class ActivitiCreateTaskAttachmentComponent implements OnChanges {

View File

@@ -55,10 +55,14 @@ export class TaskAttachmentListComponent implements OnChanges {
} }
} }
reset () { reset(): void {
this.attachments = []; this.attachments = [];
} }
reload(): void {
this.loadAttachmentsByTaskId(this.taskId);
}
private loadAttachmentsByTaskId(taskId: string) { private loadAttachmentsByTaskId(taskId: string) {
if (taskId) { if (taskId) {
this.reset(); this.reset();

View File

@@ -27,4 +27,4 @@ export * from './activiti-filters.component';
export * from './activiti-task-details.component'; export * from './activiti-task-details.component';
export * from './activiti-start-task.component'; export * from './activiti-start-task.component';
export * from './activiti-people-search.component'; export * from './activiti-people-search.component';
export * from './activiti-create-task-attachment.component'; export * from './adf-create-task-attachment.component';

View File

@@ -18,7 +18,9 @@
}, },
"BUTTON": { "BUTTON": {
"COMPLETE": "Complete", "COMPLETE": "Complete",
"CLAIM": "Claim" "CLAIM": "Claim",
"DRAG-ATTACHMENT": "Drop Files Here...",
"UPLOAD-ATTACHMENT": "Upload Attachment"
}, },
"MESSAGES": { "MESSAGES": {
"NONE": "No task details found.", "NONE": "No task details found.",