When porting office_hours from D7 to D8, the javascript is broken.
It contains:
- an Add link: 'add time slot' --> Fixed in #18
- a Copy link: 'same as above' --> Fixed in #21
- a Delete link: 'Remove' --> OK

A volunteer is needed to fix this code. See also the open issues regarding the widget.

Comments

johnv created an issue. See original summary.

gunwald’s picture

I could help with the JS part, but would you describe what exactly the JS is supposed to do so far.

johnv’s picture

Thanks for your offer.

1. The main JS-feature is:
If you define an OH field with 3 slots per day, you will now see 2 lines with the word 'and' in the first column and entry boxes in the remaining columns.
The required result (as you can see in the D7-version of OH):
- first line (of a day) is OK and is shown completely ( since it is the first line)
- 2nd line should show ONLY a JS-link with the text 'add more hours' (Since it initially contains no value, but the previous line is shown/has content.) Clicking on this exposes the entry boxes and the title 'and'.
- 3rd line should be hidden, since a) is has no initial content, and b) the line above has no initial content.

2. The D7 value contains some extra links like 'clear line' . You will find remains of it in the code.
see #2044465: Add links 'clear' and 'apply to all' to Widget to improve usability

The result should be the same as the D7 version. part one is the most important, and is a release blocker. Part 2 is a nice extra, and is not working entirely properly in D7 either.

gunwald’s picture

Thank you for making that clear.
I looked into the code, apparently someone had already ported it to the Drupal 8 version of OH, but the CSS classes to decide which slot should be hidden (is empty) are missing. So, first thing to make JS working again, is to change the widget by adding a hidden 'Add more' link.
The second would be, to add a class to all empty slots (slots with empty fields) to make it easier to the JS part to decide which slot has to be hidden. In my opinion this should be done within a form state hook (at least in Drupal 7).

Where can I check out the current version?
git clone --branch 8.x-1.x git://git.drupal.org/project/office_hours.git
Seems to give me an old one.

johnv’s picture

Sounds like a solid analysis. The git 8nstructions on the project page are correct, so:
git clone --branch 8.x-1.x https://git.drupal.org/project/office_hours.git
cd office_hours

I did the update to D8. Perhaps the css classes are missing because the theme functions are very different with D7.

captcodemonkey’s picture

What's the current status here? I'm willing to help resolve the JS blockers, but D.O isn't the best at showing them.

johnv’s picture

There hasn't been any progress. The status and tasks in #3 still reflect the current situation.

Any help would be amazing.

johnv’s picture

Component: Code » Code - widget
johnv’s picture

Priority: Normal » Major
johnv’s picture

Issue summary: View changes

  • johnv committed 89f35bb on 8.x-1.x
    Issue #2627934: Add js file to widget
    
johnv’s picture

Above commit adds a skeleton for adding the js file. It is not activated yet, since that makes the widget hidden.

  • johnv committed 47eef45 on 8.x-1.x
    Issue #2627934: Add js file to widget
    

  • johnv committed fa09d1a on 8.x-1.x
    Issue #2627934: Fix javascript - initial clean-up of code
    

  • johnv committed adb4c97 on 8.x-1.x
    Issue #2627934: Fix javascript - initial clean-up of code
    
johnv’s picture

johnv’s picture

Issue summary: View changes

  • johnv committed 35f1392 on 8.x-1.x
    Issue #2627934: Fix Add link in javascript
    
johnv’s picture

Issue summary: View changes

  • johnv committed 43f4024 on 8.x-1.x
    Issue #2627934: Fix Clearing comment in javascript link
    

  • johnv committed cad00f4 on 8.x-1.x
    Issue #2627934: Fix Copy link in javascript
    
johnv’s picture

Version: 8.x-1.x-dev » 8.x-1.0-alpha2
Issue summary: View changes
Status: Active » Fixed

This is now fixed. :-)

Status: Fixed » Closed (fixed)

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