Parcourir la source

fix string array edit

Ivan Asmer il y a 4 ans
Parent
commit
baa4aecfe5
2 fichiers modifiés avec 3 ajouts et 4 suppressions
  1. 1 1
      src/App.js
  2. 2 3
      src/front-models.js

+ 1 - 1
src/App.js

@@ -392,7 +392,7 @@ const defaultAdminOptions =
                                             onCh={data => {
                                                             data = (data && data.target) ?  data.target.value : data
                                                             console.log(data, children)
-                                                            if (!children.find(record => record && record._id === data._id)){
+                                                            if (!children.find(record => record && record._id && record._id === data._id)){
                                                                 const copy = [...children]
                                                                 copy[i] = data
                                                                 onChange(copy)

+ 2 - 3
src/front-models.js

@@ -208,9 +208,8 @@ export default async function createModels2(gql, config={create: 'Upsert', updat
                             if (this[name]) data[name] = this[name] 
                         },
                         LIST(){
-                            const otherType = inInputs(ofType.name)
-                            if (otherType  && this[name] && this[name] instanceof Array)
-                                data[name] = this[name].map(otherEntity => (otherEntity && otherEntity._id ? {_id: otherEntity._id} : (otherEntity || otherEntity)))
+                            if (this[name] instanceof Array)
+                                data[name] = this[name].map(otherEntity => (otherEntity && otherEntity._id ? {_id: otherEntity._id} : (otherEntity && otherEntity.mutationData || otherEntity)))
                         },
                         INPUT_OBJECT(){
                             const otherType = inInputs(otherName)