From 51687b1ff8945400e72b51a86f05f0ec5715cce5 Mon Sep 17 00:00:00 2001 From: Roman Dvorak Date: Tue, 12 Mar 2024 19:59:47 +0100 Subject: [PATCH] category icons --- src/OpenIntranet/plugins/store/store.py | 2 +- .../templates/store/store.api.template.component.row.hbs | 3 ++- src/OpenIntranet/templates/store/store.component.card.hbs | 2 +- src/OpenIntranet/templates/store/store.home.hbs | 7 +++++++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/OpenIntranet/plugins/store/store.py b/src/OpenIntranet/plugins/store/store.py index 3596d3e..1db1704 100644 --- a/src/OpenIntranet/plugins/store/store.py +++ b/src/OpenIntranet/plugins/store/store.py @@ -240,7 +240,7 @@ def post(self): '$limit' : int(page_len) },{ "$lookup":{ - "from": "category", + "from": "category_complete", "localField": "category", "foreignField": "_id", "as": "category" diff --git a/src/OpenIntranet/templates/store/store.api.template.component.row.hbs b/src/OpenIntranet/templates/store/store.api.template.component.row.hbs index 0209b5c..8d1de66 100644 --- a/src/OpenIntranet/templates/store/store.api.template.component.row.hbs +++ b/src/OpenIntranet/templates/store/store.api.template.component.row.hbs @@ -2,8 +2,9 @@ -->
- + +
diff --git a/src/OpenIntranet/templates/store/store.component.card.hbs b/src/OpenIntranet/templates/store/store.component.card.hbs index 87b3702..1a7459e 100644 --- a/src/OpenIntranet/templates/store/store.component.card.hbs +++ b/src/OpenIntranet/templates/store/store.component.card.hbs @@ -55,7 +55,7 @@ function select_package_formatter(data) {
-
Categories: {% for cat in component['categories'] %} {{'/'.join(cat.get('path_string', [])+[cat['name']])}}{% end %}
+
Categories: {% for cat in component['categories'] %} {% if cat.get('icon_url') and cat.get('icon_url') != 'null'%} {% end %} {{'/'.join(cat.get('path_string', [])+[cat['name']])}}{% end %}
diff --git a/src/OpenIntranet/templates/store/store.home.hbs b/src/OpenIntranet/templates/store/store.home.hbs index cd8f834..66488d0 100644 --- a/src/OpenIntranet/templates/store/store.home.hbs +++ b/src/OpenIntranet/templates/store/store.home.hbs @@ -471,6 +471,13 @@ function update_view(){ try{ tmpl.querySelector('.component_image').setAttribute('src', element['img_title']['url']) } catch(e){}; + try{ + if(element['category'][0]['icon_url'].length > 2){ + tmpl.querySelector('.component_image_category').setAttribute('src', element['category'][0]['icon_url']) + tmpl.querySelector('.component_image_category').style.display = 'block'; + } + } catch(e){}; + // zaskrtavatko vybaraných polozek if(selected.indexOf(element['_id'].$oid) >= 0){ tmpl.querySelector('.product_list-select').checked = true;