Changeset 2595
- Timestamp:
- 02/15/13 14:42:25 (11 years ago)
- Location:
- ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/browser/CommentsPanel.as
r2593 r2595 59 59 this.setStyle("paddingBottom", hPadding); 60 60 61 // this is for responding to the deletion of comments. At this point there is no way to distinghuish between item and component deletion 62 // and that probably is fine since they mostly require the same response. It does mean that this component will also reload when a 63 // commment gets deleted, which is a bit superfluous. 64 DeleteService.instance.addEventListener(DeleteService.ITEM_DELETED, commentDeletedHandler); 61 DeleteService.instance.addEventListener(DeleteService.COMMENT_DELETED, commentDeletedHandler); 65 62 } 66 63 -
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/DeleteService.as
r2558 r2595 20 20 public class DeleteService extends EventDispatcher { 21 21 public static const ITEM_DELETED:String = "itemDeleted"; 22 public static const COMMENT_DELETED:String = "commentDeleted"; 22 23 private var service:HTTPService; 23 24 private static const DELETE_METHOD:Object = {"method": "delete"}; 25 26 27 // the item to be deleted can be either a comment, or profile/component 28 // depending on int, different events should be issues because different processing will take place 29 // default value is false 30 private var _isComment:Boolean=false; 24 31 25 32 private static var _instance:DeleteService = new DeleteService(); … … 34 41 service.method = HTTPRequestMessage.POST_METHOD; 35 42 } 43 36 44 37 45 public function deleteItem(item:ItemDescription):void { … … 65 73 66 74 public function deleteComment(comment:Comment):void { 67 // Deletion of comments triggers the same response as deletion of items (which was there first). This is suboptimal 68 // but will do for now. E.g. the error messages refer to items but that is generic enough to work in the context of comment deletion. 69 // Also there is just one event, splitting this out is trivial but a bit messy. 70 75 // mark the moment that we want to delete a comment but not rofile/component 76 _isComment = true; 71 77 CursorManager.setBusyCursor(); 72 78 var url:URI = new URI(comment.dataUrl); … … 85 91 CursorManager.removeBusyCursor(); 86 92 if (resultEvent.statusCode >= 200 && resultEvent.statusCode < 300) { 87 dispatchEvent(new Event(ITEM_DELETED)); 93 if (_isComment) { 94 dispatchEvent(new Event(COMMENT_DELETED)); 95 // do not forget to reset the value back to false when a comment is deleated 96 _isComment=false; 97 } 98 else { 99 dispatchEvent(new Event(ITEM_DELETED)); 100 } 88 101 } else { 89 102 Alert.show("Unexpected error, server returned status: " + resultEvent.statusCode + "\n Message = "); … … 92 105 93 106 public function handleError(faultEvent:FaultEvent):void { 107 _isComment = false; 94 108 CursorManager.removeBusyCursor(); 95 109 if (faultEvent.statusCode == 401) { //Apparrently depending on browser status codes and errormessages are sometimes not passed along to flash.
Note: See TracChangeset
for help on using the changeset viewer.