make comments always editable for process (#2447)

make comments editable only when there are users involved
This commit is contained in:
Eugenio Romano 2017-10-06 17:27:10 +01:00 committed by GitHub
parent 7894d687ab
commit 85a275d66a
8 changed files with 106 additions and 85 deletions

View File

@ -16,20 +16,7 @@
<h3>BPM</h3> <h3>BPM</h3>
<label> Edition </label> {{ bpmVersion.edition }} <label> Edition </label> {{ bpmVersion.edition }}
<p></p> <p></p>
<table border="2" class="adf-table-version"> <label> Version </label> {{ bpmVersion.majorVersion }}.{{ bpmVersion.minorVersion }}.{{ bpmVersion.revisionVersion }}
<tr>
<th>Major Version</th>
<th>Revision Version</th>
<th>Minor Version</th>
<th>Type</th>
</tr>
<tr style="align-items: center">
<td>{{ bpmVersion.majorVersion }}</td>
<td>{{ bpmVersion.revisionVersion }}</td>
<td>{{ bpmVersion.minorVersion }}</td>
<td>{{ bpmVersion.type }}</td>
</tr>
</table>
</div> </div>
<div *ngIf="ecmVersion"> <div *ngIf="ecmVersion">
<h3>ECM</h3> <h3>ECM</h3>
@ -38,64 +25,14 @@
<label> Version </label> {{ ecmVersion.version.display }} <label> Version </label> {{ ecmVersion.version.display }}
<p></p> <p></p>
<h4>License</h4> <h4>License</h4>
<table border="2" class="adf-table-version"> <adf-datatable [data]="license"></adf-datatable>
<tr>
<th> Issued At </th>
<th> Expires At </th>
<th> Remaining Days </th>
<th> Holder </th>
<th> Mode </th>
<th> Is Cluster Enabled </th>
<th> Is Cryptodoc Enable </th>
</tr>
<tr style="align-items: center">
<td>{{ ecmVersion.license.issuedAt }}</td>
<td>{{ ecmVersion.license.expiresAt }}</td>
<td>{{ ecmVersion.license.remainingDays }}</td>
<td>{{ ecmVersion.license.holder }}</td>
<td>{{ ecmVersion.license.mode }}</td>
<td>{{ ecmVersion.license.isClusterEnabled }}</td>
<td>{{ ecmVersion.license.isCryptodocEnabled }}</td>
</tr>
</table>
<h4> Status</h4> <h4> Status</h4>
<table border="2" class="adf-table-version"> <adf-datatable [data]="status"></adf-datatable>
<tr>
<th> ReadOnly </th>
<th> Is Audit Enable </th>
<th> Is quick shared enable </th>
<th> Thumbnail Generation </th>
</tr>
<tr style="align-items: center">
<td>{{ ecmVersion.status.isReadOnly }}</td>
<td>{{ ecmVersion.status.isAuditEnabled }}</td>
<td>{{ ecmVersion.status.isQuickShareEnabled }}</td>
<td>{{ ecmVersion.status.isThumbnailGenerationEnabled }}</td>
</tr>
</table>
<h4>Modules</h4> <h4>Modules</h4>
<table border="2" class="adf-table-version">
<tr> <adf-datatable [data]="modules"></adf-datatable>
<th> ID </th>
<th> Title </th>
<th> Description </th>
<th> Version </th>
<th> Install Date </th>
<th> Install State </th>
<th> Version Minor </th>
<th> Version Max </th>
</tr>
<tr *ngFor="let module of ecmVersion.modules" style="align-items: center">
<td>{{ module.id }}</td>
<td>{{ module.title }}</td>
<td>{{ module.description }}</td>
<td>{{ module.version }}</td>
<td>{{ module.installDate }}</td>
<td>{{ module.installState }}</td>
<td>{{ module.versionMin }}</td>
<td>{{ module.versionMax }}</td>
</tr>
</table>
</div> </div>
<div *ngIf="githubUrlCommitAlpha"> <div *ngIf="githubUrlCommitAlpha">

View File

@ -15,6 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { DataSource } from '@angular/cdk/collections';
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Http } from '@angular/http'; import { Http } from '@angular/http';
import { AlfrescoAuthenticationService, AppConfigService, BpmProductVersionModel, DiscoveryApiService, EcmProductVersionModel } from 'ng2-alfresco-core'; import { AlfrescoAuthenticationService, AppConfigService, BpmProductVersionModel, DiscoveryApiService, EcmProductVersionModel } from 'ng2-alfresco-core';
@ -28,6 +29,9 @@ import { ObjectDataTableAdapter } from 'ng2-alfresco-datatable';
export class AboutComponent implements OnInit { export class AboutComponent implements OnInit {
data: ObjectDataTableAdapter; data: ObjectDataTableAdapter;
status: ObjectDataTableAdapter;
license: ObjectDataTableAdapter;
modules: ObjectDataTableAdapter;
githubUrlCommitAlpha: string = 'https://github.com/Alfresco/alfresco-ng2-components/commits/'; githubUrlCommitAlpha: string = 'https://github.com/Alfresco/alfresco-ng2-components/commits/';
configFile: string = 'app.config.json'; configFile: string = 'app.config.json';
@ -48,6 +52,33 @@ export class AboutComponent implements OnInit {
if (this.authService.isEcmLoggedIn()) { if (this.authService.isEcmLoggedIn()) {
this.discovery.getEcmProductInfo().subscribe((ecmVers) => { this.discovery.getEcmProductInfo().subscribe((ecmVers) => {
this.ecmVersion = ecmVers; this.ecmVersion = ecmVers;
this.modules = new ObjectDataTableAdapter(this.ecmVersion.modules, [
{type: 'text', key: 'id', title: 'ID', sortable: true},
{type: 'text', key: 'title', title: 'Title', sortable: true},
{type: 'text', key: 'version', title: 'Description', sortable: true},
{type: 'text', key: 'installDate', title: 'Install Date', sortable: true},
{type: 'text', key: 'installState', title: 'Install State', sortable: true},
{type: 'text', key: 'versionMin', title: 'Version Minor', sortable: true},
{type: 'text', key: 'versionMax', title: 'Version Max', sortable: true}
]);
this.status = new ObjectDataTableAdapter([this.ecmVersion.status], [
{type: 'text', key: 'isReadOnly', title: 'ReadOnly', sortable: true},
{type: 'text', key: 'isAuditEnabled', title: 'Is Audit Enable', sortable: true},
{type: 'text', key: 'isQuickShareEnabled', title: 'Is quick shared enable', sortable: true},
{type: 'text', key: 'isThumbnailGenerationEnabled', title: 'Thumbnail Generation', sortable: true}
]);
this.license = new ObjectDataTableAdapter([this.ecmVersion.license], [
{type: 'text', key: 'issuedAt', title: 'Issued At', sortable: true},
{type: 'text', key: 'expiresAt', title: 'Expires At', sortable: true},
{type: 'text', key: 'remainingDays', title: 'Remaining Days', sortable: true},
{type: 'text', key: 'holder', title: 'Holder', sortable: true},
{type: 'text', key: 'mode', title: 'Is Cluster Enabled', sortable: true},
{type: 'text', key: 'isClusterEnabled', title: 'Is Cluster Enabled', sortable: true},
{type: 'text', key: 'isCryptodocEnabled', title: 'Is Cryptodoc Enable', sortable: true}
]);
}); });
} }
@ -78,6 +109,7 @@ export class AboutComponent implements OnInit {
{type: 'text', key: 'name', title: 'Name', sortable: true}, {type: 'text', key: 'name', title: 'Name', sortable: true},
{type: 'text', key: 'version', title: 'Version', sortable: true} {type: 'text', key: 'version', title: 'Version', sortable: true}
]); ]);
}); });
this.ecmHost = this.appConfig.get<string>('ecmHost'); this.ecmHost = this.appConfig.get<string>('ecmHost');

View File

@ -158,7 +158,7 @@
</adf-process-instance-details> </adf-process-instance-details>
<hr> <hr>
<div *ngIf="currentProcessInstanceId"> <div *ngIf="currentProcessInstanceId">
{{'PS-TAB.START-PROCESS' | translate}} {{'PS-TAB.AUDIT-LOG' | translate}}
<button adf-process-audit <button adf-process-audit
[process-id]="currentProcessInstanceId" [process-id]="currentProcessInstanceId"
[download]="true" md-icon-button [download]="true" md-icon-button

View File

@ -27,7 +27,7 @@
<md-card> <md-card>
<md-card-content> <md-card-content>
<adf-process-instance-comments #activiticomments <adf-process-instance-comments #activiticomments
[readOnly]="!isRunning()" [readOnly]="false"
[processInstanceId]="processInstanceDetails.id"> [processInstanceId]="processInstanceDetails.id">
</adf-process-instance-comments> </adf-process-instance-comments>
</md-card-content> </md-card-content>

View File

@ -118,8 +118,7 @@ export let taskFormMock = {
'restLabelProperty': null, 'restLabelProperty': null,
'tab': null, 'tab': null,
'className': null, 'className': null,
'params': { 'params': {},
},
'dateDisplayFormat': null, 'dateDisplayFormat': null,
'layout': {'row': -1, 'column': -1, 'colspan': 1}, 'layout': {'row': -1, 'column': -1, 'colspan': 1},
'sizeX': 1, 'sizeX': 1,
@ -188,5 +187,15 @@ export let tasksMock = {
}; };
export let noDataMock = { export let noDataMock = {
data: [] data: [{
'size': 1,
'total': 1,
'start': 0,
'data': [{
'id': 1005,
'message': 'example-message',
'created': '2017-10-06T11:54:53.443+0000',
'createdBy': {'id': 4004, 'firstName': 'gadget', 'lastName': 'inspector', 'email': 'gadget@inspector.com'}
}]
}]
}; };

View File

@ -19,6 +19,7 @@
</div> </div>
<div class="adf-task-details-core"> <div class="adf-task-details-core">
<div class="adf-task-details-core-form"> <div class="adf-task-details-core-form">
<div *ngIf="isAssigned()"> <div *ngIf="isAssigned()">
<adf-form *ngIf="hasFormKey()" #activitiForm <adf-form *ngIf="hasFormKey()" #activitiForm
@ -84,7 +85,7 @@
<md-card *ngIf="showComments"> <md-card *ngIf="showComments">
<md-card-content> <md-card-content>
<adf-comments #activiticomments <adf-comments #activiticomments
[readOnly]="readOnlyForm" [readOnly]="taskPeople?.length === 0"
[taskId]="taskDetails.id"> [taskId]="taskDetails.id">
</adf-comments> </adf-comments>
</md-card-content> </md-card-content>

View File

@ -73,10 +73,10 @@ describe('TaskDetailsComponent', () => {
providers: [ providers: [
TaskListService, TaskListService,
PeopleProcessService, PeopleProcessService,
{ provide: TranslationService, useClass: TranslationMock }, {provide: TranslationService, useClass: TranslationMock},
{ provide: AppConfigService, useClass: AppConfigServiceMock } {provide: AppConfigService, useClass: AppConfigServiceMock}
], ],
schemas: [ NO_ERRORS_SCHEMA ] schemas: [NO_ERRORS_SCHEMA]
}).compileComponents(); }).compileComponents();
logService = TestBed.get(LogService); logService = TestBed.get(LogService);
@ -157,7 +157,7 @@ describe('TaskDetailsComponent', () => {
})); }));
it('should fetch new task details when taskId changed', () => { it('should fetch new task details when taskId changed', () => {
component.ngOnChanges({ 'taskId': change }); component.ngOnChanges({'taskId': change});
expect(getTaskDetailsSpy).toHaveBeenCalledWith('456'); expect(getTaskDetailsSpy).toHaveBeenCalledWith('456');
}); });
@ -167,12 +167,12 @@ describe('TaskDetailsComponent', () => {
}); });
it('should NOT fetch new task details when taskId changed to null', () => { it('should NOT fetch new task details when taskId changed to null', () => {
component.ngOnChanges({ 'taskId': nullChange }); component.ngOnChanges({'taskId': nullChange});
expect(getTaskDetailsSpy).not.toHaveBeenCalled(); expect(getTaskDetailsSpy).not.toHaveBeenCalled();
}); });
it('should set a placeholder message when taskId changed to null', () => { it('should set a placeholder message when taskId changed to null', () => {
component.ngOnChanges({ 'taskId': nullChange }); component.ngOnChanges({'taskId': nullChange});
fixture.detectChanges(); fixture.detectChanges();
expect(fixture.nativeElement.innerText).toBe('TASK_DETAILS.MESSAGES.NONE'); expect(fixture.nativeElement.innerText).toBe('TASK_DETAILS.MESSAGES.NONE');
}); });
@ -285,6 +285,48 @@ describe('TaskDetailsComponent', () => {
}); });
describe('Comments', () => {
it('should comments NOT be readonly if is there are user involved', () => {
component.showComments = true;
component.showHeaderContent = true;
component.ngOnChanges({'taskId': new SimpleChange('123', '456', true)});
component.taskPeople = [fakeUser];
fixture.detectChanges();
expect((component.activiticomments as any).nativeElement.readOnly).toBe(false);
});
it('should comments be readonly if is there are no user involved', () => {
component.showComments = true;
component.showHeaderContent = true;
component.ngOnChanges({'taskId': new SimpleChange('123', '456', true)});
component.taskPeople = [];
fixture.detectChanges();
expect((component.activiticomments as any).nativeElement.readOnly).toBe(true);
});
it('should comments be present if showComments is true', () => {
component.showComments = true;
component.showHeaderContent = true;
component.taskPeople = [];
component.ngOnChanges({'taskId': new SimpleChange('123', '456', true)});
fixture.detectChanges();
expect(component.activiticomments).toBeDefined();
});
it('should comments NOT be present if showComments is false', () => {
component.showComments = false;
component.taskPeople = [];
component.ngOnChanges({'taskId': new SimpleChange('123', '456', true)});
fixture.detectChanges();
expect(component.activiticomments).not.toBeDefined();
});
});
describe('assign task to user', () => { describe('assign task to user', () => {
beforeEach(() => { beforeEach(() => {

View File

@ -28,12 +28,12 @@ import { Component,
import { MdDialog, MdDialogRef } from '@angular/material'; import { MdDialog, MdDialogRef } from '@angular/material';
import { ContentLinkModel, FormFieldValidator, FormModel, FormOutcomeEvent } from 'ng2-activiti-form'; import { ContentLinkModel, FormFieldValidator, FormModel, FormOutcomeEvent } from 'ng2-activiti-form';
import { AlfrescoAuthenticationService, CardViewUpdateService, ClickNotification, LogService, UpdateNotification } from 'ng2-alfresco-core'; import { AlfrescoAuthenticationService, CardViewUpdateService, ClickNotification, LogService, UpdateNotification } from 'ng2-alfresco-core';
import { LightUserRepresentation } from 'ng2-alfresco-core'; import { LightUserRepresentation, PeopleProcessService } from 'ng2-alfresco-core';
import { PeopleProcessService } from 'ng2-alfresco-core';
import { Observable, Observer } from 'rxjs/Rx'; import { Observable, Observer } from 'rxjs/Rx';
import { TaskQueryRequestRepresentationModel } from '../models/filter.model'; import { TaskQueryRequestRepresentationModel } from '../models/filter.model';
import { TaskDetailsModel } from '../models/task-details.model'; import { TaskDetailsModel } from '../models/task-details.model';
import { TaskListService } from './../services/tasklist.service'; import { TaskListService } from './../services/tasklist.service';
import { CommentsComponent } from './comments.component';
declare var require: any; declare var require: any;
@ -48,7 +48,7 @@ declare var require: any;
export class TaskDetailsComponent implements OnInit, OnChanges { export class TaskDetailsComponent implements OnInit, OnChanges {
@ViewChild('activiticomments') @ViewChild('activiticomments')
activiticomments: any; activiticomments: CommentsComponent;
@ViewChild('activitichecklist') @ViewChild('activitichecklist')
activitichecklist: any; activitichecklist: any;