Here is quick little tip that I thought I would share with you. Someone pointed out to me that there is no process to confirm with the user while deleting a file. This is always a good idea before deleting a file from the file system.
To do this we can use the built in alert class but lets take a look at how its different from what your probably used to in the world of html/js. When the user clicks on the delete file icon the deleteFiles method is triggered. This is the method where we were deleting the files before. We are going to move that out of there and use the static Alert class to popup a little dialog box. The 3rd parameter in the Alert.show method is what buttons to display. If we use the OR operator we can add multiple buttons to the alert box. Next we add an event listener to call a method when either of the buttons are clicked.
When the onConfirmDelete method is called our event.detail property will return the integer of the button that was pressed. If you take a look at the Alert class you will see that each button is a static const represented by an integer. So we you can check to see if event.detail is equal to Alert.YES and that will tell us if the yes button was pressed.
Nothing fancy but I was not aware of how to do this before tonight so hopefully someone else will learn something.
