Changeset 2595


Ignore:
Timestamp:
02/15/13 14:42:25 (11 years ago)
Author:
olhsha
Message:

fixing the situation when the veiw is completely updated after deleeting a comment. Now it stays. It is fixed via adding a boolean flag to a STATIC detelete service. works well, because application 1-threaded. Twan allows to fix the problem via making the service not static. His suggestion is make it three istances: for profiles, for components and for comments.

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  
    5959                        this.setStyle("paddingBottom", hPadding);
    6060                       
    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);
    6562                }
    6663               
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/DeleteService.as

    r2558 r2595  
    2020        public class DeleteService extends EventDispatcher {
    2121                public static const ITEM_DELETED:String = "itemDeleted";
     22                public static const COMMENT_DELETED:String = "commentDeleted";
    2223                private var service:HTTPService;
    2324                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;
    2431               
    2532                private static var _instance:DeleteService = new DeleteService();
     
    3441                        service.method = HTTPRequestMessage.POST_METHOD;
    3542                }
     43               
    3644               
    3745                public function deleteItem(item:ItemDescription):void {
     
    6573               
    6674                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;
    7177                        CursorManager.setBusyCursor();
    7278                        var url:URI = new URI(comment.dataUrl);
     
    8591                        CursorManager.removeBusyCursor();
    8692                        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                                }
    88101                        } else {
    89102                                Alert.show("Unexpected error, server returned status: " + resultEvent.statusCode + "\n Message = ");
     
    92105               
    93106                public function handleError(faultEvent:FaultEvent):void {
     107                        _isComment = false;
    94108                        CursorManager.removeBusyCursor();
    95109                        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.