UnlyEd / ra-data-graphql-prisma

A react-admin data provider for Prisma v1, used by https://github.com/UnlyEd/next-right-now-admin
https://nrn-admin.now.sh
MIT License
8 stars 0 forks source link

Fix build variables nested #5

Closed Vadorequest closed 4 years ago

Vadorequest commented 4 years ago

Allow nodes updates

Before this PR, only node connection was handled (through reference using ReferenceInput). Now, we can also update existing nodes (nodes already connected), without using ReferenceInput.

import React from 'react';
import { Edit, SimpleForm, TextField, TextInput } from 'react-admin';
import CustomerEditToolbar from './CustomerEditToolbar';
import ColorInput from './inputs/ColorInput';

const CustomerEdit = (props): JSX.Element => {
  // Not SSR compatible
  const RichTextInput = require('ra-input-rich-text');

  console.log('customerEdit props', props);
  return (
    <Edit {...props}>
      <SimpleForm
        toolbar={<CustomerEditToolbar />}
        redirect={false}
      >
        <TextField source="ref" label={'Reference (#)'} />
        <TextInput source="labelEN" label={'Label (EN)'} />
        <TextInput source="labelFR" label={'Label (FR)'} />
        <ColorInput source="theme.primaryColor" label={'Color'} /> // <= This is a node update, it updates a customer.theme.primaryColor field when saving the customer
      </SimpleForm>
    </Edit>
  );
};

export default CustomerEdit;

Fixes https://github.com/marcantoine/ra-data-graphql-prisma/issues/20#issuecomment-599075695

Vadorequest commented 4 years ago

Tests are now passing locally.

codeclimate[bot] commented 4 years ago

Code Climate has analyzed commit c8d3e056 and detected 0 issues on this pull request.

View more on Code Climate.