Skip to content

Commit

Permalink
components refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Alzpeta committed Nov 1, 2023
1 parent 4812472 commit ffdc6d9
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 6 deletions.
21 changes: 17 additions & 4 deletions oarepo_ui/resources/templating.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from jinja2 import Environment
from jinja2.loaders import BaseLoader

import os

class RegistryLoader(BaseLoader):
def __init__(self, parent_loader) -> None:
Expand Down Expand Up @@ -57,6 +57,19 @@ def id_filter(x):
return id(x)


def to_dict(value=None):
if value:
return value
def get_components():

component_data = []
directory = os.path.dirname(os.path.abspath(__file__ or ''))
parent_directory = os.path.dirname(directory)
components_directory = os.path.join(parent_directory, 'templates', 'components')


file_names = os.listdir(components_directory)

for file_name in file_names:
component_data.append({"key": file_name.replace(".jinja", "").lower(), "component": file_name.replace(".jinja", "")})


return component_data

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions oarepo_ui/templates/components/Multilingual.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{# def data #}
<div class="ui multilingual-tabs">
<div class="ui compact text menu separated">
{% for item in data %}
<a class="green item {{'active' if loop.first else ''}}" data-tab="{{item|id}}-{{item.lang|e}}">{{item.lang|upper}}</a>
{% if not loop.last %}
<div class="separator"><div class="vertical-bar"></div></div>
{% endif %}
{% endfor %}
</div>
{% for item in data %}
<div class="ui tab {{'active' if loop.first else ''}}" data-tab="{{item|id}}-{{item.lang|e}}">
{{ item.value|e }}
</div>
{% endfor %}
</div>
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{# def className, data #}
{# def data, className="" #}
{% set data_dict = data | to_dict %}
<a class="ui {{className}}" href="{{data_dict.href | e}}" aria-label="{{data_dict.title}}" title="{{data_dict.title}}">
<span class="{className} label">
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = oarepo-ui
version = 5.0.79
version = 5.0.80
description = UI module for invenio 3.5+
long_description = file: README.md
long_description_content_type = text/markdown
Expand Down

0 comments on commit ffdc6d9

Please sign in to comment.