Skip to content

Commit

Permalink
Merge pull request #155 from orbanbotond/fix-the-binding-issue
Browse files Browse the repository at this point in the history
Fix the bind problem for the methods
  • Loading branch information
orbanbotond committed Oct 14, 2021
2 parents 43c91ad + 5141960 commit a4bb29c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/graphql/mutations/update_bike.rb
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion app/javascript/modules/bikes/edit.container.jsx
Expand Up @@ -16,6 +16,8 @@ class EditContainer extends Component {
this.state = {
bike: null,
};

this.handleSubmit = this.handleSubmit.bind(this);
}

componentWillMount() {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(){
Expand Down
10 changes: 10 additions & 0 deletions app/javascript/modules/bikes/new.container.jsx
Expand Up @@ -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){
Expand Down Expand Up @@ -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(){
Expand Down

0 comments on commit a4bb29c

Please sign in to comment.