// This only has an affect if the value is true.
isReadonly?: boolean;
+ // If this function is defined, the function will be called
+ // at render time to see if the field should be marked readonly.
+ // This supersedes all other isReadonly specifiers.
+ isReadonlyOverride?: (field: string, record: IdlObject) => boolean;
+
// Render the field using this custom template instead of chosing
// from the default set of form inputs.
customTemplate?: CustomFieldTemplate;
let promise = null;
const fieldOptions = this.fieldOptions[field.name] || {};
- field.readOnly = this.mode === 'view'
- || fieldOptions.isReadonly === true
- || this.readonlyFieldsList.includes(field.name);
+ if (this.mode === 'view') {
+ field.readOnly = true;
+
+ } else if (fieldOptions.isReadonlyOverride) {
+ field.readOnly =
+ fieldOptions.isReadonlyOverride(field.name, this.record);
+
+ } else {
+
+ field.readOnly = fieldOptions.isReadonly === true
+ || this.readonlyFieldsList.includes(field.name);
+ }
if (fieldOptions.isRequiredOverride) {
field.isRequired = () => {
<eg-grid-column [sortable]="true" path="create_date"></eg-grid-column>
</eg-grid>
-<eg-fm-record-editor #acpEditDialog idlClass="acp" hiddenFields="call_number,creator,create_date,editor,edit_time,loan_duration,fine_level,dummy_author,dummy_isbn,ref,floating,holdable,circ_as_type,active_date,mint_condition,cost,deleted,deposit,deposit_amount,circulate,status_changed_time,copy_number">
+<eg-fm-record-editor #acpEditDialog idlClass="acp"
+ [fieldOptions]="{status: {isReadonlyOverride: acpEditorReadonly}}"
+ hiddenFields="call_number,creator,create_date,editor,edit_time,loan_duration,fine_level,dummy_author,dummy_isbn,ref,floating,holdable,circ_as_type,active_date,mint_condition,cost,deleted,deposit,deposit_amount,circulate,status_changed_time,copy_number">
</eg-fm-record-editor>
<eg-string #successString text="Updated succeeded!" i18n-text></eg-string>
<eg-string #updateFailedString text="Updated failed!" i18n-text></eg-string>
myTimeForm: FormGroup;
+ acpEditorReadonly: (field: string, record: IdlObject) => boolean;
+
constructor(
private idl: IdlService,
private org: OrgService,
}
} )
});
+
+
+ this.acpEditorReadonly = (field: string, copy: IdlObject): boolean => {
+ return copy.status() === 3; // Lost
+ };
}
sbChannelHandler = msg => {