From b607c8606249b52c4e695d2edfe3a999e1ad7e80 Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Tue, 6 Dec 2022 09:57:58 +0100 Subject: [PATCH] Change category name (#948) * Typings for editor SDK. * Fix line height and cut text. * Improve integrated documentation for .NET SDK * Add access token to preview URL. * Change category name. * Fix tests. --- .../rules/pages/rules/rule.component.html | 13 +- .../pages/clients/client.component.html | 10 +- .../workflows/workflow-step.component.html | 7 +- .../app/framework/angular/avatar.stories.tsx | 11 +- .../forms/editable-title.component.html | 63 ++++---- .../forms/editable-title.component.scss | 46 +++--- .../angular/forms/editable-title.component.ts | 51 ++++--- .../angular/forms/editable-title.stories.ts | 134 ++++++++++++++++++ .../components/schema-category.component.html | 15 +- .../components/schema-category.component.scss | 19 ++- .../components/schema-category.component.ts | 6 + .../app/shared/state/schemas.state.spec.ts | 12 ++ .../src/app/shared/state/schemas.state.ts | 27 +++- 13 files changed, 317 insertions(+), 97 deletions(-) create mode 100644 frontend/src/app/framework/angular/forms/editable-title.stories.ts diff --git a/frontend/src/app/features/rules/pages/rules/rule.component.html b/frontend/src/app/features/rules/pages/rules/rule.component.html index 2771ba252..991650598 100644 --- a/frontend/src/app/features/rules/pages/rules/rule.component.html +++ b/frontend/src/app/features/rules/pages/rules/rule.component.html @@ -2,12 +2,13 @@
- +
diff --git a/frontend/src/app/features/settings/pages/clients/client.component.html b/frontend/src/app/features/settings/pages/clients/client.component.html index f9b98d175..a5afdae21 100644 --- a/frontend/src/app/features/settings/pages/clients/client.component.html +++ b/frontend/src/app/features/settings/pages/clients/client.component.html @@ -1,8 +1,12 @@
-
+
- +
@@ -10,7 +14,7 @@ {{ 'clients.connect' | sqxTranslate }}
-
+
- - + +
+
+
+ + +
- +
+ +
+
+ +
+
+ - -
-

- {{name || fallback}} + +
+
+

+ {{inputTitle || displayFallback}}

- -
- -
\ No newline at end of file +
+ +
+
+ +
+

+
\ No newline at end of file diff --git a/frontend/src/app/framework/angular/forms/editable-title.component.scss b/frontend/src/app/framework/angular/forms/editable-title.component.scss index 5579d5550..eb5b6f36c 100644 --- a/frontend/src/app/framework/angular/forms/editable-title.component.scss +++ b/frontend/src/app/framework/angular/forms/editable-title.component.scss @@ -1,34 +1,36 @@ @import 'mixins'; @import 'vars'; -.title { - @include hover-visible('.title-edit', inline); - position: relative; - - &-edit { - @include absolute(0, 0, null, null); - color: darken($color-border-dark, 20%); - cursor: pointer; - padding: .6rem .25rem; - } +:host { + display: block; +} - &-name { - display: inline; - font-size: 1.2rem; - font-weight: normal; - padding-right: 1.75rem; - } +.title-view { + @include hover-visible('.title-edit', block); - &-view { - @include truncate; - border-bottom: 1px solid transparent; - border-top: 0; - padding: .375rem 0; - position: absolute; + .col { + overflow: hidden; } } +.btn-placeholder { + padding-left: 0; + padding-right: 0; + width: 0; +} + +.row { + flex-wrap: nowrap; +} + h3 { + margin: 0; + + &.sm { + font-size: 1rem; + font-weight: normal; + } + &.fallback { color: $color-text-decent; } diff --git a/frontend/src/app/framework/angular/forms/editable-title.component.ts b/frontend/src/app/framework/angular/forms/editable-title.component.ts index 9c2a0a114..2d69fb0ab 100644 --- a/frontend/src/app/framework/angular/forms/editable-title.component.ts +++ b/frontend/src/app/framework/angular/forms/editable-title.component.ts @@ -6,42 +6,41 @@ */ import { Component, EventEmitter, Input, Output } from '@angular/core'; -import { UntypedFormControl, Validators } from '@angular/forms'; +import { FormControl, ValidatorFn, Validators } from '@angular/forms'; import { Keys } from '@app/framework/internal'; @Component({ - selector: 'sqx-editable-title[name]', + selector: 'sqx-editable-title[inputTitle]', styleUrls: ['./editable-title.component.scss'], templateUrl: './editable-title.component.html', }) export class EditableTitleComponent { @Output() - public nameChange = new EventEmitter(); + public inputTitleChange = new EventEmitter(); @Input() - public disabled?: boolean | null; + public inputTitle!: string; @Input() - public fallback = ''; + public inputTitleLength = 20; @Input() - public name!: string; + public inputTitleRequired = true; @Input() - public maxLength = 20; + public disabled?: boolean | null; @Input() - public set isRequired(value: boolean) { - const validator = - value ? - Validators.required : - Validators.nullValidator; + public closeButton = true; - this.renameForm.setValidators(validator); - } + @Input() + public size: 'sm' | 'md' | 'lg' = 'md'; + + @Input() + public displayFallback = ''; public renaming = false; - public renameForm = new UntypedFormControl(); + public renameForm = new FormControl(''); public onKeyDown(event: KeyboardEvent) { if (Keys.isEscape(event)) { @@ -54,7 +53,21 @@ export class EditableTitleComponent { return; } - this.renameForm.setValue(this.name || ''); + if (!this.renaming) { + let validators: ValidatorFn[] = []; + + if (this.inputTitleLength) { + validators.push(Validators.maxLength(this.inputTitleLength)); + } + + if (this.inputTitleRequired) { + validators.push(Validators.required); + } + + this.renameForm.setValidators(validators); + } + + this.renameForm.setValue(this.inputTitle || ''); this.renaming = !this.renaming; } @@ -64,10 +77,10 @@ export class EditableTitleComponent { } if (this.renameForm.valid) { - const name = this.renameForm.value; + const text = this.renameForm.value || ''; - this.nameChange.emit(name); - this.name = name; + this.inputTitleChange.emit(text); + this.inputTitle = text; this.renaming = false; } diff --git a/frontend/src/app/framework/angular/forms/editable-title.stories.ts b/frontend/src/app/framework/angular/forms/editable-title.stories.ts new file mode 100644 index 000000000..7f1ec2d0b --- /dev/null +++ b/frontend/src/app/framework/angular/forms/editable-title.stories.ts @@ -0,0 +1,134 @@ +/* + * Squidex Headless CMS + * + * @license + * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. + */ + +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { moduleMetadata } from '@storybook/angular'; +import { Meta, Story } from '@storybook/angular/types-6-0'; +import { EditableTitleComponent, LocalizerService, SqxFrameworkModule } from '@app/framework'; + +export default { + title: 'Framework/EditableTitle', + component: EditableTitleComponent, + argTypes: { + inputTitle: { + control: 'inputTitle', + }, + closeButton: { + control: 'boolean', + }, + inputTitleRequired: { + control: 'boolean', + }, + inputTitleLength: { + control: 'number', + }, + size: { + control: 'select', + options: [ + 'sm', + 'md', + 'lg', + ], + }, + }, + args: { + closeButton: true, + inputTitleLength: 30, + inputTitleRequired: true, + }, + decorators: [ + moduleMetadata({ + imports: [ + BrowserAnimationsModule, + FormsModule, + ReactiveFormsModule, + SqxFrameworkModule, + SqxFrameworkModule.forRoot(), + ], + providers: [ + { provide: LocalizerService, useValue: new LocalizerService({}) }, + ], + }), + ], +} as Meta; + +const Template: Story = (args: EditableTitleComponent) => ({ + props: args, + template: ` +
+
+
+ + +
+
+ +
+
+
+ `, +}); + +export const Default = Template.bind({}); + +Default.args = { + inputTitle: 'My Title', + size: 'md', +}; + +export const DefaultNoCloseButton = Template.bind({}); + +DefaultNoCloseButton.args = { + inputTitle: 'My Title', + size: 'md', + closeButton: false, +}; + +export const Small = Template.bind({}); + +Small.args = { + inputTitle: 'My Title', + size: 'sm', +}; + +export const SmallNoCloseButton = Template.bind({}); + +SmallNoCloseButton.args = { + inputTitle: 'My Title', + size: 'sm', + closeButton: false, +}; + +export const Large = Template.bind({}); + +Large.args = { + inputTitle: 'My Title', + size: 'lg', +}; + +export const LargeNoCloseButton = Template.bind({}); + +LargeNoCloseButton.args = { + inputTitle: 'My Title', + size: 'lg', + closeButton: false, +}; + +export const LongTitle = Template.bind({}); + +LongTitle.args = { + inputTitle: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua', + size: 'md', +}; \ No newline at end of file diff --git a/frontend/src/app/shared/components/schema-category.component.html b/frontend/src/app/shared/components/schema-category.component.html index 0f914a115..2ad60eb6e 100644 --- a/frontend/src/app/shared/components/schema-category.component.html +++ b/frontend/src/app/shared/components/schema-category.component.html @@ -6,16 +6,21 @@ (cdkDropListDropped)="changeCategory($event)">