Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lmb 182 | can modify custom field #455

Draft
wants to merge 21 commits into
base: karel/lmb-809-library-of-fields
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
dfc6c26
lmb-182: add modal with version one form for editing the form
JonasVanHoof Jan 9, 2025
ef8f025
lmb-182: load in the current field values for the edit modal
JonasVanHoof Jan 9, 2025
c811873
lmb-182: make the display type a dropdown
JonasVanHoof Jan 9, 2025
650cdc0
lmb-182: make the dropdown use the full width in the form
JonasVanHoof Jan 9, 2025
2b10b24
lmb-182: the field is updated
JonasVanHoof Jan 9, 2025
15f914b
lmb-182: refresh the form when updating a field
JonasVanHoof Jan 9, 2025
09bf43a
lmb-182: provide the editable form id, this fixes the disappearing fi…
JonasVanHoof Jan 9, 2025
9a3c81e
lmb-182: disable type selector when the field has a library entree
JonasVanHoof Jan 9, 2025
888da8b
lmb-182: add library entree uri to the post call
JonasVanHoof Jan 9, 2025
ef742cc
lmb-182: comment the order field in the edit modal as we do not want …
JonasVanHoof Jan 10, 2025
8f28229
lmb-182: create a component that can be shown and hidden through args…
JonasVanHoof Jan 10, 2025
fdc3edc
lmb-182: add a start form for the modal that shows different buttons …
JonasVanHoof Jan 10, 2025
1b7dd48
lmb-182: show the library entry dropdown
JonasVanHoof Jan 10, 2025
244b9b5
lmb-182: validate input field before saving + reset values when modal…
JonasVanHoof Jan 10, 2025
088bbc5
lmb-182: add the displayType selector to the form
JonasVanHoof Jan 10, 2025
c983eb1
lmb-182: show the crud modal instead of the other form in generate cu…
JonasVanHoof Jan 10, 2025
8e8c7d7
lmb-182: can create and edit a custom field
JonasVanHoof Jan 10, 2025
9fdfbbb
lmb-182: cleanup the custom field wrapper
JonasVanHoof Jan 10, 2025
3f1b671
lmb-182: move the generate custom field component logic to editable f…
JonasVanHoof Jan 10, 2025
de616df
lmb-182: always show the annuleer button
JonasVanHoof Jan 10, 2025
bfd4803
lmb-182: add changing the order to the editable form
JonasVanHoof Jan 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions app/components/custom-form-fields/display-type-selector.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<div ...attributes>
JonasVanHoof marked this conversation as resolved.
Show resolved Hide resolved
{{#unless @inTable}}
<AuLabel @required={{true}} {{did-insert this.load}}>
{{this.label}}
</AuLabel>
{{/unless}}
<PowerSelect
@disabled={{@disabled}}
name={{@variableName}}
@searchField="label"
@searchEnabled={{true}}
@selected={{this.selectedType}}
@options={{this.typeOptions}}
@onChange={{this.updateSelectedType}}
@allowClear={{false}}
@loadingMessage="Aan het laden"
@noMatchesMessage="Geen resultaten gevonden"
as |displayType|
>
<span>
{{displayType.label}}
</span>
</PowerSelect>
</div>
34 changes: 34 additions & 0 deletions app/components/custom-form-fields/display-type-selector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import Component from '@glimmer/component';

import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { service } from '@ember/service';

export default class CustomFormFieldsDisplayTypeSelectorComponent extends Component {
@service store;

@tracked typeOptions = [];

@action
async load() {
this.typeOptions = await this.store.findAll('display-type');
}

@action
async updateSelectedType(type) {
// This event.target is used in the update method of the edit field /custom-field-wrapper-js
this.args.onTypeUpdated({
target: { name: this.args.variableName, value: type.uri },
});
}

get label() {
return this.args.label || 'Type';
}

get selectedType() {
return this.typeOptions.find(
(option) => option.uri === this.args.displayTypeUri
);
}
}
18 changes: 16 additions & 2 deletions app/components/editable-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,23 @@
@customHistoryMessage={{@customHistoryMessage}}
>
{{#if this.editableFormsEnabled}}
<GenerateCustomFieldButton
<AuButton
@skin="link"
@icon="plus"
{{on "click" (fn (mut this.showModal) true)}}
class="au-u-padding-left-none au-u-margin-bottom"
>
Voeg een veld toe
</AuButton>

{{yield}}

<RdfInputFields::CrudCustomFieldModal
@isCreating={{true}}
@showModal={{this.showModal}}
@onCloseModal={{this.onFormUpdate}}
@form={{this.currentForm}}
@onUpdate={{this.onFormUpdate}}
@field={{@field}}
/>
{{/if}}
{{yield}}
Expand Down
10 changes: 10 additions & 0 deletions app/components/editable-form.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Component from '@glimmer/component';

import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { service } from '@ember/service';

import { provide } from 'ember-provide-consume-context';

export default class EditableFormComponent extends Component {
Expand All @@ -12,6 +14,8 @@ export default class EditableFormComponent extends Component {
@service semanticFormRepository;
@service features;

@tracked showModal = false;

constructor() {
super(...arguments);
this.baseFormId = this.args.form.id;
Expand All @@ -27,6 +31,7 @@ export default class EditableFormComponent extends Component {
);
this.currentForm = form;
this.loading = false;
this.showModal = false;
}

get editableFormsEnabled() {
Expand All @@ -38,4 +43,9 @@ export default class EditableFormComponent extends Component {
onFormUpdate() {
this.updateForm();
}

@provide('form-definition')
get formDefinition() {
return this.currentForm;
}
}
91 changes: 0 additions & 91 deletions app/components/generate-custom-field-button.hbs

This file was deleted.

136 changes: 0 additions & 136 deletions app/components/generate-custom-field-button.js

This file was deleted.

Loading