Skip to content

Commit

Permalink
Fix rendering of license_expression fields in admin #63
Browse files Browse the repository at this point in the history
Signed-off-by: tdruez <tdruez@nexb.com>
  • Loading branch information
tdruez committed Jun 27, 2024
1 parent 4d58976 commit 3ee264d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
12 changes: 12 additions & 0 deletions component_catalog/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,12 @@ class ComponentAdminForm(
SetKeywordsChoicesFormMixin,
DataspacedAdminForm,
):
expression_field_names = [
"license_expression",
"declared_license_expression",
"other_license_expression",
]

keywords = JSONListField(
required=False,
widget=AdminAwesompleteInputWidget(attrs=autocomplete_placeholder),
Expand Down Expand Up @@ -983,6 +989,12 @@ class PackageAdminForm(
SetKeywordsChoicesFormMixin,
DataspacedAdminForm,
):
expression_field_names = [
"license_expression",
"declared_license_expression",
"other_license_expression",
]

keywords = JSONListField(
required=False,
widget=AdminAwesompleteInputWidget(attrs=autocomplete_placeholder),
Expand Down
2 changes: 1 addition & 1 deletion component_catalog/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ def render(self, name, value, *args, **kwargs):
self.object_instance.policy_from_primary_license,
)

return rendered + value_from_license
return format_html("{}{}", rendered, value_from_license)
7 changes: 4 additions & 3 deletions dejacode/static/css/dejacode_admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,16 @@ p.url .vURLField {margin-top: 5px; width: 710px;}
fieldset.grp-module p.selector-filter label {display: none;}

/* Fix for the visibility of the awesomplete license expression builder choices */
fieldset.grp-module div.license_expression,
fieldset.grp-module div.from_expression,
fieldset.grp-module div.to_expression,
fieldset.grp-module div[class*="_expression"],
fieldset.grp-module div.primary_language,
fieldset.grp-module div.keywords,
fieldset.grp-module div.feature {overflow: visible;}
body.mass_update div.awesomplete {display: block;}
div.awesomplete > ul {z-index: 1000 !important;}

/* License expression fields */
textarea#id_declared_license_expression, textarea#id_other_license_expression {height: 60px;}

/* License choices */
code.license_expression {border: 1px solid #ccc; background-color: #EEE; color: black; padding: 2px 4px; border-radius: 3px;}
button.submit-inline-button {font-weight: bold; padding: 0 5px; width: auto; background-color: #40A7C9; border: 1px solid #2b8aab;}
Expand Down

0 comments on commit 3ee264d

Please sign in to comment.