1
0
mirror of https://github.com/ascribe/onion.git synced 2025-01-03 18:35:09 +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'; import OwnershipFetcher from '../fetchers/ownership_fetcher';
class LoanContractActions { class ContractActions {
constructor() { constructor() {
this.generateActions( this.generateActions(
'updateLoanContract', 'updateContract',
'flushLoanContract' 'flushContract'
); );
} }
fetchLoanContract(email) { fetchLoanContract(email) {
if(email.match(/.+\@.+\..+/)) { if(email.match(/.+\@.+\..+/)) {
OwnershipFetcher.fetchLoanContract(email) OwnershipFetcher.fetchContract(email)
.then((contracts) => { .then((contracts) => {
if (contracts && contracts.length > 0) { if (contracts && contracts.length > 0) {
this.actions.updateLoanContract({ this.actions.updateContract({
contractKey: contracts[0].s3Key, contractKey: contracts[0].s3Key,
contractUrl: contracts[0].s3Url, contractUrl: contracts[0].s3Url,
contractEmail: email contractEmail: email
}); });
} }
else { else {
this.actions.updateLoanContract({ this.actions.updateContract({
contractKey: null, contractKey: null,
contractUrl: null, contractUrl: null,
contractEmail: null contractEmail: null
@ -33,7 +33,7 @@ class LoanContractActions {
}) })
.catch((err) => { .catch((err) => {
console.logGlobal(err); console.logGlobal(err);
this.actions.updateLoanContract({ this.actions.updateContract({
contractKey: null, contractKey: null,
contractUrl: null, contractUrl: null,
contractEmail: 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 React from 'react';
import LoanContractListActions from '../../actions/loan_contract_list_actions'; import ContractListActions from '../../actions/contract_list_actions';
import LoanContractListStore from '../../stores/loan_contract_list_store'; import ContractListStore from '../../stores/contract_list_store';
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';
@ -26,7 +26,7 @@ let ContractForm = React.createClass({
getInitialState() { getInitialState() {
return mergeOptions( return mergeOptions(
LoanContractListStore.getState(), ContractListStore.getState(),
{ {
selectedContract: 0 selectedContract: 0
} }
@ -34,12 +34,12 @@ let ContractForm = React.createClass({
}, },
componentDidMount() { componentDidMount() {
LoanContractListStore.listen(this.onChange); ContractListStore.listen(this.onChange);
LoanContractListActions.fetchLoanContractList(); ContractListActions.fetchContractList();
}, },
componentWillUnmount() { componentWillUnmount() {
LoanContractListStore.unlisten(this.onChange); ContractListStore.unlisten(this.onChange);
}, },
onChange(state) { onChange(state) {
@ -92,7 +92,7 @@ let ContractForm = React.createClass({
<Form <Form
className="ascribe-form-bordered ascribe-form-wrapper" className="ascribe-form-bordered ascribe-form-wrapper"
ref='form' ref='form'
url={ApiUrls.ownership_loans_contract} url={ApiUrls.ownership_contract}
handleSuccess={this.props.handleSuccess} handleSuccess={this.props.handleSuccess}
buttons={<button buttons={<button
type="submit" type="submit"

View File

@ -12,8 +12,8 @@ import InputTextAreaToggable from './input_textarea_toggable';
import InputDate from './input_date'; import InputDate from './input_date';
import InputCheckbox from './input_checkbox'; import InputCheckbox from './input_checkbox';
import LoanContractStore from '../../stores/loan_contract_store'; import ContractStore from '../../stores/contract_store';
import LoanContractActions from '../../actions/loan_contract_actions'; import ContractActions from '../../actions/contract_actions';
import AppConstants from '../../constants/application_constants'; import AppConstants from '../../constants/application_constants';
@ -48,16 +48,16 @@ let LoanForm = React.createClass({
}, },
getInitialState() { getInitialState() {
return LoanContractStore.getState(); return ContractStore.getState();
}, },
componentDidMount() { componentDidMount() {
LoanContractStore.listen(this.onChange); ContractStore.listen(this.onChange);
LoanContractActions.flushLoanContract.defer(); ContractActions.flushContract.defer();
}, },
componentWillUnmount() { componentWillUnmount() {
LoanContractStore.unlisten(this.onChange); ContractStore.unlisten(this.onChange);
}, },
onChange(state) { onChange(state) {
@ -72,7 +72,7 @@ let LoanForm = React.createClass({
let potentialEmail = event.target.value; let potentialEmail = event.target.value;
if(potentialEmail.match(/.*@.*/)) { 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_editions': AppConstants.apiEndpoint + 'ownership/loans/editions/',
'ownership_loans_confirm': AppConstants.apiEndpoint + 'ownership/loans/editions/confirm/', 'ownership_loans_confirm': AppConstants.apiEndpoint + 'ownership/loans/editions/confirm/',
'ownership_loans_deny': AppConstants.apiEndpoint + 'ownership/loans/editions/deny/', '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_editions': AppConstants.apiEndpoint + 'ownership/shares/editions/',
'ownership_shares_pieces': AppConstants.apiEndpoint + 'ownership/shares/pieces/', 'ownership_shares_pieces': AppConstants.apiEndpoint + 'ownership/shares/pieces/',
'ownership_transfers': AppConstants.apiEndpoint + 'ownership/transfers/', 'ownership_transfers': AppConstants.apiEndpoint + 'ownership/transfers/',

View File

@ -6,17 +6,17 @@ import ApiUrls from '../constants/api_urls';
let OwnershipFetcher = { 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) { fetchContract(email) {
return requests.get(ApiUrls.ownership_loans_contract + '?loanee=' + email); return requests.get(ApiUrls.ownership_contract + '?loanee=' + email);
}, },
/** /**
* Fetch the contracts of the logged-in user from the API. * Fetch the contracts of the logged-in user from the API.
*/ */
fetchLoanContractList(){ fetchContractList(){
return requests.get(ApiUrls.ownership_loans_contract); return requests.get(ApiUrls.ownership_contract);
}, },
fetchLoanPieceRequestList(){ 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'; 'use strict';
import alt from '../alt'; import alt from '../alt';
import LoanContractActions from '../actions/loan_contract_actions'; import ContractActions from '../actions/contract_actions';
class LoanContractStore { class ContractStore {
constructor() { constructor() {
this.contractKey = null; this.contractKey = null;
this.contractUrl = null; this.contractUrl = null;
this.contractEmail = null; this.contractEmail = null;
this.bindActions(LoanContractActions); this.bindActions(ContractActions);
} }
onUpdateLoanContract({contractKey, contractUrl, contractEmail}) { onUpdateContract({contractKey, contractUrl, contractEmail}) {
this.contractKey = contractKey; this.contractKey = contractKey;
this.contractUrl = contractUrl; this.contractUrl = contractUrl;
this.contractEmail = contractEmail; this.contractEmail = contractEmail;
} }
onFlushLoanContract() { onFlushContract() {
this.contractKey = null; this.contractKey = null;
this.contractUrl = null; this.contractUrl = null;
this.contractEmail = 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');