Start rendering project widgets with a spinner and stuff
This commit is contained in:
parent
582602ba5d
commit
55feacab47
|
@ -23,5 +23,17 @@ return self;}
|
|||
}),
|
||||
smalltalk.Project);
|
||||
|
||||
smalltalk.addMethod(
|
||||
unescape('_renderOn_'),
|
||||
smalltalk.method({
|
||||
selector: unescape('renderOn%3A'),
|
||||
fn: function (html){
|
||||
var self=this;
|
||||
smalltalk.send(html, "_with_", [self['@repo']]);
|
||||
smalltalk.send(html, "_br", []);
|
||||
return self;}
|
||||
}),
|
||||
smalltalk.Project);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -33,5 +33,22 @@ referencedClasses: []
|
|||
}),
|
||||
smalltalk.Project);
|
||||
|
||||
smalltalk.addMethod(
|
||||
unescape('_renderOn_'),
|
||||
smalltalk.method({
|
||||
selector: unescape('renderOn%3A'),
|
||||
category: 'rendering',
|
||||
fn: function (html){
|
||||
var self=this;
|
||||
smalltalk.send(html, "_with_", [self['@repo']]);
|
||||
smalltalk.send(html, "_br", []);
|
||||
return self;},
|
||||
args: ["html"],
|
||||
source: unescape('renderOn%3A%20html%0A%09html%20with%3A%20repo.%0A%09html%20br.'),
|
||||
messageSends: ["with:", "br"],
|
||||
referencedClasses: []
|
||||
}),
|
||||
smalltalk.Project);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -46,7 +46,21 @@ smalltalk.method({
|
|||
selector: unescape('activateRepo%3A'),
|
||||
fn: function (aRepoName){
|
||||
var self=this;
|
||||
smalltalk.send(self['@activeRepos'], "_add_", [aRepoName]);
|
||||
var pulls=nil;
|
||||
smalltalk.send(smalltalk.send("div.spinner", "_asJQuery", []), "_hide", []);
|
||||
(pulls=smalltalk.send(self['@repos'], "_at_ifAbsent_", [aRepoName, (function(){return nil;})]));
|
||||
(($receiver = pulls) != nil && $receiver != undefined) ? (function(){smalltalk.send(self['@activeRepos'], "_add_", [aRepoName]);return smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.Project || Project), "_new", []), "_withRepo_andPullRequests_", [aRepoName, pulls]), "_appendToJQuery_", [smalltalk.send("div.projects", "_asJQuery", [])]);})() : nil;
|
||||
return self;}
|
||||
}),
|
||||
smalltalk.DespairApp);
|
||||
|
||||
smalltalk.addMethod(
|
||||
unescape('_activeRepos'),
|
||||
smalltalk.method({
|
||||
selector: unescape('activeRepos'),
|
||||
fn: function (){
|
||||
var self=this;
|
||||
return self['@activeRepos'];
|
||||
return self;}
|
||||
}),
|
||||
smalltalk.DespairApp);
|
||||
|
|
|
@ -62,11 +62,30 @@ selector: unescape('activateRepo%3A'),
|
|||
category: 'actions',
|
||||
fn: function (aRepoName){
|
||||
var self=this;
|
||||
smalltalk.send(self['@activeRepos'], "_add_", [aRepoName]);
|
||||
var pulls=nil;
|
||||
smalltalk.send(smalltalk.send("div.spinner", "_asJQuery", []), "_hide", []);
|
||||
(pulls=smalltalk.send(self['@repos'], "_at_ifAbsent_", [aRepoName, (function(){return nil;})]));
|
||||
(($receiver = pulls) != nil && $receiver != undefined) ? (function(){smalltalk.send(self['@activeRepos'], "_add_", [aRepoName]);return smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.Project || Project), "_new", []), "_withRepo_andPullRequests_", [aRepoName, pulls]), "_appendToJQuery_", [smalltalk.send("div.projects", "_asJQuery", [])]);})() : nil;
|
||||
return self;},
|
||||
args: ["aRepoName"],
|
||||
source: unescape('activateRepo%3A%20aRepoName%0A%09activeRepos%20add%3A%20aRepoName.'),
|
||||
messageSends: ["add:"],
|
||||
source: unescape('activateRepo%3A%20aRepoName%0A%09%7C%20pulls%20%7C%0A%09%22As%20soon%20as%20we%20start%20activating%20repos%2C%20it%27s%20safe%20to%20hide%20the%20spinner%20from%20the%20user%22%0A%09%27div.spinner%27%20asJQuery%20hide.%0A%09pulls%20%3A%3D%20repos%20at%3A%20aRepoName%20ifAbsent%3A%20%5B%5D.%0A%09pulls%20ifNotNil%3A%20%5B%0A%09%09activeRepos%20add%3A%20aRepoName.%0A%09%09%28Project%20new%20withRepo%3A%20aRepoName%20andPullRequests%3A%20pulls%29%20appendToJQuery%3A%20%27div.projects%27%20asJQuery.%0A%09%5D.'),
|
||||
messageSends: ["hide", "asJQuery", "at:ifAbsent:", "ifNotNil:", "add:", "appendToJQuery:", "withRepo:andPullRequests:", "new"],
|
||||
referencedClasses: ["Project"]
|
||||
}),
|
||||
smalltalk.DespairApp);
|
||||
|
||||
smalltalk.addMethod(
|
||||
unescape('_activeRepos'),
|
||||
smalltalk.method({
|
||||
selector: unescape('activeRepos'),
|
||||
category: 'accessors',
|
||||
fn: function (){
|
||||
var self=this;
|
||||
return self['@activeRepos'];
|
||||
return self;},
|
||||
args: [],
|
||||
source: unescape('activeRepos%0A%09%5E%20activeRepos.'),
|
||||
messageSends: [],
|
||||
referencedClasses: []
|
||||
}),
|
||||
smalltalk.DespairApp);
|
||||
|
|
|
@ -15,3 +15,10 @@ withRepo: aRepo andPullRequests: anArrayOfRequests
|
|||
pulls := anArrayOfRequests.
|
||||
! !
|
||||
|
||||
!Project methodsFor: 'rendering'!
|
||||
|
||||
renderOn: html
|
||||
html with: repo.
|
||||
html br.
|
||||
! !
|
||||
|
||||
|
|
|
@ -3,6 +3,12 @@ Object subclass: #DespairApp
|
|||
instanceVariableNames: 'repos username activeRepos'
|
||||
category: 'Despair'!
|
||||
|
||||
!DespairApp methodsFor: 'accessors'!
|
||||
|
||||
activeRepos
|
||||
^ activeRepos.
|
||||
! !
|
||||
|
||||
!DespairApp methodsFor: 'actions'!
|
||||
|
||||
loadPullRequests
|
||||
|
@ -24,7 +30,14 @@ loadPullRequests
|
|||
!
|
||||
|
||||
activateRepo: aRepoName
|
||||
activeRepos add: aRepoName.
|
||||
| pulls |
|
||||
"As soon as we start activating repos, it's safe to hide the spinner from the user"
|
||||
'div.spinner' asJQuery hide.
|
||||
pulls := repos at: aRepoName ifAbsent: [].
|
||||
pulls ifNotNil: [
|
||||
activeRepos add: aRepoName.
|
||||
(Project new withRepo: aRepoName andPullRequests: pulls) appendToJQuery: 'div.projects' asJQuery.
|
||||
].
|
||||
! !
|
||||
|
||||
!DespairApp methodsFor: 'initializers'!
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
Run Amber IDE
|
||||
%h2
|
||||
#{user} of Despair
|
||||
%center
|
||||
%div.spinner
|
||||
%img{:src => '/images/octocat-spinner-64.gif'}
|
||||
%div.projects
|
||||
|
||||
= embed_amber(:on_ready => "smalltalk.DespairApp._current()._bootstrap_('#{user}');")
|
||||
|
||||
|
|
Loading…
Reference in New Issue