Skip to content

Commit b69c295

Browse files
committed
1 parent 313c477 commit b69c295

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

resources/js/commands/CommandManager.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ export class CommandManager {
143143
await this.reopenCurrentCommand();
144144
return;
145145
}
146+
this.state.currentCommandEndpoints.onSuccess?.();
146147
this.finish();
147148
return;
148149
}
@@ -152,6 +153,9 @@ export class CommandManager {
152153
if(data.action !== 'step') {
153154
// close form modal
154155
this.state.currentCommandForm = null;
156+
if(!this.state.currentCommandShouldReopen) {
157+
this.state.currentCommandEndpoints.onSuccess?.();
158+
}
155159
}
156160

157161
await this.handleCommandResponse(data);

resources/js/commands/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ export type CommandEndpoints = {
2222
postCommand: string
2323
getForm: string
2424
query?: object
25+
/**
26+
* Called after the form is submitted and a successful response is received with some exceptions:
27+
* - if reopen has been clicked, it is not called
28+
* - if the response is a wizard step, it is not called
29+
*/
30+
onSuccess?: () => void
2531

2632
entityKey: string
2733
instanceId?: string | number

resources/js/entity-list/components/EntityList.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,10 @@
223223
.map(([instanceId, selected]) => instanceId),
224224
},
225225
entityKey,
226+
onSuccess() {
227+
selectedItems.value = null;
228+
},
226229
});
227-
228-
selectedItems.value = null;
229230
}
230231
231232
async function onDelete(instanceId: InstanceId) {

0 commit comments

Comments
 (0)