From 22a9786168d8c6c3837c0e6cb3e9289bd89906c6 Mon Sep 17 00:00:00 2001
From: Sebastian Kippe
Date: Thu, 23 May 2019 09:46:09 +0200
Subject: [PATCH 01/13] Add contribution basics
---
app/components/add-contribution/component.js | 72 ++++++++++++++++++++
app/components/add-contribution/template.hbs | 58 ++++++++++++++++
app/controllers/contributions/new.js | 28 ++++++++
app/router.js | 3 +
app/services/kredits.js | 11 +++
app/templates/contributions/new.hbs | 10 +++
package-lock.json | 51 ++++++++++++++
package.json | 1 +
8 files changed, 234 insertions(+)
create mode 100644 app/components/add-contribution/component.js
create mode 100644 app/components/add-contribution/template.hbs
create mode 100644 app/controllers/contributions/new.js
create mode 100644 app/templates/contributions/new.hbs
diff --git a/app/components/add-contribution/component.js b/app/components/add-contribution/component.js
new file mode 100644
index 0000000..205e8f1
--- /dev/null
+++ b/app/components/add-contribution/component.js
@@ -0,0 +1,72 @@
+import Component from '@ember/component';
+import { computed } from '@ember/object';
+import { and, notEmpty } from '@ember/object/computed';
+
+export default Component.extend({
+
+ attributes: null,
+ contributors: Object.freeze([]),
+
+ isValidContributor: notEmpty('contributorId'),
+ isValidKind: notEmpty('kind'),
+ isValidAmount: computed('amount', function() {
+ return parseInt(this.amount, 10) > 0;
+ }),
+ isValidDescription: notEmpty('description'),
+ isValidUrl: notEmpty('url'),
+ isValid: and('isValidContributor',
+ 'isValidKind',
+ 'isValidAmount',
+ 'isValidDescription'),
+
+ init () {
+ this._super(...arguments);
+ this.set('defaultDate', new Date());
+
+ // Default attributes used by reset
+ this.set('attributes', {
+ contributorId: null,
+ kind: null,
+ date: [new Date()],
+ amount: null,
+ description: null,
+ url: null,
+ });
+
+ this.reset();
+ },
+
+ reset () {
+ this.setProperties(this.attributes);
+ },
+
+ actions: {
+
+ submit () {
+ if (!this.isValid) {
+ alert('Invalid data. Please review and try again.');
+ return;
+ }
+
+ const attributes = this.getProperties(Object.keys(this.attributes));
+ const [ date/* , time */ ] = attributes.date[0].toISOString().split('T');
+ attributes.date = date;
+
+ this.set('inProgress', true);
+
+ this.save(attributes)
+ .then(contribution => {
+ console.debug('contribution', contribution);
+ this.reset();
+ window.scroll(0,0);
+ }, err => {
+ console.warn(err);
+ window.alert('Fail');
+ })
+ .finally(() => this.set('inProgress', false));
+
+ }
+
+ }
+
+});
diff --git a/app/components/add-contribution/template.hbs b/app/components/add-contribution/template.hbs
new file mode 100644
index 0000000..948e9db
--- /dev/null
+++ b/app/components/add-contribution/template.hbs
@@ -0,0 +1,58 @@
+
+
diff --git a/app/controllers/contributions/new.js b/app/controllers/contributions/new.js
new file mode 100644
index 0000000..9baa5d3
--- /dev/null
+++ b/app/controllers/contributions/new.js
@@ -0,0 +1,28 @@
+import Controller from '@ember/controller';
+import { alias, filterBy, sort } from '@ember/object/computed';
+import { inject as service } from '@ember/service';
+
+export default Controller.extend({
+
+ kredits: service(),
+
+ contributors: alias('kredits.contributors'),
+ minedContributors: filterBy('contributors', 'id'),
+ sortedContributors: sort('minedContributors', Object.freeze(['name:asc'])),
+
+ actions: {
+
+ save (contribution) {
+ const contributor = this.contributors.findBy('id', contribution.contributorId);
+ contribution.contributorIpfsHash = contributor.ipfsHash;
+
+ return this.kredits.addContribution(contribution)
+ .then(contribution => {
+ this.transitionToRoute('index');
+ return contribution;
+ });
+ }
+
+ }
+
+});
diff --git a/app/router.js b/app/router.js
index 53708e0..7a49d13 100644
--- a/app/router.js
+++ b/app/router.js
@@ -10,6 +10,9 @@ Router.map(function() {
this.route('proposals', function() {
this.route('new');
});
+ this.route('contributions', function() {
+ this.route('new');
+ });
});
export default Router;
diff --git a/app/services/kredits.js b/app/services/kredits.js
index 2eee5c0..c5362cc 100644
--- a/app/services/kredits.js
+++ b/app/services/kredits.js
@@ -203,6 +203,17 @@ export default Service.extend({
});
},
+ addContribution(attributes) {
+ console.debug('[kredits] add contribution', attributes);
+
+ return this.kredits.Contribution.addContribution(attributes)
+ .then(data => {
+ console.debug('[kredits] add contribution response', data);
+ attributes.contributor = this.contributors.findBy('id', attributes.contributorId);
+ return Contribution.create(attributes);
+ });
+ },
+
addProposal(attributes) {
console.debug('[kredits] add proposal', attributes);
diff --git a/app/templates/contributions/new.hbs b/app/templates/contributions/new.hbs
new file mode 100644
index 0000000..4c375f3
--- /dev/null
+++ b/app/templates/contributions/new.hbs
@@ -0,0 +1,10 @@
+
+
+ Submit a contribution
+
+
+
+ {{add-contribution contributors=minedContributors save=(action "save")}}
+
+
+
diff --git a/package-lock.json b/package-lock.json
index cc8d49b..bb54c5d 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -6515,6 +6515,38 @@
"semver": "^5.3.0"
}
},
+ "ember-diff-attrs": {
+ "version": "0.2.2",
+ "resolved": "https://registry.npmjs.org/ember-diff-attrs/-/ember-diff-attrs-0.2.2.tgz",
+ "integrity": "sha512-dziQ8G8QVRMqSFMg2l9E+Te19kcwk7+Aad7Q8lOci2b3EAiU7s0IFB3Z8rRed0JRJ3e6mPJyRmNbyUuNoyCM8g==",
+ "dev": true,
+ "requires": {
+ "ember-cli-babel": "^6.16.0"
+ },
+ "dependencies": {
+ "ember-cli-babel": {
+ "version": "6.18.0",
+ "resolved": "https://registry.npmjs.org/ember-cli-babel/-/ember-cli-babel-6.18.0.tgz",
+ "integrity": "sha512-7ceC8joNYxY2wES16iIBlbPSxwKDBhYwC8drU3ZEvuPDMwVv1KzxCNu1fvxyFEBWhwaRNTUxSCsEVoTd9nosGA==",
+ "dev": true,
+ "requires": {
+ "amd-name-resolver": "1.2.0",
+ "babel-plugin-debug-macros": "^0.2.0-beta.6",
+ "babel-plugin-ember-modules-api-polyfill": "^2.6.0",
+ "babel-plugin-transform-es2015-modules-amd": "^6.24.0",
+ "babel-polyfill": "^6.26.0",
+ "babel-preset-env": "^1.7.0",
+ "broccoli-babel-transpiler": "^6.5.0",
+ "broccoli-debug": "^0.6.4",
+ "broccoli-funnel": "^2.0.0",
+ "broccoli-source": "^1.1.0",
+ "clone": "^2.0.0",
+ "ember-cli-version-checker": "^2.1.2",
+ "semver": "^5.5.0"
+ }
+ }
+ }
+ },
"ember-export-application-global": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ember-export-application-global/-/ember-export-application-global-2.0.0.tgz",
@@ -6547,6 +6579,19 @@
}
}
},
+ "ember-flatpickr": {
+ "version": "2.14.0",
+ "resolved": "https://registry.npmjs.org/ember-flatpickr/-/ember-flatpickr-2.14.0.tgz",
+ "integrity": "sha512-YId4mRiVVYm74TWVaoKeWK0Ma8QY46dloZura9gkG3n+HADTTCerRvqZv5l6J7XaLzTC7bwXkf+4wOz3sYXmUQ==",
+ "dev": true,
+ "requires": {
+ "ember-cli-babel": "^7.1.2",
+ "ember-cli-node-assets": "^0.2.2",
+ "ember-diff-attrs": "^0.2.2",
+ "fastboot-transform": "^0.1.3",
+ "flatpickr": "4.5.2"
+ }
+ },
"ember-load-initializers": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/ember-load-initializers/-/ember-load-initializers-1.1.0.tgz",
@@ -8392,6 +8437,12 @@
"integrity": "sha1-Hxik2TgVLUlZZfnJWNkjqy3WabQ=",
"dev": true
},
+ "flatpickr": {
+ "version": "4.5.2",
+ "resolved": "https://registry.npmjs.org/flatpickr/-/flatpickr-4.5.2.tgz",
+ "integrity": "sha512-jDy4QYGpmiy7+Qk8QvKJ4spjDdxcx9cxMydmq1x427HkKWBw0qizLYeYM2F6tMcvvqGjU5VpJS55j4LnsaBblA==",
+ "dev": true
+ },
"follow-redirects": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.7.0.tgz",
diff --git a/package.json b/package.json
index bf43f95..6486fc2 100644
--- a/package.json
+++ b/package.json
@@ -45,6 +45,7 @@
"ember-cli-uglify": "^2.1.0",
"ember-cli-update": "^0.21.2",
"ember-export-application-global": "^2.0.0",
+ "ember-flatpickr": "^2.14.0",
"ember-load-initializers": "^1.1.0",
"ember-macro-helpers": "0.17.0",
"ember-maybe-import-regenerator": "^0.1.6",
From cec87f6caff2cca1e67cfba16c2917d94f15351d Mon Sep 17 00:00:00 2001
From: Sebastian Kippe
Date: Thu, 23 May 2019 10:22:37 +0200
Subject: [PATCH 02/13] Dat gas issue
---
app/services/kredits.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/services/kredits.js b/app/services/kredits.js
index c5362cc..fcfbf71 100644
--- a/app/services/kredits.js
+++ b/app/services/kredits.js
@@ -206,7 +206,7 @@ export default Service.extend({
addContribution(attributes) {
console.debug('[kredits] add contribution', attributes);
- return this.kredits.Contribution.addContribution(attributes)
+ return this.kredits.Contribution.addContribution(attributes, { gasLimit: 300000 })
.then(data => {
console.debug('[kredits] add contribution response', data);
attributes.contributor = this.contributors.findBy('id', attributes.contributorId);
From fad10ec1eae453cdb06bd371119fb0f9149ae891 Mon Sep 17 00:00:00 2001
From: Sebastian Kippe
Date: Thu, 23 May 2019 10:29:18 +0200
Subject: [PATCH 03/13] Use sorted contributor list for dropdown
---
app/controllers/contributions/new.js | 4 +++-
app/templates/contributions/new.hbs | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/app/controllers/contributions/new.js b/app/controllers/contributions/new.js
index 9baa5d3..75e00c6 100644
--- a/app/controllers/contributions/new.js
+++ b/app/controllers/contributions/new.js
@@ -8,7 +8,9 @@ export default Controller.extend({
contributors: alias('kredits.contributors'),
minedContributors: filterBy('contributors', 'id'),
- sortedContributors: sort('minedContributors', Object.freeze(['name:asc'])),
+
+ contributorsSorting: Object.freeze(['name:asc']),
+ sortedContributors: sort('minedContributors', 'contributorsSorting'),
actions: {
diff --git a/app/templates/contributions/new.hbs b/app/templates/contributions/new.hbs
index 4c375f3..da594a1 100644
--- a/app/templates/contributions/new.hbs
+++ b/app/templates/contributions/new.hbs
@@ -4,7 +4,7 @@
- {{add-contribution contributors=minedContributors save=(action "save")}}
+ {{add-contribution contributors=sortedContributors save=(action "save")}}
From 9a98b37bb6611d1c3948ca708623e3a2fdc347f6 Mon Sep 17 00:00:00 2001
From: Sebastian Kippe
Date: Thu, 23 May 2019 10:29:31 +0200
Subject: [PATCH 04/13] Improve error message
---
app/components/add-contribution/component.js | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/app/components/add-contribution/component.js b/app/components/add-contribution/component.js
index 205e8f1..0c73016 100644
--- a/app/components/add-contribution/component.js
+++ b/app/components/add-contribution/component.js
@@ -55,13 +55,12 @@ export default Component.extend({
this.set('inProgress', true);
this.save(attributes)
- .then(contribution => {
- console.debug('contribution', contribution);
+ .then((/*contribution*/) => {
this.reset();
window.scroll(0,0);
}, err => {
console.warn(err);
- window.alert('Fail');
+ window.alert('Something went wrong. Check the browser console for details.');
})
.finally(() => this.set('inProgress', false));
From 8bd4c6e6e1465b3a16a5627a29a0ac6327458265 Mon Sep 17 00:00:00 2001
From: Sebastian Kippe
Date: Thu, 23 May 2019 10:36:27 +0200
Subject: [PATCH 05/13] Use common forms partial for form styles
---
app/components/add-contribution/template.hbs | 2 +-
app/styles/{components/_add-contributor.scss => _forms.scss} | 4 +++-
app/styles/app.scss | 2 +-
3 files changed, 5 insertions(+), 3 deletions(-)
rename app/styles/{components/_add-contributor.scss => _forms.scss} (96%)
diff --git a/app/components/add-contribution/template.hbs b/app/components/add-contribution/template.hbs
index 948e9db..b5e7d20 100644
--- a/app/components/add-contribution/template.hbs
+++ b/app/components/add-contribution/template.hbs
@@ -52,7 +52,7 @@
{{input type="submit"
disabled=inProgress
value=(if inProgress "Processing" "Save")}}
- {{#link-to "index"}}Back{{/link-to}}
+ {{#link-to "index"}}Cancel{{/link-to}}
diff --git a/app/styles/components/_add-contributor.scss b/app/styles/_forms.scss
similarity index 96%
rename from app/styles/components/_add-contributor.scss
rename to app/styles/_forms.scss
index c39f8b9..5732e80 100644
--- a/app/styles/components/_add-contributor.scss
+++ b/app/styles/_forms.scss
@@ -1,4 +1,6 @@
-section#add-contributor, section#add-proposal {
+section#add-contributor,
+section#add-contribution,
+section#add-proposal {
form {
diff --git a/app/styles/app.scss b/app/styles/app.scss
index d5e0f28..cac8311 100644
--- a/app/styles/app.scss
+++ b/app/styles/app.scss
@@ -96,10 +96,10 @@ section {
}
@import "buttons";
+@import "forms";
@import "components/topbar";
@import "components/loading-spinner";
@import "components/contributor-list";
-@import "components/add-contributor";
@import "components/proposal-list";
@import "components/contribution-list";
@import "components/user-avatar";
From c30c6c2b362d81e3c694f5e5bd533b0ffdd6e0c7 Mon Sep 17 00:00:00 2001
From: Sebastian Kippe
Date: Thu, 23 May 2019 12:18:02 +0200
Subject: [PATCH 06/13] Refactor layout and button styles
* Add single-column layout for forms
* Add optional nav/buttons to section headers
---
app/components/add-contribution/template.hbs | 1 -
app/styles/_buttons.scss | 14 +++++-
app/styles/_forms.scss | 4 +-
app/styles/_layout.scss | 45 ++++++++++++++++++--
app/templates/contributions/new.hbs | 19 +++++----
app/templates/index.hbs | 14 +++---
6 files changed, 74 insertions(+), 23 deletions(-)
diff --git a/app/components/add-contribution/template.hbs b/app/components/add-contribution/template.hbs
index b5e7d20..831c498 100644
--- a/app/components/add-contribution/template.hbs
+++ b/app/components/add-contribution/template.hbs
@@ -52,7 +52,6 @@
{{input type="submit"
disabled=inProgress
value=(if inProgress "Processing" "Save")}}
- {{#link-to "index"}}Cancel{{/link-to}}
diff --git a/app/styles/_buttons.scss b/app/styles/_buttons.scss
index 8a6956a..41780e2 100644
--- a/app/styles/_buttons.scss
+++ b/app/styles/_buttons.scss
@@ -1,4 +1,4 @@
-button, input[type=submit] {
+button, input[type=submit], .button {
display: inline-block;
padding: 0.6rem 2rem;
background-color: rgba(22, 21, 40, 0.6);
@@ -6,6 +6,7 @@ button, input[type=submit] {
border-radius: 3px;
color: $primary-color;
font-weight: 500;
+ text-decoration: none;
text-transform: uppercase;
cursor: pointer;
letter-spacing: 0.1em;
@@ -22,9 +23,20 @@ button, input[type=submit] {
&.danger {
color: $red;
background-color: rgba(40, 21, 21, 0.6);
+ border-color: rgba(40, 21, 21, 1);
&:hover {
background-color: rgba(40, 21, 21, 0.8);
}
}
+
+ &.green {
+ color: $green;
+ background-color: rgba(21, 40, 21, 0.6);
+ border-color: rgba(21, 40, 21, 1);
+
+ &:hover {
+ background-color: rgba(21, 40, 21, 0.8);
+ }
+ }
}
diff --git a/app/styles/_forms.scss b/app/styles/_forms.scss
index 5732e80..6a8debd 100644
--- a/app/styles/_forms.scss
+++ b/app/styles/_forms.scss
@@ -5,10 +5,10 @@ section#add-proposal {
form {
p {
- margin-bottom: 1rem;
+ margin-bottom: 1.5rem;
&.actions {
- padding-top: 1rem;
+ padding-top: 1.5rem;
text-align: center;
a {
color: $primary-color;
diff --git a/app/styles/_layout.scss b/app/styles/_layout.scss
index 2655bdc..98552e1 100644
--- a/app/styles/_layout.scss
+++ b/app/styles/_layout.scss
@@ -13,6 +13,21 @@ main {
"stats"
"contributions";
}
+
+ &.center-column {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+
+ section {
+ width: 600px;
+ max-width: 100%;
+
+ header {
+ text-align: center;
+ }
+ }
+ }
}
@media (min-width: 550px) {
@@ -39,11 +54,35 @@ main section {
}
header {
- padding-bottom: 3rem;
- text-align: center;
+ margin-bottom: 3rem;
+
+ &.with-nav {
+ display: grid;
+ grid-template-columns: auto 5rem;
+ grid-template-areas:
+ "title" "actions";
+
+ @include media-min(medium) {
+ grid-template-columns: auto 5rem 1.2rem;
+ grid-template-areas:
+ "title" "actions" "padding";
+ }
+ }
+
+ h2 {
+ display: inline-block;
+ // padding-left: 1.2rem;
+ }
+
+ nav {
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+ justify-content: flex-end;
+ }
@include media-max(small) {
- padding-bottom: 2rem;
+ margin-bottom: 2rem;
}
}
}
diff --git a/app/templates/contributions/new.hbs b/app/templates/contributions/new.hbs
index da594a1..c7b5ffb 100644
--- a/app/templates/contributions/new.hbs
+++ b/app/templates/contributions/new.hbs
@@ -1,10 +1,13 @@
-
-
- Submit a contribution
-
+
-
- {{add-contribution contributors=sortedContributors save=(action "save")}}
-
-
+
+
+ Submit a contribution
+
+
+ {{add-contribution contributors=sortedContributors save=(action "save")}}
+
+
+
+
diff --git a/app/templates/index.hbs b/app/templates/index.hbs
index 726e927..4f8c82b 100644
--- a/app/templates/index.hbs
+++ b/app/templates/index.hbs
@@ -33,8 +33,13 @@
{{#if contributionsUnconfirmed}}
-
+
Latest Contributions
+ {{#if kredits.hasAccounts}}
+
+ {{link-to "add" "contributions.new" title="Submit a contribution" class="button small green"}}
+
+ {{/if}}
{{!-- TODO: We need a better naming for kredits.hasAccounts --}}
@@ -53,13 +58,6 @@
{{contribution-list contributions=contributionsConfirmedSorted
vetoContribution=(action "vetoContribution")}}
-
- {{!-- TODO: We need a better naming --}}
- {{#if kredits.hasAccounts}}
-
- {{#link-to "proposals.new"}}Create new proposal{{/link-to}}
-
- {{/if}}
From af9951ca5ab2583c99904270ff7626cc72613029 Mon Sep 17 00:00:00 2001
From: Sebastian Kippe
Date: Thu, 23 May 2019 12:48:18 +0200
Subject: [PATCH 07/13] Add newly created contributions to collection
---
app/services/kredits.js | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/app/services/kredits.js b/app/services/kredits.js
index fcfbf71..58996b6 100644
--- a/app/services/kredits.js
+++ b/app/services/kredits.js
@@ -210,7 +210,11 @@ export default Service.extend({
.then(data => {
console.debug('[kredits] add contribution response', data);
attributes.contributor = this.contributors.findBy('id', attributes.contributorId);
- return Contribution.create(attributes);
+ const contribution = Contribution.create(attributes);
+ // TODO receive from wrapper
+ contribution.set('confirmedAtBlock', data.blockNumber + 40320);
+ this.contributions.pushObject(contribution);
+ return contribution;
});
},
From 4efd6f8f8861f5851a7df2fbcf70565e209db1c0 Mon Sep 17 00:00:00 2001
From: Sebastian Kippe
Date: Thu, 23 May 2019 14:09:20 +0200
Subject: [PATCH 08/13] Improve whitespace a bit
---
app/styles/_layout.scss | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/app/styles/_layout.scss b/app/styles/_layout.scss
index 98552e1..932e63b 100644
--- a/app/styles/_layout.scss
+++ b/app/styles/_layout.scss
@@ -3,7 +3,11 @@
}
main {
- padding: 1rem;
+ padding: 1rem 2rem;
+
+ @include media-max(small) {
+ padding: 1rem;
+ }
index {
width: 100%;
@@ -61,12 +65,6 @@ main section {
grid-template-columns: auto 5rem;
grid-template-areas:
"title" "actions";
-
- @include media-min(medium) {
- grid-template-columns: auto 5rem 1.2rem;
- grid-template-areas:
- "title" "actions" "padding";
- }
}
h2 {
From 16ee3b6b6b6fdfcbad6b7988eefdcd4811f39279 Mon Sep 17 00:00:00 2001
From: Sebastian Kippe
Date: Thu, 23 May 2019 14:17:33 +0200
Subject: [PATCH 09/13] Move contributor-creation form for separate view
closes #74
---
app/components/add-contributor/component.js | 10 ++++-----
app/controllers/contributors/new.js | 23 +++++++++++++++++++++
app/controllers/index.js | 8 -------
app/router.js | 3 +++
app/services/kredits.js | 4 +++-
app/templates/contributors/new.hbs | 13 ++++++++++++
app/templates/index.hbs | 23 ++++++---------------
7 files changed, 53 insertions(+), 31 deletions(-)
create mode 100644 app/controllers/contributors/new.js
create mode 100644 app/templates/contributors/new.hbs
diff --git a/app/components/add-contributor/component.js b/app/components/add-contributor/component.js
index 7e3b821..954ca99 100644
--- a/app/components/add-contributor/component.js
+++ b/app/components/add-contributor/component.js
@@ -3,6 +3,7 @@ import { and, notEmpty } from '@ember/object/computed';
import { inject as service } from '@ember/service';
export default Component.extend({
+
kredits: service(),
attributes: null,
@@ -36,10 +37,7 @@ export default Component.extend({
gitea_username: null,
wiki_username: null
});
- },
- didInsertElement() {
- this._super(...arguments);
this.reset();
},
@@ -48,7 +46,8 @@ export default Component.extend({
},
actions: {
- submit() {
+
+ submit () {
if (!this.isValid) {
alert('Invalid data. Please review and try again.');
return;
@@ -63,12 +62,13 @@ export default Component.extend({
this.reset();
window.scroll(0,0);
}).catch(err => {
- console.log(err);
+ console.warn(err);
window.alert('Something went wrong. Please check the browser console.');
}).finally(() => {
this.set('inProgress', false);
});
}
+
}
});
diff --git a/app/controllers/contributors/new.js b/app/controllers/contributors/new.js
new file mode 100644
index 0000000..ed7a1f6
--- /dev/null
+++ b/app/controllers/contributors/new.js
@@ -0,0 +1,23 @@
+import Controller from '@ember/controller';
+import { alias } from '@ember/object/computed';
+import { inject as service } from '@ember/service';
+
+export default Controller.extend({
+
+ kredits: service(),
+
+ contributors: alias('kredits.contributors'),
+
+ actions: {
+
+ save (contributor) {
+ return this.kredits.addContributor(contributor)
+ .then(contributor => {
+ this.transitionToRoute('index');
+ return contributor;
+ });
+ }
+
+ }
+
+});
diff --git a/app/controllers/index.js b/app/controllers/index.js
index 9c614c7..dd7bb56 100644
--- a/app/controllers/index.js
+++ b/app/controllers/index.js
@@ -37,14 +37,6 @@ export default Controller.extend({
this.kredits.vote(proposalId).then(transaction => {
console.debug('[controllers:index] Vote submitted to Ethereum blockhain: '+transaction.hash);
});
- },
-
- save (contributor) {
- return this.kredits.addContributor(contributor)
- .then(contributor => {
- this.contributors.pushObject(contributor);
- return contributor;
- });
}
}
diff --git a/app/router.js b/app/router.js
index 7a49d13..afa8660 100644
--- a/app/router.js
+++ b/app/router.js
@@ -13,6 +13,9 @@ Router.map(function() {
this.route('contributions', function() {
this.route('new');
});
+ this.route('contributors', function() {
+ this.route('new');
+ });
});
export default Router;
diff --git a/app/services/kredits.js b/app/services/kredits.js
index 58996b6..8eb6bbb 100644
--- a/app/services/kredits.js
+++ b/app/services/kredits.js
@@ -190,7 +190,9 @@ export default Service.extend({
return this.kredits.Contributor.add(attributes, { gasLimit: 350000 })
.then(data => {
console.debug('[kredits] add contributor response', data);
- return Contributor.create(attributes);
+ const contributor = Contributor.create(attributes);
+ this.contributors.pushObject(contributor);
+ return contributor;
});
},
diff --git a/app/templates/contributors/new.hbs b/app/templates/contributors/new.hbs
new file mode 100644
index 0000000..8351f57
--- /dev/null
+++ b/app/templates/contributors/new.hbs
@@ -0,0 +1,13 @@
+
+
+
+
+ Add contributor profile
+
+
+
+ {{add-contributor contributors=contributors save=(action "save")}}
+
+
+
+
diff --git a/app/templates/index.hbs b/app/templates/index.hbs
index 4f8c82b..58fc3f0 100644
--- a/app/templates/index.hbs
+++ b/app/templates/index.hbs
@@ -2,8 +2,13 @@
-
+
Contributors
+ {{#if kredits.hasAccounts}}
+
+ {{link-to "add" "contributors.new" title="Add contributor profile" class="button small green"}}
+
+ {{/if}}
{{contributor-list contributorList=kreditsToplist
@@ -61,20 +66,4 @@
- {{#if kredits.hasAccounts}}
-
-
-
-
- {{#if kredits.currentUser.isCore}}
- {{add-contributor contributors=contributors save=(action "save")}}
- {{else}}
- Only core team members can add new contributors. Please ask someone to set you up.
- {{/if}}
-
-
- {{/if}}
-
From 883b5dc415e4ac3cdd2e58fec0b344a1d2a91db6 Mon Sep 17 00:00:00 2001
From: Sebastian Kippe
Date: Thu, 23 May 2019 14:22:34 +0200
Subject: [PATCH 10/13] Add "special" category for contributions
---
app/components/add-contribution/template.hbs | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/components/add-contribution/template.hbs b/app/components/add-contribution/template.hbs
index 831c498..ef69051 100644
--- a/app/components/add-contribution/template.hbs
+++ b/app/components/add-contribution/template.hbs
@@ -15,6 +15,7 @@
Development
Documentation
IT Operations
+ Special
From 409d5e33f900cf36c7ac7741313e776b2a6dd2f8 Mon Sep 17 00:00:00 2001
From: Sebastian Kippe
Date: Thu, 23 May 2019 14:30:36 +0200
Subject: [PATCH 11/13] Add "special" category to chart test
Ensure that it's not shown in the chart (which is already the case).
---
tests/unit/components/chart-contributions-by-type-test.js | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/unit/components/chart-contributions-by-type-test.js b/tests/unit/components/chart-contributions-by-type-test.js
index 99ae79c..9a4c674 100644
--- a/tests/unit/components/chart-contributions-by-type-test.js
+++ b/tests/unit/components/chart-contributions-by-type-test.js
@@ -14,6 +14,7 @@ module('Unit | Component | chart-contributions-by-type', function(hooks) {
{ kind: 'community' , amount: 5000 , vetoed: false },
{ kind: 'docs' , amount: 500 , vetoed: true },
{ kind: 'docs' , amount: 500 , vetoed: false },
+ { kind: 'special' , amount: 9999 , vetoed: false },
{ kind: 'docs' , amount: 500 , vetoed: false }
];
From 29115d9b161f732377437728660da5b2245615a6 Mon Sep 17 00:00:00 2001
From: Sebastian Kippe
Date: Thu, 23 May 2019 14:55:03 +0200
Subject: [PATCH 12/13] Make spacing/layout more consistent
---
app/styles/_layout.scss | 4 ----
app/styles/components/_contribution-list.scss | 5 ++---
app/styles/components/_contributor-list.scss | 17 +++++++++++------
app/styles/components/_topbar.scss | 7 +++++++
4 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/app/styles/_layout.scss b/app/styles/_layout.scss
index 932e63b..ec0e401 100644
--- a/app/styles/_layout.scss
+++ b/app/styles/_layout.scss
@@ -1,7 +1,3 @@
-#topbar {
- height: 3rem;
-}
-
main {
padding: 1rem 2rem;
diff --git a/app/styles/components/_contribution-list.scss b/app/styles/components/_contribution-list.scss
index 71367b9..0e0a938 100644
--- a/app/styles/components/_contribution-list.scss
+++ b/app/styles/components/_contribution-list.scss
@@ -15,7 +15,7 @@ ul.contribution-list {
display: grid;
grid-template-columns: auto 5rem 5rem;
grid-row-gap: 0.5rem;
- padding: 1rem 1.2rem;
+ padding: 0.8rem 1.2rem;
background-color: rgba(255,255,255,0.1);
font-size: 1.2rem;
border-bottom: 1px solid rgba(255,255,255,0.2);
@@ -80,8 +80,7 @@ ul.contribution-list {
}
.symbol {
- font-size: 1rem;
- font-weight: 500;
+ font-size: 0.8rem;
padding-left: 0.2rem;
}
diff --git a/app/styles/components/_contributor-list.scss b/app/styles/components/_contributor-list.scss
index fa5216b..0a94414 100644
--- a/app/styles/components/_contributor-list.scss
+++ b/app/styles/components/_contributor-list.scss
@@ -16,7 +16,11 @@ table.contributor-list {
&.metadata {
height: 0;
- transition: all 0.2s ease-out;
+ visibility: hidden;
+
+ &:not(.visible) {
+ border-bottom: none;
+ }
td {
padding: 0 1.2rem;
@@ -34,7 +38,6 @@ table.contributor-list {
display: block;
overflow: hidden;
height: 0;
- transition: all 0.2s ease-out;
li {
display: inline;
@@ -46,6 +49,7 @@ table.contributor-list {
&.visible {
height: auto;
+ visibility: visible;
ul {
height: auto;
}
@@ -54,11 +58,11 @@ table.contributor-list {
td {
padding: 0 1.2rem;
- line-height: 4.2rem;
+ line-height: 3.6rem;
&.person {
text-align: left;
- font-size: 1.4rem;
+ font-size: 1.2rem;
img.avatar {
margin-right: 0.2rem;
@@ -68,10 +72,11 @@ table.contributor-list {
&.kredits {
text-align: right;
.amount {
- font-size: 1.4rem;
+ font-size: 1.2rem;
+ font-weight: 500;
}
.symbol {
- font-size: 1rem;
+ font-size: 0.8rem;
padding-left: 0.2rem;
}
}
diff --git a/app/styles/components/_topbar.scss b/app/styles/components/_topbar.scss
index 48ed6c1..43e931a 100644
--- a/app/styles/components/_topbar.scss
+++ b/app/styles/components/_topbar.scss
@@ -1,8 +1,15 @@
#topbar {
padding: 0 1rem;
+ height: 3rem;
line-height: 3rem;
background-color: rgba(0,0,0,.3);
+ @include media-min(medium) {
+ padding: 0 2rem;
+ height: 4rem;
+ line-height: 4rem;
+ }
+
h1 {
display: inline-block;
text-transform: uppercase;
From e84a1cbc4e400f25d4e247f2a033bb5d148a35d8 Mon Sep 17 00:00:00 2001
From: Sebastian Kippe
Date: Tue, 28 May 2019 16:31:56 +0200
Subject: [PATCH 13/13] Remove obsolete scrolls
---
app/components/add-contribution/component.js | 1 -
app/components/add-contributor/component.js | 1 -
2 files changed, 2 deletions(-)
diff --git a/app/components/add-contribution/component.js b/app/components/add-contribution/component.js
index 0c73016..4b16e65 100644
--- a/app/components/add-contribution/component.js
+++ b/app/components/add-contribution/component.js
@@ -57,7 +57,6 @@ export default Component.extend({
this.save(attributes)
.then((/*contribution*/) => {
this.reset();
- window.scroll(0,0);
}, err => {
console.warn(err);
window.alert('Something went wrong. Check the browser console for details.');
diff --git a/app/components/add-contributor/component.js b/app/components/add-contributor/component.js
index 954ca99..ac9cb57 100644
--- a/app/components/add-contributor/component.js
+++ b/app/components/add-contributor/component.js
@@ -60,7 +60,6 @@ export default Component.extend({
this.save(contributor).then(() => {
this.reset();
- window.scroll(0,0);
}).catch(err => {
console.warn(err);
window.alert('Something went wrong. Please check the browser console.');