From a66a45e68393ebdc1692d5101c072eece1e92cba Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Wed, 19 Jul 2017 15:04:40 +0200 Subject: [PATCH] Cleanup of old directives. --- .../pages/schemas/schema-form.component.html | 4 +- .../framework/angular/cloak.directive.spec.ts | 32 ----------- .../app/framework/angular/cloak.directive.ts | 23 -------- .../angular/focus-on-change.directive.spec.ts | 53 ------------------- .../angular/focus-on-change.directive.ts | 35 ------------ src/Squidex/app/framework/declarations.ts | 2 - src/Squidex/app/framework/module.ts | 6 --- .../shared/components/app-form.component.html | 4 +- 8 files changed, 4 insertions(+), 155 deletions(-) delete mode 100644 src/Squidex/app/framework/angular/cloak.directive.spec.ts delete mode 100644 src/Squidex/app/framework/angular/cloak.directive.ts delete mode 100644 src/Squidex/app/framework/angular/focus-on-change.directive.spec.ts delete mode 100644 src/Squidex/app/framework/angular/focus-on-change.directive.ts diff --git a/src/Squidex/app/features/schemas/pages/schemas/schema-form.component.html b/src/Squidex/app/features/schemas/pages/schemas/schema-form.component.html index 15734efea..734c84f47 100644 --- a/src/Squidex/app/features/schemas/pages/schemas/schema-form.component.html +++ b/src/Squidex/app/features/schemas/pages/schemas/schema-form.component.html @@ -8,9 +8,9 @@
- + - + The schema name becomes part of the api url,
e.g {{apiUrl.buildUrl("api/content/")}}{{appName}}/{{schemaName | async}}/. diff --git a/src/Squidex/app/framework/angular/cloak.directive.spec.ts b/src/Squidex/app/framework/angular/cloak.directive.spec.ts deleted file mode 100644 index 5a5421b70..000000000 --- a/src/Squidex/app/framework/angular/cloak.directive.spec.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Squidex Headless CMS - * - * @license - * Copyright (c) Sebastian Stehle. All rights reserved - */ - -import { CloakDirective } from './cloak.directive'; - -describe('CloakDirective', () => { - it('should remove class from element on ngOnInit', () => { - let called = false; - - const element = { - nativeElement: {} - }; - - const renderer = { - setElementClass: (target: any, className: string, isAdd: boolean) => { - called = true; - - expect(target).toBe(element.nativeElement); - expect(className).toBe('sqx-cloak'); - expect(isAdd).toBeFalsy(); - } - }; - - new CloakDirective(element, renderer).ngOnInit(); - - expect(called).toBeTruthy(); - }); -}); diff --git a/src/Squidex/app/framework/angular/cloak.directive.ts b/src/Squidex/app/framework/angular/cloak.directive.ts deleted file mode 100644 index c3f073425..000000000 --- a/src/Squidex/app/framework/angular/cloak.directive.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Squidex Headless CMS - * - * @license - * Copyright (c) Sebastian Stehle. All rights reserved - */ - -import { Directive, ElementRef, OnInit, Renderer } from '@angular/core'; - -@Directive({ - selector: '[sqxCloak]' -}) -export class CloakDirective implements OnInit { - constructor( - private readonly element: ElementRef, - private readonly renderer: Renderer - ) { - } - - public ngOnInit() { - this.renderer.setElementClass(this.element.nativeElement, 'sqx-cloak', false); - } -} \ No newline at end of file diff --git a/src/Squidex/app/framework/angular/focus-on-change.directive.spec.ts b/src/Squidex/app/framework/angular/focus-on-change.directive.spec.ts deleted file mode 100644 index 0276faf91..000000000 --- a/src/Squidex/app/framework/angular/focus-on-change.directive.spec.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Squidex Headless CMS - * - * @license - * Copyright (c) Sebastian Stehle. All rights reserved - */ - -import { ElementRef, Renderer } from '@angular/core'; - -import { FocusOnChangeDirective } from './focus-on-change.directive'; - -describe('FocusOnChangeDirective', () => { - let originalTimeout = 0; - - beforeEach(() => { - originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; - - jasmine.DEFAULT_TIMEOUT_INTERVAL = 800; - }); - - it('should call focus on element when value changes', (done: any) => { - const calledMethods: string[] = []; - const calledElements: any[] = []; - - const renderer = { - invokeElementMethod: (elem: any, method: any, args: any) => { - calledElements.push(elem); - calledMethods.push(method); - } - }; - - const element: ElementRef = { - nativeElement: {} - }; - - const directive = new FocusOnChangeDirective(element, renderer as Renderer); - directive.select = true; - directive.ngOnChanges(); - - expect(calledMethods).toEqual([]); - - setTimeout(() => { - expect(calledMethods).toEqual(['focus', 'select']); - expect(calledElements).toEqual([element.nativeElement, element.nativeElement]); - - done(); - }, 400); - }); - - afterEach(() => { - jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; - }); -}); diff --git a/src/Squidex/app/framework/angular/focus-on-change.directive.ts b/src/Squidex/app/framework/angular/focus-on-change.directive.ts deleted file mode 100644 index ec74b5286..000000000 --- a/src/Squidex/app/framework/angular/focus-on-change.directive.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Squidex Headless CMS - * - * @license - * Copyright (c) Sebastian Stehle. All rights reserved - */ - -import { Directive, ElementRef, Input, OnChanges, Renderer }from '@angular/core'; - -@Directive({ - selector: '[sqxFocusOnChange]' -}) -export class FocusOnChangeDirective implements OnChanges { - @Input() - public sqxFocusOnChange: any; - - @Input() - public select: boolean; - - constructor( - private readonly element: ElementRef, - private readonly renderer: Renderer - ) { - } - - public ngOnChanges() { - setTimeout(() => { - this.renderer.invokeElementMethod(this.element.nativeElement, 'focus', []); - - if (this.select) { - this.renderer.invokeElementMethod(this.element.nativeElement, 'select', []); - } - }, 100); - } -} \ No newline at end of file diff --git a/src/Squidex/app/framework/declarations.ts b/src/Squidex/app/framework/declarations.ts index b157293f3..bab4a1762 100644 --- a/src/Squidex/app/framework/declarations.ts +++ b/src/Squidex/app/framework/declarations.ts @@ -8,14 +8,12 @@ export * from './angular/animations'; export * from './angular/autocomplete.component'; export * from './angular/can-deactivate.guard'; -export * from './angular/cloak.directive'; export * from './angular/control-errors.component'; export * from './angular/copy.directive'; export * from './angular/date-time-editor.component'; export * from './angular/date-time.pipes'; export * from './angular/dropdown.component'; export * from './angular/file-drop.directive'; -export * from './angular/focus-on-change.directive'; export * from './angular/focus-on-init.directive'; export * from './angular/geolocation-editor.component'; export * from './angular/http-extensions-impl'; diff --git a/src/Squidex/app/framework/module.ts b/src/Squidex/app/framework/module.ts index 5a6035a2d..fa6a19e8e 100644 --- a/src/Squidex/app/framework/module.ts +++ b/src/Squidex/app/framework/module.ts @@ -15,7 +15,6 @@ import { AutocompleteComponent, CanDeactivateGuard, ClipboardService, - CloakDirective, ControlErrorsComponent, CopyDirective, DateTimeEditorComponent, @@ -25,7 +24,6 @@ import { DropdownComponent, DurationPipe, FileDropDirective, - FocusOnChangeDirective, FocusOnInitDirective, FromNowPipe, GeolocationEditorComponent, @@ -76,7 +74,6 @@ import { ], declarations: [ AutocompleteComponent, - CloakDirective, ControlErrorsComponent, CopyDirective, DateTimeEditorComponent, @@ -86,7 +83,6 @@ import { DropdownComponent, DurationPipe, FileDropDirective, - FocusOnChangeDirective, FocusOnInitDirective, FromNowPipe, GeolocationEditorComponent, @@ -121,7 +117,6 @@ import { ], exports: [ AutocompleteComponent, - CloakDirective, ControlErrorsComponent, CopyDirective, DateTimeEditorComponent, @@ -131,7 +126,6 @@ import { DropdownComponent, DurationPipe, FileDropDirective, - FocusOnChangeDirective, FocusOnInitDirective, FromNowPipe, GeolocationEditorComponent, diff --git a/src/Squidex/app/shared/components/app-form.component.html b/src/Squidex/app/shared/components/app-form.component.html index 6d7418660..112e1a648 100644 --- a/src/Squidex/app/shared/components/app-form.component.html +++ b/src/Squidex/app/shared/components/app-form.component.html @@ -8,9 +8,9 @@
- + - + The app name becomes part of the api url,
e.g {{apiUrl.buildUrl("api/content/")}}{{appName | async}}/.