1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 09:23:13 +01:00

rename LoanContract to Contract

This commit is contained in:
Tim Daubenschütz 2015-08-28 16:18:10 +02:00
parent d9f3f2a9d7
commit dd20afff90
10 changed files with 83 additions and 83 deletions

View File

@ -4,27 +4,27 @@ import alt from '../alt';
import OwnershipFetcher from '../fetchers/ownership_fetcher';
class LoanContractActions {
class ContractActions {
constructor() {
this.generateActions(
'updateLoanContract',
'flushLoanContract'
'updateContract',
'flushContract'
);
}
fetchLoanContract(email) {
if(email.match(/.+\@.+\..+/)) {
OwnershipFetcher.fetchLoanContract(email)
OwnershipFetcher.fetchContract(email)
.then((contracts) => {
if (contracts && contracts.length > 0) {
this.actions.updateLoanContract({
this.actions.updateContract({
contractKey: contracts[0].s3Key,
contractUrl: contracts[0].s3Url,
contractEmail: email
});
}
else {
this.actions.updateLoanContract({
this.actions.updateContract({
contractKey: null,
contractUrl: null,
contractEmail: null
@ -33,7 +33,7 @@ class LoanContractActions {
})
.catch((err) => {
console.logGlobal(err);
this.actions.updateLoanContract({
this.actions.updateContract({
contractKey: null,
contractUrl: null,
contractEmail: null
@ -45,4 +45,4 @@ class LoanContractActions {
}
}
export default alt.createActions(LoanContractActions);
export default alt.createActions(ContractActions);

View File

@ -0,0 +1,27 @@
'use strict';
import alt from '../alt';
import OwnershipFetcher from '../fetchers/ownership_fetcher';
class ContractListActions {
constructor() {
this.generateActions(
'updateContractList',
'flushContractList'
);
}
fetchContractList() {
OwnershipFetcher.fetchContractList()
.then((contracts) => {
this.actions.updateContractList(contracts);
})
.catch((err) => {
console.logGlobal(err);
this.actions.updateContractList([]);
});
}
}
export default alt.createActions(ContractListActions);

View File

@ -1,27 +0,0 @@
'use strict';
import alt from '../alt';
import OwnershipFetcher from '../fetchers/ownership_fetcher';
class LoanContractListActions {
constructor() {
this.generateActions(
'updateLoanContractList',
'flushLoanContractList'
);
}
fetchLoanContractList() {
OwnershipFetcher.fetchLoanContractList()
.then((contracts) => {
this.actions.updateLoanContractList(contracts);
})
.catch((err) => {
console.logGlobal(err);
this.actions.updateLoanContractList([]);
});
}
}
export default alt.createActions(LoanContractListActions);

View File

@ -2,8 +2,8 @@
import React from 'react';
import LoanContractListActions from '../../actions/loan_contract_list_actions';
import LoanContractListStore from '../../stores/loan_contract_list_store';
import ContractListActions from '../../actions/contract_list_actions';
import ContractListStore from '../../stores/contract_list_store';
import GlobalNotificationModel from '../../models/global_notification_model';
import GlobalNotificationActions from '../../actions/global_notification_actions';
@ -26,7 +26,7 @@ let ContractForm = React.createClass({
getInitialState() {
return mergeOptions(
LoanContractListStore.getState(),
ContractListStore.getState(),
{
selectedContract: 0
}
@ -34,12 +34,12 @@ let ContractForm = React.createClass({
},
componentDidMount() {
LoanContractListStore.listen(this.onChange);
LoanContractListActions.fetchLoanContractList();
ContractListStore.listen(this.onChange);
ContractListActions.fetchContractList();
},
componentWillUnmount() {
LoanContractListStore.unlisten(this.onChange);
ContractListStore.unlisten(this.onChange);
},
onChange(state) {
@ -92,7 +92,7 @@ let ContractForm = React.createClass({
<Form
className="ascribe-form-bordered ascribe-form-wrapper"
ref='form'
url={ApiUrls.ownership_loans_contract}
url={ApiUrls.ownership_contract}
handleSuccess={this.props.handleSuccess}
buttons={<button
type="submit"

View File

@ -12,8 +12,8 @@ import InputTextAreaToggable from './input_textarea_toggable';
import InputDate from './input_date';
import InputCheckbox from './input_checkbox';
import LoanContractStore from '../../stores/loan_contract_store';
import LoanContractActions from '../../actions/loan_contract_actions';
import ContractStore from '../../stores/contract_store';
import ContractActions from '../../actions/contract_actions';
import AppConstants from '../../constants/application_constants';
@ -48,16 +48,16 @@ let LoanForm = React.createClass({
},
getInitialState() {
return LoanContractStore.getState();
return ContractStore.getState();
},
componentDidMount() {
LoanContractStore.listen(this.onChange);
LoanContractActions.flushLoanContract.defer();
ContractStore.listen(this.onChange);
ContractActions.flushContract.defer();
},
componentWillUnmount() {
LoanContractStore.unlisten(this.onChange);
ContractStore.unlisten(this.onChange);
},
onChange(state) {
@ -72,7 +72,7 @@ let LoanForm = React.createClass({
let potentialEmail = event.target.value;
if(potentialEmail.match(/.*@.*/)) {
LoanContractActions.fetchLoanContract(potentialEmail);
ContractActions.fetchContract(potentialEmail);
}
},

View File

@ -38,7 +38,7 @@ let ApiUrls = {
'ownership_loans_editions': AppConstants.apiEndpoint + 'ownership/loans/editions/',
'ownership_loans_confirm': AppConstants.apiEndpoint + 'ownership/loans/editions/confirm/',
'ownership_loans_deny': AppConstants.apiEndpoint + 'ownership/loans/editions/deny/',
'ownership_loans_contract': AppConstants.apiEndpoint + 'ownership/loans/editions/contract/',
'ownership_contract': AppConstants.apiEndpoint + 'ownership/loans/editions/contract/',
'ownership_shares_editions': AppConstants.apiEndpoint + 'ownership/shares/editions/',
'ownership_shares_pieces': AppConstants.apiEndpoint + 'ownership/shares/pieces/',
'ownership_transfers': AppConstants.apiEndpoint + 'ownership/transfers/',

View File

@ -6,17 +6,17 @@ import ApiUrls from '../constants/api_urls';
let OwnershipFetcher = {
/**
* Fetch the default, public loan contract of a user from the API.
* Fetch the default, public contract of a user from the API.
*/
fetchLoanContract(email) {
return requests.get(ApiUrls.ownership_loans_contract + '?loanee=' + email);
fetchContract(email) {
return requests.get(ApiUrls.ownership_contract + '?loanee=' + email);
},
/**
* Fetch the contracts of the logged-in user from the API.
*/
fetchLoanContractList(){
return requests.get(ApiUrls.ownership_loans_contract);
fetchContractList(){
return requests.get(ApiUrls.ownership_contract);
},
fetchLoanPieceRequestList(){

View File

@ -0,0 +1,22 @@
'use strict';
import alt from '../alt';
import ContractListActions from '../actions/contract_list_actions';
class ContractListStore {
constructor() {
this.contractList = [];
this.bindActions(ContractListActions);
}
onUpdateContractList(contractList) {
this.contractList = contractList;
}
onFlushContractList() {
this.contractList = [];
}
}
export default alt.createStore(ContractListStore, 'ContractListStore');

View File

@ -1,28 +1,28 @@
'use strict';
import alt from '../alt';
import LoanContractActions from '../actions/loan_contract_actions';
import ContractActions from '../actions/contract_actions';
class LoanContractStore {
class ContractStore {
constructor() {
this.contractKey = null;
this.contractUrl = null;
this.contractEmail = null;
this.bindActions(LoanContractActions);
this.bindActions(ContractActions);
}
onUpdateLoanContract({contractKey, contractUrl, contractEmail}) {
onUpdateContract({contractKey, contractUrl, contractEmail}) {
this.contractKey = contractKey;
this.contractUrl = contractUrl;
this.contractEmail = contractEmail;
}
onFlushLoanContract() {
onFlushContract() {
this.contractKey = null;
this.contractUrl = null;
this.contractEmail = null;
}
}
export default alt.createStore(LoanContractStore, 'LoanContractStore');
export default alt.createStore(ContractStore, 'ContractStore');

View File

@ -1,22 +0,0 @@
'use strict';
import alt from '../alt';
import LoanContractListActions from '../actions/loan_contract_list_actions';
class LoanContractListStore {
constructor() {
this.contractList = [];
this.bindActions(LoanContractListActions);
}
onUpdateLoanContractList(contractList) {
this.contractList = contractList;
}
onFlushLoanContractList() {
this.contractList = [];
}
}
export default alt.createStore(LoanContractListStore, 'LoanContractListStore');