CRUD icon indicating copy to clipboard operation
CRUD copied to clipboard

Morphto v2 - with ajax support

Open pxpm opened this issue 3 years ago • 5 comments

WHY

BEFORE - What was wrong? What was happening before this PR?

Before everything ... PFEEEWWWW! 😫 done!

AFTER - What is happening after this PR?

This is a re-implementation of #4330 but with support for ajax fields and a new syntax.

There are examples of both usages (array and fluent) in the demo branch https://github.com/Laravel-Backpack/demo/pull/388 . fluent implemented, array documented.

PRO pr is also updated: https://github.com/Laravel-Backpack/PRO/pull/18

@tabacitu can you give a round up on usability and let me know how we are here?

The only thing that I notice about usability is that the error messages are duplicated, in "morphTo" container field and the actual field: image Just need to discuss with you which one you think we should keep.

This was a wild wild ride! sooooooooo many details ... I LOVE it! 🙃

NOTE: not implemented yet CRUD JS API.

pxpm avatar Aug 04 '22 14:08 pxpm

We decided to write docs for this in this PR, then try doing MorphToMany too, see how the docs would be different between the two.

tabacitu avatar Aug 05 '22 04:08 tabacitu

Heads up @tabacitu this branch had been updated.

MorphTo fields are now treated as subfields.

image

I've updated demo and pro PR too. Also added to docs: https://github.com/Laravel-Backpack/docs/pull/368

pxpm avatar Aug 10 '22 17:08 pxpm

Hi @pxpm i dont know if i do something wrong. Here we go:

I set my branches as:

PRO: morphTo-relation CRUD: morphto-v2 DEMO: morphto

But when i go to CRUD: admin/pet-shop/comment/create i get 500 error

Screen Shot 2022-09-12 at 09 29 18

I get error details and is about memory leak:

2022/09/12 12:15:24 [error] 10#10: *38 FastCGI sent in stderr: "PHP message: PHP Deprecated: Required parameter $options follows optional parameter $label in /var/www/bp_demo_20220803/vendor/backpack/crud/src/app/Library/CrudPanel/Traits/Relationships.php on line 429PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in /var/www/bp_demo_20220803/vendor/laravel/framework/src/Illuminate/Database/Connection.php on line 420PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 65536 bytes) in /var/www/bp_demo_20220803/vendor/composer/ClassLoader.php on line 571" while reading response header from upstream, client: 172.19.0.1, server: backpack.test, request: "GET /admin/pet-shop/comment/create HTTP/1.1", upstream: "fastcgi://172.19.0.5:9000", host: "backpack.test", referrer: "http://backpack.test/admin/pet-shop/comment"

2022/09/12 12:20:21 [error] 10#10: *40 FastCGI sent in stderr: "PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in /var/www/bp_demo_20220803/vendor/laravel/framework/src/Illuminate/Database/Connection.php on line 420PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 65536 bytes) in /var/www/bp_demo_20220803/vendor/composer/ClassLoader.php on line 571" while reading response header from upstream, client: 172.19.0.1, server: backpack.test, request: "GET /admin/pet-shop/comment/create HTTP/1.1", upstream: "fastcgi://172.19.0.5:9000", host: "backpack.test", referrer: "http://backpack.test/admin/pet-shop/comment"

I have not limit set on PHP.

Cheers.

jcastroa87 avatar Sep 12 '22 12:09 jcastroa87

Hi @pxpm problem was created because monster have more than 500K rows, now is working.

I check implementation, till now look working normal, but i have a commment about error message: "The commentable.commentable id field is required."

Screen Shot 2022-09-12 at 15 14 42

To prevent someone need to be force to translate, is possible a message like "The commentable in commentable id field is required." replace "." by "in".

Let me know if this is possible or what you think about it.

ty.

Cheers.

jcastroa87 avatar Sep 12 '22 18:09 jcastroa87

I've change the error message, now it reads: This field is requiried. I think writting commentable and technical terms here does not help UI.

This is a message for a non-developer user.

Cheers

pxpm avatar Sep 16 '22 11:09 pxpm

Hello @pxpm im back :)

Look great for me, now is not needed touch request.

screenshot-backpack test-2022 09 22-16_40_28

Cheers.

jcastroa87 avatar Sep 22 '22 19:09 jcastroa87

@tabacitu did the changes.

Just one question still un-answered https://github.com/Laravel-Backpack/CRUD/pull/4579#discussion_r992215203

Cheers

pxpm avatar Oct 14 '22 10:10 pxpm

CleanShot 2022-10-14 at 16 43 13@2x

OMG PEDRO IT'S HAPPENING!!! 😱

tabacitu avatar Oct 14 '22 13:10 tabacitu

Here's the GIF for it:

CleanShot 2022-11-23 at 17 02 09

tabacitu avatar Nov 23 '22 13:11 tabacitu

Here's the GIF for it:

A gif with a "broken/failing" test doesn't seem very appealing to me @tabacitu 💥

pxpm avatar Nov 23 '22 13:11 pxpm