Changeset 1896


Ignore:
Timestamp:
04/20/12 13:22:08 (12 years ago)
Author:
twagoo
Message:

Linked delete button on comments to delete service. Extended DeleteService? to allow deletion of comments in addition to items. Extended Comment to provide required information. Refs #185

Location:
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/browser/CommentPanel.as

    r1893 r1896  
    22{
    33        import clarin.cmdi.componentregistry.common.Comment;
     4        import clarin.cmdi.componentregistry.services.DeleteService;
    45       
    56        import flash.events.MouseEvent;
     
    7475                private function deleteHandler(event:CloseEvent):void {
    7576                        if(event.detail == Alert.OK){
    76                                 Alert.show("Will delete","TODO");
     77                                DeleteService.instance.deleteComment(comment);
    7778                        }       
    7879                }
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/browser/CommentsPanel.as

    r1730 r1896  
    66        import clarin.cmdi.componentregistry.services.CommentListService;
    77        import clarin.cmdi.componentregistry.services.CommentPostService;
     8        import clarin.cmdi.componentregistry.services.DeleteService;
    89       
    910        import flash.events.Event;
     
    3637                        this.setStyle("paddingTop", 5);
    3738                        this.setStyle("paddingBottom", 5);
     39                       
     40                        // this is for responding to the deletion of comments. At this point there is no way to distinghuish between item and component deletion
     41                        // and that probably is fine since they mostly require the same response. It does mean that this component will also reload when a
     42                        // component gets deleted, which is a bit superfluous.
     43                        DeleteService.instance.addEventListener(DeleteService.ITEM_DELETED, commentDeletedHandler);
    3844                }
    3945               
     
    94100                        load();
    95101                }
     102               
     103                private function commentDeletedHandler(event:Event):void {
     104                        load();
     105                }
    96106        }
    97107}
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/common/Comment.as

    r1893 r1896  
    11package clarin.cmdi.componentregistry.common
    22{
     3        import clarin.cmdi.componentregistry.services.Config;
     4
    35        public class Comment implements XmlAble
    46        {
     
    1618                public var id:String;
    1719                public var canDelete:Boolean;
     20                public var itemDescription:ItemDescription;
     21                public var dataUrl:String;
    1822               
    1923                public function Comment():void{
     
    2125                }
    2226               
    23                 public function create(comment:XML):void{
     27                public function create(comment:XML, itemDescription:ItemDescription):void{
    2428                        this.comments = comment.comments;
    2529                        this.commentDate  = DateUtils.formatDateString(comment.commentDate);
     
    2933                        this.userName = comment.userName;
    3034                        this.canDelete = comment.canDelete == "true";
     35                       
     36                        this.itemDescription = itemDescription;
     37                        if(itemDescription.isProfile){
     38                                dataUrl = Config.instance.getProfileCommentsPath(itemDescription.id) + id;
     39                        } else {
     40                                dataUrl = Config.instance.getComponentCommentsPath(itemDescription.id) + id;
     41                        }
    3142                }
    3243               
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/CommentListService.as

    r1706 r1896  
    1313                ;
    1414                private var userSpace:Boolean;
     15                private var itemDescription:ItemDescription;
    1516               
    1617                /**
     
    3031                        super(url);
    3132                       
     33                        this.itemDescription = itemDescription;
    3234                        this.userSpace = userSpace;
    3335                }
     
    4648                        for each (var node:XML in nodes) {
    4749                                var comment:Comment = new Comment();
    48                                 comment.create(node);
     50                                comment.create(node, itemDescription);
    4951                                comments.addItem(comment);
    5052                        }
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/DeleteService.as

    r1375 r1896  
    11package clarin.cmdi.componentregistry.services {
     2        import clarin.cmdi.componentregistry.common.Comment;
    23        import clarin.cmdi.componentregistry.common.ItemDescription;
    3 
     4       
    45        import com.adobe.net.URI;
    5 
     6       
    67        import flash.events.Event;
    78        import flash.events.EventDispatcher;
    8 
     9       
    910        import mx.controls.Alert;
    1011        import mx.managers.CursorManager;
     
    4041                                url.setQueryValue(Config.PARAM_USERSPACE, "true");
    4142                        }
     43                        sendDelete(url);
     44                }
     45               
     46                public function deleteComment(comment:Comment):void {
     47                        // Deletion of comments triggers the same response as deletion of items (which was there first). This is suboptimal
     48                        // 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.
     49                        // Also there is just one event, splitting this out is trivial but a bit messy.
     50                       
     51                        CursorManager.setBusyCursor();
     52                        var url:URI = new URI(comment.dataUrl);
     53                        if (comment.itemDescription.isInUserSpace) {
     54                                url.setQueryValue(Config.PARAM_USERSPACE, "true");
     55                        }
     56                        sendDelete(url);
     57                }
     58               
     59                private function sendDelete(url:URI):void {
    4260                        service.url = url.toString();
    4361                        service.send(DELETE_METHOD);
Note: See TracChangeset for help on using the changeset viewer.