mirror of
https://github.com/ascribe/onion.git
synced 2025-01-03 10:25:08 +01:00
createcontract refresh added
This commit is contained in:
parent
86306fc089
commit
a8fce698a6
@ -24,7 +24,6 @@ class ContractListActions {
|
||||
}
|
||||
|
||||
makeContractPublic(contract){
|
||||
contract.public = true;
|
||||
return Q.Promise((resolve, reject) => {
|
||||
OwnershipFetcher.makeContractPublic(contract)
|
||||
.then((res) => {
|
||||
@ -38,14 +37,14 @@ class ContractListActions {
|
||||
}
|
||||
|
||||
removeContract(contractId){
|
||||
return Q.Promise((resolve, reject) => {
|
||||
return Q.Promise( (resolve, reject) => {
|
||||
OwnershipFetcher.deleteContract(contractId)
|
||||
.then((res) => {
|
||||
console.log('Contract deleted');
|
||||
console.log('Success...');
|
||||
resolve(res);
|
||||
})
|
||||
.catch( (err) => {
|
||||
console.log('Error while deleting');
|
||||
console.log('Bad news...');
|
||||
console.logGlobal(err);
|
||||
reject(err);
|
||||
});
|
||||
|
@ -8,12 +8,14 @@ import InputCheckbox from '../ascribe_forms/input_checkbox';
|
||||
|
||||
import GlobalNotificationModel from '../../models/global_notification_model';
|
||||
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
||||
|
||||
import ContractListActions from '../../actions/contract_list_actions';
|
||||
import ReactS3FineUploader from '../ascribe_uploader/react_s3_fine_uploader';
|
||||
|
||||
import AppConstants from '../../constants/application_constants';
|
||||
import ApiUrls from '../../constants/api_urls';
|
||||
|
||||
|
||||
|
||||
import { getLangText } from '../../utils/lang_utils';
|
||||
import { getCookie } from '../../utils/fetch_api_utils';
|
||||
import { formSubmissionValidation } from '../ascribe_uploader/react_s3_fine_uploader_utils';
|
||||
@ -46,6 +48,7 @@ let CreateContractForm = React.createClass({
|
||||
},
|
||||
|
||||
handleCreateSuccess(response) {
|
||||
ContractListActions.fetchContractList();
|
||||
let notification = new GlobalNotificationModel(getLangText('Contract %s successfully created', response.name), 'success', 5000);
|
||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||
},
|
||||
|
@ -33,7 +33,7 @@ let ContractSettings = React.createClass({
|
||||
},
|
||||
makeContractPublic(contract){
|
||||
ContractListActions.makeContractPublic(contract)
|
||||
.then(( ) => ContractListActions.fetchContractList())
|
||||
.then( ( ) => ContractListActions.fetchContractList())
|
||||
.catch((error)=>{
|
||||
let notification = new GlobalNotificationModel(error, 'danger', 10000);
|
||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||
@ -42,9 +42,11 @@ let ContractSettings = React.createClass({
|
||||
removeContract(contract){
|
||||
console.log(contract);
|
||||
ContractListActions.removeContract(contract.id)
|
||||
.then(( ) => ContractListActions.fetchContractList())
|
||||
.then(
|
||||
() => {
|
||||
ContractListActions.fetchContractList();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('Error', error);
|
||||
let notification = new GlobalNotificationModel(error, 'danger', 10000);
|
||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||
});
|
||||
|
@ -24,11 +24,11 @@ let OwnershipFetcher = {
|
||||
},
|
||||
|
||||
makeContractPublic(contractObj){
|
||||
return requests.put('ownership_csontract', { body: contractObj, contract_id: contractObj.id });
|
||||
return requests.put('ownership_contract', { body: contractObj, contract_id: contractObj.id });
|
||||
},
|
||||
|
||||
deleteContract(contractObjId){
|
||||
return requests.delete('ownership_contract', {contract_id: contractObjId});
|
||||
return requests.delete(ApiUrls.ownership_contract, {contract_id: contractObjId});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -119,7 +119,9 @@ class Requests {
|
||||
|
||||
return fetch(url, merged)
|
||||
.then(this.unpackResponse)
|
||||
.catch(this.handleError);
|
||||
.catch( () => {
|
||||
this.handleError();
|
||||
});
|
||||
}
|
||||
|
||||
get(url, params) {
|
||||
@ -139,7 +141,7 @@ class Requests {
|
||||
|
||||
_putOrPost(url, paramsAndBody, method){
|
||||
let paramsCopy = this._merge(paramsAndBody);
|
||||
let params = excludePropFromObject(paramsAndBody,['body']);
|
||||
let params = excludePropFromObject(paramsAndBody, ['body']);
|
||||
|
||||
let newUrl = this.prepareUrl(url, params);
|
||||
let body = null;
|
||||
|
Loading…
Reference in New Issue
Block a user