backdrop-issues icon indicating copy to clipboard operation
backdrop-issues copied to clipboard

[UX] Add a token-browser-like PHP date format helper dialog

Open klonos opened this issue 5 years ago • 8 comments

This is a spin-off from #4536.

@BWPanda

There's a bit of scrolling needed to find the actual table of formats, and no way to link straight to it from what I can see. Since I doubt those formats would change much, I wonder if it'd be better for us to create our own page to link to...? Either in Backdrop itself (in a modal like the tokens one), or on b.org/api.b.org.

@jlfranklin

The Date/Time Format Help module will include the documentation directly on the "Add date format" page.

klonos avatar Aug 20 '20 14:08 klonos

This sounds like a great idea.

stpaultim avatar Aug 21 '20 00:08 stpaultim

Related: https://github.com/backdrop/backdrop-issues/issues/1284

ghost avatar Mar 21 '22 23:03 ghost

Here's a PR that adds a fieldset of common date/time codes: https://github.com/backdrop/backdrop/pull/4007

image

It was inspired by the Date/Time Format Help contrib module, though not a direct integration (I figured we don't need to show all codes on this page, just the common ones, then link to PHP's manual for the rest).

ghost avatar Mar 22 '22 10:03 ghost

Cool, love it!

Some suggestions:

  • It could also be a details element, as this help item is new
  • It might make sense to collapse it initially
  • If the locale/language modules are enabled, one can "localize" these formats, but on that page the help isn't provided (/admin/config/regional/date-time/formats/long/localize)

That's all optional.

indigoxela avatar Mar 22 '22 11:03 indigoxela

Thanks for the suggestions.

  • What's the difference/benefit of 'details' over 'fieldset'?
  • I was about to say that I considered collapsing by default, but didn't see any benefits in doing so (considering there's nothing below to scroll to), but then I checked and the submit button is down there! So yes, we can either collapse by default, or (preferably) move the fieldset below the submit button...
  • Indeed, we should add there too.

I'll work on updating the PR, but not now. It's ~g:ia~ 10:46pm, so I'm off to bed 😉

ghost avatar Mar 22 '22 11:03 ghost

What's the difference/benefit of 'details' over 'fieldset'?

The details element is supported natively in browsers, IIRC. We used it for a similar use case of "additional information", for the "How layouts work" expandable information on /admin/structure/layouts.

bugfolder avatar Mar 22 '22 13:03 bugfolder

PR updated to:

  • Use <details> instead of <fieldset>
  • Move the PHP codes below the form submit button
  • Add the PHP codes to other forms as well:
    • 'Localize' tab for date formats
    • 'Logging and errors' form (/admin/config/development/logging)
    • Views' date fields (only visible when date format set to 'custom')

ghost avatar Mar 23 '22 02:03 ghost

Many thanks for updating. Still love it, although I find it a bit odd that the help for a form item appears sort of outside the form.

funny-form-order

Are we doing it that way somewhere else in core?

indigoxela avatar Mar 23 '22 07:03 indigoxela