Changeset 1896
- Timestamp:
- 04/20/12 13:22:08 (12 years ago)
- 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 2 2 { 3 3 import clarin.cmdi.componentregistry.common.Comment; 4 import clarin.cmdi.componentregistry.services.DeleteService; 4 5 5 6 import flash.events.MouseEvent; … … 74 75 private function deleteHandler(event:CloseEvent):void { 75 76 if(event.detail == Alert.OK){ 76 Alert.show("Will delete","TODO");77 DeleteService.instance.deleteComment(comment); 77 78 } 78 79 } -
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/browser/CommentsPanel.as
r1730 r1896 6 6 import clarin.cmdi.componentregistry.services.CommentListService; 7 7 import clarin.cmdi.componentregistry.services.CommentPostService; 8 import clarin.cmdi.componentregistry.services.DeleteService; 8 9 9 10 import flash.events.Event; … … 36 37 this.setStyle("paddingTop", 5); 37 38 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); 38 44 } 39 45 … … 94 100 load(); 95 101 } 102 103 private function commentDeletedHandler(event:Event):void { 104 load(); 105 } 96 106 } 97 107 } -
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/common/Comment.as
r1893 r1896 1 1 package clarin.cmdi.componentregistry.common 2 2 { 3 import clarin.cmdi.componentregistry.services.Config; 4 3 5 public class Comment implements XmlAble 4 6 { … … 16 18 public var id:String; 17 19 public var canDelete:Boolean; 20 public var itemDescription:ItemDescription; 21 public var dataUrl:String; 18 22 19 23 public function Comment():void{ … … 21 25 } 22 26 23 public function create(comment:XML ):void{27 public function create(comment:XML, itemDescription:ItemDescription):void{ 24 28 this.comments = comment.comments; 25 29 this.commentDate = DateUtils.formatDateString(comment.commentDate); … … 29 33 this.userName = comment.userName; 30 34 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 } 31 42 } 32 43 -
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/CommentListService.as
r1706 r1896 13 13 ; 14 14 private var userSpace:Boolean; 15 private var itemDescription:ItemDescription; 15 16 16 17 /** … … 30 31 super(url); 31 32 33 this.itemDescription = itemDescription; 32 34 this.userSpace = userSpace; 33 35 } … … 46 48 for each (var node:XML in nodes) { 47 49 var comment:Comment = new Comment(); 48 comment.create(node );50 comment.create(node, itemDescription); 49 51 comments.addItem(comment); 50 52 } -
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/DeleteService.as
r1375 r1896 1 1 package clarin.cmdi.componentregistry.services { 2 import clarin.cmdi.componentregistry.common.Comment; 2 3 import clarin.cmdi.componentregistry.common.ItemDescription; 3 4 4 5 import com.adobe.net.URI; 5 6 6 7 import flash.events.Event; 7 8 import flash.events.EventDispatcher; 8 9 9 10 import mx.controls.Alert; 10 11 import mx.managers.CursorManager; … … 40 41 url.setQueryValue(Config.PARAM_USERSPACE, "true"); 41 42 } 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 { 42 60 service.url = url.toString(); 43 61 service.send(DELETE_METHOD);
Note: See TracChangeset
for help on using the changeset viewer.