Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x | import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { FormlyFieldConfig } from '@ngx-formly/core'; import { pick } from 'lodash-es'; import { HttpError } from 'ish-core/models/http-error/http-error.model'; import { B2bUser } from '../../models/b2b-user/b2b-user.model'; @Component({ selector: 'ish-user-profile-form', templateUrl: './user-profile-form.component.html', changeDetection: ChangeDetectionStrategy.Default, }) export class UserProfileFormComponent implements OnInit { @Input({ required: true }) form: FormGroup; @Input() error: HttpError; @Input() user: B2bUser; fields: FormlyFieldConfig[]; model: Partial<B2bUser>; ngOnInit() { this.model = this.getModel(this.user); this.fields = this.getFields(); } private getModel(user: B2bUser) { return this.user ? pick(user, 'title', 'firstName', 'lastName', 'active', 'phoneHome') : { active: true }; } private getFields() { return [ { type: 'ish-fieldset-field', fieldGroup: [ { type: '#title', }, { type: '#firstName', }, { type: '#lastName', }, ], }, { type: 'ish-fieldset-field', fieldGroup: [ !this.user ? { key: 'email', type: 'ish-email-field', props: { label: 'account.user.email.label', required: true, }, } : {}, { type: '#phoneHome', }, { key: 'active', type: 'ish-checkbox-field', props: { label: 'account.user.active.label', title: 'account.user.active.title', }, }, ], }, ]; } } |