diff --git a/app/graphql/mutations/update_bike.rb b/app/graphql/mutations/update_bike.rb index f3e90d9..6f6eb0e 100644 --- a/app/graphql/mutations/update_bike.rb +++ b/app/graphql/mutations/update_bike.rb @@ -35,8 +35,10 @@ def authorized?(**args) end def back_end_operation(bike:, **args) + return @back_end_operation if @back_end_operation.present? + params = args.merge(id: bike.first.id) - params = args.merge(bike_model_id: GraphQL::Schema::UniqueWithinType.decode(args[:bike_model_id])[1]) if args[:bike_model_id].present? + params = params.merge(bike_model_id: GraphQL::Schema::UniqueWithinType.decode(args[:bike_model_id])[1]) if args[:bike_model_id].present? @back_end_operation ||= Crud::Bike::Update.as(context[:current_user]).new(params) end end diff --git a/app/javascript/modules/bikes/edit.container.jsx b/app/javascript/modules/bikes/edit.container.jsx index 31aaeed..7a97338 100644 --- a/app/javascript/modules/bikes/edit.container.jsx +++ b/app/javascript/modules/bikes/edit.container.jsx @@ -16,6 +16,8 @@ class EditContainer extends Component { this.state = { bike: null, }; + + this.handleSubmit = this.handleSubmit.bind(this); } componentWillMount() { @@ -76,7 +78,7 @@ class EditContainer extends Component { ` const query = ` - mutation UpdateBikes($color: BikeColorsEnum!, $weight: Float!, $latitude: Float!, $longitude: Float!, $bikeModelId: ID!, $bikeId: ID!){ + mutation UpdateBikes($color: BikeColorsEnum, $weight: Float, $latitude: Float, $longitude: Float, $bikeModelId: ID, $bikeId: ID!){ updateBike(input: {color: $color, weight: $weight, bikeModelId: $bikeModelId @@ -107,6 +109,7 @@ class EditContainer extends Component { handleSuccess(_response) { console.debug('Saved Successfull'); + this.props.history.push(Routes.Browser.Restfull.collection_route('bike')); } render(){ diff --git a/app/javascript/modules/bikes/new.container.jsx b/app/javascript/modules/bikes/new.container.jsx index 83c609a..a537283 100644 --- a/app/javascript/modules/bikes/new.container.jsx +++ b/app/javascript/modules/bikes/new.container.jsx @@ -9,6 +9,15 @@ import { NavLink, withRouter } from 'react-router-dom'; import { reduxForm, SubmissionError } from 'redux-form'; class NewContainer extends Component { + constructor(props) { + super(props); + + this.state = { + bike: null, + }; + + this.handleSubmit = this.handleSubmit.bind(this); + } componentWillMount() { if(!this.props.models){ @@ -64,6 +73,7 @@ class NewContainer extends Component { handleSuccess(_response) { console.debug('Saved Successfull'); + this.props.history.push(Routes.Browser.Restfull.collection_route('bike')); } render(){