Now that our phonebook editor has the ability
to create person documents how about we give them the ability to delete
person documents also.
For this I am going to create a new
action button on the content_Person custom control so open it up in your
domino designer. I could drag in a new link from the controls pane on the
right and give it all the required styleclasses etc but to save time I’m
going to reuse one of my existing action buttons. Select one of the existing
buttons and copy it to the clipboard and then position the cursor where
you’d like the new button and just paste in the clipboard contents. You
now have your basic button with all the correct styleclasses.
Select you new button and in it’s properties
give it a new name. I have called mine ‘Delete Person’.
To make the button appear to the right
person and at the right time I have setup the visible properties to the
following computed code :
var s1 = context.getUser().getRoles();
var s2 = "honebookEditorquot;;if (personDoc.isEditable())
{
return false;
} else if (@Contains(s1, s2) == @True())
{
return true;
} else
{
return false;
}
If the document is already in edit mode
then the button will be hidden, if the document is not in edit mode and
the current user has the honebookEditorrole in the ACL then the button
will be shown otherwise the button is hidden.
The last bit we need to do is set the
action for the button. Switch to the events tab and look at the ‘onClick’
event. You’ll need to remove the current event that is there and then click
on the ‘Add Action’ button. This time we will select a document action
with the ‘Delete Document’ type.
You will need to specify what XPage
you want to return to after the document is deleted and if you want you
can enter in some text that will be used to confirm the action.
Save and close the custom control and
preview your changes in the web browser. if you are logged in and have
the correct roles you should now see the edit button.
And clicking on it will bring up your
confirmation text
Clicking OK should bring you back to
the list of people in the last selected location ( thanks to the sessionScope.locationfilter
variable ) and the person you selected should now be gone.