From c676c6ae68f4a0094264fc8b3878d9d38838b490 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Sun, 5 Feb 2017 15:59:41 +0800 Subject: [PATCH] Show open/closed proposals --- app/components/proposal-list/component.js | 5 ++++ app/components/proposal-list/template.hbs | 11 ++++++++ app/controllers/index.js | 26 +++++++++++++++++++ app/models/contributor.js | 1 + app/templates/index.hbs | 20 ++++++++++++++ .../proposal-list/component-test.js | 16 ++++++++++++ 6 files changed, 79 insertions(+) create mode 100644 app/components/proposal-list/component.js create mode 100644 app/components/proposal-list/template.hbs create mode 100644 tests/integration/components/proposal-list/component-test.js diff --git a/app/components/proposal-list/component.js b/app/components/proposal-list/component.js new file mode 100644 index 0000000..47cb2d4 --- /dev/null +++ b/app/components/proposal-list/component.js @@ -0,0 +1,5 @@ +import Ember from 'ember'; + +export default Ember.Component.extend({ + +}); diff --git a/app/components/proposal-list/template.hbs b/app/components/proposal-list/template.hbs new file mode 100644 index 0000000..4e45070 --- /dev/null +++ b/app/components/proposal-list/template.hbs @@ -0,0 +1,11 @@ + diff --git a/app/controllers/index.js b/app/controllers/index.js index d687d6d..6661e2a 100644 --- a/app/controllers/index.js +++ b/app/controllers/index.js @@ -13,4 +13,30 @@ export default Ember.Controller.extend({ contractInteractionEnabled: computed.alias('kredits.web3Provided'), + proposalsOpen: function() { + let proposals = this.get('model.proposals') + .filterBy('executed', false) + .map(p => { + p.recipientName = this.findContributorByAddress(p.recipientAddress).github_username; + return p; + }); + return proposals; + }.property('model.proposals.[]', 'model.contributors.[]'), + + proposalsClosed: function() { + let proposals = this.get('model.proposals') + .filterBy('executed', true) + .map(p => { + p.recipientName = this.findContributorByAddress(p.recipientAddress).github_username; + return p; + }); + return proposals; + }.property('model.proposals.[]', 'model.contributors.[]'), + + findContributorByAddress(address) { + return this.get('model.contributors') + .findBy('address', address); + } + + }); diff --git a/app/models/contributor.js b/app/models/contributor.js index 3402308..07c490c 100644 --- a/app/models/contributor.js +++ b/app/models/contributor.js @@ -5,6 +5,7 @@ export default Ember.Object.extend({ github_username: null, github_uid: null, kredits: null, + address: null, avatarURL: function() { return `https\:\/\/avatars2.githubusercontent.com/u/${this.get('github_uid')}?v=3&s=128`; diff --git a/app/templates/index.hbs b/app/templates/index.hbs index da91456..b50049f 100644 --- a/app/templates/index.hbs +++ b/app/templates/index.hbs @@ -13,6 +13,26 @@ +{{#if proposalsOpen}} +
+
+

Open Proposals

+
+
+ {{proposal-list proposals=proposalsOpen}} +
+
+{{/if}} + +
+
+

Closed Proposals

+
+
+ {{proposal-list proposals=proposalsClosed}} +
+
+ {{#if contractInteractionEnabled}}
diff --git a/tests/integration/components/proposal-list/component-test.js b/tests/integration/components/proposal-list/component-test.js new file mode 100644 index 0000000..55be0bb --- /dev/null +++ b/tests/integration/components/proposal-list/component-test.js @@ -0,0 +1,16 @@ +import { moduleForComponent, test } from 'ember-qunit'; +import hbs from 'htmlbars-inline-precompile'; + +moduleForComponent('proposal-list', 'Integration | Component | proposal list', { + integration: true +}); + +test('it renders', function(assert) { + + // Set any properties with this.set('myProperty', 'value'); + // Handle any actions with this.on('myAction', function(val) { ... }); + + this.render(hbs`{{proposal-list}}`); + + assert.equal(this.$().text().trim(), ''); +});