Sort order of same day slots incorrect in row (widget) and column (formatter)

Created on 25 January 2024, 10 months ago
Updated 13 February 2024, 9 months ago

Problem/Motivation

Updated office_hours from a lower version to 1.12. But this problem is certainly being created between 1.11 and 1.12.
I'm using the Plain text formatter.

Attached some screenshots of the edit widget and formatter output.

Steps to reproduce

Set values in 1.11 and update the module to 1.12

Can't find a solution for now so I downgraded to 1.11.

🐛 Bug report
Status

Fixed

Version

1.12

Component

Code

Created by

🇧🇪Belgium stijnd Belgium

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

Comments & Activities

  • Issue created by @stijnd
  • 🇳🇱Netherlands johnv

    I did encounter such behaviour when developing for the upcoming version 1.13.
    But now, the problem is gone (for me, as maintainer).
    I did receive one other issue (cannot find it back).
    I expected that the error was in my development code, but now it seems it is already in v1.12.
    Please try current dev version, and report back.

  • Status changed to Postponed: needs info 10 months ago
  • 🇧🇪Belgium stijnd Belgium

    The issue is not fixed on the current dev version.

  • Status changed to Active 10 months ago
  • 🇧🇪Belgium stijnd Belgium
  • 🇳🇱Netherlands johnv

    When the data is saved wrongly, it must be corrected in the widget, first.

    First establish/test that the widget works fine, then find out which data is wrong.

  • 🇧🇪Belgium stijnd Belgium

    Had another look at this one.

    According to me there's a storage problem. The deltas are wrong. See attached screenshots. I can't see where's the issue in the Widget for now.

  • 🇳🇱Netherlands johnv

    The delta in the table is de delta for the complete field, for a 2-slots-per-day, having values 0-13 (or 1-14)
    However, this field is not used in the entityfield display. Here, you only have values 0-1 for a 2-slots-per-day system.

    You will find some issues in the issue queue regarding sorting. Days and slots per day are now sorted, according to date and start time.
    So your situation is 'works as designed.'

    Another thing:
    Your example has an empty timeslot with a non-empty comment, that is why it is stored. You can use it for 'closed today' text, instead of the 'closed text' in field settings.
    If you remove the comment, the value is not stored anymore.
    In the formatter, when the first value is an 'all_day' (values 0-0), any subsequent slots are not displayed. This must still be guared in the widget.

  • 🇧🇪Belgium stijnd Belgium

    I understand your comment regarding the delta. Weird I add a comment in the second slot and it is saved as first delta, instead of second, but I can find me in 'Works as designed'.
    Digged in quite deep and I've seen this is not an easy one.

    What I don't understand is the empty time slot. For my use case it's necessary the "not empty comment" is stored because this generated a kind of table for the morning/afternoon (with the Plain text Formatter):

    Morning / afternoon
    Monday: - 13 until 17h
    Tuesday: 8 until 12 -

    If there's another solution of doing this I'm missing out on something. Nevertheless, in the older version of the module this was possible by leaving the timeslot empty and adding a comment. I hope I'm not the only one who used this module like this :-)

  • 🇳🇱Netherlands johnv

    I understand, you ALWAYS want 2 slots. I must check this out.
    For my testing, developing, I only use the table formatters, I am not sure if the normal formatter supports all cases, too.

  • 🇧🇪Belgium stijnd Belgium

    Correct. This improves reading for the users in my opinion because in my case it's always morning/afternoon.

    At the moment of developing the project this was not possible with the Table formatter so I decided to use the Plain text formatter with some styling.

    • johnv committed d0fdba8d on 8.x-1.x
      Issue #3416914: Sort order of same day slots is lost
      
  • Status changed to Fixed 10 months ago
  • 🇳🇱Netherlands johnv

    Please test new dev version.

    I removed the sorting of hours. I feel they must be left to the user's responsibility.

    The behaviour of PHP 8 if different then of PHP 7.
    From https://www.php.net/manual/en/array.sorting.php
    // "If any of these sort functions evaluates two members as equal
    // then they retain their original order. Prior to PHP 8.0.0,
    // their order were undefined (the sorting was not stable)."

    So basically, this reverts the change in 🐛 Sort order of Same day time slots is lost Fixed .

    The sorting is now only done in the formatter, not when saving the data from the widget.
    (Perhaps i will get follow-up complaints about the sorting of exception days in the widget.)

    One doubt: not sure if the comments show up correctly. It may be my own settings.
    Please test and report back. If there is any problem, please reopen this issue.

    • johnv committed 2b544244 on 8.x-1.x
      Issue #3416914: Sort order of same day slots is lost- so is comment
      
  • 🇳🇱Netherlands johnv

    Indeed, there was an error displaying the comments

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

Production build 0.71.5 2024