| 1 |
import { ConfirmationDialog } from "@web/core/confirmation_dialog/confirmation_dialog"; |
| 2 |
|
| 3 |
export function makeAwaitable(dialog, comp, props, options) { |
| 4 |
return new Promise((resolve) => { |
| 5 |
dialog.add( |
| 6 |
comp, |
| 7 |
{ |
| 8 |
...props, |
| 9 |
getPayload: (response) => { |
| 10 |
resolve(response); |
| 11 |
}, |
| 12 |
}, |
| 13 |
{ |
| 14 |
...options, |
| 15 |
onClose: () => resolve(), |
| 16 |
} |
| 17 |
); |
| 18 |
}); |
| 19 |
} |
| 20 |
|
| 21 |
export function makeActionAwaitable(action, config, additionalArgs) { |
| 22 |
return new Promise((resolve) => { |
| 23 |
action.doAction(config, { |
| 24 |
...additionalArgs, |
| 25 |
props: { |
| 26 |
...additionalArgs?.props, |
| 27 |
onSave: (record) => { |
| 28 |
action.doAction({ |
| 29 |
type: "ir.actions.act_window_close", |
| 30 |
}); |
| 31 |
resolve(record); |
| 32 |
}, |
| 33 |
}, |
| 34 |
}); |
| 35 |
}); |
| 36 |
} |
| 37 |
|
| 38 |
export function ask(dialog, props, options, comp = ConfirmationDialog) { |
| 39 |
return new Promise((resolve) => { |
| 40 |
dialog.add( |
| 41 |
comp, |
| 42 |
{ |
| 43 |
...props, |
| 44 |
confirm: () => resolve(true), |
| 45 |
cancel: () => resolve(false), |
| 46 |
}, |
| 47 |
{ |
| 48 |
...options, |
| 49 |
onClose: () => resolve(false), |
| 50 |
} |
| 51 |
); |
| 52 |
}); |
| 53 |
} |