Skip to content

Commit

Permalink
fix(emeisOptions): include model in custom button callback (#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabauke authored Jan 10, 2022
1 parent e6565b3 commit 8136acc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand All @@ -98,7 +98,7 @@ export default class EmeisOptionsService extends Service {
},
{
label: "A second Button",
callback: () => window.alert("test"),
callback: (model) => console.log(model),
}
]
};
Expand Down
2 changes: 1 addition & 1 deletion addon/components/edit-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
4 changes: 2 additions & 2 deletions addon/components/edit-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8136acc

Please sign in to comment.