[ADF-604] Upgrade @angular/material to latest version (#1909)

* update dependencies and module imports

* fix template warnings and fix import issues

* migrate Activiti Form to MdTabsModule

* fix unit tests

* fix tests

* fix unit tests

* fix unit tests

* disable test that fails only on travis

* upgrade activiti form component to angular/material

* fix test (remove MDL class check)
This commit is contained in:
Denys Vuika
2017-05-30 11:51:50 +01:00
committed by Eugenio Romano
parent 6e3e3ab5b7
commit a2ef939860
47 changed files with 192 additions and 230 deletions

View File

@@ -18,19 +18,16 @@
import { MDL } from './mdl-upgrade-element.directive';
import { AlfrescoMdlButtonDirective } from './mdl-button.directive';
import { AlfrescoMdlMenuDirective } from './mdl-menu.directive';
import { AlfrescoMdlTabsDirective } from './mdl-tabs.directive';
import { AlfrescoMdlTextFieldDirective } from './mdl-textfield.directive';
export * from './mdl-upgrade-element.directive';
export * from './mdl-button.directive';
export * from './mdl-menu.directive';
export * from './mdl-tabs.directive';
export * from './mdl-textfield.directive';
export const MATERIAL_DESIGN_DIRECTIVES: [any] = [
MDL,
AlfrescoMdlButtonDirective,
AlfrescoMdlMenuDirective,
AlfrescoMdlTabsDirective,
AlfrescoMdlTextFieldDirective
];

View File

@@ -1,79 +0,0 @@
/*!
* @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 {
Directive,
ElementRef,
AfterViewInit,
OnDestroy
} from '@angular/core';
declare var componentHandler;
@Directive({
selector: '[alfresco-mdl-tabs]'
})
export class AlfrescoMdlTabsDirective implements AfterViewInit, OnDestroy {
private observer: MutationObserver;
constructor(private element: ElementRef) {}
ngAfterViewInit() {
if (componentHandler) {
let el = this.element.nativeElement;
el.classList.add('mdl-tabs');
el.classList.add('mdl-js-tabs');
el.classList.add('mdl-js-ripple-effect');
componentHandler.upgradeElement(el, 'MaterialTabs');
// watch widget DOM changes and re-upgrade MDL content
let tabBar = el.querySelector('.mdl-tabs__tab-bar');
if (tabBar) {
this.observer = new MutationObserver((mutations: any[]) => {
let upgrade = false;
mutations.forEach((mutation: MutationRecord) => {
if (mutation.addedNodes && mutation.addedNodes.length > 0) {
upgrade = true;
}
if (mutation.removedNodes && mutation.removedNodes.length > 0) {
upgrade = true;
}
});
if (upgrade) {
componentHandler.downgradeElements([el]);
componentHandler.upgradeElement(el);
}
});
this.observer.observe(tabBar, {
childList: true,
subtree: false
});
}
}
}
ngOnDestroy() {
if (this.observer) {
this.observer.disconnect();
}
}
}