Skip to content

Commit

Permalink
Using extra accessors
Browse files Browse the repository at this point in the history
  • Loading branch information
mesemus committed Feb 26, 2024
1 parent 7514527 commit a44dcb0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion oarepo_ui/resources/templating/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ def _as_array(self):

@property
def _is_empty(self):
return not bool(self.__data)
if not self.__data:
return False
return True

@property
def _has_value(self):
Expand Down
2 changes: 1 addition & 1 deletion oarepo_ui/templates/components/datafields/IField.jinja
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{# def d=True, label=None, placeholder=None, keep=false, field_class=None #}

{%- if not d._is_empty or keep -%}
{%- if d._has_value or keep -%}
<IBaseField label={label or d._ui_label} field_class={field_class}>
{%- if content is not none and ((content is not string) or content.strip()) -%}
{{ content }}
Expand Down
2 changes: 1 addition & 1 deletion oarepo_ui/templates/components/datafields/INonEmpty.jinja
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{# def d #}

{% if array(d, remove_empty=True) | length -%}
{% if d._has_value -%}
{{ content }}
{%- endif %}

0 comments on commit a44dcb0

Please sign in to comment.