In the field formatter, when the Day Notation option is set to a value of "none", the day-hour separator is still printed.

I can set the separator's option to an empty value, but even when doing that the item label <span> is still printed, which results in extra whitespace because of the width style that's applied to it.

These may be two separate issues
1. Not printing the separator if there's no day
2. Not printing the span if there's no label

But I figured that I would let the maintainer decide.

I would supply a patch, but to be honest I wasted a lot of time and had no success at trying to figure out where the separator is being added to the label. In my opinion a lot of this presentation logic should be moved to the template or its preprocessor function. Sorry if I'm just being clueless; I'm kind of tired this morning.

Comments

dcam created an issue. See original summary.

sumit-k’s picture

StatusFileSize
new1013 bytes

Replicate same issue. Patch is attached. Please Check

sumit-k’s picture

Status: Active » Needs review
sumit-k’s picture

johnv’s picture

StatusFileSize
new622 bytes

Perhaps I should implement your patch as well (there is another issue about the formatter not being 'clean').
But regarding your initial problem, please check attached patch.

sumit-k’s picture

Hey johnv,

Checked with your patch working fine for me.

johnv’s picture

Title: Issues when Day Notation is set to none » CSS-issues when Day-Notation is set to none
Status: Needs review » Needs work

It is not shown above, but the patch in #5 is now committed.
I'll keep this open for your patch in #2.

sumit-k’s picture

StatusFileSize
new1.05 KB

Hi johnv,

I am updating my patch for clean format. Please check.

sumit-k’s picture

Status: Needs work » Needs review
johnv’s picture

Status: Needs review » Needs work

Hmm,
I implemented your patch , but did not see any effect.
I disabled COmments in the field, and set the Day notation to None.

Which forematter do you use? The Table, or the PlainText?

sumit-k’s picture

I checked with plain text

super_romeo’s picture

Status: Needs work » Needs review
StatusFileSize
new2.09 KB

My try :)

super_romeo’s picture

matija5’s picture

Hi, confirming patch #13 applies and that label for Plain text formatter is removed if Day notation is set to none.

johnv’s picture

I just committed #3136825: Avoid HTML tags for empty slots and comments.
(How) does that influence this patch?

Also, the patches above are all very different. I am not sure if they all address the same issue.
Can someone clarify?
Thanks.

super_romeo’s picture

Patch stop applied because of this new lines in office-hours.html.twig file.

matija5’s picture

@johnv in related issue there are checks for slots and comments but not for label (days). This patch solves rendering of label element. But I think we just need this in template file

{% if item.label %}
  <span class="office-hours__item-label" style="width: {{ label_length * 0.60 }}em;">{{ item.label }}</span>
{% endif %}

and we can skip changes in src/Plugin/Field/FieldType/OfficeHoursItemList.php because if we set "none" for "Day notation" then the value for $info['label'] is "".

super_romeo’s picture

I can't see source code right now, but I remember, that if we skip changes in OfficeHoursItemList.php then the value for $info['label'] will be not empty string.
But if it will be empty string, of course we can skip whose changes.

super_romeo’s picture

Tested one more time. Without my patch I have: - : 8:00-20:00

johnv’s picture

Status: Needs review » Needs work
johnv’s picture

johnv’s picture

johnv’s picture

  • johnv committed e0ce7de on 8.x-1.x authored by super_romeo
    Issue #3074361 by bsumit5577, super_romeo: CSS-issues when Day-Notation...
johnv’s picture

The commit now looks like #13.
As commented above, the additional change in PHP might be superfluous, but more correct.

However, I need some CSS/Twig help from you: Why is this not applied in the TableFormatter, only in PlainTextFormatter?
For this, keeping it open.

super_romeo’s picture

Because currently I use PlainTextFormatter only... :)

johnv’s picture

Version: 8.x-1.x-dev » 8.x-1.3
Status: Needs work » Fixed

There is no problem in TableFormatter.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.