[ADF-1502] Fixes for AoT checks in Angular CLI (#2282)

* Fixes for AoT checks in Angular CLI

* login fixes

- aot compatibility
- fix copyright symbol
- fix toggling password (operates within the component instead of the whole document)
- remove old MDL calls on error style check

* Search fixes

* login test fixes

* form fixes

- add WidgetComponent to the module
- remove missing 'focus' property from Hyperlink widget template/style

* task-list fixes

* process-list fixes

* analytics fixes
This commit is contained in:
Denys Vuika
2017-09-04 09:28:21 +01:00
committed by Mario Romano
parent 1ffb4619cb
commit ffbfc8b87a
21 changed files with 179 additions and 109 deletions

View File

@@ -10,35 +10,45 @@
<md-grid-list cols="2" rowHeight="80px">
<md-grid-tile>
<md-input-container>
<input mdInput
[min]="minDate"
[max]="maxDate"
formControlName="startDate"
[mdDatepicker]="startDatePicker"
[value]="startDatePicker"
(keydown)="true"
placeholder="{{'DATE-WIDGET.START-DATE' | translate}}"
id="startDate_id"
required>
<input
mdInput
[min]="minDate"
[max]="maxDate"
formControlName="startDate"
[mdDatepicker]="startDatePicker"
[value]="startDatePicker"
(keydown)="true"
placeholder="{{'DATE-WIDGET.START-DATE' | translate}}"
id="startDate_id"
required>
<button mdSuffix [mdDatepickerToggle]="startDatePicker"></button>
</md-input-container>
<md-datepicker #startDatePicker [touchUi]="true" [startAt]="startAt" (selectedChanged)="onGroupValueChanged($event)"></md-datepicker>
<md-datepicker
#startDatePicker
[touchUi]="true"
(selectedChanged)="onGroupValueChanged()">
</md-datepicker>
</md-grid-tile>
<md-grid-tile>
<md-input-container class="adf-start-task-input-container">
<input mdInput
[min]="minDate"
[max]="maxDate"
formControlName="endDate"
[mdDatepicker]="endDatePicker"
[value]="endDatePicker"
(keydown)="true"
placeholder="{{'DATE-WIDGET.END-DATE' | translate}}"
id="endDate_id"
required>
<input
mdInput
[min]="minDate"
[max]="maxDate"
formControlName="endDate"
[mdDatepicker]="endDatePicker"
[value]="endDatePicker"
(keydown)="true"
placeholder="{{'DATE-WIDGET.END-DATE' | translate}}"
id="endDate_id"
required>
<button mdSuffix [mdDatepickerToggle]="endDatePicker"></button>
</md-input-container>
<md-datepicker #endDatePicker [touchUi]="true" [startAt]="startAt" (selectedChanged)="onGroupValueChanged($event)"></md-datepicker>
<md-datepicker
#endDatePicker
[touchUi]="true"
(selectedChanged)="onGroupValueChanged()">
</md-datepicker>
</md-grid-tile>
</md-grid-list>
</div>

View File

@@ -26,6 +26,7 @@ import { MaterialModule } from './src/components/material.module';
import { StartFormComponent } from './src/components/start-form.component';
import { ContentWidgetComponent } from './src/components/widgets/content/content.widget';
import { MASK_DIRECTIVE, WIDGET_DIRECTIVES } from './src/components/widgets/index';
import { WidgetComponent } from './src/components/widgets/widget.component';
import { ActivitiAlfrescoContentService } from './src/services/activiti-alfresco.service';
import { ActivitiContentService } from './src/services/activiti-content-service';
import { EcmModelService } from './src/services/ecm-model.service';
@@ -90,7 +91,8 @@ export const ACTIVITI_FORM_PROVIDERS: any[] = [
declarations: [
...ACTIVITI_FORM_DIRECTIVES,
...DEPRECATED_FORM_DIRECTIVES,
...MASK_DIRECTIVE
...MASK_DIRECTIVE,
WidgetComponent
],
entryComponents: [
...WIDGET_DIRECTIVES

View File

@@ -1,5 +1,5 @@
<div class="adf-hyperlink-widget {{field.className}}">
<label class="adf-label" [attr.for]="field.id" [class.focus]="focus" >{{field.name}}<span *ngIf="isRequired()">*</span></label>
<label class="adf-label" [attr.for]="field.id">{{field.name}}<span *ngIf="isRequired()">*</span></label>
<div>
<a [href]="linkUrl" target="_blank" rel="nofollow">{{linkText}}</a>
</div>

View File

@@ -5,10 +5,6 @@
padding: 0.4375em 0;
border-top: 0.84375em solid transparent;
.focus {
color: mat-color($primary);
}
a {
color: mat-color($primary);
}

View File

@@ -19,6 +19,8 @@ import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from
import { ActivitiContentService } from 'ng2-activiti-form';
import { ContentService, ThumbnailService } from 'ng2-alfresco-core';
declare var require: any;
@Component({
selector: 'adf-process-attachment-list',
styleUrls: ['./process-attachment-list.component.scss'],

View File

@@ -37,7 +37,7 @@
<div class="mdl-dialog__content">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<label class="mdl-textfield__label" for="addVariableName">{{ 'DETAILS.VARIABLES.ADD_DIALOG.LABEL.NAME' |translate }}</label>
<input class="mdl-textfield__input" type="text" [(ngModel)]="variableName" id="addVariableName" [readonly]="editMode" />
<input class="mdl-textfield__input" type="text" [(ngModel)]="variableName" id="addVariableName" />
</div>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<label class="mdl-textfield__label" for="addVariableValue">{{ 'DETAILS.VARIABLES.ADD_DIALOG.LABEL.VALUE' |translate }}</label>

View File

@@ -113,7 +113,7 @@ export class ProcessService extends TaskListService {
* @param appId
* @returns {FilterProcessRepresentationModel[]}
*/
public createDefaultFilters(appId: string): Observable<FilterProcessRepresentationModel[]> {
public createDefaultFilters(appId: string): Observable<any[]> {
let runnintFilter = this.getRunningFilterInstance(appId);
let runnintObservable = this.addProcessFilter(runnintFilter);

View File

@@ -19,6 +19,8 @@ import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from
import { ActivitiContentService } from 'ng2-activiti-form';
import { ContentService, ThumbnailService } from 'ng2-alfresco-core';
declare var require: any;
@Component({
selector: 'adf-task-attachment-list',
styleUrls: ['./task-attachment-list.component.scss'],

View File

@@ -20,7 +20,7 @@
</i>
</li>
</div>
<div *ngIf="!folderNode && root">
<div *ngIf="!folderNode && hasRoot">
<li class="adf-breadcrumb-item">
<div class="adf-breadcrumb-item-current">
{{ root }}

View File

@@ -41,6 +41,10 @@ export class BreadcrumbComponent implements OnChanges {
route: PathElementEntity[] = [];
get hasRoot(): boolean {
return !!this.root;
}
@Output()
navigate: EventEmitter<PathElementEntity> = new EventEmitter<PathElementEntity>();

View File

@@ -49,14 +49,13 @@
[node]="nodes"
[rowFilter]="rowFilter"
[imageResolver]="imageResolver"
[permissionsStyle]="permissionsStyle"
[currentFolderId]="folderIdToShow"
[selectionMode]="'single'"
selectionMode="single"
[contextMenuActions]="false"
[contentActions]="false"
[allowDropFiles]="false"
[enablePagination]="!showingSearchResults"
(folderChange)="onFolderChange($event)"
(folderChange)="onFolderChange()"
(ready)="onFolderLoaded()"
data-automation-id="content-node-selector-document-list">
<empty-folder-content>

View File

@@ -16,12 +16,12 @@
*/
import { ModuleWithProviders, NgModule } from '@angular/core';
import { MdCheckboxModule, MdIconModule, MdInputModule, MdProgressSpinnerModule } from '@angular/material';
import { CoreModule, TRANSLATION_PROVIDER } from 'ng2-alfresco-core';
import { LoginComponent } from './src/components/login.component';
import { LoginFooterDirective } from './src/directives/login-footer.directive';
import { LoginHeaderDirective } from './src/directives/login-header.directive';
import { MaterialModule } from './src/material.module';
export { LoginHeaderDirective } from './src/directives/login-header.directive';
export { LoginFooterDirective } from './src/directives/login-footer.directive';
@@ -43,10 +43,7 @@ export const ALFRESCO_LOGIN_DIRECTIVES: any[] = [
@NgModule({
imports: [
CoreModule,
MdInputModule,
MdIconModule,
MdCheckboxModule,
MdProgressSpinnerModule
MaterialModule
],
declarations: [
...ALFRESCO_LOGIN_DIRECTIVES
@@ -63,9 +60,7 @@ export const ALFRESCO_LOGIN_DIRECTIVES: any[] = [
],
exports: [
...ALFRESCO_LOGIN_DIRECTIVES,
MdInputModule,
MdIconModule,
MdCheckboxModule
MaterialModule
]
})
export class LoginModule {

View File

@@ -1,7 +1,7 @@
<div class="adf-login-content"
[style.background-image]="'url(' + backgroundImageUrl + ')'">
<md-card class="adf-login-card-wide">
<form [formGroup]="form" (submit)="onSubmit(form.value, $event)">
<form [formGroup]="form" (submit)="onSubmit(form.value)">
<md-card-header>
<md-card-title>

View File

@@ -161,7 +161,7 @@ describe('AlfrescoLogin', () => {
it('should render the default copyright text', () => {
expect(element.querySelector('[data-automation-id="login-copyright"]')).toBeDefined();
expect(element.querySelector('[data-automation-id="login-copyright"]').innerText).toEqual('© 2016 Alfresco Software, Inc. All Rights Reserved.');
expect(element.querySelector('[data-automation-id="login-copyright"]').innerText).toEqual('&#169; 2016 Alfresco Software, Inc. All Rights Reserved.');
});
it('should render the customised copyright text', () => {

View File

@@ -15,12 +15,11 @@
* limitations under the License.
*/
import { Component, EventEmitter, Input, OnInit, Output, TemplateRef, ViewEncapsulation } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Component, ElementRef, EventEmitter, Input, OnInit, Output, TemplateRef, ViewEncapsulation } from '@angular/core';
import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms';
import { AlfrescoAuthenticationService, AlfrescoSettingsService, AlfrescoTranslationService, LogService } from 'ng2-alfresco-core';
import { FormSubmitEvent } from '../models/form-submit-event.model';
declare let componentHandler: any;
declare var require: any;
enum LoginSteps {
@@ -59,7 +58,7 @@ export class LoginComponent implements OnInit {
backgroundImageUrl: string = require('../assets/images/background.svg');
@Input()
copyrightText: string = '© 2016 Alfresco Software, Inc. All Rights Reserved.';
copyrightText: string = '&#169; 2016 Alfresco Software, Inc. All Rights Reserved.';
@Input()
providers: string;
@@ -105,7 +104,8 @@ export class LoginComponent implements OnInit {
private authService: AlfrescoAuthenticationService,
private settingsService: AlfrescoSettingsService,
private translateService: AlfrescoTranslationService,
private logService: LogService) {
private logService: LogService,
private elementRef: ElementRef) {
this.initFormError();
this.initFormFieldsMessages();
}
@@ -258,11 +258,7 @@ export class LoginComponent implements OnInit {
*/
toggleShowPassword() {
this.isPasswordShow = !this.isPasswordShow;
if (this.isPasswordShow) {
(<HTMLInputElement> document.getElementById('password')).type = 'text';
} else {
(<HTMLInputElement> document.getElementById('password')).type = 'password';
}
this.elementRef.nativeElement.querySelector('#password').type = this.isPasswordShow ? 'text' : 'password';
}
/**
@@ -270,10 +266,7 @@ export class LoginComponent implements OnInit {
* @param field
* @returns {boolean}
*/
isErrorStyle(field: FormGroup) {
if (typeof componentHandler !== 'undefined') {
componentHandler.upgradeAllRegistered();
}
isErrorStyle(field: AbstractControl) {
return !field.valid && field.dirty && !field.pristine;
}

View File

@@ -15,29 +15,40 @@
* limitations under the License.
*/
import { Injector } from '@angular/core';
import { getTestBed, TestBed } from '@angular/core/testing';
import { async, TestBed } from '@angular/core/testing';
import { CoreModule } from 'ng2-alfresco-core';
import { MaterialModule } from '../material.module';
import { LoginComponent } from '../components/login.component';
import { LoginFooterDirective } from './login-footer.directive';
describe('LoginFooterDirective', () => {
let injector: Injector;
let loginFooterDirective: LoginFooterDirective;
let component: LoginComponent;
let directive: LoginFooterDirective;
beforeEach(() => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [CoreModule.forRoot()],
providers: [
imports: [
CoreModule,
MaterialModule
],
declarations: [
LoginFooterDirective,
LoginComponent
]
});
injector = getTestBed();
loginFooterDirective = injector.get(LoginFooterDirective);
}).compileComponents();
}));
beforeEach(() => {
let fixture = TestBed.createComponent(LoginComponent);
component = fixture.componentInstance;
directive = new LoginFooterDirective(component);
});
it('is defined', () => {
expect(loginFooterDirective).toBeDefined();
it('applies tempalate to Login component', () => {
const template = {};
directive.template = template;
directive.ngAfterContentInit();
expect(component.footerTemplate).toBe(template);
});
});

View File

@@ -15,29 +15,40 @@
* limitations under the License.
*/
import { Injector } from '@angular/core';
import { getTestBed, TestBed } from '@angular/core/testing';
import { async, TestBed } from '@angular/core/testing';
import { CoreModule } from 'ng2-alfresco-core';
import { MaterialModule } from '../material.module';
import { LoginComponent } from '../components/login.component';
import { LoginHeaderDirective } from './login-header.directive';
describe('LoginHeaderDirective', () => {
let injector: Injector;
let loginHeaderDirective: LoginHeaderDirective;
let component: LoginComponent;
let directive: LoginHeaderDirective;
beforeEach(() => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [CoreModule.forRoot()],
providers: [
imports: [
CoreModule,
MaterialModule
],
declarations: [
LoginHeaderDirective,
LoginComponent
]
});
injector = getTestBed();
loginHeaderDirective = injector.get(LoginHeaderDirective);
}).compileComponents();
}));
beforeEach(() => {
let fixture = TestBed.createComponent(LoginComponent);
component = fixture.componentInstance;
directive = new LoginHeaderDirective(component);
});
it('is defined', () => {
expect(loginHeaderDirective).toBeDefined();
it('applies tempalate to Login component', () => {
const template = {};
directive.template = template;
directive.ngAfterContentInit();
expect(component.headerTemplate).toBe(template);
});
});

View File

@@ -0,0 +1,39 @@
/*!
* @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 { NgModule } from '@angular/core';
import {
MdCheckboxModule,
MdIconModule,
MdInputModule,
MdProgressSpinnerModule
} from '@angular/material';
export function modules() {
return [
MdCheckboxModule,
MdIconModule,
MdInputModule,
MdProgressSpinnerModule
];
}
@NgModule({
imports: modules(),
exports: modules()
})
export class MaterialModule {}

View File

@@ -59,7 +59,7 @@ export const ALFRESCO_SEARCH_PROVIDERS: [any] = [
@NgModule({
imports: [
DocumentListModule.forRoot(),
DocumentListModule,
CoreModule,
FormsModule,
ReactiveFormsModule

View File

@@ -4,33 +4,37 @@
<i mdl-upgrade class="material-icons">search</i>
</label>
<div [class]="getTextFieldHolderClassName()">
<input mdl
class="mdl-textfield__input"
[type]="inputType"
[autocomplete]="getAutoComplete()"
data-automation-id="search_input"
#searchInput
id="searchControl"
[formControl]="searchControl"
[(ngModel)]="searchTerm"
(focus)="onFocus($event)"
(blur)="onBlur($event)"
(keyup.escape)="onEscape($event)"
(keyup.arrowdown)="onArrowDown($event)"
aria-labelledby="searchLabel">
<input
mdl
class="mdl-textfield__input"
[type]="inputType"
[autocomplete]="getAutoComplete()"
data-automation-id="search_input"
#searchInput
id="searchControl"
[formControl]="searchControl"
[(ngModel)]="searchTerm"
(focus)="onFocus($event)"
(blur)="onBlur($event)"
(keyup.escape)="onEscape()"
(keyup.arrowdown)="onArrowDown()"
aria-labelledby="searchLabel">
<label id="searchLabel" class="mdl-textfield__label" for="searchControl">{{'SEARCH.CONTROL.LABEL' | translate}}</label>
</div>
</div>
</form>
<adf-search-autocomplete #autocomplete *ngIf="liveSearchEnabled"
[searchTerm]="liveSearchTerm"
[rootNodeId]="liveSearchRoot"
[resultType]="liveSearchResultType"
[resultSort]="liveSearchResultSort"
[maxResults]="liveSearchMaxResults"
[highlight]="highlight"
[ngClass]="{active: searchActive, valid: searchValid}"
(fileSelect)="onFileClicked($event)"
(searchFocus)="onAutoCompleteFocus($event)"
(scrollBack)="onAutoCompleteReturn($event)"
(cancel)="onAutoCompleteCancel($event)"></adf-search-autocomplete>
<adf-search-autocomplete
#autocomplete
*ngIf="liveSearchEnabled"
[searchTerm]="liveSearchTerm"
[rootNodeId]="liveSearchRoot"
[resultType]="liveSearchResultType"
[resultSort]="liveSearchResultSort"
[maxResults]="liveSearchMaxResults"
[highlight]="highlight"
[ngClass]="{active: searchActive, valid: searchValid}"
(fileSelect)="onFileClicked($event)"
(searchFocus)="onAutoCompleteFocus($event)"
(scrollBack)="onAutoCompleteReturn($event)"
(cancel)="onAutoCompleteCancel($event)">
</adf-search-autocomplete>

View File

@@ -21,6 +21,8 @@ import { NodePaging, Pagination } from 'alfresco-js-api';
import { AlfrescoTranslationService, NotificationService, SearchOptions, SearchService } from 'ng2-alfresco-core';
import { PermissionModel } from 'ng2-alfresco-documentlist';
declare var require: any;
@Component({
selector: 'adf-search, alfresco-search',
styleUrls: ['./search.component.scss'],