2015-08-28 16:18:10 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
import alt from '../alt';
|
|
|
|
import OwnershipFetcher from '../fetchers/ownership_fetcher';
|
2015-09-03 17:19:29 +02:00
|
|
|
import Q from 'q';
|
2015-08-28 16:18:10 +02:00
|
|
|
|
|
|
|
class ContractListActions {
|
|
|
|
constructor() {
|
|
|
|
this.generateActions(
|
|
|
|
'updateContractList',
|
|
|
|
'flushContractList'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-09-11 18:23:31 +02:00
|
|
|
fetchContractList(isActive, isPublic, issuer) {
|
|
|
|
return Q.Promise((resolve, reject) => {
|
|
|
|
OwnershipFetcher.fetchContractList(isActive, isPublic, issuer)
|
|
|
|
.then((contracts) => {
|
|
|
|
this.actions.updateContractList(contracts.results);
|
|
|
|
resolve(contracts.results);
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
console.logGlobal(err);
|
|
|
|
this.actions.updateContractList([]);
|
|
|
|
reject(err);
|
|
|
|
});
|
|
|
|
});
|
2015-08-28 16:18:10 +02:00
|
|
|
}
|
2015-09-03 15:53:02 +02:00
|
|
|
|
2015-09-08 11:57:20 +02:00
|
|
|
|
2015-09-08 11:44:05 +02:00
|
|
|
changeContract(contract){
|
2015-09-03 17:19:29 +02:00
|
|
|
return Q.Promise((resolve, reject) => {
|
2015-09-16 09:47:22 +02:00
|
|
|
OwnershipFetcher.changeContract(contract)
|
2015-09-03 17:19:29 +02:00
|
|
|
.then((res) => {
|
|
|
|
resolve(res);
|
|
|
|
})
|
|
|
|
.catch((err)=> {
|
|
|
|
console.logGlobal(err);
|
|
|
|
reject(err);
|
|
|
|
});
|
|
|
|
});
|
2015-09-03 15:53:02 +02:00
|
|
|
}
|
2015-09-07 11:38:23 +02:00
|
|
|
|
2015-09-07 15:43:44 +02:00
|
|
|
removeContract(contractId){
|
2015-09-08 11:53:09 +02:00
|
|
|
return Q.Promise( (resolve, reject) => {
|
2015-09-07 15:43:44 +02:00
|
|
|
OwnershipFetcher.deleteContract(contractId)
|
2015-09-07 11:38:23 +02:00
|
|
|
.then((res) => {
|
|
|
|
resolve(res);
|
|
|
|
})
|
|
|
|
.catch( (err) => {
|
2015-09-09 11:11:16 +02:00
|
|
|
console.logGlobal(err);
|
|
|
|
reject(err);
|
2015-09-03 17:19:29 +02:00
|
|
|
});
|
|
|
|
});
|
2015-09-03 15:53:02 +02:00
|
|
|
}
|
2015-08-28 16:18:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export default alt.createActions(ContractListActions);
|