refactor: 💡 update onSubmit for add-credential-sources (#1233)
Remove submit action from form component and pass selected credential IDs directly to the submit method
This commit is contained in:
1 parent
9f09f01f36
commit
2cda4f639e
2 files changed
+7
-15
No files matched your search
@@ -1,6 +1,6 @@
|
||||
<Rose::Form
|
||||
class='full-width'
|
||||
@onSubmit={{fn this.submit @submit}}
|
||||
@onSubmit={{fn @submit this.selectedCredentialSourceIDs}}
|
||||
@cancel={{@cancel}}
|
||||
@disabled={{@model.isSaving}}
|
||||
@error={{@model.errors.base}}
|
||||
@@ -26,7 +26,7 @@
|
||||
<form.checkbox
|
||||
@label={{credentialSource.id}}
|
||||
@description={{credentialSource.description}}
|
||||
@onChange={{fn this.toggleCredentialSource credentialSource}}
|
||||
@onChange={{fn this.toggleCredentialSource credentialSource.id}}
|
||||
/>
|
||||
</row.headerCell>
|
||||
<row.cell>{{credentialSource.name}}</row.cell>
|
||||
|
||||
@@ -15,22 +15,14 @@ export default class FormTargetAddCredentialSourcesIndexComponent extends Compon
|
||||
|
||||
/**
|
||||
* Add/Remove credential source to current selection
|
||||
* @param {CredentialLibraryModel, CredentialModel} credentialSource
|
||||
* @param {string} credentialSourceId
|
||||
*/
|
||||
@action
|
||||
toggleCredentialSource(credentialSource) {
|
||||
if (!this.selectedCredentialSourceIDs.includes(credentialSource.id)) {
|
||||
this.selectedCredentialSourceIDs.addObject(credentialSource.id);
|
||||
toggleCredentialSource(credentialSourceId) {
|
||||
if (!this.selectedCredentialSourceIDs.includes(credentialSourceId)) {
|
||||
this.selectedCredentialSourceIDs.addObject(credentialSourceId);
|
||||
} else {
|
||||
this.selectedCredentialSourceIDs.removeObject(credentialSource.id);
|
||||
this.selectedCredentialSourceIDs.removeObject(credentialSourceId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit selected credential source ids
|
||||
*/
|
||||
@action
|
||||
submit(fn) {
|
||||
fn(this.selectedCredentialSourceIDs);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user