Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the bind problem for the methods #155

Merged
merged 1 commit into from Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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