webiny / webiny-js

Open-source serverless enterprise CMS. Includes a headless CMS, page builder, form builder, and file manager. Easy to customize and expand. Deploys to AWS.
https://www.webiny.com
Other
7.4k stars 614 forks source link

Edit Content Model: Ability to delete fields that are not used/set in any entries #2251

Open larissa-n opened 2 years ago

larissa-n commented 2 years ago

Is your feature request related to a problem? Please describe.

Currently, no content model fields can be deleted if there are any entries for the content model; irrespective of whether the concerning field is used. As a result, content model fields can only be added, but never removed, if there is at least one entry; and removing any fields requires clearing ALL entries for the content model (all the while bulk deletion is not yet implemented; and while removing a content model is also only possible aftere all entries are cleared). So if anything needs to change about a content model, this leads to orphan fields that are difficult to keep track of (e.g. rename label DO_NOT_USE and other possible workarounds).

Describe the solution you'd like.

It would be neat if content model fields could be edited and deleted as long as there aren't any entries using them.

Describe alternatives you've considered.

No response

Pavel910 commented 2 years ago

This will be resolved in the near future, it's been on our task list for some time now. Thanks for opening the issue! 👍

larissa-n commented 2 years ago

Awesome, thanks!

larissa-n commented 2 years ago

Just curious, what's the progress / is there a timeline for this? Thank you!

bmccarthynn commented 2 years ago

Same issue. Typed up the following for Slack but copying here instead:

  1. Create a new content model with two fields, Title (text) and Description (long text).
  2. Create a new entry, only enter the Title, leave Description empty.
  3. Save and return to edit content model.
  4. The option to delete the Description field is grayed out. Issue 1: If you do not hard refresh, the Delete option is available and will appear to delete but then throws an error notification "Cannot remove the field because it's already in use in created content." Issue 2: If you hard refresh, the grayed out action is "Cannot delete"
  5. Return to view content and delete the entry.
  6. Return to edit content model.
  7. The option to delete the Description field is grayed out. Issue 2 - If you hard refresh, the option to delete now appears "Delete".
  8. Repeat the similar steps but this time with a Reference field.
  9. Add a Reference field.
  10. Add content to Reference field and save entry.
  11. Remove content from Reference field and save entry.
  12. Return to edit content model Issue 3 - "Cannot delete" field.

In summary, you cannot delete fields unless you delete all entries. Even if there is no content in a field, it is assumed there is and a field cannot be deleted. Furthermore, there are UI issues when switching between views that are resolved by a hard refresh.

I understand the cautiousness in Deleting a field when entries already exist, but if there is actually no data in a field, you should be able to delete it.

Even if there is content, a user with permissions should be able to delete a field with a warning "Content may exist in this field already so data loss may occur and cannot be restored."

Pavel910 commented 2 years ago

@bmccarthynn This problem is scheduled for Q3, so it will be resolved. There are more issues with this than just field deletion. With Elasticsearch this becomes very tricky, because you can have Field A of type number, you create an entry, Elasticsearch now treats Field A as a number. If you delete that field and create Field A again, but this time as a string, Elasticsearch will not like it (to put it mildly).

We do have a solid implementation plan so stay patient for just a bit longer :)