diff --git a/app/assets/frontend/javascripts/actions/appos.js b/app/assets/frontend/javascripts/actions/appos.js index fee574a..08e5a7c 100644 --- a/app/assets/frontend/javascripts/actions/appos.js +++ b/app/assets/frontend/javascripts/actions/appos.js @@ -67,7 +67,8 @@ export function fulFillForm() { .then(json => dispatch(setAppoForm(json))); }; }; - + +/* Auxiliar Method */ function setAppoForm(appo_arrays) { return { type: FULFILL_FORM, @@ -103,7 +104,12 @@ function receiveAppo(update_form) { }; }; +/* + Load pets owned for a customer + owner defines if it gets the pets (:id, :name) for owner or for appointment model +*/ export function getPets(id, owner=true) { + console.log('############# In action getPets!!!'); return function (dispatch) { let data = { method: 'POST', @@ -126,6 +132,7 @@ export function getPets(id, owner=true) { }; export function setPets(pets_options) { + console.log('>>>>>>>>>>>>> Fields in setPets: ' + JSON.stringify(pets_options)); return { type: SET_PETS, pets_options diff --git a/app/assets/frontend/javascripts/components/AppoModalNewComponent.js b/app/assets/frontend/javascripts/components/AppoModalNewComponent.js index 52534fc..61142f6 100644 --- a/app/assets/frontend/javascripts/components/AppoModalNewComponent.js +++ b/app/assets/frontend/javascripts/components/AppoModalNewComponent.js @@ -56,7 +56,8 @@ class AppoModalNewComponent extends Component { } componentWillReceiveProps(nextProps) { - if ( JSON.stringify(nextProps.appo_arrays.owners) != JSON.stringify(this.state.owners_options) ) { + // if ( JSON.stringify(nextProps.appo_arrays.owners) != JSON.stringify(this.state.owners_options) ) { + if ( ! this.state.owners_options.length ) { let action = ApposActionCreators.fulFillForm(); this.props.dispatch(action); this.setState({ @@ -81,7 +82,6 @@ class AppoModalNewComponent extends Component { let action = ApposActionCreators.createAppo(fields); this.props.dispatch(action); // thunk middlew console.log( ">>>>>> Sending data >>>>>>> " + JSON.stringify(fields)); - // browserHistory.push('/appointments'); window.location='/appointments'; } @@ -97,9 +97,10 @@ class AppoModalNewComponent extends Component { } changeOwner(value) { - this.setState({owner_id: value['value']}); + this.setState({owner_id: value['value']}); // change owner let action = ApposActionCreators.getPets(value['value'], true); this.props.dispatch(action); + setTimeout(function(){ console.log(">> #># setTimeout 6000"); }, 6000); this.setState({pets_options: this.props.pets_options}); } @@ -161,7 +162,7 @@ class AppoModalNewComponent extends Component { Modal Überschrift -
+