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
+