From 721251f09f6efe6a9cacc176ea355ba7cffb9008 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Wed, 18 Nov 2020 17:56:37 +0530 Subject: [PATCH] feat: add product category cards --- .../product_category_cards.html | 53 +++++++++++++++++++ .../product_category_cards.json | 28 ++++------ 2 files changed, 62 insertions(+), 19 deletions(-) diff --git a/erpnext/shopping_cart/web_template/product_category_cards/product_category_cards.html b/erpnext/shopping_cart/web_template/product_category_cards/product_category_cards.html index e69de29bb2..88ba7fd898 100644 --- a/erpnext/shopping_cart/web_template/product_category_cards/product_category_cards.html +++ b/erpnext/shopping_cart/web_template/product_category_cards/product_category_cards.html @@ -0,0 +1,53 @@ +{%- macro card(title, image, url, text_primary=False) -%} +{%- set align_class = resolve_class({ + 'text-right': text_primary, + 'text-centre': align == 'Center', + 'text-left': align == 'Left', +}) -%} +
+ {% if image %} + {{ title }} + {% endif %} +
+ {{ title or '' }} +
+ +
+{%- endmacro -%} + +
+ {%- if title -%} +

{{ title }}

+ {%- endif -%} + {%- if subtitle -%} +

{{ subtitle }}

+ {%- endif -%} + +
+
+ {%- for index in ['1', '2', '3', '4', '5', '6', '7', '8'] -%} + {%- set category = values['category_' + index] -%} + {%- if category -%} + {%- set category = frappe.get_doc("Item Group", category) -%} + {{ card(category.name, category.image, category.route) }} + {%- endif -%} + {%- endfor -%} +
+
+
+ + diff --git a/erpnext/shopping_cart/web_template/product_category_cards/product_category_cards.json b/erpnext/shopping_cart/web_template/product_category_cards/product_category_cards.json index 1a3143c209..ba5f63b48b 100644 --- a/erpnext/shopping_cart/web_template/product_category_cards/product_category_cards.json +++ b/erpnext/shopping_cart/web_template/product_category_cards/product_category_cards.json @@ -5,78 +5,68 @@ "doctype": "Web Template", "fields": [ { - "__unsaved": 1, "fieldname": "title", "fieldtype": "Data", "label": "Title", "reqd": 1 }, { - "__unsaved": 1, "fieldname": "subtitle", "fieldtype": "Data", "label": "Subtitle", "reqd": 0 }, { - "__unsaved": 1, - "fieldname": "category_1_group", + "fieldname": "category_1", "fieldtype": "Link", "label": "Item Group", "options": "Item Group", "reqd": 0 }, { - "__unsaved": 1, - "fieldname": "category_2_group", + "fieldname": "category_2", "fieldtype": "Link", "label": "Item Group", "options": "Item Group", "reqd": 0 }, { - "__unsaved": 1, - "fieldname": "category_3_group", + "fieldname": "category_3", "fieldtype": "Link", "label": "Item Group", "options": "Item Group", "reqd": 0 }, { - "__unsaved": 1, - "fieldname": "category_4_group", + "fieldname": "category_4", "fieldtype": "Link", "label": "Item Group", "options": "Item Group", "reqd": 0 }, { - "__unsaved": 1, - "fieldname": "category_5_group", + "fieldname": "category_5", "fieldtype": "Link", "label": "Item Group", "options": "Item Group", "reqd": 0 }, { - "__unsaved": 1, - "fieldname": "category_6_group", + "fieldname": "category_6", "fieldtype": "Link", "label": "Item Group", "options": "Item Group", "reqd": 0 }, { - "__unsaved": 1, - "fieldname": "category_7_group", + "fieldname": "category_7", "fieldtype": "Link", "label": "Item Group", "options": "Item Group", "reqd": 0 }, { - "__unsaved": 1, - "fieldname": "category_8_group", + "fieldname": "category_8", "fieldtype": "Link", "label": "Item Group", "options": "Item Group", @@ -84,7 +74,7 @@ } ], "idx": 0, - "modified": "2020-11-17 15:27:36.250460", + "modified": "2020-11-18 17:26:28.726260", "modified_by": "Administrator", "module": "Shopping Cart", "name": "Product Category Cards",