const dialog_fields = [// List of DocFields{ fieldname: "name", label: "Name", fieldtype: "Data" }]​const dialog_data = {// the title to be shown on the modal windowtitle: "Test Dialog",​// the fields to fill in the modalfields: dialog_fields,​// the events to fire when specific fields changeevents: {name: (core, doc) => {}},​// to define the behaviour of the main buttonprimary_button: {// you can set any label you wantlabel: "Ok!",​// function called on clicking this main button// modal will auto close after clickonclick: (core, doc) => {// do something}},close_button: {label: "Close",onclick: (core, doc) => {// say bye ?}}}​core.bus.post({id: "show_dialog",data: dialog_data});
The above code snippet can get you going with the dialog box in no time. You can control the fields and you can listen on events raised on them
If you would like to do some validations before the user window is closed, you can declare the onclick
function with three params. The third param, usually named close_dialog
is a function which when invoked will actually close the dialog/modal.
If the third function was declared and was not called, the modal will not close.
...​primary_button: {label: "Save",onclick: (core, doc, close_dialog) => {if (core.model.saveDoc(doc)) {// the window can close now.close_dialog()} else {// something went wrong, let user recheck what he enteredalert("Please try again")}}}​...