Skip to content

Commit

Permalink
feat(core): allow hiding of fields through config (#2668)
Browse files Browse the repository at this point in the history
while still including the angular form field for default values etc.

see #2635
  • Loading branch information
sleidig authored Nov 21, 2024
1 parent 0f4846c commit 961a9de
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<div
*ngIf="_field && form && _field.editComponent; else displayComponent"
class="flex-row"
[ngClass]="{ hidden: _field?.hideFromForm }"
>
<div class="flex-grow">
<ng-container
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.hidden {
display: none;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
EntityFormService,
} from "../entity-form/entity-form.service";
import { ColumnConfig, FormFieldConfig } from "../entity-form/FormConfig";
import { NgIf } from "@angular/common";
import { NgClass, NgIf } from "@angular/common";
import { EntityFieldViewComponent } from "../entity-field-view/entity-field-view.component";
import { InheritedValueButtonComponent } from "../../default-values/inherited-value-button/inherited-value-button.component";

Expand All @@ -30,6 +30,7 @@ import { InheritedValueButtonComponent } from "../../default-values/inherited-va
NgIf,
EntityFieldViewComponent,
InheritedValueButtonComponent,
NgClass,
],
})
export class EntityFieldEditComponent<T extends Entity = Entity>
Expand Down
4 changes: 4 additions & 0 deletions src/app/core/common-components/entity-form/FormConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ export interface FormFieldConfig extends EntitySchemaField {

/**
* If true, the field will only be shown in tables and excluded from forms and popups.
* You can also use this to include a hidden form in a Public Form.
*
* The form field is still generated but hidden in the UI,
* so default values can be applied to such hidden fields.
*/
hideFromForm?: boolean;

Expand Down
2 changes: 1 addition & 1 deletion src/app/core/form-dialog/form-dialog.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class FormDialogService {
const columns: FormFieldConfig[] = this.inferFormFieldColumns(
columnsOverall,
entity,
).filter((col) => !col.hideFromForm);
);

const columnsToDisplay = columns
.filter((col) => col.editComponent)
Expand Down

0 comments on commit 961a9de

Please sign in to comment.