Browse Source

Cleanup unused code. (#832)

* Cleanup unused code.

* Get rid of import.
pull/837/head
Sebastian Stehle 4 years ago
committed by GitHub
parent
commit
99def14943
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      frontend/src/app/app.module.ts
  2. 47
      frontend/src/app/framework/angular/pipes/money.pipe.spec.ts
  3. 35
      frontend/src/app/framework/angular/pipes/money.pipe.ts
  4. 17
      frontend/src/app/framework/configurations.ts
  5. 1
      frontend/src/app/framework/declarations.ts
  6. 4
      frontend/src/app/framework/module.ts

12
frontend/src/app/app.module.ts

@ -18,7 +18,7 @@ import { ActivatedRouteSnapshot, BaseRouteReuseStrategy, RouteReuseStrategy, Rou
import { environment } from './../environments/environment'; import { environment } from './../environments/environment';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
import { routing } from './app.routes'; import { routing } from './app.routes';
import { ApiUrlConfig, CurrencyConfig, DateHelper, DecimalSeparatorConfig, LocalizerService, SqxFrameworkModule, SqxSharedModule, TitlesConfig, UIOptions } from './shared'; import { ApiUrlConfig, DateHelper, LocalizerService, SqxFrameworkModule, SqxSharedModule, TitlesConfig, UIOptions } from './shared';
import { SqxShellModule } from './shell'; import { SqxShellModule } from './shell';
DateHelper.setlocale(window['options']?.more?.culture); DateHelper.setlocale(window['options']?.more?.culture);
@ -51,14 +51,6 @@ function configTitles() {
return new TitlesConfig(undefined, 'i18n:common.product'); return new TitlesConfig(undefined, 'i18n:common.product');
} }
function configDecimalSeparator() {
return new DecimalSeparatorConfig('.');
}
function configCurrency() {
return new CurrencyConfig('EUR', '€', true);
}
function configLocalizerService() { function configLocalizerService() {
return new LocalizerService(environment.textResolver()).logMissingKeys(environment.textLogger); return new LocalizerService(environment.textResolver()).logMissingKeys(environment.textLogger);
} }
@ -88,8 +80,6 @@ export class AppRouteReuseStrategy extends BaseRouteReuseStrategy {
], ],
providers: [ providers: [
{ provide: ApiUrlConfig, useFactory: configApiUrl }, { provide: ApiUrlConfig, useFactory: configApiUrl },
{ provide: CurrencyConfig, useFactory: configCurrency },
{ provide: DecimalSeparatorConfig, useFactory: configDecimalSeparator },
{ provide: LocalizerService, useFactory: configLocalizerService }, { provide: LocalizerService, useFactory: configLocalizerService },
{ provide: RouteReuseStrategy, useClass: AppRouteReuseStrategy }, { provide: RouteReuseStrategy, useClass: AppRouteReuseStrategy },
{ provide: TitlesConfig, useFactory: configTitles }, { provide: TitlesConfig, useFactory: configTitles },

47
frontend/src/app/framework/angular/pipes/money.pipe.spec.ts

@ -1,47 +0,0 @@
/*
* Squidex Headless CMS
*
* @license
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/
import { CurrencyConfig, DecimalSeparatorConfig } from '@app/framework/internal';
import { MoneyPipe } from './money.pipe';
describe('MoneyPipe', () => {
it('should format money values with symbol after number', () => {
const pipe = new MoneyPipe(new CurrencyConfig('EUR', '€'), new DecimalSeparatorConfig(','));
const actual = pipe.transform(123.49);
const expected = '123,<span class="decimal">49</span> €';
expect(actual).toBe(expected);
});
it('should format money values with symbol after number and one decimal', () => {
const pipe = new MoneyPipe(new CurrencyConfig('EUR', '€'), new DecimalSeparatorConfig(','));
const actual = pipe.transform(123.4);
const expected = '123,<span class="decimal">40</span> €';
expect(actual).toBe(expected);
});
it('should format money values with symbol before number', () => {
const pipe = new MoneyPipe(new CurrencyConfig('EUR', '€', false), new DecimalSeparatorConfig(','));
const actual = pipe.transform(123.49);
const expected = '€ 123,<span class="decimal">49</span>';
expect(actual).toBe(expected);
});
it('should format money values with symbol before number and one decimal', () => {
const pipe = new MoneyPipe(new CurrencyConfig('EUR', '€', false), new DecimalSeparatorConfig(','));
const actual = pipe.transform(123.4);
const expected = '€ 123,<span class="decimal">40</span>';
expect(actual).toBe(expected);
});
});

35
frontend/src/app/framework/angular/pipes/money.pipe.ts

@ -1,35 +0,0 @@
/*
* Squidex Headless CMS
*
* @license
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/
import { Pipe, PipeTransform } from '@angular/core';
import { CurrencyConfig, DecimalSeparatorConfig } from '@app/framework/internal';
@Pipe({
name: 'sqxMoney',
pure: true,
})
export class MoneyPipe implements PipeTransform {
constructor(
private readonly currency: CurrencyConfig,
private readonly separator: DecimalSeparatorConfig,
) {
}
public transform(value: number): any {
const money = value.toFixed(2).toString();
let result = `${money.substring(0, money.length - 3) + this.separator.value}<span class="decimal">${money.substring(money.length - 2)}</span>`;
if (this.currency.showAfter) {
result = `${result} ${this.currency.symbol}`;
} else {
result = `${this.currency.symbol} ${result}`;
}
return result;
}
}

17
frontend/src/app/framework/configurations.ts

@ -53,20 +53,3 @@ export class ApiUrlConfig {
return this.value + path; return this.value + path;
} }
} }
export class CurrencyConfig {
constructor(
public readonly code: string,
public readonly symbol: string,
public readonly showAfter: boolean = true,
) {
}
}
export class DecimalSeparatorConfig {
constructor(public readonly value: string) {}
}
export class ProductionModeConfig {
constructor(public readonly isProductionMode: boolean) {}
}

1
frontend/src/app/framework/declarations.ts

@ -61,7 +61,6 @@ export * from './angular/pipes/date-time.pipes';
export * from './angular/pipes/highlight.pipe'; export * from './angular/pipes/highlight.pipe';
export * from './angular/pipes/keys.pipe'; export * from './angular/pipes/keys.pipe';
export * from './angular/pipes/markdown.pipe'; export * from './angular/pipes/markdown.pipe';
export * from './angular/pipes/money.pipe';
export * from './angular/pipes/name.pipe'; export * from './angular/pipes/name.pipe';
export * from './angular/pipes/numbers.pipes'; export * from './angular/pipes/numbers.pipes';
export * from './angular/pipes/translate.pipe'; export * from './angular/pipes/translate.pipe';

4
frontend/src/app/framework/module.ts

@ -11,7 +11,7 @@ import { ModuleWithProviders, NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import { ColorPickerModule } from 'ngx-color-picker'; import { ColorPickerModule } from 'ngx-color-picker';
import { AnalyticsService, AutocompleteComponent, AvatarComponent, CachingInterceptor, CanDeactivateGuard, CheckboxGroupComponent, ClipboardService, CodeComponent, CodeEditorComponent, ColorPickerComponent, ConfirmClickDirective, ControlErrorsComponent, ControlErrorsMessagesComponent, CopyDirective, DarkenPipe, DatePipe, DateTimeEditorComponent, DayOfWeekPipe, DayPipe, DialogRendererComponent, DialogService, DisplayNamePipe, DropdownComponent, DropdownMenuComponent, DurationPipe, EditableTitleComponent, ExternalLinkDirective, FileDropDirective, FileSizePipe, FocusOnInitDirective, FormAlertComponent, FormErrorComponent, FormHintComponent, FromNowPipe, FullDateTimePipe, HighlightPipe, HoverBackgroundDirective, ImageSourceDirective, IndeterminateValueDirective, ISODatePipe, KeysPipe, KNumberPipe, LanguageSelectorComponent, LayoutComponent, LayoutContainerDirective, LightenPipe, ListViewComponent, LoadingInterceptor, LoadingService, LocalizedInputComponent, LocalStoreService, MarkdownDirective, MarkdownInlinePipe, MarkdownPipe, MessageBus, ModalDialogComponent, ModalDirective, ModalPlacementDirective, MoneyPipe, MonthPipe, OnboardingService, OnboardingTooltipComponent, PagerComponent, ParentLinkDirective, ProgressBarComponent, ResizedDirective, ResizeService, ResourceLoaderService, RootViewComponent, SafeHtmlPipe, SafeResourceUrlPipe, SafeUrlPipe, ScrollActiveDirective, ShortcutComponent, ShortcutDirective, ShortcutService, ShortDatePipe, ShortTimePipe, StarsComponent, StatusIconComponent, StopClickDirective, StopDragDirective, SyncScollingDirective, SyncWidthDirective, TabRouterlinkDirective, TagEditorComponent, TemplateWrapperDirective, TempService, TitleComponent, TitleService, ToggleComponent, ToolbarComponent, TooltipDirective, TransformInputDirective, TranslatePipe, VideoPlayerComponent } from './declarations'; import { AnalyticsService, AutocompleteComponent, AvatarComponent, CachingInterceptor, CanDeactivateGuard, CheckboxGroupComponent, ClipboardService, CodeComponent, CodeEditorComponent, ColorPickerComponent, ConfirmClickDirective, ControlErrorsComponent, ControlErrorsMessagesComponent, CopyDirective, DarkenPipe, DatePipe, DateTimeEditorComponent, DayOfWeekPipe, DayPipe, DialogRendererComponent, DialogService, DisplayNamePipe, DropdownComponent, DropdownMenuComponent, DurationPipe, EditableTitleComponent, ExternalLinkDirective, FileDropDirective, FileSizePipe, FocusOnInitDirective, FormAlertComponent, FormErrorComponent, FormHintComponent, FromNowPipe, FullDateTimePipe, HighlightPipe, HoverBackgroundDirective, ImageSourceDirective, IndeterminateValueDirective, ISODatePipe, KeysPipe, KNumberPipe, LanguageSelectorComponent, LayoutComponent, LayoutContainerDirective, LightenPipe, ListViewComponent, LoadingInterceptor, LoadingService, LocalizedInputComponent, LocalStoreService, MarkdownDirective, MarkdownInlinePipe, MarkdownPipe, MessageBus, ModalDialogComponent, ModalDirective, ModalPlacementDirective, MonthPipe, OnboardingService, OnboardingTooltipComponent, PagerComponent, ParentLinkDirective, ProgressBarComponent, ResizedDirective, ResizeService, ResourceLoaderService, RootViewComponent, SafeHtmlPipe, SafeResourceUrlPipe, SafeUrlPipe, ScrollActiveDirective, ShortcutComponent, ShortcutDirective, ShortcutService, ShortDatePipe, ShortTimePipe, StarsComponent, StatusIconComponent, StopClickDirective, StopDragDirective, SyncScollingDirective, SyncWidthDirective, TabRouterlinkDirective, TagEditorComponent, TemplateWrapperDirective, TempService, TitleComponent, TitleService, ToggleComponent, ToolbarComponent, TooltipDirective, TransformInputDirective, TranslatePipe, VideoPlayerComponent } from './declarations';
@NgModule({ @NgModule({
imports: [ imports: [
@ -71,7 +71,6 @@ import { AnalyticsService, AutocompleteComponent, AvatarComponent, CachingInterc
ModalDialogComponent, ModalDialogComponent,
ModalDirective, ModalDirective,
ModalPlacementDirective, ModalPlacementDirective,
MoneyPipe,
MonthPipe, MonthPipe,
OnboardingTooltipComponent, OnboardingTooltipComponent,
PagerComponent, PagerComponent,
@ -155,7 +154,6 @@ import { AnalyticsService, AutocompleteComponent, AvatarComponent, CachingInterc
ModalDialogComponent, ModalDialogComponent,
ModalDirective, ModalDirective,
ModalPlacementDirective, ModalPlacementDirective,
MoneyPipe,
MonthPipe, MonthPipe,
OnboardingTooltipComponent, OnboardingTooltipComponent,
PagerComponent, PagerComponent,

Loading…
Cancel
Save