Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions tir/technologies/core/language.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def __init__(self, language="pt-BR"):

self.filters = languagepack["Filters"]
self.apply_filters = languagepack["Apply Filters"]
self.remove_filters = languagepack["Remove Filters"]
self.old_browse_edit = languagepack["Old Browse Edit"]
self.old_browse_delete = languagepack["Old Browse Delete"]
self.old_browse_insert = languagepack["Old Browse Insert"]
Expand Down Expand Up @@ -204,6 +205,7 @@ def get_language_pack(self, language):
"New Home Menu About": "About",
"Filters": "Filters",
"Apply Filters": "Apply filters",
"Remove Filters": "Remove filters",

"Old Browse Edit":"Edit",
"Old Browse Delete":"Delete",
Expand Down Expand Up @@ -311,7 +313,8 @@ def get_language_pack(self, language):
"Input Set Program": "Pesquisar e executar",
"New Home Menu About": "Sobre",
"Filters": "Filtros",
"Apply Filters": "Aplicar Filtros",
"Apply Filters": "Aplicar Filtros",
"Remove Filters": "Remover filtros",

"Old Browse Edit":"Alterar",
"Old Browse Delete":"Excluir",
Expand Down Expand Up @@ -418,7 +421,8 @@ def get_language_pack(self, language):
"Input Set Program": "Buscar y ejecutar",
"New Home Menu About": "Sobre",
"Filters": "Filtros",
"Apply Filters": "Aplicar Filtros",
"Apply Filters": "Aplicar Filtros",
"Remove Filters": "Eliminar filtros",
"Old Browse Edit":"Modificar",
"Old Browse Delete":"Borrar",
"Old Browse Insert":"Incluir",
Expand Down Expand Up @@ -525,6 +529,9 @@ def get_language_pack(self, language):
"Schedule Menu": "Settings > Schedule > Schedule",
"Input Set Program": "Ищи и беги",
"New Home Menu About": "О программе…",
"Filters": "Фильтры",
"Apply Filters": "Применить фильтры",
"Remove Filters": "Удалить фильтры",

"Old Browse Edit":"Редактировать",
"Old Browse Delete":"Удалить",
Expand Down
69 changes: 66 additions & 3 deletions tir/technologies/poui_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -5637,8 +5637,8 @@ def _set_browse_filters(self, filters):
[Internal]
Open and apply filters to each field in a THF Browse component.

:param filters: Dictionary or list of filters to apply, where keys are field names and values are filter values.
:type filters: dict or list
:param filters: List of dictionaries representing filters to apply, where each dictionary's keys are field names and values are filter values.
:type filters: list
:param browse_div: BeautifulSoup object representing the browse container element.
:type browse_div: bs4.element.Tag
:return: None
Expand All @@ -5647,9 +5647,11 @@ def _set_browse_filters(self, filters):
Usage:

>>> # Calling the method:
>>> self._filter_thf_browse(filters={'name': 'John'}, browse_div=browse_element)
>>> self._filter_thf_browse(filters=[{'name': 'John'}], browse_div=browse_element)
"""

self._remove_filters_from_browse()

self.click_button(self.language.filters)

self.wait_element_timeout('po-page-slide', scrap_type=enum.ScrapType.CSS_SELECTOR, main_container='body',
Expand Down Expand Up @@ -5683,6 +5685,67 @@ def _set_browse_filters(self, filters):
self.click_button(self.language.apply_filters)


def _remove_filters_from_browse(self):
"""
[Internal]

Clicks the "Remove Filters" button in a THF Browse component to clear all applied filters.
Also checks for a po-tag element inside kendo-grid whose span text is
"Remover filtros" or "Remove filters", and clicks it when found.

:return: None
:rtype: None

Usage:

>>> # Calling the method:
>>> self._remove_filters_from_browse()
"""

po_tag_filter = self._get_po_tag(text=self.language.remove_filters, container_selector='kendo-grid')
if po_tag_filter:
logger().debug("Found applied filters, clicking to remove filters.")
clickable = po_tag_filter.select_one('.po-tag-wrapper.po-clickable')
target = clickable if clickable else po_tag_filter
self.poui_click(target)
self.po_loading(self.containers_selectors['GetCurrentContainer'])
else:
logger().debug("No 'Remove Filters' found; skipping filter removal.")


def _get_po_tag(self, text: str, container_selector: str):
"""
[Internal]

Searches for a po-tag element inside a specified container whose span text matches
the given text (case-insensitive).

:param text: Text to match inside the po-tag span.
:type text: str
:param container_selector: CSS selector for the container to search within.
:type container_selector: str
:return: The matching po-tag BeautifulSoup element, or None if not found.
:rtype: bs4.element.Tag or None
"""

soup = self.get_current_DOM(twebview=True)
if container_selector:
container = soup.select_one(container_selector)
else:
container = soup

if not container:
logger().debug(f"No container found in DOM when searching for po-tag filter with selector '{container_selector}'.")
return None

for po_tag in container.select('po-tag'):
span = po_tag.select_one('.po-tag-value span')
if span and span.text.strip().lower() == text.strip().lower():
return po_tag

return None


def _fill_lookup_input(self, input_element, value: str) -> None:
"""
[Internal]
Expand Down
Loading