diff --git a/backend/src/Squidex.Domain.Apps.Entities/Schemas/Commands/IUpsertCommand.cs b/backend/src/Squidex.Domain.Apps.Entities/Schemas/Commands/IUpsertCommand.cs index 7c109ade7..3581417cc 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Schemas/Commands/IUpsertCommand.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Schemas/Commands/IUpsertCommand.cs @@ -21,16 +21,16 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Commands SchemaField[]? Fields { get; set; } + SchemaScripts? Scripts { get; set; } + + SchemaProperties Properties { get; set; } + FieldNames? FieldsInReferences { get; set; } FieldNames? FieldsInLists { get; set; } FieldRuleCommand[]? FieldRules { get; set; } - SchemaScripts? Scripts { get; set; } - - SchemaProperties Properties { get; set; } - Dictionary? PreviewUrls { get; set; } Schema ToSchema(string name, bool isSingleton) diff --git a/backend/src/Squidex/Areas/Api/Controllers/Schemas/Models/UpsertSchemaDto.cs b/backend/src/Squidex/Areas/Api/Controllers/Schemas/Models/UpsertSchemaDto.cs index 03cfe5ce8..98a91acae 100644 --- a/backend/src/Squidex/Areas/Api/Controllers/Schemas/Models/UpsertSchemaDto.cs +++ b/backend/src/Squidex/Areas/Api/Controllers/Schemas/Models/UpsertSchemaDto.cs @@ -54,8 +54,7 @@ namespace Squidex.Areas.Api.Controllers.Schemas.Models /// public bool IsPublished { get; set; } - public static TCommand ToCommand(TDto dto, TCommand command) - where TCommand : SchemaCommand, IUpsertCommand where TDto : UpsertSchemaDto + public static T ToCommand(TSoure dto, T command) where T : SchemaCommand, IUpsertCommand where TSoure : UpsertSchemaDto { SimpleMapper.Map(dto, command); diff --git a/frontend/app/framework/angular/forms/editors/date-time-editor.component.ts b/frontend/app/framework/angular/forms/editors/date-time-editor.component.ts index 14cc2caf9..9e5bdddd4 100644 --- a/frontend/app/framework/angular/forms/editors/date-time-editor.component.ts +++ b/frontend/app/framework/angular/forms/editors/date-time-editor.component.ts @@ -8,6 +8,7 @@ import { AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, EventEmitter, forwardRef, Input, OnInit, Output, ViewChild } from '@angular/core'; import { FormControl, NG_VALUE_ACCESSOR } from '@angular/forms'; import { DateHelper, DateTime, StatefulControlComponent, UIOptions } from '@app/framework/internal'; +import format from 'date-fns/format'; import * as Pikaday from 'pikaday/pikaday'; import { FocusComponent } from './../forms-helper'; @@ -136,7 +137,12 @@ export class DateTimeEditorComponent extends StatefulControlComponent<{}, string } public ngAfterViewInit() { - this.picker = new Pikaday({field: this.dateInput.nativeElement, format: 'YYYY-MM-DD', + const i18n = getLocalizationSettings(); + + this.picker = new Pikaday({ + field: this.dateInput.nativeElement, + i18n, + format: 'YYYY-MM-DD', onSelect: () => { if (this.suppressEvents) { return; @@ -242,4 +248,33 @@ export class DateTimeEditorComponent extends StatefulControlComponent<{}, string public setCompact(isCompact: boolean) { this.next(s => ({ ...s, isCompact })); } +} + +let localizedValues: any; + +function getLocalizationSettings() { + if (!localizedValues) { + localizedValues = { + months: [], + weekdays: [], + weekdaysShort: [] + }; + + const options = { locale: DateHelper.getFnsLocale() }; + + for (let i = 0; i < 12; i++) { + const firstOfMonth = new Date(2020, i, 1); + + localizedValues.months.push(format(firstOfMonth, 'LLLL', options)); + } + + for (let i = 1; i <= 7; i++) { + const weekDay = new Date(2020, 11, i); + + localizedValues.weekdays.push(format(weekDay, 'EEEE', options)); + localizedValues.weekdaysShort.push(format(weekDay, 'EEE', options)); + } + } + + return localizedValues; } \ No newline at end of file diff --git a/frontend/app/framework/internal.ts b/frontend/app/framework/internal.ts index fe16c3199..01355f25c 100644 --- a/frontend/app/framework/internal.ts +++ b/frontend/app/framework/internal.ts @@ -24,6 +24,7 @@ export * from './services/temp.service'; export * from './services/title.service'; export * from './services/localizer.service'; export * from './utils/array-helper'; +export * from './utils/cookies'; export * from './utils/date-helper'; export * from './utils/date-time'; export * from './utils/duration'; diff --git a/frontend/app/framework/utils/cookies.ts b/frontend/app/framework/utils/cookies.ts new file mode 100644 index 000000000..b3b3cbaf6 --- /dev/null +++ b/frontend/app/framework/utils/cookies.ts @@ -0,0 +1,26 @@ +/* + * Squidex Headless CMS + * + * @license + * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. + */ + +export module Cookies { + export function set(name: string, value: string, days: number) { + let expires = ''; + + if (days) { + const date = new Date(); + + date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); + + expires = '; expires=' + date.toUTCString(); + } + + document.cookie = `${name}=${value || ''}${expires}; path=/`; + } + + export function remove(name: string) { + document.cookie = `${name}=; Max-Age=-99999999;`; + } +} \ No newline at end of file diff --git a/frontend/app/shell/pages/internal/profile-menu.component.ts b/frontend/app/shell/pages/internal/profile-menu.component.ts index 1f170401c..68a83b592 100644 --- a/frontend/app/shell/pages/internal/profile-menu.component.ts +++ b/frontend/app/shell/pages/internal/profile-menu.component.ts @@ -6,7 +6,7 @@ */ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core'; -import { ApiUrlConfig, AuthService, fadeAnimation, ModalModel, StatefulComponent, UILanguages, UIOptions, UIState } from '@app/shared'; +import { ApiUrlConfig, AuthService, Cookies, fadeAnimation, ModalModel, StatefulComponent, UILanguages, UIOptions, UIState } from '@app/shared'; interface State { // The display name of the user. @@ -71,7 +71,8 @@ export class ProfileMenuComponent extends StatefulComponent implements On } public changeLanguage(code: string) { - document.cookie = `.AspNetCore.Culture=c=${code}|uic=${code}`; + Cookies.remove('.AspNetCore.Culture'); + Cookies.set('.AspNetCore.Culture', `c=${code}|uic=${code}`, 365); location.reload(); }