[ADF-2055] Ability to pre-populate form with a file and values (#2834)

* fix translations form

* fix style webpack script

* fix tslint error problem in viewer

* fix naming problems in attach file widget

* add start process form values data initialization option

* fix translation problems

* missing return type

* start process name configuration

* add CS cross PS configuration

* start process from file example

* fix minor issues

* add documentation and move the dialog in a separate component

* easy test select app

* alfrescoRepositoryName right property

* file conversion test

* fix issue after CR

* Remove forgotten semicolon.
This commit is contained in:
Eugenio Romano
2018-01-17 17:06:00 +00:00
committed by GitHub
parent 244234db4f
commit b1fd6cb60c
48 changed files with 789 additions and 344 deletions

View File

@@ -55,7 +55,7 @@ describe('AppsListComponent', () => {
component = fixture.componentInstance;
debugElement = fixture.debugElement;
service = fixture.debugElement.injector.get(AppsProcessService);
service = TestBed.get(AppsProcessService);
getAppsSpy = spyOn(service, 'getDeployedApplications').and.returnValue(Observable.of(deployedApps));
});

View File

@@ -22,6 +22,7 @@ import { MaterialModule } from '../material.module';
import { TranslateModule } from '@ngx-translate/core';
import { AppsListComponent } from './apps-list.component';
import { SelectAppsDialogComponent } from './select-apps-dialog-component';
@NgModule({
imports: [
@@ -31,11 +32,16 @@ import { AppsListComponent } from './apps-list.component';
TranslateModule
],
declarations: [
AppsListComponent
AppsListComponent,
SelectAppsDialogComponent
],
providers: [],
exports: [
AppsListComponent
AppsListComponent,
SelectAppsDialogComponent
],
entryComponents: [
SelectAppsDialogComponent
]
})
export class AppsListModule {

View File

@@ -16,3 +16,4 @@
*/
export * from './apps-list.component';
export * from './select-apps-dialog-component';

View File

@@ -0,0 +1,13 @@
<header mat-dialog-title id="adf-selet-app-dialog-title">{{'APP.DIALOG.TITLE' | translate}}</header>
<section mat-dialog-content>
<mat-select id="adf-selet-app-dialog-dropdown" placeholder="{{'APP.DIALOG.LIST' | translate}}" [(value)]="selectedProcess" >
<mat-option *ngFor="let currentProcessApp of processApps" [value]="currentProcessApp">
{{ currentProcessApp.name }}
</mat-option>
</mat-select>
</section>
<footer mat-dialog-actions fxLayout="row" fxLayoutAlign="end center">
<button mat-button (click)="onStart()">{{'APP.DIALOG.START' | translate}}</button>
</footer>

View File

@@ -0,0 +1,131 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Component } from '@angular/core';
import { async, TestBed } from '@angular/core/testing';
import { ComponentFixture } from '@angular/core/testing';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
import { MaterialModule } from '../material.module';
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
import { MatDialog } from '@angular/material';
import { OverlayContainer } from '@angular/cdk/overlay';
import { AppsProcessService } from '@alfresco/adf-core';
import { deployedApps } from '../mock/apps-list.mock';
import { Observable } from 'rxjs/Observable';
import { SelectAppsDialogComponent } from './select-apps-dialog-component';
@Component({
selector: 'adf-dialog-test',
template: ''
})
export class DialogSelectAppTestComponent {
processId: any;
dialogRef: any;
constructor(private dialog: MatDialog) {
}
startProcesAction() {
this.dialogRef = this.dialog.open(SelectAppsDialogComponent, {
width: '630px'
});
this.dialogRef.afterClosed().subscribe(selectedProcess => {
this.processId = selectedProcess.id;
});
}
}
describe('Select app dialog', () => {
let fixture: ComponentFixture<DialogSelectAppTestComponent>;
let component: DialogSelectAppTestComponent;
let dialogRef;
let overlayContainerElement: HTMLElement;
let service: AppsProcessService;
beforeEach(async(() => {
dialogRef = {
close: jasmine.createSpy('close')
};
TestBed.configureTestingModule({
imports: [
MaterialModule,
FormsModule,
ReactiveFormsModule,
BrowserDynamicTestingModule
],
declarations: [
SelectAppsDialogComponent,
DialogSelectAppTestComponent
],
providers: [
AppsProcessService,
{
provide: OverlayContainer,
useFactory: () => {
overlayContainerElement = document.createElement('div');
return { getContainerElement: () => overlayContainerElement };
}
}
{
provide: MatDialogRef, useValue: dialogRef
},
{
provide: MAT_DIALOG_DATA,
useValue: {}
}
]
});
TestBed.overrideModule(BrowserDynamicTestingModule, {
set: { entryComponents: [SelectAppsDialogComponent] }
});
TestBed.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(DialogSelectAppTestComponent);
component = fixture.componentInstance;
service = TestBed.get(AppsProcessService);
spyOn(service, 'getDeployedApplications').and.returnValue(Observable.of(deployedApps));
});
describe('Dialog', () => {
beforeEach(() => {
fixture.detectChanges();
};
it('should init title and dropdown', () => {
component.startProcesAction();
expect(overlayContainerElement.querySelector('.adf-selet-app-dialog-title')).toBeDefined();
expect(overlayContainerElement.querySelector('.adf-selet-app-dialog-dropdown')).toBeDefined();
});
});
});

View File

@@ -0,0 +1,56 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { AppsProcessService, NotificationService, TranslationService } from '@alfresco/adf-core';
import { Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
@Component({
selector: 'adf-select-apps-dialog',
templateUrl: 'select-apps-dialog-component.html'
})
export class SelectAppsDialogComponent {
processApps: any;
selectedProcess: any;
constructor(private appsProcessService: AppsProcessService,
private translateService: TranslationService,
private notificationService: NotificationService,
public dialogRef: MatDialogRef<SelectAppsDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any) {
this.appsProcessService.getDeployedApplications().subscribe(
(apps: any[]) => {
this.processApps = apps.filter((currentApp) => {
return currentApp.id;
});
},
(err) => {
this.translateService.get('TAG.MESSAGES.EXIST').subscribe((error) => {
this.notificationService.openSnackMessage(error, 4000);
});
}
);
}
onStart(): void {
this.dialogRef.close(this.selectedProcess);
}
}