SenseNet / sn-client

Monorepo for sensenet client packages 🐱‍💻
https://sensenet.com
GNU General Public License v2.0
25 stars 37 forks source link

[BUG] Cannot remove type from allowed childtypes #823

Closed herflis closed 3 years ago

herflis commented 4 years ago

🐜 Bug Report

Manually added content types cannot be removed from the allowed childtype field.

📦 Package / Application

@sensenet/sn-app @sensenet/controls-react

📃 Version

latest

🐜 Describe the bug

After removing a content type from the allowed childtypes field on the ui, the content seems to be successfully deleted, but if you go back to the edit form again, you can see that the type remained in the allowed childtypes list.

👉 Steps To Reproduce

  1. Login to admin-ui
  2. Go to Content/IT
  3. Right click on Document library and choose Edit from the actionmenu
  4. Add Image to the allowed childtypes list and click on save
  5. Open the same document library for edit

😯 Current behavior

The previously deleted allowed childtype it's still there in the allowed childtypes list.

🤔 Expected behavior

The deleted items should be completely removed from the list

🖼 Screenshots

act

taki9 commented 4 years ago

Frontend related issue is fixed by https://github.com/SenseNet/sn-client/pull/840 But I think something also wrong on backend. When deleting one or all of the allowed childtypes coming from the CTD, it gives strange results.

tusmester commented 4 years ago

When adding the first new type (Image) to the list (step 4) tha PATCH request body is the following, which is correct:

{ "AllowedChildTypes": ["Folder", "File", "SystemFolder", "Image"]}

Subsequent payloads look very different: the field value contains objects instead of type names. The backend cannot parse this request.

"AllowedChildTypes": [ 
{"Id": 1252, "ParentId": 1249, "VersionId": 265, "Type": "ContentType", "TypeIs": "ContentType", "Name": "Folder",…}
{"Id": 1277, "ParentId": 1249, "VersionId": 290, "Type": "ContentType", "TypeIs": "ContentType", "Name": "File",…}
{"Id": 1305, "ParentId": 1252, "VersionId": 318, "Type": "ContentType", "TypeIs": "ContentType",…}
]