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){
|
makeContractPublic(contract){
|
||||||
contract.public = true;
|
|
||||||
return Q.Promise((resolve, reject) => {
|
return Q.Promise((resolve, reject) => {
|
||||||
OwnershipFetcher.makeContractPublic(contract)
|
OwnershipFetcher.makeContractPublic(contract)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
@ -38,14 +37,14 @@ class ContractListActions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
removeContract(contractId){
|
removeContract(contractId){
|
||||||
return Q.Promise((resolve, reject) => {
|
return Q.Promise( (resolve, reject) => {
|
||||||
OwnershipFetcher.deleteContract(contractId)
|
OwnershipFetcher.deleteContract(contractId)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log('Contract deleted');
|
console.log('Success...');
|
||||||
resolve(res);
|
resolve(res);
|
||||||
})
|
})
|
||||||
.catch( (err) => {
|
.catch( (err) => {
|
||||||
console.log('Error while deleting');
|
console.log('Bad news...');
|
||||||
console.logGlobal(err);
|
console.logGlobal(err);
|
||||||
reject(err);
|
reject(err);
|
||||||
});
|
});
|
||||||
|
@ -8,12 +8,14 @@ import InputCheckbox from '../ascribe_forms/input_checkbox';
|
|||||||
|
|
||||||
import GlobalNotificationModel from '../../models/global_notification_model';
|
import GlobalNotificationModel from '../../models/global_notification_model';
|
||||||
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
||||||
|
import ContractListActions from '../../actions/contract_list_actions';
|
||||||
import ReactS3FineUploader from '../ascribe_uploader/react_s3_fine_uploader';
|
import ReactS3FineUploader from '../ascribe_uploader/react_s3_fine_uploader';
|
||||||
|
|
||||||
import AppConstants from '../../constants/application_constants';
|
import AppConstants from '../../constants/application_constants';
|
||||||
import ApiUrls from '../../constants/api_urls';
|
import ApiUrls from '../../constants/api_urls';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import { getLangText } from '../../utils/lang_utils';
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
import { getCookie } from '../../utils/fetch_api_utils';
|
import { getCookie } from '../../utils/fetch_api_utils';
|
||||||
import { formSubmissionValidation } from '../ascribe_uploader/react_s3_fine_uploader_utils';
|
import { formSubmissionValidation } from '../ascribe_uploader/react_s3_fine_uploader_utils';
|
||||||
@ -46,6 +48,7 @@ let CreateContractForm = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
handleCreateSuccess(response) {
|
handleCreateSuccess(response) {
|
||||||
|
ContractListActions.fetchContractList();
|
||||||
let notification = new GlobalNotificationModel(getLangText('Contract %s successfully created', response.name), 'success', 5000);
|
let notification = new GlobalNotificationModel(getLangText('Contract %s successfully created', response.name), 'success', 5000);
|
||||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
},
|
},
|
||||||
|
@ -33,7 +33,7 @@ let ContractSettings = React.createClass({
|
|||||||
},
|
},
|
||||||
makeContractPublic(contract){
|
makeContractPublic(contract){
|
||||||
ContractListActions.makeContractPublic(contract)
|
ContractListActions.makeContractPublic(contract)
|
||||||
.then(( ) => ContractListActions.fetchContractList())
|
.then( ( ) => ContractListActions.fetchContractList())
|
||||||
.catch((error)=>{
|
.catch((error)=>{
|
||||||
let notification = new GlobalNotificationModel(error, 'danger', 10000);
|
let notification = new GlobalNotificationModel(error, 'danger', 10000);
|
||||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
@ -42,9 +42,11 @@ let ContractSettings = React.createClass({
|
|||||||
removeContract(contract){
|
removeContract(contract){
|
||||||
console.log(contract);
|
console.log(contract);
|
||||||
ContractListActions.removeContract(contract.id)
|
ContractListActions.removeContract(contract.id)
|
||||||
.then(( ) => ContractListActions.fetchContractList())
|
.then(
|
||||||
|
() => {
|
||||||
|
ContractListActions.fetchContractList();
|
||||||
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.log('Error', error);
|
|
||||||
let notification = new GlobalNotificationModel(error, 'danger', 10000);
|
let notification = new GlobalNotificationModel(error, 'danger', 10000);
|
||||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
});
|
});
|
||||||
|
@ -24,11 +24,11 @@ let OwnershipFetcher = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
makeContractPublic(contractObj){
|
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){
|
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)
|
return fetch(url, merged)
|
||||||
.then(this.unpackResponse)
|
.then(this.unpackResponse)
|
||||||
.catch(this.handleError);
|
.catch( () => {
|
||||||
|
this.handleError();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
get(url, params) {
|
get(url, params) {
|
||||||
@ -139,7 +141,7 @@ class Requests {
|
|||||||
|
|
||||||
_putOrPost(url, paramsAndBody, method){
|
_putOrPost(url, paramsAndBody, method){
|
||||||
let paramsCopy = this._merge(paramsAndBody);
|
let paramsCopy = this._merge(paramsAndBody);
|
||||||
let params = excludePropFromObject(paramsAndBody,['body']);
|
let params = excludePropFromObject(paramsAndBody, ['body']);
|
||||||
|
|
||||||
let newUrl = this.prepareUrl(url, params);
|
let newUrl = this.prepareUrl(url, params);
|
||||||
let body = null;
|
let body = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user