Difference between revisions of "Patch Email DeleteAll"
Jump to navigation
Jump to search
Hopspitfire (talk | contribs) (Moving comment to discussion page.) |
|||
Line 86: | Line 86: | ||
}, | }, | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
− |
Revision as of 21:13, 14 August 2009
This will add a button at the bottom of the screen with a trashcan icon between the Compose and Refresh buttons. Selecting the button will delete all email items in the list after prompting the user for confirmation.
I am deliberately not using line numbers to minimize the need for updates as new WebOS releases come out.
Open:
/usr/palm/applications/com.palm.app.email/app/controllers/list-assistant.js
Find the setup function and modify the cmdMenuModel items, replace the
{},
with
{label:$L('Delete All'), icon:'delete', command:'deleteall'},
Find the handleCommand function and add the following case statement:
case 'deleteall': this.handleDeleteAll(); break;
Now add the following three functions:
handleDeleteAllResponse: function (event) { //check to see if there are more items to delete. this.deleteAll(); }, deleteAll: function(){ var count = this.emailListElement.mojo.getLength(); var id; if(count > 0) { var item = this.emailListElement.mojo.getNodeByIndex(0); if(item !== undefined) { id = item.id; if(id) { this.controller.serviceRequest(Email.identifier, { method: 'setDeleted', parameters: {'message':id, 'value': true }, onSuccess: this.handleDeleteAllResponse.bind(this), onFailure: this.handleDeleteAllResponse.bind(this) }); }//if(id) }//if item !== undefined else { //item was undefined probably because it is currently marked for delete this.deleteAll(); } }//count > 0 }, handleDeleteAll: function (event) { var totalCount = 0; totalCount = this.emailListElement.mojo.getLength(); this.controller.showAlertDialog({ onChoose: function(value) { if(value == 'yes') { //Delete all items in this folder this.deleteAll(); } }, title: '<b>' + $L('Delete All') + '</b>', message: $L('Are you sure you want to delte all ') + "<b>" + totalCount + "</b>" + $L(' items in this folder?'), choices: [ {label:$L('Yes'), value:'yes', type:'affirmative'}, {label:$L('No'), value:'no', type:'alert'} ] }); },