ichec-angular-core 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _angular_forms from '@angular/forms';
2
- import { FormGroup, FormControl } from '@angular/forms';
2
+ import { FormGroup, FormArray, FormControl, FormBuilder } from '@angular/forms';
3
3
  import * as rxjs from 'rxjs';
4
4
  import { Observable, BehaviorSubject } from 'rxjs';
5
5
  import { HttpClient, HttpErrorResponse } from '@angular/common/http';
@@ -38,11 +38,11 @@ declare class Permission {
38
38
  static typename: string;
39
39
  static plural: string;
40
40
  }
41
- interface IForm<C, D> {
41
+ interface IForm<C, D, U = D> {
42
42
  form: FormGroup;
43
43
  setValue(item: D): void;
44
44
  createItem(): C;
45
- updateItem(item: D): D;
45
+ updateItem(item: D): U;
46
46
  }
47
47
 
48
48
  interface IPortalMemberBase {
@@ -56,7 +56,7 @@ type IPortalMemberCreate = IPortalMemberBase;
56
56
  interface IPortalMemberList extends IPortalMemberBase, Identifiable {
57
57
  organization: string;
58
58
  profile_url: string;
59
- all_permissions: string[];
59
+ permissions: string[];
60
60
  }
61
61
  type IPortalMemberDetail = IPortalMemberList;
62
62
  declare class PortalMember {
@@ -169,6 +169,56 @@ interface IRestOptions {
169
169
  actions?: Record<string, Record<string, OptionAction>>;
170
170
  }
171
171
 
172
+ interface TypeChoice {
173
+ value: string;
174
+ display_name: string;
175
+ }
176
+ declare const FORM_FIELD_CHOICES: TypeChoice[];
177
+ interface IFormFieldBase {
178
+ label: string;
179
+ required: boolean;
180
+ order: number;
181
+ field_type: string;
182
+ description: string;
183
+ default: string;
184
+ template: null;
185
+ options: {
186
+ key: string;
187
+ value: string;
188
+ }[] | null;
189
+ }
190
+ type IFormFieldCreate = IFormFieldBase;
191
+ interface IFormFieldDetail extends IFormFieldBase {
192
+ id: number;
193
+ }
194
+ interface IFormGroupBase {
195
+ label: string | null;
196
+ description: string | null;
197
+ order: number;
198
+ }
199
+ interface IFormGroupCreate extends IFormGroupBase {
200
+ fields: IFormFieldCreate[];
201
+ }
202
+ interface IFormGroupDetail extends IFormGroupBase {
203
+ id: number;
204
+ fields: IFormFieldDetail[];
205
+ }
206
+ interface IFormGroupUpdate extends IFormGroupBase {
207
+ id: number;
208
+ fields: IFormFieldBase[];
209
+ }
210
+ interface IFormCreate {
211
+ groups: IFormGroupCreate[];
212
+ }
213
+ interface IFormDetail {
214
+ id: number;
215
+ groups: IFormGroupDetail[];
216
+ }
217
+ interface IFormUpdate {
218
+ id: number;
219
+ groups: IFormGroupBase[];
220
+ }
221
+
172
222
  interface LeftNavOption {
173
223
  name: string;
174
224
  route: string;
@@ -179,7 +229,7 @@ interface LeftNavCategory {
179
229
  }
180
230
 
181
231
  declare const ENDPOINT_URL: InjectionToken<string>;
182
- declare class RestService<D extends Identifiable, L extends Identifiable = D, C = D> {
232
+ declare class RestService<D extends Identifiable, L extends Identifiable = D, C = D, U extends Identifiable = D> {
183
233
  readonly _url: string;
184
234
  protected _endpoint_url: string;
185
235
  protected _http: HttpClient;
@@ -190,10 +240,10 @@ declare class RestService<D extends Identifiable, L extends Identifiable = D, C
190
240
  getUrl(url: string): Observable<D>;
191
241
  getPaginatedUrl(url: string): Observable<IPaginated<L>>;
192
242
  getOptions(): Observable<IRestOptions>;
193
- putItem(item: D, content_type?: string): Observable<D>;
243
+ putItem(item: U, content_type?: string): Observable<D>;
194
244
  patchItemMedia(id: number, form: FormData): Observable<D>;
195
245
  postFile(id: number, field: string, file: File): Observable<D>;
196
- patchItem(item: D, include_keys: string[], exclude_keys: string[]): Observable<D>;
246
+ patchItem(item: U, include_keys: string[], exclude_keys: string[]): Observable<D>;
197
247
  postItem(item: C): Observable<D>;
198
248
  private getHeaders;
199
249
  private getBaseUrl;
@@ -201,7 +251,7 @@ declare class RestService<D extends Identifiable, L extends Identifiable = D, C
201
251
  handleError(error: HttpErrorResponse): Observable<never>;
202
252
  }
203
253
 
204
- declare class ItemService<D extends Identifiable, L extends Identifiable = D, C = D> extends RestService<D, L, C> {
254
+ declare class ItemService<D extends Identifiable, L extends Identifiable = D, C = D, U extends Identifiable = D> extends RestService<D, L, C, U> {
205
255
  typenamePlural: string;
206
256
  typename: string;
207
257
  canEdit(): boolean;
@@ -275,6 +325,12 @@ declare class OrganizationService extends ItemWithUserService<IOrganizationDetai
275
325
  static ɵprov: _angular_core.ɵɵInjectableDeclaration<OrganizationService>;
276
326
  }
277
327
 
328
+ declare class FormService {
329
+ toFormGroup(form: IFormDetail): FormGroup<any>;
330
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormService, never>;
331
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<FormService>;
332
+ }
333
+
278
334
  interface NavOption {
279
335
  name: string;
280
336
  route: string;
@@ -371,16 +427,16 @@ declare abstract class DetailView<D extends Identifiable, L extends Identifiable
371
427
  protected canDelete(): boolean;
372
428
  }
373
429
 
374
- declare abstract class EditView<D extends Identifiable, L extends Identifiable, C = D> {
430
+ declare abstract class EditView<D extends Identifiable, L extends Identifiable, C = D, U extends Identifiable = D> {
375
431
  createMode: _angular_core.WritableSignal<boolean>;
376
432
  heading: _angular_core.Signal<string>;
377
433
  protected item: _angular_core.WritableSignal<D | null>;
378
434
  protected _route: ActivatedRoute;
379
435
  protected _location: Location;
380
436
  protected _userService: UserService;
381
- protected form: IForm<C, D>;
382
- protected itemService: ItemService<D, L, C>;
383
- constructor(itemService: ItemService<D, L, C>, form: IForm<C, D>);
437
+ protected form: IForm<C, D, U>;
438
+ protected itemService: ItemService<D, L, C, U>;
439
+ constructor(itemService: ItemService<D, L, C, U>, form: IForm<C, D, U>);
384
440
  onInit(): void;
385
441
  onItemAvailable(item: D): void;
386
442
  onItemAndUserAvailable(_item: D, _user: IPortalMemberDetail): void;
@@ -393,7 +449,7 @@ declare abstract class EditView<D extends Identifiable, L extends Identifiable,
393
449
  protected onUploadedFileReady(_file: File): void;
394
450
  protected onFileRead(_content: string | ArrayBuffer): void;
395
451
  protected createItem(): C;
396
- protected updateItem(item: D): D;
452
+ protected updateItem(item: D): U;
397
453
  protected postItem(): void;
398
454
  protected putItem(item: D): void;
399
455
  protected saveFiles(item: D): void;
@@ -404,6 +460,114 @@ declare abstract class EditView<D extends Identifiable, L extends Identifiable,
404
460
  protected onPostActions(_actions: Record<string, OptionAction>): void;
405
461
  }
406
462
 
463
+ declare class FormFieldDetailComponent {
464
+ readonly field: _angular_core.InputSignal<IFormFieldDetail>;
465
+ readonly form: _angular_core.InputSignal<FormGroup<any>>;
466
+ get isValid(): boolean;
467
+ get key(): string;
468
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormFieldDetailComponent, never>;
469
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<FormFieldDetailComponent, "lib-form-field-detail", never, { "field": { "alias": "field"; "required": true; "isSignal": true; }; "form": { "alias": "form"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
470
+ }
471
+
472
+ declare class FormFieldListComponent {
473
+ form: _angular_core.InputSignal<FormArray<any>>;
474
+ edit: _angular_core.OutputEmitterRef<number>;
475
+ columns: ichec_angular_core.TableColumn[];
476
+ columnNames: _angular_core.Signal<string[]>;
477
+ onEdit(id: number): void;
478
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormFieldListComponent, never>;
479
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<FormFieldListComponent, "lib-form-field-list", never, { "form": { "alias": "form"; "required": true; "isSignal": true; }; }, { "edit": "edit"; }, never, never, true, never>;
480
+ }
481
+
482
+ declare class FormFieldEditComponent {
483
+ availableTypes: ichec_angular_core.TypeChoice[];
484
+ form: _angular_core.InputSignal<FormGroup<any>>;
485
+ editMode: _angular_core.InputSignal<boolean>;
486
+ submitted: _angular_core.OutputEmitterRef<void>;
487
+ cancelled: _angular_core.OutputEmitterRef<void>;
488
+ get isBoolean(): boolean;
489
+ get isShortText(): boolean;
490
+ get isLongText(): boolean;
491
+ get isRichText(): boolean;
492
+ get isSelection(): boolean;
493
+ get isInteger(): boolean;
494
+ get isFile(): boolean;
495
+ get fieldType(): string;
496
+ submit(): void;
497
+ cancel(): void;
498
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormFieldEditComponent, never>;
499
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<FormFieldEditComponent, "lib-form-field-edit", never, { "form": { "alias": "form"; "required": true; "isSignal": true; }; "editMode": { "alias": "editMode"; "required": false; "isSignal": true; }; }, { "submitted": "submitted"; "cancelled": "cancelled"; }, never, never, true, never>;
500
+ }
501
+
502
+ declare class DynamicFormComponent {
503
+ private readonly formService;
504
+ readonly inputForm: _angular_core.InputSignal<IFormDetail>;
505
+ readonly form: _angular_core.Signal<FormGroup<any>>;
506
+ payLoad: string;
507
+ onSubmit(): void;
508
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<DynamicFormComponent, never>;
509
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<DynamicFormComponent, "lib-dynamic-form", never, { "inputForm": { "alias": "inputForm"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
510
+ }
511
+
512
+ interface IFormFieldForm {
513
+ label: FormControl<string | null>;
514
+ required: FormControl<boolean | null>;
515
+ description: FormControl<string | null>;
516
+ template: FormControl<null>;
517
+ options: FormControl<string | null>;
518
+ default: FormControl<string | null>;
519
+ field_type: FormControl<string | null>;
520
+ order: FormControl<number | null>;
521
+ id: FormControl<number | null>;
522
+ }
523
+
524
+ interface IFormGroupForm {
525
+ label: FormControl<string | null>;
526
+ description: FormControl<string | null>;
527
+ order: FormControl<number | null>;
528
+ id: FormControl<number | null>;
529
+ fields: FormArray<FormGroup<IFormFieldForm>>;
530
+ }
531
+
532
+ interface IDynamicFormForm {
533
+ groups: FormArray<FormGroup<IFormGroupForm>>;
534
+ }
535
+ declare class DynamicFormForm {
536
+ fb: FormBuilder;
537
+ form: FormGroup;
538
+ constructor();
539
+ get groups(): FormArray<FormGroup<IFormGroupForm>>;
540
+ createGroup(group: FormGroup<IFormGroupForm>): void;
541
+ deleteGroup(id: number): void;
542
+ reset(): void;
543
+ setValue(item: IFormCreate | IFormDetail): void;
544
+ createItem(): IFormCreate;
545
+ createOrUpdateGroup(form: FormGroup<IFormGroupForm>, items: IFormGroupBase[]): IFormGroupCreate | IFormGroupUpdate;
546
+ updateItem(item: IFormDetail): IFormCreate | IFormUpdate;
547
+ }
548
+
549
+ declare class DynamicFormBuilderComponent {
550
+ form: _angular_core.InputSignal<DynamicFormForm>;
551
+ handleSubmit: _angular_core.InputSignal<boolean>;
552
+ submitted: _angular_core.OutputEmitterRef<void>;
553
+ editingField: _angular_core.WritableSignal<number>;
554
+ creatingField: _angular_core.WritableSignal<boolean>;
555
+ editingGroup: _angular_core.WritableSignal<number>;
556
+ creatingGroup: _angular_core.WritableSignal<boolean>;
557
+ dirty: _angular_core.WritableSignal<boolean>;
558
+ formBuilder: FormBuilder;
559
+ groupForm: FormGroup | null;
560
+ addGroup(): void;
561
+ editGroup(id: number): void;
562
+ deleteGroup(id: number): void;
563
+ submitGroup(): void;
564
+ cancel(): void;
565
+ reset(): void;
566
+ onSubmit(): void;
567
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<DynamicFormBuilderComponent, never>;
568
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<DynamicFormBuilderComponent, "lib-dynamic-form-builder", never, { "form": { "alias": "form"; "required": true; "isSignal": true; }; "handleSubmit": { "alias": "handleSubmit"; "required": false; "isSignal": true; }; }, { "submitted": "submitted"; }, never, never, true, never>;
569
+ }
570
+
407
571
  declare class ListDataSource<D extends Identifiable, L extends Identifiable, C = D> extends DataSource<L> {
408
572
  length: _angular_core.WritableSignal<number>;
409
573
  loading: _angular_core.WritableSignal<boolean>;
@@ -485,7 +649,7 @@ declare class SelectionManager {
485
649
 
486
650
  declare class ListViewComponent<D extends Identifiable, L extends Identifiable, C = D> implements OnInit, AfterViewInit {
487
651
  viewType: _angular_core.InputSignal<string>;
488
- itemService: _angular_core.InputSignal<ItemService<D, L, C> | undefined>;
652
+ itemService: _angular_core.InputSignal<ItemService<D, L, C, D> | undefined>;
489
653
  itemDetailTemplate: _angular_core.InputSignal<TemplateRef<unknown> | null>;
490
654
  columns: _angular_core.InputSignal<TableColumn[]>;
491
655
  sortFields: _angular_core.InputSignal<string[]>;
@@ -590,6 +754,7 @@ declare class FileUploadComponent {
590
754
  declare class UserDetailComponent extends DetailView<IPortalMemberDetail, IPortalMemberList, IPortalMemberCreate> implements OnInit {
591
755
  constructor();
592
756
  ngOnInit(): void;
757
+ protected canEdit(): boolean;
593
758
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<UserDetailComponent, never>;
594
759
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<UserDetailComponent, "lib-user-detail", never, {}, {}, never, never, true, never>;
595
760
  }
@@ -674,6 +839,7 @@ declare class OrganizationDetailComponent extends DetailView<IOrganizationDetail
674
839
 
675
840
  declare class OrganizationEditComponent extends EditView<IOrganizationDetail, IOrganizationList, IOrganizationCreate> implements OnInit {
676
841
  countryOptions: _angular_core.WritableSignal<ICountry[]>;
842
+ addressService: AddressService;
677
843
  selectionManager: SelectionManager;
678
844
  constructor();
679
845
  ngOnInit(): void;
@@ -687,5 +853,5 @@ declare class OrganizationEditComponent extends EditView<IOrganizationDetail, IO
687
853
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<OrganizationEditComponent, "lib-organization-edit", never, {}, {}, never, never, true, never>;
688
854
  }
689
855
 
690
- export { Address, AddressDetailComponent, AddressEditComponent, AddressForm, AddressService, ApiError, AvatarComponent, BackButtonComponent, DetailHeaderComponent, DetailView, ENDPOINT_URL, EditView, ErrorCode, FeedbackComponent, FileRecord, FileUploadComponent, Group, GroupComponent, GroupDetailComponent, GroupService, ItemQuery, ItemService, ItemWithUserService, LOGIN_USER, LandingComponent, LeftNavComponent, LeftNavService, ListTableViewComponent, ListViewComponent, MockItemService, Organization, OrganizationComponent, OrganizationDetailComponent, OrganizationEditComponent, OrganizationService, Paginated, Permission, PortalMember, ResolvedPermission, RestService, SearchBarComponent, SelectTableComponent, SelectionManager, TopBarComponent, UserComponent, UserDetailComponent, UserEditComponent, UserService };
691
- export type { IAddressBase, IAddressCreate, IAddressDetail, IAddressList, ICountry, IFileRecord, IFileUpload, IForm, IGroupBase, IGroupCreate, IGroupDetail, IGroupList, IItemQuery, IOrganizationBase, IOrganizationCreate, IOrganizationDetail, IOrganizationList, IPaginated, IPermission, IPortalMemberBase, IPortalMemberCreate, IPortalMemberDetail, IPortalMemberList, IPreview, IRestOptions, Identifiable, LeftNavCategory, LeftNavOption, NavGroup, NavOption, OptionAction, OptionActionChoice, Selectable, TableColumn };
856
+ export { Address, AddressDetailComponent, AddressEditComponent, AddressForm, AddressService, ApiError, AvatarComponent, BackButtonComponent, DetailHeaderComponent, DetailView, DynamicFormBuilderComponent, DynamicFormComponent, DynamicFormForm, ENDPOINT_URL, EditView, ErrorCode, FORM_FIELD_CHOICES, FeedbackComponent, FileRecord, FileUploadComponent, FormFieldDetailComponent, FormFieldEditComponent, FormFieldListComponent, FormService, Group, GroupComponent, GroupDetailComponent, GroupService, ItemQuery, ItemService, ItemWithUserService, LOGIN_USER, LandingComponent, LeftNavComponent, LeftNavService, ListTableViewComponent, ListViewComponent, MockItemService, Organization, OrganizationComponent, OrganizationDetailComponent, OrganizationEditComponent, OrganizationService, Paginated, Permission, PortalMember, ResolvedPermission, RestService, SearchBarComponent, SelectTableComponent, SelectionManager, TopBarComponent, UserComponent, UserDetailComponent, UserEditComponent, UserService };
857
+ export type { IAddressBase, IAddressCreate, IAddressDetail, IAddressList, ICountry, IDynamicFormForm, IFileRecord, IFileUpload, IForm, IFormCreate, IFormDetail, IFormFieldBase, IFormFieldCreate, IFormFieldDetail, IFormGroupBase, IFormGroupCreate, IFormGroupDetail, IFormGroupUpdate, IFormUpdate, IGroupBase, IGroupCreate, IGroupDetail, IGroupList, IItemQuery, IOrganizationBase, IOrganizationCreate, IOrganizationDetail, IOrganizationList, IPaginated, IPermission, IPortalMemberBase, IPortalMemberCreate, IPortalMemberDetail, IPortalMemberList, IPreview, IRestOptions, Identifiable, LeftNavCategory, LeftNavOption, NavGroup, NavOption, OptionAction, OptionActionChoice, Selectable, TableColumn, TypeChoice };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ichec-angular-core",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^20.1.1",
6
6
  "@angular/core": "^20.1.1"