-
Notifications
You must be signed in to change notification settings - Fork 20
Development: UI API
Sami Mokaddem edited this page Jan 12, 2021
·
18 revisions
The bootstrap-helper.js contains classes providing utility functions to create and interact with UI components such as modal or toast.
- The
UIFactoryclass: Exposes quick and easy to use functions for frequently used operations such as opening a toast or loading a modal from an URL - The
Toasterclass: Let you create bootstrap toasts and manipulate them - The
ModalFactoryclass: Let you create bootstrap modals and manipulate them. It supports callback functions for various events and pre-build template - The
OverlayFactoryclass: Let you create overlays providing a loading feedback or simply to tell users that an operation is in progress - The
FormHelperclass: Let you interact with a form validation state
Create and open a toast
UI.toast({
title: 'Title',
body: 'Body',
muted: 'Muted',
variant: 'danger',
delay: 20000
})Create and open a modal from a URL. Additionally a reload URL can be passed to reload the table after a successful operation
// openModalFromURL(url, reloadUrl=false, tableId=false)
UI.openModalFromURL('/users/add', '/users/index', 'table-id-to-reload')Create and open a modal from a URL where the modal's content is fetched from the provided URL. The callbacks functions will be fired upon modal submission
// modalFromURL(url, POSTSuccessCallback=function(){}, POSTFailCallback=function(){})
UI.modalFromURL(
'/users/add',
() => {console.log('success')},
() => {console.log('error')}
)Fetch the content at the provided url and override the $container's content. $statusNode allows to specify another HTML node to display the loading animation
// reload(url, $container, $statusNode=null)
UI.reload('/users/index', $('#userIndexTableContainer'), $('#userIndexTable')).then(() => {
console.log('reload complete')
})