Updated: Comment #5
Problem/Motivation
When guessing an existing format, D8 returns the error message:
"This format already exists. Enter a unique format string. "
Similary, when guessing and existing machine name, D8 returns the error message:
"The machine-readable name is already in use. It must be unique."
This is confusing because some formats are not included in the list on:
http://example.com/admin/config/regional/date-time
Steps to recreate:
First case: Guessing an existing format
Steps to reproduce:
1. Install Drupal8 Head
2. Go to admin/config/regional/date-time/formats/add
3. Add new date format:
Name: TestFormat
Machine name: testformat
Format String: Y
Languages: English
=> Add format
Second case:
1. Install Drupal8 Head
2. Go to admin/config/regional/date-time/formats/add
3. Add new date format:
Name: HTML Date
Machine Name: html_date
Format String: YYYY
Languages: English
=> Add format
Error message: ""The machine-readable name is already in use. It must be unique."
Here are all currently defined date formats (in core/modules/system/config):
Not in UI list:
Fallback date format | fallback | intl: 'ccc, MM/dd/yyyy - kk:mm' |
HTML Date | html_date | intl: yyyy-MM-dd |
HTML Datetime | html_datetime | intl: 'yyyy-MM-dd''T''kk:mm:ssZZ' |
HTML Month | html_month | intl: Y-MM |
HTML Time | html_time | intl: 'H:mm:ss' |
HTML Week | html_week | intl: 'Y-''W''WW' |
HTML Year | html_year | intl: MM-d |
Currently in UI list:
Default long date | long | intl: 'EEEE, LLLL d, yyyy - kk:mm' |
Default medium date | medium | intl: 'ccc, MM/dd/yyyy - kk:mm' |
Default short date | short | intl: 'MM/dd/yyyy - kk:mm' |
Proposed resolution
Display the unmutable machine names and formats in the Date and Time format list - but don't allow them to be changed.
Remaining tasks
- (novice) do @webchick #25 point 2. lower case (locked) | git instructions for creating patch | Contributor task documentation for creating a patch
- (novice) Add automated tests | Contributor task document for writing automated tests
- ui review
- patch or mock up of system ones in a collapse
- (done) open related issue to allow creating formats with duplicate patterns #2120813: Allow several date formats with identical date format strings
- (novice) (postponed on new lowercase (locked) patch) Update embed before screenshots in the issue summary | Contributor task document for adding screenshots
User interface changes
Yes.
before
from comment #19
after
from comment #19
API changes
Probably not.
Related Issues
#2100351: Date format name 'custom' is reserved but not checked for
#2119997: Change UI to remove display machine name for date formats
Comment | File | Size | Author |
---|---|---|---|
#30 | 2119903-date_format-locked-30.patch | 3.61 KB | mparker17 |
Comments
Comment #0.0
ursula CreditAttribution: ursula commentedUpdated issue summary - add more details
Comment #0.1
ursula CreditAttribution: ursula commentedissue summary update - formatting
Comment #0.2
ursula CreditAttribution: ursula commentedissue summary edit - more information.
Comment #1
YesCT CreditAttribution: YesCT commentedclarifying title
Comment #1.0
YesCT CreditAttribution: YesCT commentedIssue summary update - formatting
Comment #2
evilehk CreditAttribution: evilehk commentedI believe I can help here and am working on this.
Comment #3
evilehk CreditAttribution: evilehk commentedThe attached patch implements the proposed solution of displaying the locked date format fields in the date format entity list page. Similar to how the field ui displays locked fields by adding " (Locked)" in the label, the date format list does the same thing.
The below highlights the new rows. The path in the screenshot is admin/config/regional/date-time
Comment #4
YesCT CreditAttribution: YesCT commentedcool. that is a great start.
@evilehk did we open an issue also to *allow* creating a new format even if it duplicates another patter? (not duplicate machine name, but pattern) I dont think we did, so
next steps:
* ui review
* open another issue to allow duplicate formats (and link it in the summaries of these related issues)
I think we need a usability review.
We can help that by looking around in core for other UIs that show locked things like this.
HM. the language detection and selection hides a type. it is invisible.
and we hide the not applicable, etc system language, often.
hm.
roles is kind of similar, in that it shows system things (but different in that we can change stuff about the roles, like their human names I think)
this might be a wont fix.
new idea:
put the system ones is a collapsed set
maybe with a label like "System date formats"
and, (optional) since there is no edit on the system ones, we might want to include the info we see on edit of the regular ones, like the php pattern.
In summary, we really need that other issue that allows creating duplicate formats.
Maybe with a little helper step that says: "hi, you already have these other formats with that same pattern. Do you really want another one?" ... well that might not be a great pattern. but we can discuss that in the other issue.
Comment #4.0
YesCT CreditAttribution: YesCT commentedadded related issue
Comment #5
tim.plunkettFilter formats make the locked filter undelete-able. But it is still editable.
Comment #5.0
tim.plunkettupdated remaining tasks
Comment #6
evilehk CreditAttribution: evilehk commentedAdding related issue #2120813: Allow several date formats with identical date format strings
Comment #7
evilehk CreditAttribution: evilehk commentedUnassigning for no particular reason other than I didn't realize this patch was still assigned to me and do not want to discourage others from reviewing
Comment #8
wylbur CreditAttribution: wylbur commentedInstalled this patch on a clean install of D8-dev today. The patch applied cleanly and, the UI shows all the locked system date formats. The US is not very friendly at this point, new formats are added under all the locked system formats. (see screen shot)
There is another issue about removing the machine names from the UI list, Change UI to remove display machine name for date formats, and replacing it as a hover. If we do show all these system elements, does it really make sense to show them if we don't show the machine name except as a hover?
Comment #9
Bojhan CreditAttribution: Bojhan commentedWhy cant one edit these?
Comment #10
tim.plunkettBecause they are an enforced standard: http://www.w3.org/TR/html5-author/the-time-element.html#attr-time-datetime
Comment #11
vijaycs85#2091397: Create hook_help for Datetime module blocked by this issue. raising this as critical as well.
Comment #12
tim.plunkettNo, #2091397: Create hook_help for Datetime module is not actually blocked by this. The hook_help() should describe what is happening.
If we choose to change things in this issue, this issue will update the hook_help() accordingly.
Comment #13
jhodgdonComment #14
vijaycs85This patch has:
1. Reroll of patch in #3
2. Addressing the sort issue reported by @wylbur at #8
3. Manual test (before vs after) for sorting fix.
Comment #15
YesCT CreditAttribution: YesCT commentedThe before and after screenshots show a different number of things...
We still need a before screenshot before any patch is applied.
Is the sort based on locked first (to put them at the bottom) and then Name (or machine name)?
Comment #16
YesCT CreditAttribution: YesCT commentedfixing html
Comment #17
vijaycs85Thanks for the review @YesCT.
- added new set.
- It wasn't order by name in #14, but it does sort by name, if the lock status are same.
Comment #18
jhodgdonI don't think that "before" screenshot in #17 is really "before any patch is applied", unless the title and issue summary are way out of date. It doesn't seem to be illustrating the bug.
Comment #19
vijaycs85Really very sorry for making this more complicated :(
@jhodgdon is correct. The before is "before I fix the order problem" instead of "before *this* issue patch as a whole". Here is proper before/after.
Comment #20
vijaycs85Comment #21
jhodgdonThanks!!
Comment #22
tim.plunkettYou can remove this method override completely. ConfigEntityListBuilder::load() already calls the sort method on the entity class.
Use $this->t() please.
This should be moved to the DateFormat class directly. Also, the indentation is wrong.
I updated the title to reflect the solution, and date formats are owned by system module, unrelated to the optional datetime.module.
Comment #23
vijaycs85Thanks for the review @tim.plunkett
#22.1 - Fixed
#22.2 - Fixed
#22.3 - Fixed
Still the result is same.
Comment #24
tim.plunkettLooks great, thanks!
Comment #25
webchickUnless mine eyes deceive me, we're lacking explicit test coverage for this, so needs work for that.
Also needs work because the only other place I've seen this "(locked)" pattern is on the Roles page, and there it's "anonymous user (locked)," (lowercase L, emphasized) so we should do the same here.
Don't want to scope creep this too much, but off-hand, it feels weird to have more locked things in an admin than unlocked things that you can actually do something with, and having those two things co-mingling in the same list. Would it be easy/desirable to simply split the table in two (Custom / Locked), similar to Enabled / Disabled in the Views UI listing)?
If that's a huge ball of wax, feel free to just fix the first two points, though, unless someone from the UX team feels strongly.
Comment #26
YesCT CreditAttribution: YesCT commentedupdated issue summary remaining tasks, added contributor task document links, and tagged.
Comment #27
mparker17I want to learn how to write automated tests: assigning to myself.
Comment #28
mparker17Re-rolled patch because it didn't apply. Haven't made any changes yet, so no interdiff.
Comment #29
mparker17Changed "(Locked)" to "(locked)".
As an aside, I didn't notice any "locked" text on the Roles page currently, but this could be because of a recent patch.
Still have to write tests.
Comment #30
mparker17Added tests.
Feedback welcome.
Special thanks to @lauriii for mentoring me!
Comment #31
mparker17Comment #32
vijaycs85Thanks @mparker17 for the patch. Let's add an unique tag for date issues (as this is system.module component), so that we can track them.
reg #25:
Thanks @webchick for the valuable comments & QA.
- @mparker17 addressed this in current patch
- @mparker17 addressed this current patch
Totally agreed on unifying UI part, but may be not this issue :). Let's fix both pages (and if there any other pages with this case) at #2280055: Unify the UI of locked+unlocked components list
Comment #33
vijaycs85Comment #34
jhodgdonYes, I agree that all the points from webchick's "needs work" in #25 seem to be addressed. Back to RTBC. Thanks mparker17!
Comment #35
xjm#2091397: Create hook_help for Datetime module is also (presumably briefly) postponed on this issue.
Comment #36
catchCommitted/pushed to 8.x, thanks!