Add an 'Add Comment' link to the issue detail dialog

This commit is contained in:
R. Tyler Croy 2012-03-25 02:08:44 -07:00
parent 0218257d8c
commit 6b3b24fe4a
3 changed files with 49 additions and 11 deletions

View File

@ -475,7 +475,7 @@ smalltalk.method({
selector: unescape('becomeDialog%3A'),
fn: function (aBlockCallback){
var self=this;
smalltalk.send(smalltalk.send(self, "_asJQuery", []), "_dialog_", [smalltalk.HashedCollection._fromPairs_([smalltalk.send("modal", "__minus_gt", [self['@modal']]),smalltalk.send("minWidth", "__minus_gt", [self['@minWidth']]),smalltalk.send("draggable", "__minus_gt", [self['@draggable']]),smalltalk.send("position", "__minus_gt", [self['@position']]),smalltalk.send("close", "__minus_gt", [(function(event, ui){smalltalk.send(smalltalk.send(unescape(".ui-dialog"), "_asJQuery", []), "_remove", []);return smalltalk.send(smalltalk.send(self, "_asJQuery", []), "_remove", []);})])])]);
smalltalk.send(smalltalk.send(self, "_asJQuery", []), "_dialog_", [smalltalk.HashedCollection._fromPairs_([smalltalk.send("modal", "__minus_gt", [self['@modal']]),smalltalk.send("minWidth", "__minus_gt", [self['@minWidth']]),smalltalk.send("draggable", "__minus_gt", [self['@draggable']]),smalltalk.send("position", "__minus_gt", [self['@position']]),smalltalk.send("close", "__minus_gt", [(function(event, ui){return smalltalk.send(smalltalk.send(self, "_asJQuery", []), "_remove", []);})])])]);
smalltalk.send(aBlockCallback, "_value", []);
return self;}
}),
@ -546,6 +546,17 @@ return self;}
}),
smalltalk.NewIssueDialog);
smalltalk.addMethod(
unescape('_buttons'),
smalltalk.method({
selector: unescape('buttons'),
fn: function (){
var self=this;
return nil;
return self;}
}),
smalltalk.NewIssueDialog);
smalltalk.addMethod(
unescape('_show'),
@ -585,7 +596,8 @@ selector: unescape('renderOn%3A'),
fn: function (html){
var self=this;
(function($rec){smalltalk.send($rec, "_at_put_", ["title", smalltalk.send(smalltalk.send(smalltalk.send(unescape("%23"), "__comma", [smalltalk.send(self['@model'], "_number", [])]), "__comma", [unescape("%20-%20")]), "__comma", [smalltalk.send(self['@model'], "_title", [])])]);smalltalk.send($rec, "_id_", [self['@elementId']]);return smalltalk.send($rec, "_with_", [(function(){var body=nil;
(body=smalltalk.send(self['@model'], "_body", []));((($receiver = smalltalk.send(smalltalk.send(body, "_size", []), "__eq", [(0)])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return (body="No description given");})() : (function(){return (body=smalltalk.send((smalltalk.Markdown || Markdown), "_asTagBrush_", [smalltalk.send(smalltalk.send(self['@model'], "_body", []), "_asString", [])]));})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return (body="No description given");}), (function(){return (body=smalltalk.send((smalltalk.Markdown || Markdown), "_asTagBrush_", [smalltalk.send(smalltalk.send(self['@model'], "_body", []), "_asString", [])]));})]));smalltalk.send(smalltalk.send(html, "_div", []), "_with_", [body]);(function($rec){smalltalk.send($rec, "_id_", ["comments_container"]);smalltalk.send($rec, "_style_", [unescape("display%3A%20none%3B")]);return smalltalk.send($rec, "_with_", [(function(){smalltalk.send(html, "_hr", []);smalltalk.send(smalltalk.send(html, "_strong", []), "_with_", ["Comments:"]);smalltalk.send(html, "_hr", []);return (function($rec){smalltalk.send($rec, "_id_", ["comments"]);return smalltalk.send($rec, "_style_", [unescape("overflow%3A%20auto%3B%20max-height%3A%20300px")]);})(smalltalk.send(html, "_div", []));})]);})(smalltalk.send(html, "_div", []));return (function($rec){smalltalk.send($rec, "_style_", [unescape("float%3A%20right%3B")]);return smalltalk.send($rec, "_with_", [(function(){return (function($rec){smalltalk.send($rec, "_href_", [smalltalk.send(self['@model'], "_url", [])]);return smalltalk.send($rec, "_with_", ["view on GitHub"]);})(smalltalk.send(html, "_a", []));})]);})(smalltalk.send(html, "_div", []));})]);})(smalltalk.send(html, "_div", []));
(body=smalltalk.send(self['@model'], "_body", []));((($receiver = smalltalk.send(smalltalk.send(body, "_size", []), "__eq", [(0)])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return (body="No description given");})() : (function(){return (body=smalltalk.send((smalltalk.Markdown || Markdown), "_asTagBrush_", [smalltalk.send(smalltalk.send(self['@model'], "_body", []), "_asString", [])]));})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return (body="No description given");}), (function(){return (body=smalltalk.send((smalltalk.Markdown || Markdown), "_asTagBrush_", [smalltalk.send(smalltalk.send(self['@model'], "_body", []), "_asString", [])]));})]));smalltalk.send(smalltalk.send(html, "_div", []), "_with_", [body]);(function($rec){smalltalk.send($rec, "_id_", ["comments_container"]);smalltalk.send($rec, "_style_", [unescape("display%3A%20none%3B")]);return smalltalk.send($rec, "_with_", [(function(){smalltalk.send(html, "_hr", []);smalltalk.send(smalltalk.send(html, "_strong", []), "_with_", ["Comments:"]);smalltalk.send(html, "_hr", []);return (function($rec){smalltalk.send($rec, "_id_", ["comments"]);return smalltalk.send($rec, "_style_", [unescape("overflow%3A%20auto%3B%20max-height%3A%20300px")]);})(smalltalk.send(html, "_div", []));})]);})(smalltalk.send(html, "_div", []));(function($rec){smalltalk.send($rec, "_style_", [unescape("float%3A%20right%3B")]);return smalltalk.send($rec, "_with_", [(function(){return (function($rec){smalltalk.send($rec, "_href_", [smalltalk.send(self['@model'], "_url", [])]);return smalltalk.send($rec, "_with_", ["View on GitHub"]);})(smalltalk.send(html, "_a", []));})]);})(smalltalk.send(html, "_div", []));return (function($rec){smalltalk.send($rec, "_style_", [unescape("float%3A%20right%3B%20margin-right%3A%2010px%3B")]);return smalltalk.send($rec, "_with_", [(function(){return (function($rec){smalltalk.send($rec, "_href_", [unescape("%23")]);smalltalk.send($rec, "_with_", ["Add Comment"]);return smalltalk.send($rec, "_onClick_", [(function(){var dialog=nil;
(dialog=smalltalk.send(smalltalk.send((smalltalk.CommentDialog || CommentDialog), "_new", []), "_withIssue_", [self['@model']]));return smalltalk.send(dialog, "_appendToJQuery_", [smalltalk.send("body", "_asJQuery", [])]);})]);})(smalltalk.send(html, "_a", []));})]);})(smalltalk.send(html, "_div", []));})]);})(smalltalk.send(html, "_div", []));
smalltalk.send(self, "_becomeDialog", []);
smalltalk.send(self['@model'], "_loadComments_", [(function(comments){return smalltalk.send(smalltalk.send(comments, "_reversed", []), "_do_", [(function(comment){return smalltalk.send((function(html){return smalltalk.send(self, "_renderComment_onto_", [comment, html]);}), "_appendToJQuery_", [smalltalk.send(unescape("%23comments"), "_asJQuery", [])]);})]);})]);
return self;}

View File

@ -651,11 +651,11 @@ selector: unescape('becomeDialog%3A'),
category: 'dialog-helpers',
fn: function (aBlockCallback){
var self=this;
smalltalk.send(smalltalk.send(self, "_asJQuery", []), "_dialog_", [smalltalk.HashedCollection._fromPairs_([smalltalk.send("modal", "__minus_gt", [self['@modal']]),smalltalk.send("minWidth", "__minus_gt", [self['@minWidth']]),smalltalk.send("draggable", "__minus_gt", [self['@draggable']]),smalltalk.send("position", "__minus_gt", [self['@position']]),smalltalk.send("close", "__minus_gt", [(function(event, ui){smalltalk.send(smalltalk.send(unescape(".ui-dialog"), "_asJQuery", []), "_remove", []);return smalltalk.send(smalltalk.send(self, "_asJQuery", []), "_remove", []);})])])]);
smalltalk.send(smalltalk.send(self, "_asJQuery", []), "_dialog_", [smalltalk.HashedCollection._fromPairs_([smalltalk.send("modal", "__minus_gt", [self['@modal']]),smalltalk.send("minWidth", "__minus_gt", [self['@minWidth']]),smalltalk.send("draggable", "__minus_gt", [self['@draggable']]),smalltalk.send("position", "__minus_gt", [self['@position']]),smalltalk.send("close", "__minus_gt", [(function(event, ui){return smalltalk.send(smalltalk.send(self, "_asJQuery", []), "_remove", []);})])])]);
smalltalk.send(aBlockCallback, "_value", []);
return self;},
args: ["aBlockCallback"],
source: unescape('becomeDialog%3A%20aBlockCallback%0A%09self%20asJQuery%20dialog%3A%20%23%7B%0A%09%09%09%27modal%27%20-%3E%20modal.%0A%09%09%09%27minWidth%27%20-%3E%20minWidth.%0A%09%09%09%27draggable%27%20-%3E%20draggable.%0A%09%09%09%27position%27%20-%3E%20position.%0A%09%09%09%27close%27%20-%3E%20%5B%20%3Aevent%20%3Aui%20%7C%0A%09%09%09%09%22Ugly%20hack%20to%20make%20sure%20we%20nuke%20all%20trash%20the%20jQuery%20UI%20Dialog%20leaves%20around%22%0A%09%09%09%09%27.ui-dialog%27%20asJQuery%20remove.%0A%09%09%09%09self%20asJQuery%20remove.%0A%09%09%09%5D%7D.%0A%09aBlockCallback%20value.'),
source: unescape('becomeDialog%3A%20aBlockCallback%0A%09self%20asJQuery%20dialog%3A%20%23%7B%0A%09%09%09%27modal%27%20-%3E%20modal.%0A%09%09%09%27minWidth%27%20-%3E%20minWidth.%0A%09%09%09%27draggable%27%20-%3E%20draggable.%0A%09%09%09%27position%27%20-%3E%20position.%0A%09%09%09%27close%27%20-%3E%20%5B%20%3Aevent%20%3Aui%20%7C%0A%09%09%09%09self%20asJQuery%20remove.%0A%09%09%09%5D%7D.%0A%09aBlockCallback%20value.'),
messageSends: ["dialog:", "asJQuery", unescape("-%3E"), "remove", "value"],
referencedClasses: []
}),
@ -751,6 +751,22 @@ referencedClasses: []
}),
smalltalk.NewIssueDialog);
smalltalk.addMethod(
unescape('_buttons'),
smalltalk.method({
selector: unescape('buttons'),
category: 'rendering',
fn: function (){
var self=this;
return nil;
return self;},
args: [],
source: unescape('buttons%0A%09%5E%20nil.'),
messageSends: [],
referencedClasses: []
}),
smalltalk.NewIssueDialog);
smalltalk.addMethod(
unescape('_show'),
@ -801,14 +817,15 @@ category: 'rendering',
fn: function (html){
var self=this;
(function($rec){smalltalk.send($rec, "_at_put_", ["title", smalltalk.send(smalltalk.send(smalltalk.send(unescape("%23"), "__comma", [smalltalk.send(self['@model'], "_number", [])]), "__comma", [unescape("%20-%20")]), "__comma", [smalltalk.send(self['@model'], "_title", [])])]);smalltalk.send($rec, "_id_", [self['@elementId']]);return smalltalk.send($rec, "_with_", [(function(){var body=nil;
(body=smalltalk.send(self['@model'], "_body", []));((($receiver = smalltalk.send(smalltalk.send(body, "_size", []), "__eq", [(0)])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return (body="No description given");})() : (function(){return (body=smalltalk.send((smalltalk.Markdown || Markdown), "_asTagBrush_", [smalltalk.send(smalltalk.send(self['@model'], "_body", []), "_asString", [])]));})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return (body="No description given");}), (function(){return (body=smalltalk.send((smalltalk.Markdown || Markdown), "_asTagBrush_", [smalltalk.send(smalltalk.send(self['@model'], "_body", []), "_asString", [])]));})]));smalltalk.send(smalltalk.send(html, "_div", []), "_with_", [body]);(function($rec){smalltalk.send($rec, "_id_", ["comments_container"]);smalltalk.send($rec, "_style_", [unescape("display%3A%20none%3B")]);return smalltalk.send($rec, "_with_", [(function(){smalltalk.send(html, "_hr", []);smalltalk.send(smalltalk.send(html, "_strong", []), "_with_", ["Comments:"]);smalltalk.send(html, "_hr", []);return (function($rec){smalltalk.send($rec, "_id_", ["comments"]);return smalltalk.send($rec, "_style_", [unescape("overflow%3A%20auto%3B%20max-height%3A%20300px")]);})(smalltalk.send(html, "_div", []));})]);})(smalltalk.send(html, "_div", []));return (function($rec){smalltalk.send($rec, "_style_", [unescape("float%3A%20right%3B")]);return smalltalk.send($rec, "_with_", [(function(){return (function($rec){smalltalk.send($rec, "_href_", [smalltalk.send(self['@model'], "_url", [])]);return smalltalk.send($rec, "_with_", ["view on GitHub"]);})(smalltalk.send(html, "_a", []));})]);})(smalltalk.send(html, "_div", []));})]);})(smalltalk.send(html, "_div", []));
(body=smalltalk.send(self['@model'], "_body", []));((($receiver = smalltalk.send(smalltalk.send(body, "_size", []), "__eq", [(0)])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return (body="No description given");})() : (function(){return (body=smalltalk.send((smalltalk.Markdown || Markdown), "_asTagBrush_", [smalltalk.send(smalltalk.send(self['@model'], "_body", []), "_asString", [])]));})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return (body="No description given");}), (function(){return (body=smalltalk.send((smalltalk.Markdown || Markdown), "_asTagBrush_", [smalltalk.send(smalltalk.send(self['@model'], "_body", []), "_asString", [])]));})]));smalltalk.send(smalltalk.send(html, "_div", []), "_with_", [body]);(function($rec){smalltalk.send($rec, "_id_", ["comments_container"]);smalltalk.send($rec, "_style_", [unescape("display%3A%20none%3B")]);return smalltalk.send($rec, "_with_", [(function(){smalltalk.send(html, "_hr", []);smalltalk.send(smalltalk.send(html, "_strong", []), "_with_", ["Comments:"]);smalltalk.send(html, "_hr", []);return (function($rec){smalltalk.send($rec, "_id_", ["comments"]);return smalltalk.send($rec, "_style_", [unescape("overflow%3A%20auto%3B%20max-height%3A%20300px")]);})(smalltalk.send(html, "_div", []));})]);})(smalltalk.send(html, "_div", []));(function($rec){smalltalk.send($rec, "_style_", [unescape("float%3A%20right%3B")]);return smalltalk.send($rec, "_with_", [(function(){return (function($rec){smalltalk.send($rec, "_href_", [smalltalk.send(self['@model'], "_url", [])]);return smalltalk.send($rec, "_with_", ["View on GitHub"]);})(smalltalk.send(html, "_a", []));})]);})(smalltalk.send(html, "_div", []));return (function($rec){smalltalk.send($rec, "_style_", [unescape("float%3A%20right%3B%20margin-right%3A%2010px%3B")]);return smalltalk.send($rec, "_with_", [(function(){return (function($rec){smalltalk.send($rec, "_href_", [unescape("%23")]);smalltalk.send($rec, "_with_", ["Add Comment"]);return smalltalk.send($rec, "_onClick_", [(function(){var dialog=nil;
(dialog=smalltalk.send(smalltalk.send((smalltalk.CommentDialog || CommentDialog), "_new", []), "_withIssue_", [self['@model']]));return smalltalk.send(dialog, "_appendToJQuery_", [smalltalk.send("body", "_asJQuery", [])]);})]);})(smalltalk.send(html, "_a", []));})]);})(smalltalk.send(html, "_div", []));})]);})(smalltalk.send(html, "_div", []));
smalltalk.send(self, "_becomeDialog", []);
smalltalk.send(self['@model'], "_loadComments_", [(function(comments){return smalltalk.send(smalltalk.send(comments, "_reversed", []), "_do_", [(function(comment){return smalltalk.send((function(html){return smalltalk.send(self, "_renderComment_onto_", [comment, html]);}), "_appendToJQuery_", [smalltalk.send(unescape("%23comments"), "_asJQuery", [])]);})]);})]);
return self;},
args: ["html"],
source: unescape('renderOn%3A%20html%0A%09html%20div%0A%09%09at%3A%20%27title%27%20put%3A%20%27%23%27%2C%20%28model%20number%29%2C%20%27%20-%20%27%2C%20%28model%20title%29%3B%0A%09%09id%3A%20elementId%3B%0A%09%09with%3A%20%5B%0A%09%09%09%7C%20body%20%7C%0A%09%09%09body%20%3A%3D%20model%20body.%0A%09%09%09%28body%20size%29%20%3D%200%0A%09%09%09%09ifTrue%3A%20%5B%20body%20%3A%3D%20%27No%20description%20given%27.%5D%0A%09%09%09%09ifFalse%3A%20%5B%20body%20%3A%3D%20Markdown%20asTagBrush%3A%20%28model%20body%20asString%29%20%5D.%0A%09%09%09html%20div%20with%3A%20body.%0A%09%09%09html%20div%0A%09%09%09%09id%3A%20%27comments_container%27%3B%0A%09%09%09%09style%3A%20%27display%3A%20none%3B%27%3B%0A%09%09%09%09with%3A%20%5B%0A%09%09%09%09%09html%20hr.%0A%09%09%09%09%09html%20strong%20with%3A%20%27Comments%3A%27.%0A%09%09%09%09%09html%20hr.%0A%09%09%09%09%09html%20div%20id%3A%20%27comments%27%3B%20style%3A%20%27overflow%3A%20auto%3B%20max-height%3A%20300px%27.%0A%09%09%09%09%5D.%0A%09%09%09html%20div%0A%09%09%09%09style%3A%20%27float%3A%20right%3B%27%3B%0A%09%09%09%09with%3A%20%5B%20html%20a%20href%3A%20%28model%20url%29%3B%20with%3A%20%27view%20on%20GitHub%27%5D.%0A%09%5D.%0A%0A%09self%20becomeDialog.%0A%0A%09model%20loadComments%3A%20%5B%20%3Acomments%20%7C%20comments%20reversed%20do%3A%20%5B%20%3Acomment%20%7C%20%5B%20%3Ahtml%20%7C%20self%20renderComment%3A%20comment%20onto%3A%20html%20%5D%20appendToJQuery%3A%20%27%23comments%27%20asJQuery%20%5D%20%5D.'),
messageSends: ["at:put:", unescape("%2C"), "number", "title", "id:", "with:", "body", "ifTrue:ifFalse:", unescape("%3D"), "size", "asTagBrush:", "asString", "div", "style:", "hr", "strong", "href:", "url", "a", "becomeDialog", "loadComments:", "do:", "reversed", "appendToJQuery:", "renderComment:onto:", "asJQuery"],
referencedClasses: ["Markdown"]
source: unescape('renderOn%3A%20html%0A%09html%20div%0A%09%09at%3A%20%27title%27%20put%3A%20%27%23%27%2C%20%28model%20number%29%2C%20%27%20-%20%27%2C%20%28model%20title%29%3B%0A%09%09id%3A%20elementId%3B%0A%09%09with%3A%20%5B%0A%09%09%09%7C%20body%20%7C%0A%09%09%09body%20%3A%3D%20model%20body.%0A%09%09%09%28body%20size%29%20%3D%200%0A%09%09%09%09ifTrue%3A%20%5B%20body%20%3A%3D%20%27No%20description%20given%27.%5D%0A%09%09%09%09ifFalse%3A%20%5B%20body%20%3A%3D%20Markdown%20asTagBrush%3A%20%28model%20body%20asString%29%20%5D.%0A%09%09%09html%20div%20with%3A%20body.%0A%09%09%09html%20div%0A%09%09%09%09id%3A%20%27comments_container%27%3B%0A%09%09%09%09style%3A%20%27display%3A%20none%3B%27%3B%0A%09%09%09%09with%3A%20%5B%0A%09%09%09%09%09html%20hr.%0A%09%09%09%09%09html%20strong%20with%3A%20%27Comments%3A%27.%0A%09%09%09%09%09html%20hr.%0A%09%09%09%09%09html%20div%20id%3A%20%27comments%27%3B%20style%3A%20%27overflow%3A%20auto%3B%20max-height%3A%20300px%27.%0A%09%09%09%09%5D.%0A%09%09%09html%20div%0A%09%09%09%09style%3A%20%27float%3A%20right%3B%27%3B%0A%09%09%09%09with%3A%20%5B%20html%20a%20href%3A%20%28model%20url%29%3B%20with%3A%20%27View%20on%20GitHub%27%5D.%0A%09%09%09html%20div%0A%09%09%09%09style%3A%20%27float%3A%20right%3B%20margin-right%3A%2010px%3B%27%3B%0A%09%09%09%09with%3A%20%5B%20html%20a%20href%3A%20%27%23%27%3B%20with%3A%20%27Add%20Comment%27%3B%20onClick%3A%20%5B%0A%09%09%09%09%09%09%7C%20dialog%20%7C%0A%09%09%09%09%09dialog%20%3A%3D%20CommentDialog%20new%20withIssue%3A%20model.%0A%09%09%09%09%09dialog%20appendToJQuery%3A%20%27body%27%20asJQuery.%0A%09%09%09%09%5D%5D.%0A%09%5D.%0A%0A%09self%20becomeDialog.%0A%0A%09model%20loadComments%3A%20%5B%20%3Acomments%20%7C%20comments%20reversed%20do%3A%20%5B%20%3Acomment%20%7C%20%5B%20%3Ahtml%20%7C%20self%20renderComment%3A%20comment%20onto%3A%20html%20%5D%20appendToJQuery%3A%20%27%23comments%27%20asJQuery%20%5D%20%5D.'),
messageSends: ["at:put:", unescape("%2C"), "number", "title", "id:", "with:", "body", "ifTrue:ifFalse:", unescape("%3D"), "size", "asTagBrush:", "asString", "div", "style:", "hr", "strong", "href:", "url", "a", "onClick:", "withIssue:", "new", "appendToJQuery:", "asJQuery", "becomeDialog", "loadComments:", "do:", "reversed", "renderComment:onto:"],
referencedClasses: ["Markdown", "CommentDialog"]
}),
smalltalk.IssueDetailDialog);

View File

@ -378,8 +378,6 @@ becomeDialog: aBlockCallback
'draggable' -> draggable.
'position' -> position.
'close' -> [ :event :ui |
"Ugly hack to make sure we nuke all trash the jQuery UI Dialog leaves around"
'.ui-dialog' asJQuery remove.
self asJQuery remove.
]}.
aBlockCallback value.
@ -467,6 +465,10 @@ renderOn: html
].
self becomeDialog: [ ':input[name=title]' asJQuery focus ].
!
buttons
^ nil.
! !
!NewIssueDialog class methodsFor: 'not yet classified'!
@ -522,7 +524,14 @@ renderOn: html
].
html div
style: 'float: right;';
with: [ html a href: (model url); with: 'view on GitHub'].
with: [ html a href: (model url); with: 'View on GitHub'].
html div
style: 'float: right; margin-right: 10px;';
with: [ html a href: '#'; with: 'Add Comment'; onClick: [
| dialog |
dialog := CommentDialog new withIssue: model.
dialog appendToJQuery: 'body' asJQuery.
]].
].
self becomeDialog.