In the two previous blog posts, we covered the implementation of the CopyComments workbook script (wbs) method in Dodeca and added a tool on the toolbar to perform the Copy Comments action. In this post, we will describe the steps to add some message boxes to the Dodeca View to improve the user experience. We will ask for confirmation and provide feedback when the action has been completed.
We are all familiar with message boxes, or dialog boxes. They are a secondary window that opens during a session that can be used for a number of purposes including the following:
1. Provide information to a user
2. Ask for confirmation on an action
3. Provide feedback on something that has happened
4. Perform a command
5. Ask for specific information
Message boxes in Dodeca can be customized for the Caption, Icon, Message and Buttons. See below.
We will use something like the above to ask the user for confirmation that would like to proceed with copying the previous months comments. In addition to providing the confirmation message, we can also very easily capture which of the two buttons was clicked by the user. If yes, we will continue with the operation. If no, we will cancel the operation.
Let’s have a look at the current wbs for this view.
We currently have one Procedure with two methods as were developed in the blog post: Copy Forward Comments with Dodeca
We do not have any Event links in this wbs because the action is called from a button on the toolbar we developed in the last blog post: Adding a Button to a Toolbar
What we will do here is to insert a few more methods within this procedure to add the message boxes to the process. The first step is the confirmation message box. For this we will add two methods:
1. ShowMessageBox – to display the confirmation dialog per our specifications, asking the use to continue (Yes) or not (No).
2. ExitProcedure – to exit ONLY if the user selects the No button.
Let’s insert the first new method. Right click on the current CopyComments method, and then select “Insert a New Method Above the Selected Row”.
This will add a new line for you to select the appropriate method. You can start typing (ShowMess…) to go directly to the method we want, or you can simply scroll down to select it.
Once we have selected the method, we see the following arguments:
We can see that four of the arguments listed here are the same as the first image in this post: Message, Caption, Icon and Buttons. The Icon and Buttons arguments are drop downs that we can select from. Let’s enter the following for these arguments:
Message: “Are you sure you want to copy in the comments from the previous month? This will overwrite any comments currently displayed.”
Captions: Please confirm
See below. The Icon and the Buttons arguments can be selected from the drop downs.
Next, we will the last two arguments, PropertyName and PropertyDataType, to capture the user selection i.e. whether they have selected Yes or No.
We can name the result property anything we like. Let’s make it specific to what it means. In this case, Yes means please continue with the Copy, so lets name it ContinueWithCopy. Also, this a yes/no, true/false situation, so let’s make the PropertyDataType “Boolean”.
Great, we are done with this method. Next, we will add the ExitProcedure method which will check the property to decide whether to exit, or to continue with the copy. Do the same steps to add a new method (right click and insert) in the correct place:
For this method, we only need to enter the argument for the Exit condition.
There is a bit of logic to consider here. We asked the user if they want to continue. We did not ask them if they want to cancel. So, we want to exit if the user selects the No button. We do not want to exit if the user selects the Yes button. Our ContinueWithCopy will be set to true if they select Yes, and false if they select No.
We will use the Dodeca function PropertyValue to return the value of the property. We use the following syntax with this property @PVal(ContinueWithCopy).
If we are going to continue with the copy process, then we DO NOT want the exit the procedure. For this reason, our entry for the argument to EXIT will be
That’s it. We are done with the Confirmation message box and the result of the user selection.
Now let’s just add another simple message box after the other methods in the procedure to indicate that the copy has completed.
Right click on the last method and select “Add a New Method Below the Selected Row”. Select the ShowMessageBox method enter the appropriate arguments. I have selected the Information Icon and the OK button:
We’re done! Now let’s simply run the View and test.
I have opened the View and selected December, 2017. I know that there are comments that exist for November and I want to copy them in.
When I click on the “Copy Previous Month Comments” button I see the message box.
If I click on No, nothing happens. The Procedure has exited and no comments are copied. If I click on Yes, the comments are copied, and I see the confirmation message:
Tested and verified!
I hope this has been helpful in demonstrating how easy it is to add some simple message boxes in Dodeca which improve the user experience with the View.