Timestamp CE Field Formatter

Created on 7 August 2024, 8 months ago

Problem/Motivation

Currently the module doesn't have a proper formatter for timestamp, created and changed field types.

Proposed resolution

Create a new TimestampCeFieldFormatter plugin derivative

Feature request
Status

Needs work

Version

3.0

Component

Code

Created by

🇭🇺Hungary junkuncz Budapest

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @junkuncz
  • Merge request !75Add TimestampCeFieldFormatter plugin → (Merged) created by junkuncz
  • Pipeline finished with Success
    8 months ago
    #246716
  • Pipeline finished with Success
    8 months ago
    #246726
  • Pipeline finished with Success
    8 months ago
    #246732
  • Issue was unassigned.
  • Status changed to Needs review 8 months ago
  • 🇭🇺Hungary junkuncz Budapest

    Phpstan report is irrelevant regarding code changes. Ready for review.

  • 🇳🇱Netherlands roderik Amsterdam,NL / Budapest,HU

    Random FYI

    I now briefly checked 📌 Improve CustomElement::createFromRenderArray() to better handle entites that render to custom elements Active and understand what that issue is about and why.

    But that (i.e. some logic that 'strips down' the render array) won't help with using the Core formatter for dates for timestamp/created/changed fields. It just has too many options, optionally a tooltip, optionally attached JS libraries... (Which is why it has its own #theme function.)

    ...Unless we add a config option to Core field formatters, to just take the literal value from the #text key, and discard literally everything else. But that doesn't feel very useful to me, at the moment.

  • Status changed to Needs work 8 months ago
  • 🇳🇱Netherlands roderik Amsterdam,NL / Budapest,HU
  • Status changed to Needs review 8 months ago
  • 🇭🇺Hungary junkuncz Budapest
  • Pipeline finished with Success
    8 months ago
    Total: 203s
    #252921
  • Pipeline finished with Success
    8 months ago
    Total: 171s
    #252932
  • Status changed to RTBC 8 months ago
  • 🇳🇱Netherlands roderik Amsterdam,NL / Budapest,HU

    I'll set this to RTBC and I might commit this.

    But i will wait to see if my (still to be made) issue about changing CustomElementsFieldFormatterBase::getSetting() gets reviewed soon. If so, and if @fago feels that the $configuration = $this->configuration + $this->defaultSettings(); is 'code pollution' after that, we might still change that.

  • Assigned to fago
  • 🇦🇹Austria fago Vienna

    taking a look

  • Issue was unassigned.
  • 🇳🇱Netherlands roderik Amsterdam,NL / Budapest,HU

    Rebased (because Github complains the branch is un-mergeable for no reason), and added 1 commit which updates to our latest conventions, now that 📌 Doublecheck CustomElementsFieldFormatterBase::getSetting() Active is committed.

    Some summary of that issue's outcome and our code conventions that I will stick to:

    • We use $this->configuration[KEY] instead of $this->getSetting(KEY) in our code. (They are interchangeable; we are apparently acting as if getSetting() does not exist, because we would rather it didn't exist. But it's part of an interface we implement, so we can't remove it.)
    • never implement defaultSetttings() (which we also would rather see disappear); always implement defaultConfiguration().
    • KEY does not need to be checked for existence, as long as it's defined in defaultConfiguration() + we are implementing CustomElementsFieldFormatterBase, which merges the defaults into $this->configuration

    In the meantime, FileCeFieldFormatter got similar additions in Create a image-style dropdown to the file/image formatter Fixed which also needs to be updated according to the same conventions. Doing that in the same commit.

    Also:

    I was wondering about 'optional' configuration values. My feeling says that I don't like them always being present, in saved configuration. (Why would we save e.g. custom_format: "" when we never set or use it?). However,

    • It is easier for the code, to define it in defaultConfiguration()
    • I tested Core field formatters, and they (at least TimestampFormatter) also always export all configuration settings, including optional/empty ones. So let's treat that as convention, then.
  • Pipeline finished with Skipped
    4 months ago
    #367014
  • 🇳🇱Netherlands roderik Amsterdam,NL / Budapest,HU
    • roderik committed c59abea5 on 3.x
      Issue #3466510: fix #states selector for custom date format.
      
    • roderik committed d795dc86 on 3.x
      Issue #3466510: Fix custom date format in settings summary
      
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024