backdrop-issues
backdrop-issues copied to clipboard
[UX] More info on field removal
Describe your issue or idea
When deleting a field, we see this message:
If you have any content left in this field, it will be lost. This action cannot be undone.
This always makes me a little nervous, even when I'm pretty sure there is no content in the field. Actually even if I've checked the database directly to make sure there is none. 😄 This is an idea for feedback: can we check if there is any content in that field and tell the user whether there is or not instead of this broad brush approach?
It could be simply:
There is content in this field which will be lost. This action cannot be undone.
Or (for example) when deleting a field from the "Page" content type:
7 pages have content in this field which will be lost. This action cannot be undone.
Good idea! I like the 2nd proposal because it makes also clear that the removal concerns only content of a certain type; that is helpful if you're going to delete a field which is shared across different content types.
Or wait ... to make it more clear, we should specify the content type (also) in the "Are you sure" question. Here an example for the current combination of question and message:
Are you sure you want to delete the field Body? If you have any content left in this field, it will be lost. This action cannot be undone.
I'd propose:
Are you sure you want to delete the field Body from the content type Page? 7 pages have content in this field which will be lost. This action cannot be undone.
Hm, while "7 pages" or "7 posts" is fine, it might be difficult to get the correct plural form for other content types, so I guess we need to be slightly more formal, e.g. "7 items of the Page content type have content in this field ..."
I've made a PR that changes the question to:
Are you sure you want to delete the field
%fieldfrom%bundle?
Examples:
- Are you sure you want to delete the field Body from Page?
- Are you sure you want to delete the field Image from Tags?
I originally added in the bundle type as well (e.g. "delete the field Image from the vocabulary Tags?"), but the bundle name for nodes is 'Type', and the same for user accounts. "Are you sure you want to delete the field Photo from the type User account?" doesn't really work very well...
Also, I don't think it'll be possible to display the number of fields with content in them, since (AFAIK) that'll require an EntityFieldQuery, which requires a FieldCondition, which requires knowing what column in the DB the content for each field is stored in (e.g. textfields (and most other fields) use value, but file fields use fid). I guess this is why we're currently saying "If you have any content left in this field...", since there's no definitive way to check this...
I don't think it'll be possible to display the number of fields with content in them
That's a pity. @laryn - do you have any idea how to get the number of fields?
(Apart of that, the PR works for me.)
There is an old PR here that doesn't entirely solve the problem that was raised, but it does make an incremental improvement. I like this idea and it would be pretty easy to move forward. Someone just needs to recreate this PR and submit it again. It's a pretty simple PR and would be fairly easy to recreate.
I've done this a number of times with PR's from folks who are no longer around to keep them up to date. Anyone?