-
Notifications
You must be signed in to change notification settings - Fork 3
Using Option API
The option API can be used in two ways, wether it's for the system or for the user. Tendoo ships a frontend API and a Backend API to interact with theses types of Options.
This section will treat the option management for the frontend api, for the users and the system.
Sometime, you might want to update an option of the system without having to refresh entirely a page. It can be made throught an asynchronous request (XHR). Tendoo CMS declare a JavaScript object on each page loaded on the backend called tendooApi. This object host various Frontend object (API) which can be use to interact with the system on the system UI. In order to manipulate the option, here is how it's made :
tendooApi.options.save( 'foo', 'bar' ).then( result => {
// result.data consist of a success Object send back by the server.
})tendooApi.options.get( 'foo' ).then( result => {
// result.data will return an object with the following shape { value : 'yourvalue' }
})tendooApi.options.delete( 'foo' ).then( result => {
// result.data consist of a success Object send by the server.
})The user options is similar to the system option. However, the object which host the implementation of options for the user is different. Note that all options will be saved as a private meta data for the logged user :
tendooApi.userOptions.save( 'foo', 'bar' ).then( result => {
// result.data consist of a success Object send back by the server.
})tendooApi.userOptions.get( 'foo' ).then( result => {
// result.data will return an object with the following shape { value : 'yourvalue' }
})tendooApi.userOptions.delete( 'foo' ).then( result => {
// result.data consist of a success Object send by the server.
})