connect add contributor form to ethereum
This commit is contained in:
@@ -5,31 +5,58 @@ export default Ember.Component.extend({
|
||||
id: null,
|
||||
realName: null,
|
||||
address: null,
|
||||
ipfsHash: null,
|
||||
isCore: true,
|
||||
|
||||
classId: function() {
|
||||
let value = this.get('id');
|
||||
return (Ember.isEmpty(value)) ? null : 'valid';
|
||||
inProgress: false,
|
||||
|
||||
isValidId: function() {
|
||||
return Ember.isPresent(this.get('id'));
|
||||
}.property('id'),
|
||||
|
||||
classRealName: function() {
|
||||
let value = this.get('realName');
|
||||
return (Ember.isEmpty(value)) ? null : 'valid';
|
||||
isValidRealName: function() {
|
||||
return Ember.isPresent(this.get('realName'))
|
||||
}.property('realName'),
|
||||
|
||||
classAddress: function() {
|
||||
let value = this.get('address');
|
||||
return (Ember.isEmpty(value)) ? null : 'valid';
|
||||
isValidAddress: function() {
|
||||
return this.get('kredits.web3Instance').isAddress(this.get('address'));
|
||||
}.property('address'),
|
||||
|
||||
isValid: function() {
|
||||
return this.get('isValidId') && this.get('isValidRealName') && this.get('isValidAddress');
|
||||
}.property('isValidAddress', 'isValidId', 'isValidRealName'),
|
||||
|
||||
reset: function() {
|
||||
this.setProperties({
|
||||
id: null,
|
||||
realName: null,
|
||||
address: null,
|
||||
ipfsHash: null,
|
||||
isCore: true,
|
||||
inProgress: false
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
||||
save() {
|
||||
console.log('id', this.get('id'));
|
||||
console.log('realName', this.get('realName'));
|
||||
console.log('address', this.get('address'));
|
||||
if(this.get('isValid')) {
|
||||
this.set('inProgress', true);
|
||||
this.get('kredits').addContributor(
|
||||
this.get('address'),
|
||||
this.get('realName'),
|
||||
'', // TODO: this.get('ipfsHash')
|
||||
this.get('isCore'),
|
||||
this.get('id')
|
||||
).then(contributor => {
|
||||
this.reset();
|
||||
this.get('contributors').pushObject(contributor);
|
||||
window.scroll(0,0);
|
||||
});
|
||||
} else {
|
||||
alert('invalid data. please review');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -4,23 +4,23 @@
|
||||
type="text"
|
||||
placeholder="GitHub UID (123)"
|
||||
value=id
|
||||
class=classId}}
|
||||
class=(if isValidId 'valid' '')}}
|
||||
</p>
|
||||
<p>
|
||||
{{input name="realname"
|
||||
type="text"
|
||||
placeholder="Carl Sagan"
|
||||
value=realName
|
||||
class=classRealName}}
|
||||
class=(if isValidRealName 'valid' '')}}
|
||||
</p>
|
||||
<p>
|
||||
{{input name="address"
|
||||
type="text"
|
||||
placeholder="0xF18E631Ea191aE4ebE70046Fcb01a436554421BA4"
|
||||
value=address
|
||||
class=classAddress}}
|
||||
class=(if isValidAddress 'valid' '')}}
|
||||
</p>
|
||||
<p class="actions">
|
||||
<input type="submit" value="Save">
|
||||
{{input type="submit" value=(if inProgress 'Processing' 'Save') disabled=inProgress}}
|
||||
</p>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user