1 <ng-template #dialogContent>
2 <div class="modal-header bg-info">
3 <h4 class="modal-title" i18n>Record Editor: {{recordLabel}}</h4>
4 <button type="button" class="close"
5 i18n-aria-label aria-label="Close"
6 (click)="dismiss('cross_click')">
7 <span aria-hidden="true">×</span>
10 <div class="modal-body">
11 <form #fmEditForm="ngForm" role="form" class="form-validated common-form striped-odd">
12 <div class="form-group row" *ngFor="let field of fields">
13 <div class="col-lg-3 offset-lg-1">
14 <label for="{{idPrefix}}-{{field.name}}">{{field.label}}</label>
16 <div class="col-lg-7">
18 <span *ngIf="field.template">
20 *ngTemplateOutlet="field.template; context:customTemplateFieldContext(field)">
24 <span *ngIf="!field.template">
26 <span *ngIf="field.datatype == 'id' && !pkeyIsEditable">
27 {{record[field.name]()}}
30 <ng-container *ngIf="field.datatype == 'id' && pkeyIsEditable">
31 <ng-container *ngIf="field.readOnly">
32 <span>{{record[field.name]()}}</span>
34 <ng-container *ngIf="!field.readOnly">
38 id="{{idPrefix}}-{{field.name}}"
39 placeholder="{{field.label}}..."
41 [required]="field.isRequired()"
42 [ngModel]="record[field.name]()"
43 (ngModelChange)="record[field.name]($event)"/>
48 *ngIf="field.datatype == 'text' || field.datatype == 'interval'">
49 <ng-container *ngIf="field.readOnly">
50 <span>{{record[field.name]()}}</span>
52 <ng-container *ngIf="!field.readOnly">
56 id="{{idPrefix}}-{{field.name}}"
57 placeholder="{{field.label}}..."
59 [required]="field.isRequired()"
60 [ngModel]="record[field.name]()"
61 (ngModelChange)="record[field.name]($event)"/>
65 <!-- TODO: add support to eg-date-select for read-only view -->
66 <span *ngIf="field.datatype == 'timestamp'">
68 domId="{{idPrefix}}-{{field.name}}"
69 (onChangeAsIso)="record[field.name]($event)"
70 initialIso="{{record[field.name]()}}">
74 <ng-container *ngIf="field.datatype == 'int'">
75 <ng-container *ngIf="field.readOnly">
76 <span>{{record[field.name]()}}</span>
78 <ng-container *ngIf="!field.readOnly">
84 id="{{idPrefix}}-{{field.name}}"
85 placeholder="{{field.label}}..."
87 [required]="field.isRequired()"
88 [ngModel]="record[field.name]()"
89 (ngModelChange)="record[field.name]($event)"/>
93 <ng-container *ngIf="field.datatype == 'float'">
94 <ng-container *ngIf="field.readOnly">
95 <span>{{record[field.name]()}}</span>
97 <ng-container *ngIf="!field.readOnly">
100 type="number" step="0.1"
101 name="{{field.name}}"
102 id="{{idPrefix}}-{{field.name}}"
103 placeholder="{{field.label}}..."
105 [required]="field.isRequired()"
106 [ngModel]="record[field.name]()"
107 (ngModelChange)="record[field.name]($event)"/>
111 <ng-container *ngIf="field.datatype == 'money'">
112 <ng-container *ngIf="field.readOnly">
113 <span>{{record[field.name]() | currency}}</span>
115 <ng-container *ngIf="!field.readOnly">
118 type="number" step="0.1"
119 name="{{field.name}}"
120 id="{{idPrefix}}-{{field.name}}"
121 placeholder="{{field.label}}..."
123 [readonly]="field.readOnly"
124 [required]="field.isRequired()"
125 [ngModel]="record[field.name]()"
126 (ngModelChange)="record[field.name]($event)"/>
130 <input *ngIf="field.datatype == 'bool'"
131 class="form-check-input"
133 name="{{field.name}}"
134 id="{{idPrefix}}-{{field.name}}"
135 [disabled]="field.readOnly"
136 [ngModel]="record[field.name]()"
137 (ngModelChange)="record[field.name]($event)"/>
139 <ng-container *ngIf="field.datatype == 'link'">
140 <ng-container *ngIf="field.readOnly">
141 <!-- in readOnly mode, if a value is present, it will
142 live as the only item in the linkedValues array -->
143 <ng-container *ngIf="(field.linkedValues != null) && (field.linkedValues.length)">
144 <span>{{field.linkedValues[0].name}}</span>
147 <ng-container *ngIf="!field.readOnly">
148 <span [ngClass]="{nullable : !field.isRequired()}">
151 name="{{field.name}}"
152 id="{{idPrefix}}-{{field.name}}"
153 [required]="field.isRequired()"
154 [ngModel]="record[field.name]()"
155 (ngModelChange)="record[field.name]($event)">
156 <option *ngFor="let item of field.linkedValues"
157 [value]="item.id">{{item.name}}</option>
163 <eg-org-select *ngIf="field.datatype == 'org_unit'"
164 placeholder="{{field.label}}..."
166 domId="{{idPrefix}}-{{field.name}}"
167 [limitPerms]="modePerms[mode]"
168 [readOnly]="field.readOnly"
169 [applyDefault]="field.orgDefaultAllowed"
170 [initialOrgId]="record[field.name]()"
171 (onChange)="record[field.name]($event)">
179 <div class="modal-footer">
180 <button type="button" class="btn btn-success" *ngIf="mode == 'view'"
181 (click)="close()" i18n>Close</button>
182 <button type="button" class="btn btn-info"
183 [disabled]="fmEditForm.invalid" *ngIf="mode != 'view'"
184 (click)="save()" i18n>Save</button>
185 <button type="button" class="btn btn-warning ml-2" *ngIf="mode != 'view'"
186 (click)="cancel()" i18n>Cancel</button>