[ADF-3299] and [ADF-3300] upgrade to Angular and Material 6 (#3579)

* upgrade to HttpClient

* upgrade to Renderer2

* upgrade Document reference

* remove useless test with deprecated ReflectiveInjector

* upgrade to latest typescript

* upgrade libs

* upgrade package scripts

* remove rxjs blacklists and duplicate rules

* add rxjs compat to help with migration

* fix breaking changes

* fix breaking changes in material

* fix breaking changes (material 6)

* upgrade rxjs, ngx-translate and flex layout

* update unit tests

* restore providers

* upgrade deprecated Observable.error

* rebase
fix first configuration problems

* fix style issues commented

* fix core build

* fix lib template errors

* move lib test execution in angular.json

* ignore

* karma conf files

* fix import statement test

* single run option

* update packages reporter

* restore report

* increase timeout

* improve karma conf test configuration

* fix test issues about lint

* fix test analytics

* fix process service test

* content service fix test

* fix logout directive test

* fix core test

* fix build

* update node-sass to latest

* update angular cli dependencies

* improve build script

create directorites and move files only if previous command succeded

* upgrade individual libs to 6.0

* remove old webpack files

* revert sass change

* fix type issues
fix style issues

* fix tslint demo shell issue

* fix peerdependencies

* fix test e2e BC

* package upate

* fix style import issue

* extract-text-webpack-plugin beta

* fix test dist build command

* remove alpha js-api

* fix tslint issue
add banner tslint rule

* upload service fix

* change BC script

* fix test dist script

* increase demo shell timeout test

* verbose copy

* path absolute

* fix script bc

* fix copy part

* fix path warning
fix monaco editor

* remove duplicate header

* remove unused import

* fix align and check ago tests

* add missing import

* fix notification button selector

* [ANGULAR6] fixed core tests

* fix CS test

* fix cs test step 2

* increase travis_wait for dist

* fix attachment PS

* fix checklist test

* use pdf min
This commit is contained in:
Denys Vuika
2018-08-07 11:58:16 +01:00
committed by Eugenio Romano
parent c510ec864d
commit 6b24bfb1d4
371 changed files with 16287 additions and 24504 deletions

View File

@@ -17,7 +17,7 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { TranslationService, TranslationMock } from '../../index';
import { Observable } from 'rxjs/Observable';
import { of } from 'rxjs';
import { FormService } from '../services/form.service';
import { FormListComponent } from './form-list.component';
import { setupTestBed } from '../../testing/setupTestBed';
@@ -51,7 +51,7 @@ describe('TaskAttachmentList', () => {
}));
it('should show the forms as a list', async(() => {
spyOn(service, 'getForms').and.returnValue(Observable.of([
spyOn(service, 'getForms').and.returnValue(of([
{ name: 'FakeName-1', lastUpdatedByFullName: 'FakeUser-1', lastUpdated: '2017-01-02' },
{ name: 'FakeName-2', lastUpdatedByFullName: 'FakeUser-2', lastUpdated: '2017-01-03' }
]));
@@ -62,6 +62,6 @@ describe('TaskAttachmentList', () => {
fixture.whenStable().then(() => {
expect(element.querySelectorAll('.adf-datatable-body > .adf-datatable-row').length).toBe(2);
});
});
}));
});

View File

@@ -26,7 +26,7 @@
</mat-card-header>
<mat-card-content>
<div *ngIf="form.hasTabs()">
<tabs-widget [tabs]="form.tabs" (formTabChanged)="onFieldChanged($event);"></tabs-widget>
<tabs-widget [tabs]="form.tabs"></tabs-widget>
</div>
<div *ngIf="!form.hasTabs() && form.hasFields()">
@@ -42,7 +42,7 @@
mat-button
[disabled]="!isOutcomeButtonEnabled(outcome)"
[class.adf-form-hide-button]="!isOutcomeButtonVisible(outcome, form.readOnly)"
(click)="onOutcomeClicked(outcome, $event)">
(click)="onOutcomeClicked(outcome)">
{{outcome.name | uppercase}}
</button>
</mat-card-actions>

View File

@@ -35,7 +35,7 @@
height: 4px;
}
& .mat-input-wrapper {
& .mat-form-field-wrapper {
margin: 0px 12px 0px 0px;
}
}

View File

@@ -17,7 +17,7 @@
import { SimpleChange } from '@angular/core';
import { LogService } from '../../services/log.service';
import { Observable } from 'rxjs/Observable';
import { Observable, of, throwError } from 'rxjs';
import { fakeForm } from '../../mock';
import { FormService } from './../services/form.service';
import { NodeService } from './../services/node.service';
@@ -177,7 +177,7 @@ describe('FormComponent', () => {
});
});
spyOn(visibilityService, 'getTaskProcessVariable').and.returnValue(Observable.of({}));
spyOn(visibilityService, 'getTaskProcessVariable').and.returnValue(of({}));
spyOn(formService, 'getTask').and.callFake((currentTaskId) => {
return Observable.create(observer => {
observer.next({ taskId: currentTaskId, processDefinitionId: '10201' });
@@ -200,7 +200,7 @@ describe('FormComponent', () => {
});
});
spyOn(visibilityService, 'getTaskProcessVariable').and.returnValue(Observable.of({}));
spyOn(visibilityService, 'getTaskProcessVariable').and.returnValue(of({}));
spyOn(formService, 'getTask').and.callFake((currentTaskId) => {
return Observable.create(observer => {
observer.next({ taskId: currentTaskId, processDefinitionId: 'null' });
@@ -226,7 +226,7 @@ describe('FormComponent', () => {
});
it('should refresh visibility when the form is loaded', () => {
spyOn(formService, 'getFormDefinitionById').and.returnValue(Observable.of(JSON.parse(JSON.stringify(fakeForm))));
spyOn(formService, 'getFormDefinitionById').and.returnValue(of(JSON.parse(JSON.stringify(fakeForm))));
const formId = '123';
formComponent.formId = formId;
@@ -418,7 +418,7 @@ describe('FormComponent', () => {
});
it('should fetch and parse form by task id', (done) => {
spyOn(formService, 'getTask').and.returnValue(Observable.of({}));
spyOn(formService, 'getTask').and.returnValue(of({}));
spyOn(formService, 'getTaskForm').and.callFake((currentTaskId) => {
return Observable.create(observer => {
observer.next({ taskId: currentTaskId });
@@ -441,10 +441,10 @@ describe('FormComponent', () => {
it('should handle error when getting form by task id', (done) => {
const error = 'Some error';
spyOn(formService, 'getTask').and.returnValue(Observable.of({}));
spyOn(formService, 'getTask').and.returnValue(of({}));
spyOn(formComponent, 'handleError').and.stub();
spyOn(formService, 'getTaskForm').and.callFake((taskId) => {
return Observable.throw(error);
return throwError(error);
});
formComponent.getFormByTaskId('123').then(_ => {
@@ -454,7 +454,7 @@ describe('FormComponent', () => {
});
it('should apply readonly state when getting form by task id', (done) => {
spyOn(formService, 'getTask').and.returnValue(Observable.of({}));
spyOn(formService, 'getTask').and.returnValue(of({}));
spyOn(formService, 'getTaskForm').and.callFake((taskId) => {
return Observable.create(observer => {
observer.next({ taskId: taskId });
@@ -495,7 +495,7 @@ describe('FormComponent', () => {
const error = 'Some error';
spyOn(formComponent, 'handleError').and.stub();
spyOn(formService, 'getFormDefinitionById').and.callFake(() => Observable.throw(error));
spyOn(formService, 'getFormDefinitionById').and.callFake(() => throwError(error));
formComponent.getFormDefinitionByFormId('123');
expect(formService.getFormDefinitionById).toHaveBeenCalledWith('123');
@@ -562,7 +562,7 @@ describe('FormComponent', () => {
it('should handle error during form save', () => {
const error = 'Error';
spyOn(formService, 'saveTaskForm').and.callFake(() => Observable.throw(error));
spyOn(formService, 'saveTaskForm').and.callFake(() => throwError(error));
spyOn(formComponent, 'handleError').and.stub();
formComponent.form = new FormModel({ taskId: '123' });

View File

@@ -23,8 +23,9 @@ import { FormService } from './../services/form.service';
import { NodeService } from './../services/node.service';
import { ContentLinkModel } from './widgets/core/content-link.model';
import { FormFieldModel, FormModel, FormOutcomeEvent, FormOutcomeModel, FormValues, FormFieldValidator } from './widgets/core/index';
import { Observable } from 'rxjs/Observable';
import { Observable, of } from 'rxjs';
import { WidgetVisibilityService } from './../services/widget-visibility.service';
import { switchMap } from 'rxjs/operators';
@Component({
selector: 'adf-form',
@@ -320,14 +321,15 @@ export class FormComponent implements OnInit, OnChanges {
}
findProcessVariablesByTaskId(taskId: string): Observable<any> {
return this.formService.getTask(taskId).
switchMap((task: any) => {
if (this.isAProcessTask(task)) {
return this.visibilityService.getTaskProcessVariable(taskId);
} else {
return Observable.of({});
}
});
return this.formService.getTask(taskId).pipe(
switchMap((task: any) => {
if (this.isAProcessTask(task)) {
return this.visibilityService.getTaskProcessVariable(taskId);
} else {
return of({});
}
})
);
}
isAProcessTask(taskRepresentation) {

View File

@@ -17,7 +17,7 @@
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { SimpleChange } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { of } from 'rxjs';
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
@@ -75,8 +75,8 @@ describe('FormComponent UI and visibility', () => {
describe('Validation icon', () => {
it('should display valid icon for valid form', () => {
spyOn(service, 'getTask').and.returnValue(Observable.of({}));
spyOn(service, 'getTaskForm').and.returnValue(Observable.of(formDefinitionTwoTextFields));
spyOn(service, 'getTask').and.returnValue(of({}));
spyOn(service, 'getTaskForm').and.returnValue(of(formDefinitionTwoTextFields));
let change = new SimpleChange(null, 1, true);
component.ngOnChanges({ 'taskId': change });
@@ -87,8 +87,8 @@ describe('FormComponent UI and visibility', () => {
});
it('should display invalid icon for valid form', () => {
spyOn(service, 'getTask').and.returnValue(Observable.of({}));
spyOn(service, 'getTaskForm').and.returnValue(Observable.of(formDefinitionRequiredField));
spyOn(service, 'getTask').and.returnValue(of({}));
spyOn(service, 'getTaskForm').and.returnValue(of(formDefinitionRequiredField));
let change = new SimpleChange(null, 1, true);
component.ngOnChanges({ 'taskId': change });
@@ -99,8 +99,8 @@ describe('FormComponent UI and visibility', () => {
});
it('should NOT display validation icon when [showValidationIcon] is false', () => {
spyOn(service, 'getTask').and.returnValue(Observable.of({}));
spyOn(service, 'getTaskForm').and.returnValue(Observable.of(formDefinitionTwoTextFields));
spyOn(service, 'getTask').and.returnValue(of({}));
spyOn(service, 'getTaskForm').and.returnValue(of(formDefinitionTwoTextFields));
let change = new SimpleChange(null, 1, true);
component.ngOnChanges({ 'taskId': change });
@@ -114,8 +114,8 @@ describe('FormComponent UI and visibility', () => {
describe('form definition', () => {
it('should display two text fields form definition', () => {
spyOn(service, 'getTask').and.returnValue(Observable.of({}));
spyOn(service, 'getTaskForm').and.returnValue(Observable.of(formDefinitionTwoTextFields));
spyOn(service, 'getTask').and.returnValue(of({}));
spyOn(service, 'getTaskForm').and.returnValue(of(formDefinitionTwoTextFields));
let change = new SimpleChange(null, 1, true);
component.ngOnChanges({ 'taskId': change });
@@ -131,8 +131,8 @@ describe('FormComponent UI and visibility', () => {
});
it('should display dropdown field', fakeAsync(() => {
spyOn(service, 'getTask').and.returnValue(Observable.of({}));
spyOn(service, 'getTaskForm').and.returnValue(Observable.of(formDefinitionDropdownField));
spyOn(service, 'getTask').and.returnValue(of({}));
spyOn(service, 'getTaskForm').and.returnValue(of(formDefinitionDropdownField));
let change = new SimpleChange(null, 1, true);
component.ngOnChanges({ 'taskId': change });
@@ -162,8 +162,8 @@ describe('FormComponent UI and visibility', () => {
describe('Visibility conditions', () => {
it('should hide the field based on the next one', () => {
spyOn(service, 'getTask').and.returnValue(Observable.of({}));
spyOn(service, 'getTaskForm').and.returnValue(Observable.of(formDefVisibilitiFieldDependsOnNextOne));
spyOn(service, 'getTask').and.returnValue(of({}));
spyOn(service, 'getTaskForm').and.returnValue(of(formDefVisibilitiFieldDependsOnNextOne));
let change = new SimpleChange(null, 1, true);
component.ngOnChanges({ 'taskId': change });
@@ -179,8 +179,8 @@ describe('FormComponent UI and visibility', () => {
});
it('should hide the field based on the previous one', () => {
spyOn(service, 'getTask').and.returnValue(Observable.of({}));
spyOn(service, 'getTaskForm').and.returnValue(Observable.of(formDefVisibilitiFieldDependsOnPreviousOne));
spyOn(service, 'getTask').and.returnValue(of({}));
spyOn(service, 'getTaskForm').and.returnValue(of(formDefVisibilitiFieldDependsOnPreviousOne));
let change = new SimpleChange(null, 1, true);
component.ngOnChanges({ 'taskId': change });
@@ -196,8 +196,8 @@ describe('FormComponent UI and visibility', () => {
});
it('should show the hidden field when the visibility condition change to true', () => {
spyOn(service, 'getTask').and.returnValue(Observable.of({}));
spyOn(service, 'getTaskForm').and.returnValue(Observable.of(formDefVisibilitiFieldDependsOnNextOne));
spyOn(service, 'getTask').and.returnValue(of({}));
spyOn(service, 'getTaskForm').and.returnValue(of(formDefVisibilitiFieldDependsOnNextOne));
let change = new SimpleChange(null, 1, true);
component.ngOnChanges({ 'taskId': change });
@@ -221,8 +221,8 @@ describe('FormComponent UI and visibility', () => {
describe('Readonly Form', () => {
it('should display two text fields readonly', () => {
spyOn(service, 'getTask').and.returnValue(Observable.of({}));
spyOn(service, 'getTaskForm').and.returnValue(Observable.of(formReadonlyTwoTextFields));
spyOn(service, 'getTask').and.returnValue(of({}));
spyOn(service, 'getTaskForm').and.returnValue(of(formReadonlyTwoTextFields));
let change = new SimpleChange(null, 1, true);
component.ngOnChanges({ 'taskId': change });

View File

@@ -24,7 +24,7 @@
[disabled]="!isOutcomeButtonEnabled(outcome)"
[class.mdl-button--colored]="!outcome.isSystem"
[class.adf-form-hide-button]="!isOutcomeButtonVisible(outcome, form.readOnly)"
(click)="onOutcomeClicked(outcome, $event)">
(click)="onOutcomeClicked(outcome)">
{{outcome.name}}
</button>
</mat-card-content>

View File

@@ -17,7 +17,7 @@
import { CUSTOM_ELEMENTS_SCHEMA, SimpleChange } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs/Observable';
import { of, throwError } from 'rxjs';
import { startFormDateWidgetMock, startFormDropdownDefinitionMock, startFormTextDefinitionMock, startMockForm, startMockFormWithTab } from '../../mock';
import { startFormAmountWidgetMock, startFormNumberWidgetMock, startFormRadioButtonWidgetMock } from '../../mock';
import { FormService } from './../services/form.service';
@@ -53,7 +53,7 @@ describe('StartFormComponent', () => {
formService = TestBed.get(FormService);
visibilityService = TestBed.get(WidgetVisibilityService);
getStartFormSpy = spyOn(formService, 'getStartFormDefinition').and.returnValue(Observable.of({
getStartFormSpy = spyOn(formService, 'getStartFormDefinition').and.returnValue(of({
processDefinitionName: 'my:process'
}));
});
@@ -89,13 +89,13 @@ describe('StartFormComponent', () => {
});
it('should consume errors encountered when loading start form', () => {
getStartFormSpy.and.returnValue(Observable.throw({}));
getStartFormSpy.and.returnValue(throwError({}));
component.processDefinitionId = exampleId1;
component.ngOnInit();
});
it('should show outcome buttons by default', () => {
getStartFormSpy.and.returnValue(Observable.of({
getStartFormSpy.and.returnValue(of({
id: '1',
processDefinitionName: 'my:process',
outcomes: [{
@@ -111,7 +111,7 @@ describe('StartFormComponent', () => {
});
it('should show outcome buttons if showOutcomeButtons is true', () => {
getStartFormSpy.and.returnValue(Observable.of({
getStartFormSpy.and.returnValue(of({
id: '1',
processDefinitionName: 'my:process',
outcomes: [{
@@ -127,7 +127,7 @@ describe('StartFormComponent', () => {
});
it('should fetch start form detasils by processDefinitionId ', () => {
getStartFormSpy.and.returnValue(Observable.of(startMockForm));
getStartFormSpy.and.returnValue(of(startMockForm));
component.processDefinitionId = exampleId1;
component.showOutcomeButtons = true;
component.ngOnChanges({ processDefinitionId: new SimpleChange(exampleId1, exampleId2, true) });
@@ -139,7 +139,7 @@ describe('StartFormComponent', () => {
describe('Disply widgets', () => {
it('should be able to display a textWidget from a process definition', () => {
getStartFormSpy.and.returnValue(Observable.of(startFormTextDefinitionMock));
getStartFormSpy.and.returnValue(of(startFormTextDefinitionMock));
component.processDefinitionId = exampleId1;
component.showOutcomeButtons = true;
component.ngOnChanges({ processDefinitionId: new SimpleChange(exampleId1, exampleId2, true) });
@@ -157,7 +157,7 @@ describe('StartFormComponent', () => {
});
it('should be able to display a radioButtonWidget from a process definition', () => {
getStartFormSpy.and.returnValue(Observable.of(startFormRadioButtonWidgetMock));
getStartFormSpy.and.returnValue(of(startFormRadioButtonWidgetMock));
component.processDefinitionId = exampleId1;
component.showOutcomeButtons = true;
component.ngOnChanges({ processDefinitionId: new SimpleChange(exampleId1, exampleId2, true) });
@@ -175,7 +175,7 @@ describe('StartFormComponent', () => {
});
it('should be able to display a amountWidget from a process definition', () => {
getStartFormSpy.and.returnValue(Observable.of(startFormAmountWidgetMock));
getStartFormSpy.and.returnValue(of(startFormAmountWidgetMock));
component.processDefinitionId = exampleId1;
component.showOutcomeButtons = true;
component.ngOnChanges({ processDefinitionId: new SimpleChange(exampleId1, exampleId2, true) });
@@ -193,7 +193,7 @@ describe('StartFormComponent', () => {
});
it('should be able to display a numberWidget from a process definition', () => {
getStartFormSpy.and.returnValue(Observable.of(startFormNumberWidgetMock));
getStartFormSpy.and.returnValue(of(startFormNumberWidgetMock));
component.processDefinitionId = exampleId1;
component.showOutcomeButtons = true;
component.ngOnChanges({ processDefinitionId: new SimpleChange(exampleId1, exampleId2, true) });
@@ -209,7 +209,7 @@ describe('StartFormComponent', () => {
});
it('should be able to display a dropDown Widget from a process definition', () => {
getStartFormSpy.and.returnValue(Observable.of(startFormDropdownDefinitionMock));
getStartFormSpy.and.returnValue(of(startFormDropdownDefinitionMock));
component.processDefinitionId = exampleId1;
component.showOutcomeButtons = true;
component.ngOnChanges({ processDefinitionId: new SimpleChange(exampleId1, exampleId2, true) });
@@ -232,7 +232,7 @@ describe('StartFormComponent', () => {
});
it('should be able to display a date Widget from a process definition', () => {
getStartFormSpy.and.returnValue(Observable.of(startFormDateWidgetMock));
getStartFormSpy.and.returnValue(of(startFormDateWidgetMock));
component.processDefinitionId = exampleId1;
component.showOutcomeButtons = true;
component.ngOnChanges({ processDefinitionId: new SimpleChange(exampleId1, exampleId2, true) });
@@ -242,7 +242,7 @@ describe('StartFormComponent', () => {
const formFields = component.form.getFormFields();
const labelField = formFields.find(field => field.id === 'date');
const dateWidget = fixture.debugElement.nativeElement.querySelector('dropdown-widget');
const dateLabelElement = fixture.debugElement.nativeElement.querySelector('#data-widget .mat-input-infix> .adf-label');
const dateLabelElement = fixture.debugElement.nativeElement.querySelector('#data-widget .mat-form-field-infix> .adf-label');
expect(dateWidget).toBeDefined();
expect(labelField.type).toBe('date');
expect(dateLabelElement.innerText).toBe('date (D-M-YYYY)');
@@ -250,7 +250,7 @@ describe('StartFormComponent', () => {
});
it('should fetch and define form fields with proper type', () => {
getStartFormSpy.and.returnValue(Observable.of(startMockForm));
getStartFormSpy.and.returnValue(of(startMockForm));
component.processDefinitionId = exampleId1;
component.showOutcomeButtons = true;
component.ngOnChanges({ processDefinitionId: new SimpleChange(exampleId1, exampleId2, true) });
@@ -265,7 +265,7 @@ describe('StartFormComponent', () => {
});
it('should show dropdown options', () => {
getStartFormSpy.and.returnValue(Observable.of(startMockForm));
getStartFormSpy.and.returnValue(of(startMockForm));
component.processDefinitionId = exampleId1;
component.showOutcomeButtons = true;
component.ngOnChanges({ processDefinitionId: new SimpleChange(exampleId1, exampleId2, true) });
@@ -281,7 +281,7 @@ describe('StartFormComponent', () => {
});
it('should disply start form with fields ', async(() => {
getStartFormSpy.and.returnValue(Observable.of(startMockForm));
getStartFormSpy.and.returnValue(of(startMockForm));
component.processDefinitionId = exampleId1;
component.showOutcomeButtons = true;
component.ngOnChanges({ processDefinitionId: new SimpleChange(exampleId1, exampleId2, true) });
@@ -289,9 +289,9 @@ describe('StartFormComponent', () => {
fixture.detectChanges();
const formFieldsWidget = fixture.debugElement.nativeElement.querySelector('form-field');
const inputElement = fixture.debugElement.nativeElement.querySelector('.adf-input');
const inputLabelElement = fixture.debugElement.nativeElement.querySelector('.mat-input-infix > .adf-label');
const inputLabelElement = fixture.debugElement.nativeElement.querySelector('.mat-form-field-infix > .adf-label');
const dateElement = fixture.debugElement.nativeElement.querySelector('#billdate');
const dateLabelElement = fixture.debugElement.nativeElement.querySelector('#data-widget .mat-input-infix> .adf-label');
const dateLabelElement = fixture.debugElement.nativeElement.querySelector('#data-widget .mat-form-field-infix> .adf-label');
const selectElement = fixture.debugElement.nativeElement.querySelector('#claimtype');
const selectLabelElement = fixture.debugElement.nativeElement.querySelector('.adf-dropdown-widget > .adf-label');
expect(formFieldsWidget).toBeDefined();
@@ -305,7 +305,7 @@ describe('StartFormComponent', () => {
}));
it('should refresh start form on click of refresh button ', async(() => {
getStartFormSpy.and.returnValue(Observable.of(startMockForm));
getStartFormSpy.and.returnValue(of(startMockForm));
component.processDefinitionId = exampleId1;
component.showOutcomeButtons = true;
component.showRefreshButton = true;
@@ -324,7 +324,7 @@ describe('StartFormComponent', () => {
}));
it('should difine custom-tabs ', async(() => {
getStartFormSpy.and.returnValue(Observable.of(startMockFormWithTab));
getStartFormSpy.and.returnValue(of(startMockFormWithTab));
component.processDefinitionId = exampleId1;
component.showOutcomeButtons = true;
component.showRefreshButton = true;
@@ -342,7 +342,7 @@ describe('StartFormComponent', () => {
}));
it('should difine title and [custom-action-buttons]', async(() => {
getStartFormSpy.and.returnValue(Observable.of(startMockFormWithTab));
getStartFormSpy.and.returnValue(of(startMockFormWithTab));
component.processDefinitionId = exampleId1;
component.showOutcomeButtons = true;
component.showRefreshButton = true;

View File

@@ -31,11 +31,7 @@
&-amount-widget__container {
max-width: 100%;
.mat-input-placeholder-wrapper {
top: -6px !important;
}
.mat-input-placeholder-wrapper {
.mat-form-field-label-wrapper {
top: 0 !important;
left: 13px;
}

View File

@@ -62,7 +62,7 @@
width: 100%;
}
.mat-input-placeholder-wrapper {
.mat-form-field-label-wrapper {
top: 5px !important;
}
@@ -79,7 +79,7 @@
color: mat-color($primary);
}
.mat-input-prefix {
.mat-form-field-prefix {
color: mat-color($primary);
}
}

View File

@@ -19,7 +19,7 @@ import { SimpleChange } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { TranslationService, ContentService } from '../../../../services';
import { Observable } from 'rxjs/Observable';
import { of } from 'rxjs';
import { ProcessContentService } from '../../../services/process-content.service';
import { ContentLinkModel } from '../index';
@@ -105,7 +105,7 @@ describe('ContentWidgetComponent', () => {
it('should load the thumbnail preview of the png image', (done) => {
let blob = createFakeImageBlob();
spyOn(processContentService, 'getFileRawContent').and.returnValue(Observable.of(blob));
spyOn(processContentService, 'getFileRawContent').and.returnValue(of(blob));
component.thumbnailLoaded.subscribe((res) => {
fixture.detectChanges();
@@ -148,7 +148,7 @@ describe('ContentWidgetComponent', () => {
it('should load the thumbnail preview of a pdf', (done) => {
let blob = createFakePdfBlob();
spyOn(processContentService, 'getContentThumbnail').and.returnValue(Observable.of(blob));
spyOn(processContentService, 'getContentThumbnail').and.returnValue(of(blob));
component.thumbnailLoaded.subscribe((res) => {
fixture.detectChanges();
@@ -230,8 +230,8 @@ describe('ContentWidgetComponent', () => {
it('should open the viewer when the view button is clicked', (done) => {
let blob = createFakePdfBlob();
spyOn(processContentService, 'getContentPreview').and.returnValue(Observable.of(blob));
spyOn(processContentService, 'getFileRawContent').and.returnValue(Observable.of(blob));
spyOn(processContentService, 'getContentPreview').and.returnValue(of(blob));
spyOn(processContentService, 'getFileRawContent').and.returnValue(of(blob));
component.content = new ContentLinkModel({
id: 4004,
@@ -264,7 +264,7 @@ describe('ContentWidgetComponent', () => {
it('should download the pdf when the download button is clicked', () => {
let blob = createFakePdfBlob();
spyOn(processContentService, 'getFileRawContent').and.returnValue(Observable.of(blob));
spyOn(processContentService, 'getFileRawContent').and.returnValue(of(blob));
spyOn(serviceContent, 'downloadBlob').and.callThrough();
component.content = new ContentLinkModel({

View File

@@ -18,7 +18,7 @@
import { ContentService } from '../../../../services/content.service';
import { LogService } from '../../../../services/log.service';
import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges, ViewEncapsulation } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Observable } from 'rxjs';
import { ProcessContentService } from '../../../services/process-content.service';
import { ContentLinkModel } from '../core/content-link.model';
import { FormService } from './../../../services/form.service';

View File

@@ -4,7 +4,7 @@
&-date-time-widget {
.mat-input-suffix {
.mat-form-field-suffix {
text-align: right;
position: absolute;
margin-top: 30px;

View File

@@ -3,7 +3,7 @@
.adf {
&-date-widget {
.mat-input-suffix {
.mat-form-field-suffix {
text-align: right;
position: absolute;
margin-top: 30px;

View File

@@ -151,7 +151,7 @@ describe('DateWidgetComponent', () => {
widget.field = new FormFieldModel(new FormModel(), {
id: 'date-field-id',
name: 'date-name',
value: '12-30-9999';
value: '12-30-9999',
type: 'date',
readOnly: 'false'
});

View File

@@ -17,7 +17,7 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { Observable } from 'rxjs/Observable';
import { Observable, of } from 'rxjs';
import { FormService } from '../../../services/form.service';
import { WidgetVisibilityService } from '../../../services/widget-visibility.service';
import { FormFieldOption } from './../core/form-field-option';
@@ -130,7 +130,7 @@ describe('DropdownWidgetComponent', () => {
beforeEach(async(() => {
spyOn(visibilityService, 'refreshVisibility').and.stub();
spyOn(formService, 'getRestFieldValues').and.callFake(() => {
return Observable.of(fakeOptionList);
return of(fakeOptionList);
});
widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id' }), {
id: 'dropdown-id',
@@ -194,7 +194,7 @@ describe('DropdownWidgetComponent', () => {
beforeEach(async(() => {
spyOn(visibilityService, 'refreshVisibility').and.stub();
spyOn(formService, 'getRestFieldValuesByProcessId').and.callFake(() => {
return Observable.of(fakeOptionList);
return of(fakeOptionList);
});
widget.field = new FormFieldModel(new FormModel({ processDefinitionId: 'fake-process-id' }), {
id: 'dropdown-id',

View File

@@ -63,7 +63,6 @@
<row-editor *ngIf="editMode"
[table]="content"
[row]="editRow"
[column]="column"
(save)="onSaveChanges()"
(cancel)="onCancelChanges()">
</row-editor>

View File

@@ -17,7 +17,7 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { Observable } from 'rxjs/Observable';
import { Observable, of, throwError } from 'rxjs';
import { FormService } from './../../../../../services/form.service';
import { FormFieldModel, FormModel } from './../../../core/index';
import { DynamicTableColumnOption } from './../../dynamic-table-column-option.model';
@@ -145,7 +145,7 @@ describe('DropdownEditorComponent', () => {
const error = 'error';
spyOn(formService, 'getRestFieldValuesColumn').and.returnValue(
Observable.throw(error)
throwError(error)
);
spyOn(component, 'handleError').and.stub();
@@ -161,7 +161,7 @@ describe('DropdownEditorComponent', () => {
const error = 'error';
spyOn(formService, 'getRestFieldValuesColumnByProcessId').and.returnValue(
Observable.throw(error)
throwError(error)
);
spyOn(component, 'handleError').and.stub();
@@ -209,7 +209,7 @@ describe('DropdownEditorComponent', () => {
beforeEach(async(() => {
stubFormService = fixture.debugElement.injector.get(FormService);
spyOn(stubFormService, 'getRestFieldValuesColumn').and.returnValue(Observable.of(fakeOptionList));
spyOn(stubFormService, 'getRestFieldValuesColumn').and.returnValue(of(fakeOptionList));
row = <DynamicTableRow> {value: {dropdown: 'one'}};
column = <DynamicTableColumn> {
id: 'column-id',
@@ -257,7 +257,7 @@ describe('DropdownEditorComponent', () => {
beforeEach(async(() => {
stubFormService = fixture.debugElement.injector.get(FormService);
spyOn(stubFormService, 'getRestFieldValuesColumnByProcessId').and.returnValue(Observable.of(fakeOptionList));
spyOn(stubFormService, 'getRestFieldValuesColumnByProcessId').and.returnValue(of(fakeOptionList));
row = <DynamicTableRow> {value: {dropdown: 'one'}};
column = <DynamicTableColumn> {
id: 'column-id',

View File

@@ -39,7 +39,7 @@
&-invalid {
.mat-input-underline {
.mat-form-field-underline {
background-color: #f44336 !important;
}
@@ -47,7 +47,7 @@
border-color: mat-color($warn);
}
.mat-input-prefix {
.mat-form-field-prefix {
color: mat-color($warn);
}

View File

@@ -16,7 +16,7 @@
*/
import { ElementRef } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Observable } from 'rxjs';
import { FormService } from '../../../services/form.service';
import { FormFieldModel } from '../core/form-field.model';
import { FormModel } from '../core/form.model';

View File

@@ -18,7 +18,7 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { UserProcessModel } from '../../../../models';
import { Observable } from 'rxjs/Observable';
import { Observable } from 'rxjs';
import { FormService } from '../../../services/form.service';
import { FormFieldTypes } from '../core/form-field-types';
import { FormFieldModel } from '../core/form-field.model';

View File

@@ -24,7 +24,7 @@ import { FormService } from '../../../services/form.service';
import { GroupModel } from '../core/group.model';
import { baseHost, WidgetComponent } from './../widget.component';
import { FormControl } from '@angular/forms';
import { Observable } from 'rxjs/Observable';
import { Observable, empty } from 'rxjs';
import {
catchError,
distinctUntilChanged,
@@ -32,7 +32,6 @@ import {
switchMap,
tap
} from 'rxjs/operators';
import 'rxjs/add/observable/empty';
@Component({
selector: 'people-widget',
@@ -62,7 +61,7 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit {
}),
distinctUntilChanged(),
switchMap((searchTerm) => {
let userResponse = Observable.empty();
let userResponse: any = empty();
if (typeof searchTerm === 'string') {
userResponse = this.formService.getWorkflowUsers(searchTerm, this.groupId)

View File

@@ -16,7 +16,7 @@
*/
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs/Observable';
import { Observable, of } from 'rxjs';
import { FormService } from '../../../services/form.service';
import { ContainerModel } from '../core/container.model';
import { FormFieldTypes } from '../core/form-field-types';
@@ -123,7 +123,7 @@ describe('RadioButtonsWidgetComponent', () => {
});
it('should update the field value when an option is selected', () => {
spyOn(widget, 'onFieldChanged').and.returnValue(Observable.of({}));
spyOn(widget, 'onFieldChanged').and.returnValue(of({}));
widget.onOptionClick('fake-opt');
expect(widget.field.value).toEqual('fake-opt');
@@ -153,7 +153,7 @@ describe('RadioButtonsWidgetComponent', () => {
beforeEach(async(() => {
stubFormService = fixture.debugElement.injector.get(FormService);
spyOn(stubFormService, 'getRestFieldValues').and.returnValue(Observable.of(restOption));
spyOn(stubFormService, 'getRestFieldValues').and.returnValue(of(restOption));
radioButtonWidget.field = new FormFieldModel(new FormModel({ taskId: 'task-id' }), {
id: 'radio-id',
name: 'radio-name',
@@ -196,7 +196,7 @@ describe('RadioButtonsWidgetComponent', () => {
restUrl: 'rest-url'
});
stubFormService = fixture.debugElement.injector.get(FormService);
spyOn(stubFormService, 'getRestFieldValuesByProcessId').and.returnValue(Observable.of(restOption));
spyOn(stubFormService, 'getRestFieldValuesByProcessId').and.returnValue(of(restOption));
radioButtonWidget.field.isVisible = true;
fixture.detectChanges();
}));

View File

@@ -24,7 +24,7 @@ import {
HostListener,
Input,
OnChanges,
Renderer,
Renderer2,
SimpleChanges
} from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
@@ -59,7 +59,7 @@ export class InputMaskDirective implements OnChanges, ControlValueAccessor {
private value;
private invalidCharacters = [];
constructor(private el: ElementRef, private render: Renderer) {
constructor(private el: ElementRef, private render: Renderer2) {
}
_onChange = (_: any) => {
@@ -100,7 +100,7 @@ export class InputMaskDirective implements OnChanges, ControlValueAccessor {
if (this.byPassKeys.indexOf(keyCode) === -1) {
let value = this.getMasked(false, actualValue, maskToApply, isMaskReversed);
let calculatedCaret = this.calculateCaretPosition(startCaret, actualValue, keyCode);
this.render.setElementAttribute(this.el.nativeElement, 'value', value);
this.render.setAttribute(this.el.nativeElement, 'value', value);
this.el.nativeElement.value = value;
this.setValue(value);
this._onChange(value);

View File

@@ -16,7 +16,7 @@
*/
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs/Observable';
import { Observable, of, throwError } from 'rxjs';
import { By } from '@angular/platform-browser';
import { FormService } from '../../../services/form.service';
@@ -99,7 +99,7 @@ describe('TypeaheadWidgetComponent', () => {
restUrl: 'whateverURL'
});
const err = 'Error';
spyOn(formService, 'getRestFieldValues').and.returnValue(Observable.throw(err));
spyOn(formService, 'getRestFieldValues').and.returnValue(throwError(err));
spyOn(widget, 'handleError').and.stub();
widget.ngOnInit();
@@ -121,7 +121,7 @@ describe('TypeaheadWidgetComponent', () => {
restUrl: 'whateverURL'
});
const err = 'Error';
spyOn(formService, 'getRestFieldValuesByProcessId').and.returnValue(Observable.throw(err));
spyOn(formService, 'getRestFieldValuesByProcessId').and.returnValue(throwError(err));
spyOn(widget, 'handleError').and.stub();
widget.ngOnInit();
@@ -270,7 +270,7 @@ describe('TypeaheadWidgetComponent', () => {
beforeEach(async(() => {
stubFormService = fixture.debugElement.injector.get(FormService);
spyOn(stubFormService, 'getRestFieldValues').and.returnValue(Observable.of(fakeOptionList));
spyOn(stubFormService, 'getRestFieldValues').and.returnValue(of(fakeOptionList));
typeaheadWidgetComponent.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id' }), {
id: 'typeahead-id',
name: 'typeahead-name',
@@ -348,7 +348,7 @@ describe('TypeaheadWidgetComponent', () => {
beforeEach(async(() => {
stubFormService = fixture.debugElement.injector.get(FormService);
spyOn(stubFormService, 'getRestFieldValuesByProcessId').and.returnValue(Observable.of(fakeOptionList));
spyOn(stubFormService, 'getRestFieldValuesByProcessId').and.returnValue(of(fakeOptionList));
typeaheadWidgetComponent.field = new FormFieldModel(new FormModel({ processDefinitionId: 'fake-process-id' }), {
id: 'typeahead-id',
name: 'typeahead-name',

View File

@@ -20,12 +20,12 @@
import { LogService } from '../../../../services/log.service';
import { ThumbnailService } from '../../../../services/thumbnail.service';
import { Component, ElementRef, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Observable, from } from 'rxjs';
import { FormService } from '../../../services/form.service';
import { ProcessContentService } from '../../../services/process-content.service';
import { ContentLinkModel } from '../core/content-link.model';
import { baseHost, WidgetComponent } from './../widget.component';
import 'rxjs/add/operator/mergeMap';
import { mergeMap, map } from 'rxjs/operators';
@Component({
selector: 'upload-folder-widget',
@@ -75,27 +75,32 @@ export class UploadFolderWidgetComponent extends WidgetComponent implements OnIn
}
if (files && files.length > 0) {
Observable.from(files).mergeMap(file => this.uploadRawContent(file)).subscribe((res) => {
filesSaved.push(res);
},
(error) => {
this.logService.error('Error uploading file. See console output for more details.');
},
() => {
this.field.value = filesSaved;
this.field.json.value = filesSaved;
});
from(files)
.pipe(mergeMap(file => this.uploadRawContent(file)))
.subscribe(
(res) => {
filesSaved.push(res);
},
() => {
this.logService.error('Error uploading file. See console output for more details.');
},
() => {
this.field.value = filesSaved;
this.field.json.value = filesSaved;
}
);
this.hasFile = true;
}
}
private uploadRawContent(file): Observable<any> {
return this.processContentService.createTemporaryRawRelatedContent(file)
.map((response: any) => {
return this.processContentService.createTemporaryRawRelatedContent(file).pipe(
map((response: any) => {
this.logService.info(response);
return response;
});
})
);
}
private getMultipleFileParam() {

View File

@@ -18,7 +18,7 @@
import { DebugElement } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { Observable } from 'rxjs/Observable';
import { of } from 'rxjs';
import { FormService } from '../../../services/form.service';
import { ProcessContentService } from '../../../services/process-content.service';
import { FormFieldTypes } from '../core/form-field-types';
@@ -189,7 +189,7 @@ describe('UploadWidgetComponent', () => {
}));
it('should show the list file after upload a new content', async(() => {
spyOn(contentService, 'createTemporaryRawRelatedContent').and.returnValue(Observable.of(fakePngAnswer));
spyOn(contentService, 'createTemporaryRawRelatedContent').and.returnValue(of(fakePngAnswer));
uploadWidgetComponent.field.params.multiple = false;
fixture.detectChanges();
@@ -204,11 +204,11 @@ describe('UploadWidgetComponent', () => {
it('should update the form after deleted a file', async(() => {
spyOn(contentService, 'createTemporaryRawRelatedContent').and.callFake((file) => {
if (file.name === 'file-fake.png') {
return Observable.of(fakePngAnswer);
return of(fakePngAnswer);
}
if (file.name === 'file-fake.jpg') {
return Observable.of(fakeJpgAnswer);
return of(fakeJpgAnswer);
}
});
@@ -232,11 +232,11 @@ describe('UploadWidgetComponent', () => {
it('should set has field value all the files uploaded', async(() => {
spyOn(contentService, 'createTemporaryRawRelatedContent').and.callFake((file) => {
if (file.name === 'file-fake.png') {
return Observable.of(fakePngAnswer);
return of(fakePngAnswer);
}
if (file.name === 'file-fake.jpg') {
return Observable.of(fakeJpgAnswer);
return of(fakeJpgAnswer);
}
});
@@ -380,8 +380,8 @@ describe('UploadWidgetComponent', () => {
}));
it('should emit form content clicked event on icon click', (done) => {
spyOn(contentService, 'getContentPreview').and.returnValue(Observable.of(new Blob()));
spyOn(contentService, 'getFileRawContent').and.returnValue(Observable.of(new Blob()));
spyOn(contentService, 'getContentPreview').and.returnValue(of(new Blob()));
spyOn(contentService, 'getFileRawContent').and.returnValue(of(new Blob()));
formServiceInstance.formContentClicked.subscribe((content: any) => {
expect(content.name).toBe(fakeJpgAnswer.name);

View File

@@ -20,12 +20,12 @@
import { LogService } from '../../../../services/log.service';
import { ThumbnailService } from '../../../../services/thumbnail.service';
import { Component, ElementRef, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Observable, from } from 'rxjs';
import { FormService } from '../../../services/form.service';
import { ProcessContentService } from '../../../services/process-content.service';
import { ContentLinkModel } from '../core/content-link.model';
import { baseHost, WidgetComponent } from './../widget.component';
import 'rxjs/add/operator/mergeMap';
import { mergeMap, map } from 'rxjs/operators';
@Component({
selector: 'upload-widget',
@@ -75,27 +75,29 @@ export class UploadWidgetComponent extends WidgetComponent implements OnInit {
}
if (files && files.length > 0) {
Observable.from(files).mergeMap(file => this.uploadRawContent(file)).subscribe((res) => {
filesSaved.push(res);
},
(error) => {
this.logService.error('Error uploading file. See console output for more details.');
},
() => {
this.field.value = filesSaved;
this.field.json.value = filesSaved;
this.hasFile = true;
});
from(files)
.pipe(mergeMap(file => this.uploadRawContent(file)))
.subscribe(
(res) => filesSaved.push(res),
() => this.logService.error('Error uploading file. See console output for more details.'),
() => {
this.field.value = filesSaved;
this.field.json.value = filesSaved;
this.hasFile = true;
}
);
}
}
private uploadRawContent(file): Observable<any> {
return this.processContentService.createTemporaryRawRelatedContent(file)
.map((response: any) => {
this.logService.info(response);
response.contentBlob = file;
return response;
});
.pipe(
map((response: any) => {
this.logService.info(response);
response.contentBlob = file;
return response;
})
);
}
getMultipleFileParam() {

View File

@@ -121,7 +121,7 @@ export class WidgetComponent implements AfterViewInit {
return null;
}
protected event(event: Event): void {
event(event: Event): void {
this.formService.formEvents.next(event);
}
}

View File

@@ -18,11 +18,11 @@
import { CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { NgModule } from '@angular/core';
import { HttpModule } from '@angular/http';
import { TranslateModule } from '@ngx-translate/core';
import { DataTableModule } from '../datatable/datatable.module';
import { DataColumnModule } from '../data-column/data-column.module';
import { PipeModule } from '../pipes/pipe.module';
import { HttpClientModule } from '@angular/common/http';
import { MaterialModule } from '../material.module';
@@ -50,7 +50,7 @@ import { MatDatetimepickerModule, MatNativeDatetimeModule } from '@mat-datetimep
imports: [
CommonModule,
DataTableModule,
HttpModule,
HttpClientModule,
MaterialModule,
TranslateModule,
FormsModule,

View File

@@ -19,10 +19,10 @@ import { AlfrescoApiService } from '../../services/alfresco-api.service';
import { LogService } from '../../services/log.service';
import { Injectable } from '@angular/core';
import { AlfrescoApi, MinimalNodeEntryEntity, RelatedContentRepresentation } from 'alfresco-js-api';
import { Observable } from 'rxjs/Observable';
import { Observable, from, throwError } from 'rxjs';
import { ExternalContent } from '../components/widgets/core/external-content';
import { ExternalContentLink } from '../components/widgets/core/external-content-link';
import 'rxjs/add/observable/throw';
import { map, catchError } from 'rxjs/operators';
@Injectable()
export class ActivitiContentService {
@@ -43,9 +43,11 @@ export class ActivitiContentService {
getAlfrescoNodes(accountId: string, folderId: string): Observable<[ExternalContent]> {
let apiService: AlfrescoApi = this.apiService.getInstance();
let accountShortId = accountId.replace('alfresco-', '');
return Observable.fromPromise(apiService.activiti.alfrescoApi.getContentInFolder(accountShortId, folderId))
.map(this.toJsonArray)
.catch(err => this.handleError(err));
return from(apiService.activiti.alfrescoApi.getContentInFolder(accountShortId, folderId))
.pipe(
map(this.toJsonArray),
catchError(err => this.handleError(err))
);
}
/**
@@ -60,9 +62,11 @@ export class ActivitiContentService {
tenantId: tenantId,
includeAccounts: includeAccount
};
return Observable.fromPromise(apiService.activiti.alfrescoApi.getRepositories(opts))
.map(this.toJsonArray)
.catch(err => this.handleError(err));
return from(apiService.activiti.alfrescoApi.getRepositories(opts))
.pipe(
map(this.toJsonArray),
catchError(err => this.handleError(err))
);
}
/**
@@ -73,14 +77,18 @@ export class ActivitiContentService {
* @param siteId
*/
linkAlfrescoNode(accountId: string, node: ExternalContent, siteId: string): Observable<ExternalContentLink> {
let apiService: AlfrescoApi = this.apiService.getInstance();
return Observable.fromPromise(apiService.activiti.contentApi.createTemporaryRelatedContent({
const apiService: AlfrescoApi = this.apiService.getInstance();
return from(apiService.activiti.contentApi.createTemporaryRelatedContent({
link: true,
name: node.title,
simpleType: node.simpleType,
source: accountId,
sourceId: node.id + '@' + siteId
})).map(this.toJson).catch(err => this.handleError(err));
}))
.pipe(
map(this.toJson),
catchError(err => this.handleError(err))
);
}
applyAlfrescoNode(node: MinimalNodeEntryEntity, siteId: string, accountId: string) {
@@ -93,10 +101,11 @@ export class ActivitiContentService {
name: node.name,
link: false
};
return Observable.fromPromise(
apiService.activiti.contentApi.createTemporaryRelatedContent(params))
.map(this.toJson)
.catch(err => this.handleError(err));
return from(apiService.activiti.contentApi.createTemporaryRelatedContent(params))
.pipe(
map(this.toJson),
catchError(err => this.handleError(err))
);
}
private getSiteNameFromNodePath(node: MinimalNodeEntryEntity): string {
@@ -132,6 +141,6 @@ export class ActivitiContentService {
error.status ? `${error.status} - ${error.statusText}` : ActivitiContentService.GENERIC_ERROR_MESSAGE;
}
this.logService.error(errMsg);
return Observable.throw(errMsg);
return throwError(errMsg);
}
}

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { Observable } from 'rxjs/Observable';
import { Observable } from 'rxjs';
import { FormModel } from './../components/widgets/core/form.model';
import { EcmModelService } from './ecm-model.service';
import { setupTestBed } from '../../testing/setupTestBed';

View File

@@ -18,9 +18,9 @@
import { LogService } from '../../services/log.service';
import { AlfrescoApiService } from '../../services/alfresco-api.service';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Observable, from } from 'rxjs';
import { FormModel } from '../components/widgets/core/form.model';
import 'rxjs/add/observable/fromPromise';
import { map, catchError } from 'rxjs/operators';
@Injectable()
export class EcmModelService {
@@ -56,9 +56,9 @@ export class EcmModelService {
}
searchActivitiEcmModel() {
return this.getEcmModels().map(function (ecmModels: any) {
return this.getEcmModels().pipe(map(function (ecmModels: any) {
return ecmModels.list.entries.find(model => model.entry.name === EcmModelService.MODEL_NAME);
});
}));
}
createActivitiEcmModel(formName: string, form: FormModel): Observable<any> {
@@ -120,41 +120,51 @@ export class EcmModelService {
}
public searchEcmType(typeName: string, modelName: string): Observable<any> {
return this.getEcmType(modelName).map(function (customTypes: any) {
return this.getEcmType(modelName).pipe(map(function (customTypes: any) {
return customTypes.list.entries.find(type => type.entry.prefixedName === typeName || type.entry.title === typeName);
});
}));
}
public activeEcmModel(modelName: string): Observable<any> {
return Observable.fromPromise(this.apiService.getInstance().core.customModelApi.activateCustomModel(modelName))
.map(this.toJson)
.catch(err => this.handleError(err));
return from(this.apiService.getInstance().core.customModelApi.activateCustomModel(modelName))
.pipe(
map(this.toJson),
catchError(err => this.handleError(err))
);
}
public createEcmModel(modelName: string, nameSpace: string): Observable<any> {
return Observable.fromPromise(this.apiService.getInstance().core.customModelApi.createCustomModel('DRAFT', '', modelName, modelName, nameSpace))
.map(this.toJson)
.catch(err => this.handleError(err));
return from(this.apiService.getInstance().core.customModelApi.createCustomModel('DRAFT', '', modelName, modelName, nameSpace))
.pipe(
map(this.toJson),
catchError(err => this.handleError(err))
);
}
public getEcmModels(): Observable<any> {
return Observable.fromPromise(this.apiService.getInstance().core.customModelApi.getAllCustomModel())
.map(this.toJson)
.catch(err => this.handleError(err));
return from(this.apiService.getInstance().core.customModelApi.getAllCustomModel())
.pipe(
map(this.toJson),
catchError(err => this.handleError(err))
);
}
public getEcmType(modelName: string): Observable<any> {
return Observable.fromPromise(this.apiService.getInstance().core.customModelApi.getAllCustomType(modelName))
.map(this.toJson)
.catch(err => this.handleError(err));
return from(this.apiService.getInstance().core.customModelApi.getAllCustomType(modelName))
.pipe(
map(this.toJson),
catchError(err => this.handleError(err))
);
}
public createEcmType(typeName: string, modelName: string, parentType: string): Observable<any> {
let name = this.cleanNameType(typeName);
return Observable.fromPromise(this.apiService.getInstance().core.customModelApi.createCustomType(modelName, name, parentType, typeName, ''))
.map(this.toJson)
.catch(err => this.handleError(err));
return from(this.apiService.getInstance().core.customModelApi.createCustomType(modelName, name, parentType, typeName, ''))
.pipe(
map(this.toJson),
catchError(err => this.handleError(err))
);
}
public addPropertyToAType(modelName: string, typeName: string, formFields: any) {
@@ -177,9 +187,11 @@ export class EcmModelService {
}
}
return Observable.fromPromise(this.apiService.getInstance().core.customModelApi.addPropertyToType(modelName, name, properties))
.map(this.toJson)
.catch(err => this.handleError(err));
return from(this.apiService.getInstance().core.customModelApi.addPropertyToType(modelName, name, properties))
.pipe(
map(this.toJson),
catchError(err => this.handleError(err))
);
}

View File

@@ -19,8 +19,7 @@ import { AlfrescoApiService } from '../../services/alfresco-api.service';
import { LogService } from '../../services/log.service';
import { UserProcessModel } from '../../models';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Subject } from 'rxjs/Subject';
import { Observable, Subject, from, of, throwError } from 'rxjs';
import { FormDefinitionModel } from '../models/form-definition.model';
import { ContentLinkModel } from './../components/widgets/core/content-link.model';
import { GroupModel } from './../components/widgets/core/group.model';
@@ -30,10 +29,7 @@ import {
ValidateDynamicTableRowEvent, ValidateFormEvent, ValidateFormFieldEvent
} from './../events/index';
import { EcmModelService } from './ecm-model.service';
import 'rxjs/add/observable/fromPromise';
import 'rxjs/add/operator/defaultIfEmpty';
import 'rxjs/add/operator/catch';
import 'rxjs/add/observable/throw';
import { map, catchError, switchMap, combineAll, defaultIfEmpty } from 'rxjs/operators';
@Injectable()
export class FormService {
@@ -150,7 +146,7 @@ export class FormService {
stencilSet: 0
};
return Observable.fromPromise(
return from(
this.modelsApi.createModel(dataModel)
);
}
@@ -162,7 +158,7 @@ export class FormService {
* @returns Data for the saved form
*/
saveForm(formId: string, formModel: FormDefinitionModel): Observable<any> {
return Observable.fromPromise(
return from(
this.editorApi.saveForm(formId, formModel)
);
}
@@ -175,7 +171,7 @@ export class FormService {
*/
addFieldsToAForm(formId: string, formModel: FormDefinitionModel): Observable<any> {
this.logService.log('addFieldsToAForm is deprecated in 1.7.0, use saveForm API instead');
return Observable.fromPromise(
return from(
this.editorApi.saveForm(formId, formModel)
);
}
@@ -190,13 +186,15 @@ export class FormService {
'modelType': 2
};
return Observable.fromPromise(
return from(
this.modelsApi.getModels(opts)
)
.map(function (forms: any) {
.pipe(
map(function (forms: any) {
return forms.data.find(formdata => formdata.name === name);
})
.catch(err => this.handleError(err));
}),
catchError(err => this.handleError(err))
);
}
/**
@@ -208,9 +206,11 @@ export class FormService {
'modelType': 2
};
return Observable.fromPromise(this.modelsApi.getModels(opts))
.map(this.toJsonArray)
.catch(err => this.handleError(err));
return from(this.modelsApi.getModels(opts))
.pipe(
map(this.toJsonArray),
catchError(err => this.handleError(err))
);
}
/**
@@ -218,9 +218,11 @@ export class FormService {
* @returns List of process definitions
*/
getProcessDefinitions(): Observable<any> {
return Observable.fromPromise(this.processApi.getProcessDefinitions({}))
.map(this.toJsonArray)
.catch(err => this.handleError(err));
return from(this.processApi.getProcessDefinitions({}))
.pipe(
map(this.toJsonArray),
catchError(err => this.handleError(err))
);
}
/**
@@ -229,9 +231,11 @@ export class FormService {
* @returns List of instance variable information
*/
getProcessVarablesById(processInstanceId: string): Observable<any[]> {
return Observable.fromPromise(this.processInstanceVariablesApi.getProcessInstanceVariables(processInstanceId))
.map(this.toJson)
.catch(err => this.handleError(err));
return from(this.processInstanceVariablesApi.getProcessInstanceVariables(processInstanceId))
.pipe(
map(this.toJson),
catchError(err => this.handleError(err))
);
}
/**
@@ -239,9 +243,11 @@ export class FormService {
* @returns List of tasks
*/
getTasks(): Observable<any> {
return Observable.fromPromise(this.taskApi.listTasks({}))
.map(this.toJsonArray)
.catch(err => this.handleError(err));
return from(this.taskApi.listTasks({}))
.pipe(
map(this.toJsonArray),
catchError(err => this.handleError(err))
);
}
/**
@@ -250,9 +256,11 @@ export class FormService {
* @returns Task info
*/
getTask(taskId: string): Observable<any> {
return Observable.fromPromise(this.taskApi.getTask(taskId))
.map(this.toJson)
.catch(err => this.handleError(err));
return from(this.taskApi.getTask(taskId))
.pipe(
map(this.toJson),
catchError(err => this.handleError(err))
);
}
/**
@@ -264,8 +272,10 @@ export class FormService {
saveTaskForm(taskId: string, formValues: FormValues): Observable<any> {
let body = JSON.stringify({values: formValues});
return Observable.fromPromise(this.taskApi.saveTaskForm(taskId, body))
.catch(err => this.handleError(err));
return from(this.taskApi.saveTaskForm(taskId, body))
.pipe(
catchError(err => this.handleError(err))
);
}
/**
@@ -282,8 +292,10 @@ export class FormService {
}
let body = JSON.stringify(data);
return Observable.fromPromise(this.taskApi.completeTaskForm(taskId, body))
.catch(err => this.handleError(err));
return from(this.taskApi.completeTaskForm(taskId, body))
.pipe(
catchError(err => this.handleError(err))
);
}
/**
@@ -292,9 +304,11 @@ export class FormService {
* @returns Form definition
*/
getTaskForm(taskId: string): Observable<any> {
return Observable.fromPromise(this.taskApi.getTaskForm(taskId))
.map(this.toJson)
.catch(err => this.handleError(err));
return from(this.taskApi.getTaskForm(taskId))
.pipe(
map(this.toJson),
catchError(err => this.handleError(err))
);
}
/**
@@ -303,9 +317,11 @@ export class FormService {
* @returns Form definition
*/
getFormDefinitionById(formId: string): Observable<any> {
return Observable.fromPromise(this.editorApi.getForm(formId))
.map(this.toJson)
.catch(err => this.handleError(err));
return from(this.editorApi.getForm(formId))
.pipe(
map(this.toJson),
catchError(err => this.handleError(err))
);
}
/**
@@ -320,9 +336,11 @@ export class FormService {
'modelType': 2
};
return Observable.fromPromise(this.modelsApi.getModels(opts))
.map(this.getFormId)
.catch(err => this.handleError(err));
return from(this.modelsApi.getModels(opts))
.pipe(
map(this.getFormId),
catchError(err => this.handleError(err))
);
}
/**
@@ -331,10 +349,11 @@ export class FormService {
* @returns Form definition
*/
getStartFormInstance(processId: string): Observable<any> {
return Observable.fromPromise(
this.processApi.getProcessInstanceStartForm(processId))
.map(this.toJson)
.catch(err => this.handleError(err));
return from(this.processApi.getProcessInstanceStartForm(processId))
.pipe(
map(this.toJson),
catchError(err => this.handleError(err))
);
}
/**
@@ -343,9 +362,11 @@ export class FormService {
* @returns Process instance
*/
getProcessIntance(processId: string): Observable<any> {
return Observable.fromPromise(this.processApi.getProcessInstance(processId))
.map(this.toJson)
.catch(err => this.handleError(err));
return from(this.processApi.getProcessInstance(processId))
.pipe(
map(this.toJson),
catchError(err => this.handleError(err))
);
}
/**
@@ -354,10 +375,11 @@ export class FormService {
* @returns Form definition
*/
getStartFormDefinition(processId: string): Observable<any> {
return Observable.fromPromise(
this.processApi.getProcessDefinitionStartForm(processId))
.map(this.toJson)
.catch(err => this.handleError(err));
return from(this.processApi.getProcessDefinitionStartForm(processId))
.pipe(
map(this.toJson),
catchError(err => this.handleError(err))
);
}
/**
@@ -367,7 +389,10 @@ export class FormService {
* @returns Field values
*/
getRestFieldValues(taskId: string, field: string): Observable<any> {
return Observable.fromPromise(this.taskApi.getRestFieldValues(taskId, field)).catch(err => this.handleError(err));
return from(this.taskApi.getRestFieldValues(taskId, field))
.pipe(
catchError(err => this.handleError(err))
);
}
/**
@@ -377,7 +402,10 @@ export class FormService {
* @returns Field values
*/
getRestFieldValuesByProcessId(processDefinitionId: string, field: string): Observable<any> {
return Observable.fromPromise(this.processApi.getRestFieldValues(processDefinitionId, field)).catch(err => this.handleError(err));
return from(this.processApi.getRestFieldValues(processDefinitionId, field))
.pipe(
catchError(err => this.handleError(err))
);
}
/**
@@ -388,7 +416,10 @@ export class FormService {
* @returns Field values
*/
getRestFieldValuesColumnByProcessId(processDefinitionId: string, field: string, column?: string): Observable<any> {
return Observable.fromPromise(this.processApi.getRestTableFieldValues(processDefinitionId, field, column)).catch(err => this.handleError(err));
return from(this.processApi.getRestTableFieldValues(processDefinitionId, field, column))
.pipe(
catchError(err => this.handleError(err))
);
}
/**
@@ -399,7 +430,10 @@ export class FormService {
* @returns Field values
*/
getRestFieldValuesColumn(taskId: string, field: string, column?: string): Observable<any> {
return Observable.fromPromise(this.taskApi.getRestFieldValuesColumn(taskId, field, column)).catch(err => this.handleError(err));
return from(this.taskApi.getRestFieldValuesColumn(taskId, field, column))
.pipe(
catchError(err => this.handleError(err))
);
}
/**
@@ -422,15 +456,17 @@ export class FormService {
if (groupId) {
option.groupId = groupId;
}
return Observable.fromPromise(this.usersWorkflowApi.getUsers(option))
.switchMap((response: any) => <UserProcessModel[]> response.data || [])
.map((user: any) => {
user.userImage = this.getUserProfileImageApi(user.id);
return Observable.of(user);
})
.combineAll()
.defaultIfEmpty([])
.catch(err => this.handleError(err));
return from(this.usersWorkflowApi.getUsers(option))
.pipe(
switchMap((response: any) => <UserProcessModel[]> response.data || []),
map((user: any) => {
user.userImage = this.getUserProfileImageApi(user.id);
return of(user);
}),
combineAll(),
defaultIfEmpty([]),
catchError(err => this.handleError(err))
);
}
/**
@@ -444,9 +480,11 @@ export class FormService {
if (groupId) {
option.groupId = groupId;
}
return Observable.fromPromise(this.groupsApi.getGroups(option))
.map((response: any) => <GroupModel[]> response.data || [])
.catch(err => this.handleError(err));
return from(this.groupsApi.getGroups(option))
.pipe(
map((response: any) => <GroupModel[]> response.data || []),
catchError(err => this.handleError(err))
);
}
/**
@@ -500,6 +538,6 @@ export class FormService {
error.status ? `${error.status} - ${error.statusText}` : FormService.GENERIC_ERROR_MESSAGE;
}
this.logService.error(errMsg);
return Observable.throw(errMsg);
return throwError(errMsg);
}
}

View File

@@ -17,8 +17,9 @@
import { AlfrescoApiService } from '../../services/alfresco-api.service';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Observable, from } from 'rxjs';
import { NodeMetadata } from '../models/node-metadata.model';
import { map } from 'rxjs/operators';
@Injectable()
export class NodeService {
@@ -31,7 +32,8 @@ export class NodeService {
* @param nodeId Node Id
*/
public getNodeMetadata(nodeId: string): Observable<NodeMetadata> {
return Observable.fromPromise(this.apiService.getInstance().nodes.getNodeInfo(nodeId)).map(this.cleanMetadataFromSemicolon);
return from(this.apiService.getInstance().nodes.getNodeInfo(nodeId))
.pipe(map(this.cleanMetadataFromSemicolon));
}
/**
@@ -69,7 +71,7 @@ export class NodeService {
// TODO: requires update to alfresco-js-api typings
let apiService: any = this.apiService.getInstance();
return Observable.fromPromise(apiService.nodes.addNode('-root-', body, {}));
return from(apiService.nodes.addNode('-root-', body, {}));
}
private generateUuid() {

View File

@@ -16,7 +16,7 @@
*/
import { TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs/Observable';
import { of } from 'rxjs';
import { ProcessContentService } from './process-content.service';
import { setupTestBed } from '../../testing/setupTestBed';
import { CoreModule } from '../../core.module';
@@ -188,7 +188,7 @@ describe('ProcessContentService', () => {
it('should return a Blob as thumbnail', (done) => {
let contentId: number = 999;
let blob = createFakeBlob();
spyOn(service, 'getContentThumbnail').and.returnValue(Observable.of(blob));
spyOn(service, 'getContentThumbnail').and.returnValue(of(blob));
service.getContentThumbnail(contentId).subscribe(result => {
expect(result).toEqual(jasmine.any(Blob));
expect(result.size).toEqual(48);

View File

@@ -19,10 +19,8 @@ import { AlfrescoApiService } from '../../services/alfresco-api.service';
import { LogService } from '../../services/log.service';
import { Injectable } from '@angular/core';
import { RelatedContentRepresentation } from 'alfresco-js-api';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/fromPromise';
import 'rxjs/add/operator/catch';
import 'rxjs/add/observable/throw';
import { Observable, from, throwError } from 'rxjs';
import { catchError } from 'rxjs/operators';
@Injectable()
export class ProcessContentService {
@@ -44,7 +42,8 @@ export class ProcessContentService {
* @returns The created content data
*/
createTemporaryRawRelatedContent(file: any): Observable<RelatedContentRepresentation> {
return Observable.fromPromise(this.contentApi.createTemporaryRawRelatedContent(file)).catch(err => this.handleError(err));
return from(this.contentApi.createTemporaryRawRelatedContent(file))
.pipe(catchError(err => this.handleError(err)));
}
/**
@@ -53,7 +52,8 @@ export class ProcessContentService {
* @returns Metadata for the content
*/
getFileContent(contentId: number): Observable<RelatedContentRepresentation> {
return Observable.fromPromise(this.contentApi.getContent(contentId)).catch(err => this.handleError(err));
return from(this.contentApi.getContent(contentId))
.pipe(catchError(err => this.handleError(err)));
}
/**
@@ -62,7 +62,8 @@ export class ProcessContentService {
* @returns Binary data of the related content
*/
getFileRawContent(contentId: number): Observable<Blob> {
return Observable.fromPromise(this.contentApi.getRawContent(contentId)).catch(err => this.handleError(err));
return from(this.contentApi.getRawContent(contentId))
.pipe(catchError(err => this.handleError(err)));
}
/**
@@ -108,7 +109,8 @@ export class ProcessContentService {
* @returns Binary data of the thumbnail image
*/
getContentThumbnail(contentId: number): Observable<Blob> {
return Observable.fromPromise(this.contentApi.getContentThumbnail(contentId)).catch(err => this.handleError(err));
return from(this.contentApi.getContentThumbnail(contentId))
.pipe(catchError(err => this.handleError(err)));
}
/**
@@ -117,8 +119,8 @@ export class ProcessContentService {
* @returns Metadata for the content
*/
getTaskRelatedContent(taskId: string): Observable<any> {
return Observable.fromPromise(this.contentApi.getRelatedContentForTask(taskId))
.catch(err => this.handleError(err));
return from(this.contentApi.getRelatedContentForTask(taskId))
.pipe(catchError(err => this.handleError(err)));
}
/**
@@ -127,8 +129,8 @@ export class ProcessContentService {
* @returns Metadata for the content
*/
getProcessRelatedContent(processId: string): Observable<any> {
return Observable.fromPromise(this.contentApi.getRelatedContentForProcessInstance(processId))
.catch(err => this.handleError(err));
return from(this.contentApi.getRelatedContentForProcessInstance(processId))
.pipe(catchError(err => this.handleError(err)));
}
/**
@@ -137,8 +139,8 @@ export class ProcessContentService {
* @returns Null response that notifies when the deletion is complete
*/
deleteRelatedContent(contentId: number): Observable<any> {
return Observable.fromPromise(this.contentApi.deleteContent(contentId))
.catch(err => this.handleError(err));
return from(this.contentApi.deleteContent(contentId))
.pipe(catchError(err => this.handleError(err)));
}
/**
@@ -149,8 +151,8 @@ export class ProcessContentService {
* @returns Details of created content
*/
createProcessRelatedContent(processInstanceId: string, content: any, opts?: any): Observable<any> {
return Observable.fromPromise(this.contentApi.createRelatedContentOnProcessInstance(processInstanceId, content, opts))
.catch(err => this.handleError(err));
return from(this.contentApi.createRelatedContentOnProcessInstance(processInstanceId, content, opts))
.pipe(catchError(err => this.handleError(err)));
}
/**
@@ -161,8 +163,8 @@ export class ProcessContentService {
* @returns Details of created content
*/
createTaskRelatedContent(taskId: string, file: any, opts?: any) {
return Observable.fromPromise(this.contentApi.createRelatedContentOnTask(taskId, file, opts))
.catch(err => this.handleError(err));
return from(this.contentApi.createRelatedContentOnTask(taskId, file, opts))
.pipe(catchError(err => this.handleError(err)));
}
/**
@@ -201,7 +203,7 @@ export class ProcessContentService {
error.status ? `${error.status} - ${error.statusText}` : ProcessContentService.GENERIC_ERROR_MESSAGE;
}
this.logService.error(errMsg);
return Observable.throw(errMsg);
return throwError(errMsg);
}
}

View File

@@ -19,11 +19,11 @@ import { AlfrescoApiService } from '../../services/alfresco-api.service';
import { LogService } from '../../services/log.service';
import { Injectable } from '@angular/core';
import moment from 'moment-es6';
import { Observable } from 'rxjs/Observable';
import { Observable, from, throwError } from 'rxjs';
import { FormFieldModel, FormModel, TabModel } from '../components/widgets/core/index';
import { TaskProcessVariableModel } from '../models/task-process-variable.model';
import { WidgetVisibilityModel } from '../models/widget-visibility.model';
import 'rxjs/add/observable/throw';
import { map, catchError } from 'rxjs/operators';
@Injectable()
export class WidgetVisibilityService {
@@ -244,13 +244,15 @@ export class WidgetVisibilityService {
}
getTaskProcessVariable(taskId: string): Observable<TaskProcessVariableModel[]> {
return Observable.fromPromise(this.apiService.getInstance().activiti.taskFormsApi.getTaskFormVariables(taskId))
.map(res => {
let jsonRes = this.toJson(res);
this.processVarList = <TaskProcessVariableModel[]> jsonRes;
return jsonRes;
})
.catch(err => this.handleError(err));
return from(this.apiService.getInstance().activiti.taskFormsApi.getTaskFormVariables(taskId))
.pipe(
map(res => {
let jsonRes = this.toJson(res);
this.processVarList = <TaskProcessVariableModel[]> jsonRes;
return jsonRes;
}),
catchError(err => this.handleError(err))
);
}
toJson(res: any) {
@@ -259,6 +261,6 @@ export class WidgetVisibilityService {
private handleError(err) {
this.logService.error('Error while performing a call');
return Observable.throw('Error while performing a call - Server error');
return throwError('Error while performing a call - Server error');
}
}