add repo on success
This commit is contained in:
parent
ec0864f3d2
commit
a17bd05a58
|
@ -28,6 +28,7 @@ GitHub Burndown Chart as a service. Public repos are free, for private access au
|
|||
- [ ] Check location.hash is supported
|
||||
- [ ] Have an app wide of triggering a URL and have named routes too
|
||||
- [ ] Check that we have not run out of requests to make
|
||||
- [ ] Deal with running out of GH API requests
|
||||
|
||||
### Extras
|
||||
|
||||
|
|
|
@ -24617,20 +24617,19 @@ requireModule('promise/polyfill').polyfill();
|
|||
'adapt': [Ractive.adaptors.Ractive],
|
||||
init: function() {
|
||||
var autocomplete;
|
||||
autocomplete = function(value) {
|
||||
return console.log('Autocomplete', value);
|
||||
};
|
||||
autocomplete = function(value) {};
|
||||
this.observe('value', _.debounce(autocomplete, 200), {
|
||||
'init': false
|
||||
});
|
||||
return this.on('submit', function() {
|
||||
var repo, reponame, username, _ref;
|
||||
_ref = this.get('value').split('/'), username = _ref[0], reponame = _ref[1];
|
||||
repo = github.getRepo(username, reponame);
|
||||
var name, owner, repo, _ref;
|
||||
_ref = this.get('value').split('/'), owner = _ref[0], name = _ref[1];
|
||||
repo = github.getRepo(owner, name);
|
||||
return repo.show(function(err, repo, xhr) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
mediator.fire('!projects/add', repo);
|
||||
return window.location.hash = '#';
|
||||
});
|
||||
});
|
||||
|
@ -24812,7 +24811,7 @@ requireModule('promise/polyfill').polyfill();
|
|||
},
|
||||
init: function() {
|
||||
var _this = this;
|
||||
return mediator.on('!projects/get', function(provider) {
|
||||
mediator.on('!projects/get', function(provider) {
|
||||
switch (provider) {
|
||||
case 'local':
|
||||
return localforage.getItem('projects', function(items) {
|
||||
|
@ -24825,6 +24824,12 @@ requireModule('promise/polyfill').polyfill();
|
|||
throw 'Not implemented yet';
|
||||
}
|
||||
});
|
||||
return mediator.on('!projects/add', function(repo) {
|
||||
return _this.push('items', {
|
||||
'owner': repo.owner.login,
|
||||
'name': repo.name
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -24941,7 +24946,7 @@ requireModule('promise/polyfill').polyfill();
|
|||
// projects.mustache
|
||||
root.require.register('burnchart/src/templates/projects.js', function(exports, require, module) {
|
||||
|
||||
module.exports = ["{{#projects.items}}"," <div id=\"projects\">"," <div class=\"header\">"," <a href=\"#\" class=\"sort\"><span class=\"icon sort-alphabet\"></span> Sorted by priority</a>"," <h2>Projects</h2>"," </div>",""," <table>"," {{#projects.items}}"," <tr>"," <td><a class=\"repo\" href=\"#\">demo/demo</a></td>"," <td><span class=\"milestone\">Milestone 1.0 <span class=\"icon down-open\"></span></a></td>"," <td>"," <div class=\"progress\">"," <span class=\"percent\">40%</span>"," <span class=\"due\">due on Friday</span>"," <div class=\"outer bar\">"," <div class=\"inner bar red\" style=\"width:40%\"></div>"," </div>"," </div>"," </td>"," </tr>"," {{/projects.items}}",""," <tr>"," <td><a class=\"repo\" href=\"#\">radekstepan/disposable</a></td>"," <td><span class=\"milestone\">Milestone 1.0 <span class=\"icon down-open\"></span></a></td>"," <td>"," <div class=\"progress\">"," <span class=\"percent\">40%</span>"," <span class=\"due\">due on Friday</span>"," <div class=\"outer bar\">"," <div class=\"inner bar red\" style=\"width:40%\"></div>"," </div>"," </div>"," </td>"," </tr>"," <tr class=\"done\">"," <td><a class=\"repo\" href=\"#\">radekstepan/burnchart</a></td>"," <td><span class=\"milestone\">Beta Milestone <span class=\"icon down-open\"></span></a></td>"," <td>"," <div class=\"progress\">"," <span class=\"percent\">100%</span>"," <span class=\"due\">due tomorrow</span>"," <div class=\"outer bar\">"," <div class=\"inner bar green\" style=\"width:100%\"></div>"," </div>"," </div>"," </td>"," </tr>"," <tr>"," <td><a class=\"repo\" href=\"#\">intermine/intermine</a></td>"," <td><span class=\"milestone\">Emma Release 96 <span class=\"icon down-open\"></span></a></td>"," <td>"," <div class=\"progress\">"," <span class=\"percent\">27%</span>"," <span class=\"due\">due in 2 weeks</span>"," <div class=\"outer bar\">"," <div class=\"inner bar red\" style=\"width:27%\"></div>"," </div>"," </div>"," </td>"," </tr>"," <tr>"," <td><a class=\"repo\" href=\"#\">microsoft/windows</a></td>"," <td><span class=\"milestone\">RC 9 <span class=\"icon down-open\"></span></a></td>"," <td>"," <div class=\"progress\">"," <span class=\"percent\">90%</span>"," <span class=\"due red\">overdue by a month</span>"," <div class=\"outer bar\">"," <div class=\"inner bar red\" style=\"width:90%\"></div>"," </div>"," </div>"," </td>"," </tr>"," </table>",""," <div class=\"footer\">"," <a href=\"#\"><span class=\"icon cog\"></span> Edit</a>"," </div>"," </div>","{{/projects.items}}"].join("\n");
|
||||
module.exports = ["{{#projects.items}}"," <div id=\"projects\">"," <div class=\"header\">"," <a href=\"#\" class=\"sort\"><span class=\"icon sort-alphabet\"></span> Sorted by priority</a>"," <h2>Projects</h2>"," </div>",""," <table>"," {{#projects.items}}"," <tr>"," <td><a class=\"repo\" href=\"#\">{{owner}}/{{name}}</a></td>"," <td><span class=\"milestone\">??? <span class=\"icon down-open\"></span></a></td>"," <td>"," <div class=\"progress\">"," <span class=\"percent\">10%</span>"," <span class=\"due\">???</span>"," <div class=\"outer bar\">"," <div class=\"inner bar green\" style=\"width:10%\"></div>"," </div>"," </div>"," </td>"," </tr>"," {{/projects.items}}",""," <tr>"," <td><a class=\"repo\" href=\"#\">radekstepan/disposable</a></td>"," <td><span class=\"milestone\">Milestone 1.0 <span class=\"icon down-open\"></span></a></td>"," <td>"," <div class=\"progress\">"," <span class=\"percent\">40%</span>"," <span class=\"due\">due on Friday</span>"," <div class=\"outer bar\">"," <div class=\"inner bar red\" style=\"width:40%\"></div>"," </div>"," </div>"," </td>"," </tr>"," <tr class=\"done\">"," <td><a class=\"repo\" href=\"#\">radekstepan/burnchart</a></td>"," <td><span class=\"milestone\">Beta Milestone <span class=\"icon down-open\"></span></a></td>"," <td>"," <div class=\"progress\">"," <span class=\"percent\">100%</span>"," <span class=\"due\">due tomorrow</span>"," <div class=\"outer bar\">"," <div class=\"inner bar green\" style=\"width:100%\"></div>"," </div>"," </div>"," </td>"," </tr>"," <tr>"," <td><a class=\"repo\" href=\"#\">intermine/intermine</a></td>"," <td><span class=\"milestone\">Emma Release 96 <span class=\"icon down-open\"></span></a></td>"," <td>"," <div class=\"progress\">"," <span class=\"percent\">27%</span>"," <span class=\"due\">due in 2 weeks</span>"," <div class=\"outer bar\">"," <div class=\"inner bar red\" style=\"width:27%\"></div>"," </div>"," </div>"," </td>"," </tr>"," <tr>"," <td><a class=\"repo\" href=\"#\">microsoft/windows</a></td>"," <td><span class=\"milestone\">RC 9 <span class=\"icon down-open\"></span></a></td>"," <td>"," <div class=\"progress\">"," <span class=\"percent\">90%</span>"," <span class=\"due red\">overdue by a month</span>"," <div class=\"outer bar\">"," <div class=\"inner bar red\" style=\"width:90%\"></div>"," </div>"," </div>"," </td>"," </tr>"," </table>",""," <div class=\"footer\">"," <a href=\"#\"><span class=\"icon cog\"></span> Edit</a>"," </div>"," </div>","{{/projects.items}}"].join("\n");
|
||||
});
|
||||
})();
|
||||
|
||||
|
|
|
@ -69,20 +69,19 @@
|
|||
'adapt': [Ractive.adaptors.Ractive],
|
||||
init: function() {
|
||||
var autocomplete;
|
||||
autocomplete = function(value) {
|
||||
return console.log('Autocomplete', value);
|
||||
};
|
||||
autocomplete = function(value) {};
|
||||
this.observe('value', _.debounce(autocomplete, 200), {
|
||||
'init': false
|
||||
});
|
||||
return this.on('submit', function() {
|
||||
var repo, reponame, username, _ref;
|
||||
_ref = this.get('value').split('/'), username = _ref[0], reponame = _ref[1];
|
||||
repo = github.getRepo(username, reponame);
|
||||
var name, owner, repo, _ref;
|
||||
_ref = this.get('value').split('/'), owner = _ref[0], name = _ref[1];
|
||||
repo = github.getRepo(owner, name);
|
||||
return repo.show(function(err, repo, xhr) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
mediator.fire('!projects/add', repo);
|
||||
return window.location.hash = '#';
|
||||
});
|
||||
});
|
||||
|
@ -264,7 +263,7 @@
|
|||
},
|
||||
init: function() {
|
||||
var _this = this;
|
||||
return mediator.on('!projects/get', function(provider) {
|
||||
mediator.on('!projects/get', function(provider) {
|
||||
switch (provider) {
|
||||
case 'local':
|
||||
return localforage.getItem('projects', function(items) {
|
||||
|
@ -277,6 +276,12 @@
|
|||
throw 'Not implemented yet';
|
||||
}
|
||||
});
|
||||
return mediator.on('!projects/add', function(repo) {
|
||||
return _this.push('items', {
|
||||
'owner': repo.owner.login,
|
||||
'name': repo.name
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -393,7 +398,7 @@
|
|||
// projects.mustache
|
||||
root.require.register('burnchart/src/templates/projects.js', function(exports, require, module) {
|
||||
|
||||
module.exports = ["{{#projects.items}}"," <div id=\"projects\">"," <div class=\"header\">"," <a href=\"#\" class=\"sort\"><span class=\"icon sort-alphabet\"></span> Sorted by priority</a>"," <h2>Projects</h2>"," </div>",""," <table>"," {{#projects.items}}"," <tr>"," <td><a class=\"repo\" href=\"#\">demo/demo</a></td>"," <td><span class=\"milestone\">Milestone 1.0 <span class=\"icon down-open\"></span></a></td>"," <td>"," <div class=\"progress\">"," <span class=\"percent\">40%</span>"," <span class=\"due\">due on Friday</span>"," <div class=\"outer bar\">"," <div class=\"inner bar red\" style=\"width:40%\"></div>"," </div>"," </div>"," </td>"," </tr>"," {{/projects.items}}",""," <tr>"," <td><a class=\"repo\" href=\"#\">radekstepan/disposable</a></td>"," <td><span class=\"milestone\">Milestone 1.0 <span class=\"icon down-open\"></span></a></td>"," <td>"," <div class=\"progress\">"," <span class=\"percent\">40%</span>"," <span class=\"due\">due on Friday</span>"," <div class=\"outer bar\">"," <div class=\"inner bar red\" style=\"width:40%\"></div>"," </div>"," </div>"," </td>"," </tr>"," <tr class=\"done\">"," <td><a class=\"repo\" href=\"#\">radekstepan/burnchart</a></td>"," <td><span class=\"milestone\">Beta Milestone <span class=\"icon down-open\"></span></a></td>"," <td>"," <div class=\"progress\">"," <span class=\"percent\">100%</span>"," <span class=\"due\">due tomorrow</span>"," <div class=\"outer bar\">"," <div class=\"inner bar green\" style=\"width:100%\"></div>"," </div>"," </div>"," </td>"," </tr>"," <tr>"," <td><a class=\"repo\" href=\"#\">intermine/intermine</a></td>"," <td><span class=\"milestone\">Emma Release 96 <span class=\"icon down-open\"></span></a></td>"," <td>"," <div class=\"progress\">"," <span class=\"percent\">27%</span>"," <span class=\"due\">due in 2 weeks</span>"," <div class=\"outer bar\">"," <div class=\"inner bar red\" style=\"width:27%\"></div>"," </div>"," </div>"," </td>"," </tr>"," <tr>"," <td><a class=\"repo\" href=\"#\">microsoft/windows</a></td>"," <td><span class=\"milestone\">RC 9 <span class=\"icon down-open\"></span></a></td>"," <td>"," <div class=\"progress\">"," <span class=\"percent\">90%</span>"," <span class=\"due red\">overdue by a month</span>"," <div class=\"outer bar\">"," <div class=\"inner bar red\" style=\"width:90%\"></div>"," </div>"," </div>"," </td>"," </tr>"," </table>",""," <div class=\"footer\">"," <a href=\"#\"><span class=\"icon cog\"></span> Edit</a>"," </div>"," </div>","{{/projects.items}}"].join("\n");
|
||||
module.exports = ["{{#projects.items}}"," <div id=\"projects\">"," <div class=\"header\">"," <a href=\"#\" class=\"sort\"><span class=\"icon sort-alphabet\"></span> Sorted by priority</a>"," <h2>Projects</h2>"," </div>",""," <table>"," {{#projects.items}}"," <tr>"," <td><a class=\"repo\" href=\"#\">{{owner}}/{{name}}</a></td>"," <td><span class=\"milestone\">??? <span class=\"icon down-open\"></span></a></td>"," <td>"," <div class=\"progress\">"," <span class=\"percent\">10%</span>"," <span class=\"due\">???</span>"," <div class=\"outer bar\">"," <div class=\"inner bar green\" style=\"width:10%\"></div>"," </div>"," </div>"," </td>"," </tr>"," {{/projects.items}}",""," <tr>"," <td><a class=\"repo\" href=\"#\">radekstepan/disposable</a></td>"," <td><span class=\"milestone\">Milestone 1.0 <span class=\"icon down-open\"></span></a></td>"," <td>"," <div class=\"progress\">"," <span class=\"percent\">40%</span>"," <span class=\"due\">due on Friday</span>"," <div class=\"outer bar\">"," <div class=\"inner bar red\" style=\"width:40%\"></div>"," </div>"," </div>"," </td>"," </tr>"," <tr class=\"done\">"," <td><a class=\"repo\" href=\"#\">radekstepan/burnchart</a></td>"," <td><span class=\"milestone\">Beta Milestone <span class=\"icon down-open\"></span></a></td>"," <td>"," <div class=\"progress\">"," <span class=\"percent\">100%</span>"," <span class=\"due\">due tomorrow</span>"," <div class=\"outer bar\">"," <div class=\"inner bar green\" style=\"width:100%\"></div>"," </div>"," </div>"," </td>"," </tr>"," <tr>"," <td><a class=\"repo\" href=\"#\">intermine/intermine</a></td>"," <td><span class=\"milestone\">Emma Release 96 <span class=\"icon down-open\"></span></a></td>"," <td>"," <div class=\"progress\">"," <span class=\"percent\">27%</span>"," <span class=\"due\">due in 2 weeks</span>"," <div class=\"outer bar\">"," <div class=\"inner bar red\" style=\"width:27%\"></div>"," </div>"," </div>"," </td>"," </tr>"," <tr>"," <td><a class=\"repo\" href=\"#\">microsoft/windows</a></td>"," <td><span class=\"milestone\">RC 9 <span class=\"icon down-open\"></span></a></td>"," <td>"," <div class=\"progress\">"," <span class=\"percent\">90%</span>"," <span class=\"due red\">overdue by a month</span>"," <div class=\"outer bar\">"," <div class=\"inner bar red\" style=\"width:90%\"></div>"," </div>"," </div>"," </td>"," </tr>"," </table>",""," <div class=\"footer\">"," <a href=\"#\"><span class=\"icon cog\"></span> Edit</a>"," </div>"," </div>","{{/projects.items}}"].join("\n");
|
||||
});
|
||||
})();
|
||||
|
||||
|
|
|
@ -14,17 +14,20 @@ module.exports = Ractive.extend
|
|||
'adapt': [ Ractive.adaptors.Ractive ]
|
||||
|
||||
init: ->
|
||||
# TODO: autocomplete on our username if we are logged in or based
|
||||
# on repos we already have.
|
||||
autocomplete = (value) ->
|
||||
console.log 'Autocomplete', value
|
||||
|
||||
@observe 'value', _.debounce(autocomplete, 200), { 'init': no }
|
||||
|
||||
# TODO: listen to Enter keypress.
|
||||
@on 'submit', ->
|
||||
[ username, reponame ] = @get('value').split('/')
|
||||
repo = github.getRepo username, reponame
|
||||
[ owner, name ] = @get('value').split('/')
|
||||
repo = github.getRepo owner, name
|
||||
repo.show (err, repo, xhr) ->
|
||||
throw err if err
|
||||
# TODO: save repo to us & Firebase.
|
||||
mediator.fire '!projects/add', repo
|
||||
# Redirect to the dashboard.
|
||||
# TODO: trigger a named route
|
||||
window.location.hash = '#'
|
|
@ -1,4 +1,5 @@
|
|||
mediator = require './mediator'
|
||||
user = require './user'
|
||||
RactiveModel = require './ractiveModel'
|
||||
|
||||
module.exports = new RactiveModel
|
||||
|
@ -7,11 +8,15 @@ module.exports = new RactiveModel
|
|||
'items': []
|
||||
|
||||
init: ->
|
||||
mediator.on '!projects/get', (provider) =>
|
||||
switch provider
|
||||
mediator.on '!projects/get', =>
|
||||
switch @get 'provider'
|
||||
when 'local'
|
||||
localforage.getItem 'projects', (items=[]) =>
|
||||
@set 'items', items
|
||||
|
||||
when 'github'
|
||||
throw 'Not implemented yet'
|
||||
throw 'Not implemented yet'
|
||||
|
||||
mediator.on '!projects/add', (repo) =>
|
||||
# TODO: deal with repo.hasIssues and warn if there are none.
|
||||
@push 'items', { 'owner': repo.owner.login, 'name': repo.name }
|
|
@ -13,4 +13,4 @@ module.exports = new RactiveModel
|
|||
init: ->
|
||||
# When we are changed, get our projects.
|
||||
@observe 'uid', ->
|
||||
mediator.fire '!projects/get', @get('provider')
|
||||
mediator.fire '!projects/get'
|
|
@ -8,14 +8,14 @@
|
|||
<table>
|
||||
{{#projects.items}}
|
||||
<tr>
|
||||
<td><a class="repo" href="#">demo/demo</a></td>
|
||||
<td><span class="milestone">Milestone 1.0 <span class="icon down-open"></span></a></td>
|
||||
<td><a class="repo" href="#">{{owner}}/{{name}}</a></td>
|
||||
<td><span class="milestone">??? <span class="icon down-open"></span></a></td>
|
||||
<td>
|
||||
<div class="progress">
|
||||
<span class="percent">40%</span>
|
||||
<span class="due">due on Friday</span>
|
||||
<span class="percent">10%</span>
|
||||
<span class="due">???</span>
|
||||
<div class="outer bar">
|
||||
<div class="inner bar red" style="width:40%"></div>
|
||||
<div class="inner bar green" style="width:10%"></div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
|
Loading…
Reference in New Issue