diff --git a/libs/docs/platform/form-generator/examples/platform-form-generator-example.component.html b/libs/docs/platform/form-generator/examples/platform-form-generator-example.component.html index 520ba4c867d..0bc278a774f 100644 --- a/libs/docs/platform/form-generator/examples/platform-form-generator-example.component.html +++ b/libs/docs/platform/form-generator/examples/platform-form-generator-example.component.html @@ -7,9 +7,27 @@ > @if (formCreated) { - + }

Form created: {{ formCreated }}

@if (formValue) {

Form value: {{ formValue | json }}

} + + + +

The History of Pineapple

+
+ + + + + +
+
diff --git a/libs/docs/platform/form-generator/examples/platform-form-generator-example.component.ts b/libs/docs/platform/form-generator/examples/platform-form-generator-example.component.ts index 2e84e6fe1a2..331991a338a 100644 --- a/libs/docs/platform/form-generator/examples/platform-form-generator-example.component.ts +++ b/libs/docs/platform/form-generator/examples/platform-form-generator-example.component.ts @@ -1,7 +1,16 @@ -import { Component, ViewChild } from '@angular/core'; +import { Component, inject, TemplateRef, ViewChild } from '@angular/core'; import { Validators } from '@angular/forms'; import { JsonPipe } from '@angular/common'; +import { + ButtonBarComponent, + DialogBodyComponent, + DialogComponent, + DialogFooterComponent, + DialogHeaderComponent, + DialogService, + TitleComponent +} from '@fundamental-ngx/core'; import { FdDate, provideDateTimeFormats } from '@fundamental-ngx/core/datetime'; import { PlatformButtonModule } from '@fundamental-ngx/platform/button'; import { @@ -18,6 +27,16 @@ export const dummyAwaitablePromise = (timeout = 200): Promise => }, timeout); }); +enum BuildTool { + Docker = 'Docker', + Golang = 'Golang', + Gradle = 'Gradle', + Maven = 'Maven', + Mta = 'Mta', + Npm = 'Npm', + Python = 'Python' +} + @Component({ selector: 'fdp-platform-form-generator-example', templateUrl: './platform-form-generator-example.component.html', @@ -27,10 +46,21 @@ export const dummyAwaitablePromise = (timeout = 200): Promise => provideDateTimeFormats() ], standalone: true, - imports: [PlatformFormGeneratorModule, PlatformButtonModule, JsonPipe] + imports: [ + PlatformFormGeneratorModule, + PlatformButtonModule, + JsonPipe, + DialogComponent, + ButtonBarComponent, + TitleComponent, + DialogHeaderComponent, + DialogBodyComponent, + DialogFooterComponent + ] }) export class PlatformFormGeneratorExampleComponent { @ViewChild(FormGeneratorComponent) formGenerator: FormGeneratorComponent; + private _dialogService = inject(DialogService); loading = false; @@ -228,10 +258,54 @@ export class PlatformFormGeneratorExampleComponent { } ]; + questions2: DynamicFormItem<{}, any>[] = [ + { + type: 'header', + name: 'buildToolHeader', + message: '', + guiOptions: { + additionalData: { + header: 'Which build tool do you currently use?', + ignoreTopMargin: true + } + } + }, + { + type: 'radio', + name: 'buildTool', + message: '', + guiOptions: { + inline: true + }, + choices: [ + BuildTool.Docker, + BuildTool.Golang, + BuildTool.Gradle, + BuildTool.Maven, + BuildTool.Mta, + BuildTool.Npm, + BuildTool.Python + ].map((tool) => ({ + label: tool.charAt(0).toUpperCase() + tool.slice(1).toLocaleLowerCase(), + value: tool + })), + validators: [Validators.required] + } + ]; + onFormCreated(): void { this.formCreated = true; } + openDialog(dialog: TemplateRef): void { + const dialogRef = this._dialogService.open(dialog, { + responsivePadding: true, + ariaLabelledBy: 'fd-dialog-header-10', + ariaDescribedBy: 'fd-dialog-body-10', + focusTrapped: true + }); + } + async onFormSubmitted(value: DynamicFormValue): Promise { console.log(value); diff --git a/libs/docs/platform/form-generator/platform-form-generator-docs.component.html b/libs/docs/platform/form-generator/platform-form-generator-docs.component.html index 89d0a417629..b2708446ab6 100644 --- a/libs/docs/platform/form-generator/platform-form-generator-docs.component.html +++ b/libs/docs/platform/form-generator/platform-form-generator-docs.component.html @@ -9,194 +9,194 @@ - - Form Generator usage with Observable-based values - - - This example shows default scenario of the Form Generator usage with values received from Observable objects. - - - - - - - - Form generator usage with custom controls - - - If default set of controls is not enough to cover your needs, FormGeneratorService allows to define - custom controls and render them for respective question types. In order to make your component work properly, it - should follow these requirements: -
    -
  • - Component must include these - viewProviders: [dynamicFormFieldProvider, dynamicFormGroupChildProvider], which can be imported - from @fundamental-ngx/platform; -
  • -
  • - Component must inherit BaseDynamicFormGeneratorControl, which can be imported from - @fundamental-ngx/platform; -
  • -
  • - Inner form control should be wrapped with - <ng-container [formGroup]="form"></ng-container> - and <ng-container [formGroupName]="formGroupName"></ng-container> - for appropriate binding to work. -
  • -
-
- - - - - - - Form Generator programmatic submit - - - If you want to trigger form submission outside form generator component, this example shows how to do it. - - - - - - - - Custom errors in Form Generator - - - Form generator supports multiple ways of defining validation error hints: -
    -
  • With validation function, which returns string if field is invalid;
  • -
  • With predefined generic texts
  • -
- If you want to change default validation error messages, you can use addValidationErrorHint method in - FormGeneratorService. This will allow you to override default ones, and add new generic validation - error messages. -
- - - - - - - Form Generator with form field column layout and inline layout - - - This example shows arrangement of form-field based on columnLayout values and - inLineLayout values. - - - - - - - - Form Generator labels without colons - - - By default, form generator labels rendered with colon at the end of the label. To disable this behaviour please - specify appendColon: false in guiOptions object. - - - - - - - - Grouping of the fields - - -

Form generator supports grouping of the fields.

-

To achieve this, developers must pass group object into [formItems] input array.

-
- - - - - - - Custom form field column layout - - -

- Developers can define their own grid layout for the form field the same way as it's done for - Form container. -

-

Below is the example of how to define custom grid layout for the form field component:

-
- - - - - Inline helps - - DynamicFormItem.guiOptions.hint can be either string or HintOptions for more - control over appearance of hint. By default target for hints is auto, meaning that it will be added to - the label on S breakpoint and will be added to the input over S. If gap is not provided, then it will - automatically add gap with size 1 and subtract 1 from - DynamicFormItem.guiOptions.fieldLayoutConfig. If any of the elements have inline help with target - either input or auto, every form item in form generator will have gap size minimum of - 1(more, if requested, by you, via DynamicFormItem.guiOptions.gapLayoutConfig). - - - - - - - - Form Generator with provided default field configuration - - - This code snipped shows an example module which imports Form Generator module and provides default configuration for - the fields. - -@if (defaultConfigExample | async; as defaultConfigExampleString) { - {{ defaultConfigExampleString }} -} - Initial loading - -

- Before form is created or no form items are provided it will automatically show skeleton placeholders while data - is being loaded. -

-

- Please note, that skeleton placeholders only shown before items are loaded for the first time. Every subsequent - loading will be shown with busy indicator. -

-
- - - - - - - Advanced control management - - -

There are several options on how to manage the control visibility in Form Generator:

-
    -
  • - With when function. This function reacts on form value changes and calculates whether the - particular control should be visible or not; -
  • -
  • - With addControl and removeControl methods. The logic of calling these methods - should be implemented by the developers; -
  • -
  • - With custom control that has inner form. This method allows developers to create groups of controls that can - be added or removed on the fly; -
  • -
-

- The difference between addControl/removeControl and control with inner form is that with first - case, control can be placed into any group of Form Generator, where second option will be bound to the control - itself. -

-
- - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/docs/platform/form-generator/platform-form-generator-header/platform-form-generator-header.component.html b/libs/docs/platform/form-generator/platform-form-generator-header/platform-form-generator-header.component.html index 8bc281c9160..f5ccca8f9e0 100644 --- a/libs/docs/platform/form-generator/platform-form-generator-header/platform-form-generator-header.component.html +++ b/libs/docs/platform/form-generator/platform-form-generator-header/platform-form-generator-header.component.html @@ -1,79 +1,79 @@
Form generator
- - Form generator is an utility that helps to generate form with appropriate controls. -

Form generator features

-
    -
  • Support of form layout with multiple responsive columns;
  • -
  • Automatic component rendering without predefined template;
  • -
  • Ability to extend the default set of controls with custom ones;
  • -
  • Dynamic validators for each form item
  • -
  • Dynamic options for choice-based components
  • -
-

Questions in Form Generator can have:

-
    -
  • Individual labels with async function support;
  • -
  • Support for adding a hint for question;
  • -
  • Ability to set available variants for question with async function support;
  • -
  • Transformation function which will transform form item value as defined in function itself;
  • -
  • Standard Angular validators support;
  • -
  • Question-specific validator function with asynchronous functions support;
  • -
  • Rule function that can determine if question should be shown to the user;
  • -
-

- Developers can also set default form field parameters by calling withConfig() method of the - PlatformFormGeneratorModule during it's import. -

-

Form Generator Elements:

-

- The table below shows a list of element types, attributes, and descriptions. All types have a built-in - validator function validators: [Validators.required] but you can choose to write your own - validator functions. -

- - - - - - - - - - @for (prop of Elementtype; track prop) { - - - - - - } - -
TypeAttributeDescription
{{ prop[0] }}{{ prop[1] }}{{ prop[2] }}
-
-

Inline help default global options

-

Inline help has default options as below:

- - - - - - - - - @for (prop of defaultHintOptions; track prop) { - - - - - } - -
Property nameValue
{{ prop[0] }}{{ prop[1] }}
-

- if you want to modify default values globally and not per-field, provide - FDP_FORM_GENERATOR_DEFAULT_HINT_OPTIONS - in your module or component. - -

-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/libs/docs/platform/table/examples/platform-table-initial-state-example.component.html b/libs/docs/platform/table/examples/platform-table-initial-state-example.component.html index 7aff3722abd..1b486616295 100644 --- a/libs/docs/platform/table/examples/platform-table-initial-state-example.component.html +++ b/libs/docs/platform/table/examples/platform-table-initial-state-example.component.html @@ -4,30 +4,27 @@ [initialVisibleColumns]="['updatedOn', 'name', 'price', 'status']" [initialSortBy]="[{ field: 'price.value', direction: sortDirectionEnum.ASC }]" [initialFilterBy]="initialFilterBy" - [initialGroupBy]="[{ field: 'verified', direction: sortDirectionEnum.NONE, showAsColumn: true }]" + [rowNavigatable]="true" + [initialGroupBy]="[ + { + field: 'name', + direction: SortDirection.NONE, + showAsColumn: true + } + ]" + semanticHighlighting="semantic" > - - + - - + - - + - + - - + diff --git a/libs/docs/platform/table/examples/platform-table-initial-state-example.component.ts b/libs/docs/platform/table/examples/platform-table-initial-state-example.component.ts index 70e07906aea..510bab68b13 100644 --- a/libs/docs/platform/table/examples/platform-table-initial-state-example.component.ts +++ b/libs/docs/platform/table/examples/platform-table-initial-state-example.component.ts @@ -2,6 +2,7 @@ import { ChangeDetectionStrategy, Component, ViewEncapsulation } from '@angular/ import { Observable, of } from 'rxjs'; import { FormsModule } from '@angular/forms'; +import { ButtonComponent } from '@fundamental-ngx/core/button'; import { DatetimeAdapter, FdDate, FdDatetimeModule, provideDateTimeFormats } from '@fundamental-ngx/core/datetime'; import { FdpFormGroupModule, PlatformInputModule } from '@fundamental-ngx/platform/form'; import { @@ -44,7 +45,8 @@ import { FdpFormGroupModule, PlatformInputModule, FormsModule, - FdDatetimeModule + FdDatetimeModule, + ButtonComponent ] }) export class PlatformTableInitialStateExampleComponent { @@ -64,13 +66,22 @@ export class PlatformTableInitialStateExampleComponent { readonly sortDirectionEnum = SortDirection; + datetimeAdapter: DatetimeAdapter; + readonly initialFilterBy: CollectionCustomFilter[] = [ - { field: 'price.value', strategy: 'greaterThanOrEqualTo', value: { min: 100 } } + { + field: 'price.value', + strategy: 'greaterThanOrEqualTo', + value: { min: 100 } + } ]; constructor(datetimeAdapter: DatetimeAdapter) { - this.source = new TableDataSource(new TableDataProviderExample(datetimeAdapter)); + this.datetimeAdapter = datetimeAdapter; + this.source = new TableDataSource(new TableDataProviderExample(this.datetimeAdapter, ITEMS)); } + + protected readonly SortDirection = SortDirection; } export interface ExampleItem { @@ -84,6 +95,7 @@ export interface ExampleItem { statusColor?: string; date: FdDate; verified: boolean; + semantic: string; } /** @@ -94,12 +106,15 @@ export class TableDataProviderExample extends TableDataProvider { items: ExampleItem[] = []; totalItems = 0; - constructor(public dateTimeAdapter: DatetimeAdapter) { + constructor( + public dateTimeAdapter: DatetimeAdapter, + public listOfany: any[] + ) { super(); } fetch(tableState?: TableState): Observable { - this.items = [...ITEMS]; + this.items = this.listOfany; // apply searching if (tableState?.searchInput) { @@ -372,7 +387,8 @@ const ITEMS: ExampleItem[] = [ status: 'Stocked on demand', statusColor: 'informative', date: new FdDate(2020, 1, 7), - verified: true + verified: true, + semantic: 'information' }, { name: 'Astro Laptop 1516', @@ -384,7 +400,8 @@ const ITEMS: ExampleItem[] = [ status: 'Out of stock', statusColor: 'negative', date: new FdDate(2020, 2, 5), - verified: true + verified: true, + semantic: 'information' }, { name: 'Astro Phone 6', @@ -396,7 +413,8 @@ const ITEMS: ExampleItem[] = [ status: 'Stocked on demand', statusColor: 'informative', date: new FdDate(2020, 1, 12), - verified: true + verified: true, + semantic: 'information' }, { name: 'Beam Breaker B-1', @@ -408,7 +426,8 @@ const ITEMS: ExampleItem[] = [ status: 'Stocked on demand', statusColor: 'informative', date: new FdDate(2020, 11, 24), - verified: false + verified: false, + semantic: 'information' }, { name: 'Beam Breaker B-2', @@ -419,7 +438,8 @@ const ITEMS: ExampleItem[] = [ }, status: 'No info', date: new FdDate(2020, 10, 23), - verified: true + verified: true, + semantic: 'information' }, { name: 'Benda Laptop 1408', @@ -431,123 +451,7 @@ const ITEMS: ExampleItem[] = [ status: 'Stocked on demand', statusColor: 'informative', date: new FdDate(2020, 9, 22), - verified: true - }, - { - name: 'Bending Screen 21HD', - description: 'nunc nisl duis bibendum', - price: { - value: 66.46, - currency: 'EUR' - }, - status: 'Available', - statusColor: 'positive', - date: new FdDate(2020, 8, 14), - verified: false - }, - { - name: 'Blaster Extreme', - description: 'quisque ut', - price: { - value: 436.88, - currency: 'USD' - }, - status: 'Available', - statusColor: 'positive', - date: new FdDate(2020, 8, 15), - verified: true - }, - { - name: 'Broad Screen 22HD', - description: 'ultrices posuere', - price: { - value: 458.18, - currency: 'CNY' - }, - status: 'Available', - statusColor: 'positive', - date: new FdDate(2020, 5, 4), - verified: true - }, - { - name: 'Camcorder View', - description: 'integer ac leo pellentesque', - price: { - value: 300.52, - currency: 'USD' - }, - status: 'Available', - statusColor: 'positive', - date: new FdDate(2020, 5, 5), - verified: true - }, - { - name: 'Cepat Tablet 10.5', - description: 'rutrum rutrum neque aenean auctor', - price: { - value: 365.12, - currency: 'NZD' - }, - status: 'No info', - date: new FdDate(2020, 5, 6), - verified: true - }, - { - name: 'Ergo Mousepad', - description: 'tortor duis mattis egestas', - price: { - value: 354.46, - currency: 'EUR' - }, - status: 'Stocked on demand', - statusColor: 'informative', - date: new FdDate(2020, 5, 7), - verified: true - }, - { - name: 'Ergo Screen E-I', - description: 'massa quis augue luctus tincidunt', - price: { - value: 387.23, - currency: 'NZD' - }, - status: 'Stocked on demand', - statusColor: 'informative', - date: new FdDate(2020, 3, 23), - verified: true - }, - { - name: 'Ergo Screen E-II', - description: 'orci eget', - price: { - value: 75.86, - currency: 'EUR' - }, - status: 'No info', - date: new FdDate(2020, 3, 20), - verified: false - }, - { - name: 'Gaming Monster', - description: 'cubilia curae', - price: { - value: 152.95, - currency: 'EGP' - }, - status: 'No info', - date: new FdDate(2020, 9, 20), - verified: false - }, - { - name: 'Gaming Monster Pro', - description: 'pharetra magna vestibulum aliquet', - price: { - value: 213.47, - currency: 'MZN' - }, - status: 'Out of stock', - statusColor: 'negative', - date: new FdDate(2020, 4, 17), - verified: false + verified: true, + semantic: 'information' } ];