Submit contributions via form #119
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
@@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,9 @@ Router.map(function() {
|
||||
this.route('contributions', function() {
|
||||
this.route('new');
|
||||
});
|
||||
this.route('contributors', function() {
|
||||
this.route('new');
|
||||
});
|
||||
});
|
||||
|
||||
export default Router;
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<main class="center-column">
|
||||
|
||||
<section id="add-contributor">
|
||||
<header>
|
||||
<h2>Add contributor profile</h2>
|
||||
</header>
|
||||
|
||||
<div class="content">
|
||||
{{add-contributor contributors=contributors save=(action "save")}}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</main>
|
||||
+6
-17
@@ -2,8 +2,13 @@
|
||||
|
||||
<div id="stats">
|
||||
<section id="people">
|
||||
<header>
|
||||
<header class="with-nav">
|
||||
<h2>Contributors</h2>
|
||||
{{#if kredits.hasAccounts}}
|
||||
<nav>
|
||||
{{link-to "add" "contributors.new" title="Add contributor profile" class="button small green"}}
|
||||
</nav>
|
||||
{{/if}}
|
||||
</header>
|
||||
<div class="content">
|
||||
{{contributor-list contributorList=kreditsToplist
|
||||
@@ -61,20 +66,4 @@
|
||||
</section>
|
||||
</div>
|
||||
|
||||
{{#if kredits.hasAccounts}}
|
||||
<section id="add-contributor">
|
||||
<header>
|
||||
<h2>Add Contributor</h2>
|
||||
</header>
|
||||
|
||||
<div class="content">
|
||||
{{#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}}
|
||||
</div>
|
||||
</section>
|
||||
{{/if}}
|
||||
|
||||
</main>
|
||||
|
||||
Reference in New Issue
Block a user
Same as above, the reset and scrolling is not necessary. I guess that's still from when the form was on the index page.