From 8136acc4bad5319d401ce528a546430d938e87e7 Mon Sep 17 00:00:00 2001 From: Falk Neumann Date: Mon, 10 Jan 2022 16:32:51 +0100 Subject: [PATCH] fix(emeisOptions): include model in custom button callback (#377) --- README.md | 4 ++-- addon/components/edit-form.hbs | 2 +- addon/components/edit-form.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 20ae086a..9a918ceb 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ export default class EmeisOptionsService extends Service { // show only a subset of the main navigation entries navigationEntries = ["users", "scopes"]; - // On each model edit view (e.g. users) you can define a list of custom buttons. Each button needs a label and a callback function. Optionally you can highlight the button with the 'type' attribute. + // On each model edit view (e.g. users) you can define a list of custom buttons. Each button needs a label and a callback function. The callback function gets the current active model as first argument. Optionally you can highlight the button with the 'type' attribute. customButtons = { users: [ { @@ -98,7 +98,7 @@ export default class EmeisOptionsService extends Service { }, { label: "A second Button", - callback: () => window.alert("test"), + callback: (model) => console.log(model), } ] }; diff --git a/addon/components/edit-form.hbs b/addon/components/edit-form.hbs index 3f9d338c..2a6e4e5c 100644 --- a/addon/components/edit-form.hbs +++ b/addon/components/edit-form.hbs @@ -12,7 +12,7 @@ @type="button" @label={{optional-translate button.label}} class="uk-margin-right {{if button.type (concat 'uk-button-' button.type) ''}}" - {{on "click" (fn this.customAction button)}} + {{on "click" (fn this.customAction button @model)}} data-test-custom-button /> {{/each}} diff --git a/addon/components/edit-form.js b/addon/components/edit-form.js index 046091e7..2383726b 100644 --- a/addon/components/edit-form.js +++ b/addon/components/edit-form.js @@ -49,13 +49,13 @@ export default class EditFormComponent extends Component { } @action - customAction(button) { + customAction(button, model) { if (typeof button.callback !== "function") { this.notification.danger( this.intl.t("emeis.form.custom-button-action-error") ); } - button.callback(); + button.callback(model); } @task