WEBAPPS
Front-end Submit WebApps

WebApps - Delete owned WebApps from front-end

8min
introduction when your users have created webapp items front end, you can now give them the option to delete the items they no longer need a user will only be able to delete a webapp item they own generally a user will own a webapp item they've already created, but it's now possible to change webapp ownership in admin you can use liquid to further control when the button is presented to users you can use optionally use javascript to change the behaviour when the button is successful, or when it errors syntax including the button to include the delete button, add the following syntax inside a webapp layout of your choice {% include "webapp delete", layout "default" %} nesting this inside a webapp layout allows it to easily pick up the id of the current webapp item security we recommend wrapping the layout in the following liquid to make sure the button is only visible to those users who have the minimum permission needed to successfully delete the current item {% if context current user id and context current user id == this creator id %} {% include "webapp delete", layout "default" %} {% endif %} note that on the backend we will be running an additional check that the webapp id passed through is owned by the currently logged in user so it won't be possible for malicious users to delete items they don't own by passing through different ids developing the layout including the button in liquid as above will require a small layout which allows you to customise the way the button looks and functions file structure layouts for this button are stored at the following path layouts/webapp components/webapp delete/my layout liquid calling the main javascript function to make the delete button functional, you need to run the s owned webapp delete() function on an event (usually a click event) you should pass the following arguments argument number what is it? example 1 this webapp id {{this id}} 2 token {{token}} 3 optional custom success callback function name webapp delete success 4 optional custom error callback function name webapp delete fail customising the javascript you can add custom javascript functions to customise the way the button behaves on success and failure examples are included on the default layout if you don't provide custom functions, the default behaviour will be to on success, show a success message alert and reload the page on failure, show an error message alert here's an example of custom functions defined and then passed into the 3rd and 4th arguments in the function x {% content for 'siteglide footer scripts' %} ,, {% endcontent for %} note that the siteglide footer scripts feature is a helpful tool to make sure your function definitions are only included in the page once, avoiding duplicates as multiple iterations of the webapp layout are included on the page just be aware that inline comments are not supported by this feature! additionally, you could add in custom behaviour before the main delete function runs, for example to provide a confirmation message to users to check they really want to delete the webapp item x {% content for 'siteglide footer scripts' %} ,, {% endcontent for %}