-
Notifications
You must be signed in to change notification settings - Fork 647
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
Have KModal pass through their 'submit' and 'cancel' events to simplify other modals #5439
Changes from all commits
ec04c7f
c89e7b6
0e7dd79
97492de
c81dbf3
589b2ce
444af6e
46f5354
78bb8ed
6c9dd77
d395ac6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,8 @@ | |
:submitText="$tr('save')" | ||
:cancelText="$tr('cancel')" | ||
:submitDisabled="submitting" | ||
@cancel="$emit('cancel')" | ||
@submit="callCreateGroup" | ||
@cancel="close" | ||
> | ||
<KTextbox | ||
ref="name" | ||
|
@@ -82,21 +82,18 @@ | |
}, | ||
}, | ||
methods: { | ||
...mapActions('groups', ['displayModal', 'createGroup']), | ||
...mapActions('groups', ['createGroup']), | ||
callCreateGroup() { | ||
this.formSubmitted = true; | ||
if (this.formIsValid) { | ||
this.submitting = true; | ||
this.createGroup({ groupName: this.name, classId: this.classId }).then(() => { | ||
this.$emit('success'); | ||
this.$emit('submit'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. won't this emit submit twice? Once for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CreateGroupModal only emits 'submit' once. I think if you explicitly set a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interestingly, though, if you remove this I'm just going to remove the In the future, I would like to to remove async behavior API calls from modals, and delegate them to the parents of modals. So modals just synchronously emit events and data, basically. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah that seems reasonable. another alternative is for modals that handle their own internal async code, to explicitly emit an event that's not .then(() => this.$emit('finished')) |
||
}); | ||
} else { | ||
this.$refs.name.focus(); | ||
} | ||
}, | ||
close() { | ||
this.displayModal(false); | ||
}, | ||
}, | ||
$trs: { | ||
newLearnerGroup: 'Create new group', | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it necessary to emit anything here? I think the
v-on
will do this for you?