diff --git a/README.md b/README.md index cdffbb1..e46a3d2 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/public/js/app.bundle.js b/public/js/app.bundle.js index 11f50bc..b342b06 100644 --- a/public/js/app.bundle.js +++ b/public/js/app.bundle.js @@ -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}}","
","
"," Sorted by priority","

Projects

","
",""," "," {{#projects.items}}"," "," "," "," "," "," {{/projects.items}}",""," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ","
demo/demoMilestone 1.0 ","
"," 40%"," due on Friday","
","
","
","
","
radekstepan/disposableMilestone 1.0 ","
"," 40%"," due on Friday","
","
","
","
","
radekstepan/burnchartBeta Milestone ","
"," 100%"," due tomorrow","
","
","
","
","
intermine/intermineEmma Release 96 ","
"," 27%"," due in 2 weeks","
","
","
","
","
microsoft/windowsRC 9 ","
"," 90%"," overdue by a month","
","
","
","
","
","","
"," Edit","
","
","{{/projects.items}}"].join("\n"); + module.exports = ["{{#projects.items}}","
","
"," Sorted by priority","

Projects

","
",""," "," {{#projects.items}}"," "," "," "," "," "," {{/projects.items}}",""," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ","
{{owner}}/{{name}}??? ","
"," 10%"," ???","
","
","
","
","
radekstepan/disposableMilestone 1.0 ","
"," 40%"," due on Friday","
","
","
","
","
radekstepan/burnchartBeta Milestone ","
"," 100%"," due tomorrow","
","
","
","
","
intermine/intermineEmma Release 96 ","
"," 27%"," due in 2 weeks","
","
","
","
","
microsoft/windowsRC 9 ","
"," 90%"," overdue by a month","
","
","
","
","
","","
"," Edit","
","
","{{/projects.items}}"].join("\n"); }); })(); diff --git a/public/js/app.js b/public/js/app.js index 1ca3008..a64c2e4 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -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}}","
","
"," Sorted by priority","

Projects

","
",""," "," {{#projects.items}}"," "," "," "," "," "," {{/projects.items}}",""," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ","
demo/demoMilestone 1.0 ","
"," 40%"," due on Friday","
","
","
","
","
radekstepan/disposableMilestone 1.0 ","
"," 40%"," due on Friday","
","
","
","
","
radekstepan/burnchartBeta Milestone ","
"," 100%"," due tomorrow","
","
","
","
","
intermine/intermineEmma Release 96 ","
"," 27%"," due in 2 weeks","
","
","
","
","
microsoft/windowsRC 9 ","
"," 90%"," overdue by a month","
","
","
","
","
","","
"," Edit","
","
","{{/projects.items}}"].join("\n"); + module.exports = ["{{#projects.items}}","
","
"," Sorted by priority","

Projects

","
",""," "," {{#projects.items}}"," "," "," "," "," "," {{/projects.items}}",""," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ","
{{owner}}/{{name}}??? ","
"," 10%"," ???","
","
","
","
","
radekstepan/disposableMilestone 1.0 ","
"," 40%"," due on Friday","
","
","
","
","
radekstepan/burnchartBeta Milestone ","
"," 100%"," due tomorrow","
","
","
","
","
intermine/intermineEmma Release 96 ","
"," 27%"," due in 2 weeks","
","
","
","
","
microsoft/windowsRC 9 ","
"," 90%"," overdue by a month","
","
","
","
","
","","
"," Edit","
","
","{{/projects.items}}"].join("\n"); }); })(); diff --git a/src/components/addProjectForm.coffee b/src/components/addProjectForm.coffee index 15d85ef..5539809 100644 --- a/src/components/addProjectForm.coffee +++ b/src/components/addProjectForm.coffee @@ -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 = '#' \ No newline at end of file diff --git a/src/modules/projects.coffee b/src/modules/projects.coffee index dfa2a96..9612d6a 100644 --- a/src/modules/projects.coffee +++ b/src/modules/projects.coffee @@ -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' \ No newline at end of file + 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 } \ No newline at end of file diff --git a/src/modules/user.coffee b/src/modules/user.coffee index 76e54bd..503eb89 100644 --- a/src/modules/user.coffee +++ b/src/modules/user.coffee @@ -13,4 +13,4 @@ module.exports = new RactiveModel init: -> # When we are changed, get our projects. @observe 'uid', -> - mediator.fire '!projects/get', @get('provider') \ No newline at end of file + mediator.fire '!projects/get' \ No newline at end of file diff --git a/src/templates/projects.mustache b/src/templates/projects.mustache index 981a1f9..22a36fe 100644 --- a/src/templates/projects.mustache +++ b/src/templates/projects.mustache @@ -8,14 +8,14 @@ {{#projects.items}} - - + +
demo/demoMilestone 1.0 {{owner}}/{{name}}???
- 40% - due on Friday + 10% + ???
-
+