Skip to content

Instantly share code, notes, and snippets.

View ernestoruiz89's full-sized avatar
🎯
Focusing

Ernesto Ruiz ernestoruiz89

🎯
Focusing
View GitHub Profile
@ernestoruiz89
ernestoruiz89 / dialog_promise.js
Created March 3, 2023 19:39 — forked from barredterra/dialog_promise.js
Comfortably work with dialogs in Frappe Framework
function dialog_promise (title, fields, primary_action_label) {
// Return a function that returns a promise
// The promise resolves when the dialog is submitted and rejects when the dialog is closed
// On resolve, the promise returns the values from the dialog.
return () => new Promise((resolve, reject) => {
const dialog = new frappe.ui.Dialog({
title: title,
fields: fields,
onhide: () => reject(),
primary_action_label: primary_action_label,