瀏覽代碼

annoying save fix

Ivan Asmer 4 年之前
父節點
當前提交
75969cf7bb
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. 6 1
      src/App.js

+ 6 - 1
src/App.js

@@ -28,6 +28,10 @@ const EditForm = ({record, models={}, model, options=defaultAdminOptions, Compon
 
 
     if (!record) return <></>
     if (!record) return <></>
 
 
+    if (!record.save || !record._id){
+        Object.assign(record, edit)
+    }
+
     const fields =  model.fields
     const fields =  model.fields
     const onlyInputs = model.inputs.filter(input => !fields.find(field => field.name === input.name))
     const onlyInputs = model.inputs.filter(input => !fields.find(field => field.name === input.name))
     return (
     return (
@@ -53,13 +57,14 @@ const EditForm = ({record, models={}, model, options=defaultAdminOptions, Compon
 
 
                 </tbody>
                 </tbody>
             </table>
             </table>
+            {record._id && record.save && 
             <button onClick={() => {
             <button onClick={() => {
                 Object.assign(record, edit);
                 Object.assign(record, edit);
                 if ('_id' in record && 'save' in record)
                 if ('_id' in record && 'save' in record)
                     record.save()
                     record.save()
             }}>
             }}>
                 Save
                 Save
-            </button>
+            </button>}
         </>
         </>
     )
     )
 }
 }