diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index 8a79d6bca..a057b9899 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -18,7 +18,7 @@ import { ActivatedRouteSnapshot, BaseRouteReuseStrategy, RouteReuseStrategy, Rou import { environment } from './../environments/environment'; import { AppComponent } from './app.component'; 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'; DateHelper.setlocale(window['options']?.more?.culture); @@ -51,14 +51,6 @@ function configTitles() { return new TitlesConfig(undefined, 'i18n:common.product'); } -function configDecimalSeparator() { - return new DecimalSeparatorConfig('.'); -} - -function configCurrency() { - return new CurrencyConfig('EUR', '€', true); -} - function configLocalizerService() { return new LocalizerService(environment.textResolver()).logMissingKeys(environment.textLogger); } @@ -88,8 +80,6 @@ export class AppRouteReuseStrategy extends BaseRouteReuseStrategy { ], providers: [ { provide: ApiUrlConfig, useFactory: configApiUrl }, - { provide: CurrencyConfig, useFactory: configCurrency }, - { provide: DecimalSeparatorConfig, useFactory: configDecimalSeparator }, { provide: LocalizerService, useFactory: configLocalizerService }, { provide: RouteReuseStrategy, useClass: AppRouteReuseStrategy }, { provide: TitlesConfig, useFactory: configTitles }, diff --git a/frontend/src/app/framework/angular/pipes/money.pipe.spec.ts b/frontend/src/app/framework/angular/pipes/money.pipe.spec.ts deleted file mode 100644 index e2beb48a4..000000000 --- a/frontend/src/app/framework/angular/pipes/money.pipe.spec.ts +++ /dev/null @@ -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,49 €'; - - 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,40 €'; - - 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,49'; - - 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,40'; - - expect(actual).toBe(expected); - }); -}); diff --git a/frontend/src/app/framework/angular/pipes/money.pipe.ts b/frontend/src/app/framework/angular/pipes/money.pipe.ts deleted file mode 100644 index 652d14343..000000000 --- a/frontend/src/app/framework/angular/pipes/money.pipe.ts +++ /dev/null @@ -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}${money.substring(money.length - 2)}`; - - if (this.currency.showAfter) { - result = `${result} ${this.currency.symbol}`; - } else { - result = `${this.currency.symbol} ${result}`; - } - - return result; - } -} diff --git a/frontend/src/app/framework/configurations.ts b/frontend/src/app/framework/configurations.ts index e014c23f6..5d39ffc7a 100644 --- a/frontend/src/app/framework/configurations.ts +++ b/frontend/src/app/framework/configurations.ts @@ -53,20 +53,3 @@ export class ApiUrlConfig { 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) {} -} diff --git a/frontend/src/app/framework/declarations.ts b/frontend/src/app/framework/declarations.ts index 855456485..626c0439d 100644 --- a/frontend/src/app/framework/declarations.ts +++ b/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/keys.pipe'; export * from './angular/pipes/markdown.pipe'; -export * from './angular/pipes/money.pipe'; export * from './angular/pipes/name.pipe'; export * from './angular/pipes/numbers.pipes'; export * from './angular/pipes/translate.pipe'; diff --git a/frontend/src/app/framework/module.ts b/frontend/src/app/framework/module.ts index 938aabc69..0bc75db2b 100644 --- a/frontend/src/app/framework/module.ts +++ b/frontend/src/app/framework/module.ts @@ -11,7 +11,7 @@ import { ModuleWithProviders, NgModule } from '@angular/core'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { RouterModule } from '@angular/router'; 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({ imports: [ @@ -71,7 +71,6 @@ import { AnalyticsService, AutocompleteComponent, AvatarComponent, CachingInterc ModalDialogComponent, ModalDirective, ModalPlacementDirective, - MoneyPipe, MonthPipe, OnboardingTooltipComponent, PagerComponent, @@ -155,7 +154,6 @@ import { AnalyticsService, AutocompleteComponent, AvatarComponent, CachingInterc ModalDialogComponent, ModalDirective, ModalPlacementDirective, - MoneyPipe, MonthPipe, OnboardingTooltipComponent, PagerComponent,