Skip to content

Commit

Permalink
added more demo cases
Browse files Browse the repository at this point in the history
  • Loading branch information
heinerwalter committed Jun 3, 2024
1 parent 5bdee13 commit 38d90a5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,15 @@ <h4>Groups</h4>
</pe-array-form-group>
</demo-input-demo-wrapper>

<demo-input-demo-wrapper [value]="values.arrayInitiallyEmpty">
<pe-array-form-group label="Initially empty array with custom input elements (text input)"
infoIconTooltip='Component: <pe-array-form-group> + <pe-text-input>'
[(value)]="values.arrayInitiallyEmpty"
[itemTemplate]="arrayFormGroupTemplate"
(valueChange)="onInputValueChange('initially empty array', $event)">
</pe-array-form-group>
</demo-input-demo-wrapper>

<ng-template #arrayFormGroupTemplate let-value="value" let-onValueChange="onValueChange" let-index="index">
<pe-text-input [value]="value"
(valueChange)="onValueChange($event)">
Expand Down Expand Up @@ -271,6 +280,16 @@ <h4>Groups</h4>
</pe-array-form-group>
</demo-input-demo-wrapper>

<demo-input-demo-wrapper [value]="values.arrayWithInputGroupInitiallyEmpty">
<pe-array-form-group label="Initially empty array with input group"
infoIconTooltip='Components: <pe-array-form-group> + <pe-input-group>'
[(value)]="values.arrayWithInputGroupInitiallyEmpty"
[itemTemplate]="arrayFormGroupWithInputGroupTemplate"
[newItemFunction]="arrayWithInputGroupNewItemFunction"
(valueChange)="onInputValueChange('initially empty array with input group', $event)">
</pe-array-form-group>
</demo-input-demo-wrapper>

<ng-template #arrayFormGroupWithInputGroupTemplate let-value="value" let-onValueChange="onValueChange"
let-index="index">
<pe-input-group orientation="horizontal">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,17 @@ export class AllInputsDemoComponent {
rating: 0 as number | undefined,
ratingCustom: 0 as number | undefined,
array: ['Line 1', 'Line 2', 'Not line 3'] as any[],
arrayInitiallyEmpty: undefined as unknown as any[],
arrayWithInputGroup: [{ name: 'Max', number: 5 }, { name: 'Moritz', number: 3, country: 'Germany' }] as {
name: string | undefined,
number: number | undefined,
country: string | undefined,
}[],
arrayWithInputGroupInitiallyEmpty: undefined as unknown as {
name: string | undefined,
number: number | undefined,
country: string | undefined,
}[],
inputGroup: {
street: undefined as string | undefined,
number: undefined as number | undefined,
Expand Down
12 changes: 11 additions & 1 deletion projects/demo/src/app/model/contact.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PropertiesConfiguration, PropertyConfiguration } from 'ngx-property-editor';
import { PropertiesConfiguration, PropertyConfiguration, PropertyEditorMode } from 'ngx-property-editor';
import { Address } from './address';

type FriendType = {
Expand Down Expand Up @@ -170,6 +170,16 @@ export class Contact {
isArray: true,
newArrayItemFunction: () => ({ name: undefined, type: undefined }),
editable: true,
hideIfEmpty: true,
hidden: (data: Contact, mode: PropertyEditorMode) => {
switch (mode) {
case 'view':
case 'edit':
return false;
case 'table':
return true;
}
},
group: [[
new PropertyConfiguration({
propertyName: 'name',
Expand Down

0 comments on commit 38d90a5

Please sign in to comment.