Skip to main content

buildfire.input

buildfire.input is a framework that allows your plugin to show a full-size view with multiple inputs to get user input data.

Example

Methods

showTextDialog()

buildfire.input.showTextDialog(options, callback)

Displays a full screen text dialog that can be used to write text, wysiwyg content, upload images and more.

buildfire.input.showTextDialog(
{
placeholder: "Enter your title here",
saveText: "Set",
maxLength: 50,
defaultValue: "HI",
},
(err, response) => {
if (err) return console.error(err);
if (response.cancelled) return;

console.log(response.results[0].textValue);
}
);

options

NameTypeRequiredDescriptionDefault
placeholderstringnoInput placeholder value"Type something..."
saveTextstringnoSave button text"Done"
cancelTextstringnoCancel button text"Cancel"
doneTextstringnoWhen there are multiple steps and you have reached the end.saveText value
maxLengthnumbernoMaximum input length allowed2000
defaultValuestringnoSet pre existing value of input. Usually used during edits
defaultAttachmentsobjectnoSet pre existing value of attachments. Usually used during edits. defaultAttachments should not be used along with wysiwyg mode
wysiwygbooleannoUsed to switch text input to wysiwyg inputfalse
attachmentsobjectnoSpecifies which attachments to enable
confirmOnCancelobjectnoDetect any input changes and prompts the user to confirm dismissing the dialog if there were any.
options.defaultAttachments
NameTypeRequiredDescriptionDefault
images[string]noArray of image urls
gifs[string]noArray of gif urls
locationobjectnoGeolocation object { long, lat, // address_name }
options.attachments
NameTypeRequiredDescriptionDefault
imagesobjectnoEnables the images attachment. Can allow multiple images to be uploaded { enable: Boolean, multiple: Boolean }
gifs[string]noEnables the gif attachment. { enable: Boolean}
locationobjectnoEnables the location attachment { enable: Boolean}
options.confirmOnCancel
NameTypeRequiredDescriptionDefault
enablebooleannoEnables confirmOnCancel option.false
titleTextstringnoPrompt title text."Unsaved Changes"
messageTextstringnoPrompt body text."Are you sure you want to leave? If you leave now, all the information entered will be lost."
confirmTextstringnoConfirm button text."Leave"
confirmTypestringnoConfirm button type, used to specify the button style. Styles available: default, primary, success, info, warning, danger"primary"
dismissTextstringnoDismiss button text."Resume"

callback(err, data)

NameTypeDescription
errstringerror string, null when operation is successful
dataobjectObject containing cancelled and results
data
NameTypeDescription
cancelledbooleanIndicate if input dialog was cancelled
results[object]Array of result objects
data.results[]
NameTypeDescription
textValuebooleanText value the user entered. If wysiwyg is true, this will contain plaintext version of wysiwyg input without html tags.
wysiwygValue[object]Html value of users input in wysiwyg mode.objects
images[object]Array of image urls objects
gifs[object]Array of gif objects
location[object]Geolocation object `{ long, lat, // address_name }
note

Images and gifs object will be empty if wysiwyg is true since these are embedded in wysiwyg content itself and will be returned in value.

Multiple Inputs

Sometimes you want the user to enter multiple values in order. To do this you can pass multiple option objects in an array.

const steps = [options1, options2, options3];

buildfire.input.showTextDialog(steps, callback);

showListDialog

buildfire.input.showListDialog(options, callback)

Shows a list dialog with multiple list options as a checkbox or radio button.

buildfire.input.showListDialog(
{
title: "List dialog",
listItems: [
{ text: "Item 1", value: "item 1" },
{ text: "Item 1", value: "item 1" },
],
},
(err, result) => {
if (err) return console.error(err);
if (result.cancelled) return;

console.log("Selected values: ", result.selected);
}
);

options

NameTypeRequiredDescriptionDefault
titlestringnoDialog title
multiSelectbooleannoAllows multiple selection of list items. If true, list items are checboxes, otherwise radio buttonsfalse
listItems[object]noList of options to present to the user.
cancelButtonobjectnoChanges cancel button text or value{text: "Cancel", value: "cancel"}
confirmButtonobjectnoChanges confirm button text or value{text: "Ok", value: "ok"}

callback(err, data)

NameTypeDescription
errstringerror string, null when operation is successful
dataobjectObject containing cancelled and selected
data
NameTypeDescription
cancelledbooleanIndicate if list dialog was cancelled
selected[object]Array of selected objects