Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPDX support + license selection improvements #1546

Merged
merged 12 commits into from
Aug 23, 2023
Merged

SPDX support + license selection improvements #1546

merged 12 commits into from
Aug 23, 2023

Conversation

fbacall
Copy link
Contributor

@fbacall fbacall commented Jul 25, 2023

  • Adds SPDX licenses to the current supported set of licenses in SEEK (non-SPDX licenses are retained).
  • Improves license selection to be searchable/filterable (using select2).
  • Allows licenses to be provided by URI instead of just ID.

image

image

@fbacall fbacall requested a review from stuzart August 18, 2023 09:22
Comment on lines 8 to 9
licenses['notspecified']['title'] = I18n.t('null_license')
licenses['notspecified']['url'] = Seek::Help::HelpDictionary.instance.help_link(:null_license)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be using NULL_LICENSE constant to get the key

Comment on lines 6 to 15
opts[:data] ||= {}
opts[:data]['role'] ||= 'seek-license-select'
recommended = opts.delete(:recommended)
source = opts.delete(:source) || Seek::License.combined
if recommended
options = grouped_options_for_select(grouped_license_options(source.values, recommended), selected)
else
options = options_for_select(license_options(source.values), selected)
end
select_tag(name, options, opts)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be good if this could be done via the objects_input helper, in the interest of keeping things self contained and easier to understand and maintain in the future. I can see the grouped options would be a problem here, but may be something useful elsewhere in the future. Did you give this any thought?

I'm a bit uncomfortable having different select2 implementations in various places, it was a pain and error prone when switching over from typeahead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use objects_input, but I think it needs some tweaks to make it more appropriate for selecting single values.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can just include options[:limit]=1 for single values, which ends up setting select2's maximumSelectionLength when initializing - https://github.com/seek4science/seek/blob/seek-1.14/app/assets/javascripts/objects_input.js#L22C17-L22C44

Or perhaps I'm misunderstanding something, it's not clear to me how it is currently limiting the number of licenses selected

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it's via the displayUrl function, might want to look at using select2 built in handlers, I added another review comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's currently just a regular select tag (not a multiple select combobox) so it only allows 1 selection by default.

Limiting to 1 is a possibility, but then you have to clear the value with the X icon before you can choose a different license, instead of just directly selecting another option, which is a bit awkward

Comment on lines +8 to +22
displayUrl: function () {
var element = $j('option:selected', $j(this));
var link = $j('#license-url');
if (link.length) {
var block = link.parents('.license-url-block');

if (element.data('url')) {
block.show();
} else {
block.hide();
}

link.attr('href', element.data('url'));
link.html(element.data('url'));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might want to look at https://select2.org/programmatic-control/retrieving-selections about retrieving selections, which also advices against reading the selected option. Probably also use select2:select as the event for when it has been selected.

* Allow single value mode for `objects_input`
* Add ability to pass select options to `objects_input`
@fbacall fbacall merged commit d1f1bd1 into main Aug 23, 2023
25 checks passed
@fbacall fbacall deleted the spdx branch September 8, 2023 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

spdx licenses Feature request: Licenses
2 participants