Skip to content

Commit

Permalink
Replace action helper with fn (#683)
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeAstapov authored Oct 15, 2024
1 parent 4ad9df4 commit 84b78de
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Empty file.
12 changes: 6 additions & 6 deletions tests/dummy/app/components/changeset-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
data-test-cid
type='number'
value={{this.changeset.cid}}
oninput={{action (changeset-set this.changeset 'cid') value='target.value'}}
oninput={{fn this.updateAttrOnInput (changeset-set this.changeset 'cid')}}
/>
</div>

Expand All @@ -40,7 +40,7 @@
data-test-user-name
type='text'
value={{get this.changeset 'user.name'}}
oninput={{action (changeset-set this.changeset 'user.name') value='target.value'}}
oninput={{fn this.updateAttrOnInput (changeset-set this.changeset 'user.name')}}
/>
</div>

Expand All @@ -50,7 +50,7 @@
data-test-user-email
type='text'
value={{this.changeset.user.email}}
oninput={{action (changeset-set this.changeset 'user.email') value='target.value'}}
oninput={{fn this.updateAttrOnInput (changeset-set this.changeset 'user.email')}}
/>
</div>

Expand All @@ -60,14 +60,14 @@
data-test-notifications-email
type='checkbox'
checked={{this.changeset.notifications.email}}
onchange={{action (changeset-set this.changeset 'notifications.email') value='target.checked'}}
onchange={{fn this.updateAttrOnChange (changeset-set this.changeset 'notifications.email')}}
/>
<label>Notifications sms</label>
<input
data-test-notifications-sms
type='checkbox'
checked={{this.changeset.notifications.sms}}
onchange={{action (changeset-set this.changeset 'notifications.sms') value='target.checked'}}
onchange={{fn this.updateAttrOnChange (changeset-set this.changeset 'notifications.sms')}}
/>
</div>

Expand All @@ -83,7 +83,7 @@
<input
type='number'
value={{changeset-get this.changeset 'growth'}}
{{on 'input' (action (changeset-set this.changeset 'growth') value='target.value')}}
{{on 'input' (fn this.updateAttrOnInput (changeset-set this.changeset 'growth'))}}
/>
</div>

Expand Down
8 changes: 8 additions & 0 deletions tests/dummy/app/components/changeset-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ export default class ChangesetForm extends Component {
this.changeset = Changeset(this.model, dummyValidator);
}

updateAttrOnInput(changesetSet, event) {
changesetSet(event.target.value);
}

updateAttrOnChange(changesetSet, event) {
changesetSet(event.target.checked);
}

get validateOnRender() {
let cs = Changeset({}, null, { title: validate });
cs.validate();
Expand Down

0 comments on commit 84b78de

Please sign in to comment.