Problem/Motivation

"- Select a value -" for required field or "- None -" for unrequired field doesn't appear (becomes empty) if term is single in a level.
They appear if terms are multiple in a level.

Steps to reproduce

Create terms; (See terms.png)
Level1 "1" > Level2 "1-1", "1-2", "1-3", "1-4"
Level1 "2" > Level2 "2-1"
Show SHS on a node. (See rc4_multiterm_OK.png, rc4_singleterm_NG.png, expected_singleterm.png)

Proposed resolution

Reverting /shs/js/views/WidgetView.js of 2.0.0-rc4 to 2.0.0-rc1 works OK.

diff WidgetView.js WidgetView.js.rc1
97a98,100
> // Add "any" option.
> widget.$el.append($('').text(widget.container.app.getSetting('anyLabel')).val(widget.container.app.getSetting('anyValue')));
>
122,126d124
<
< // Add "any" option.
< if (widget.model.itemCollection.length > 1) {
< widget.$el.append($('').text(widget.container.app.getSetting('anyLabel')).val(widget.container.app.getSetting('anyValue')));

Issue fork shs-3359292

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

kubokura created an issue. See original summary.

sunidhinegi31’s picture

I am working on this issue.

sunidhinegi31’s picture

Assigned: Unassigned » sunidhinegi31
dydave’s picture

Version: 2.0.0-rc4 » 2.0.x-dev
Assigned: sunidhinegi31 » Unassigned
Status: Active » Needs review
Related issues: +#3254384: anyLabel is set up even if there is only one element in the list
StatusFileSize
new469 bytes

Hi everyone,

Thank you very much for raising this issue and suggesting the changes needed, it's greatly appreciated.

After taking a closer look in the issue queue, it appears this particular ticket is conflicting with the work that was done previously in #3254384: anyLabel is set up even if there is only one element in the list, with the following change:
https://git.drupalcode.org/project/shs/-/commit/e0847eb9c10182ac0057f298...

As suggested in the issue summary, roling back these changes seems to fix the problem.

Please find attached to this reply a patch on '2.0.x':
shs-support-anylabel-for-single-select-value-3359292-4.patch

We would greatly appreciate if you could please try testing the patch and let us know if you encounter any issues.

Feel free to let us know if you have any questions on the patch, or this ticket in general, we would be glad to provide more information.
Thanks in advance!

kubokura’s picture

Hi DYdave-san, thank you for the patch.
The patch works for me. Terms appear correctly instead of blank.
(It seems the patch conflicts with 4.diff on https://www.drupal.org/project/shs/issues/3269746 , so I have needed to edit js/views/WidgetView.js manually.)

grimreaper’s picture

Status: Needs review » Reviewed & tested by the community

Hi,

Thanks for the patch.

Applied and it fixed the problem.

rossb89’s picture

Thanks for the work here. I also had the same issue as @kubokura in that I need this patch and the MR patch from #3269746 as well really and they are both modifying the same line.

I've created a combo patch if anyone finds they need both patches really (I can't see why you wouldn't need both!) which will suffice until such time one is merged and then the other can be patched cleanly and merged :)

grimreaper’s picture

Assigned: Unassigned » grimreaper
Status: Reviewed & tested by the community » Needs work

Hi,

Patch no more apply on 2.0.2.

Creating MR.

grimreaper’s picture

Assigned: grimreaper » Unassigned
Status: Needs work » Reviewed & tested by the community
StatusFileSize
new872 bytes

MR created.

Patch from MR for Composer.

luongosb’s picture

Tested and can confirm it is working correctly in our environment.

steven jones’s picture

Patch in #10 / MR!36 is working for us, thanks for the work here.

giannis makantasis’s picture

Patch in #10 for module version 2.0.2 is working for us as well , thanks!

luongosb’s picture

Confirming that patch #10 is working with version 2.0.2. Thank you!

joseph.olstad’s picture

Status: Reviewed & tested by the community » Fixed
joseph.olstad’s picture

Status: Fixed » Closed (fixed)

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