diff --git a/erpnext/public/css/website.css b/erpnext/public/css/website.css index 8b5b900ce5..25d08f615f 100644 --- a/erpnext/public/css/website.css +++ b/erpnext/public/css/website.css @@ -48,10 +48,12 @@ text-transform: uppercase; font-size: 12px; } +.product-search { + margin-bottom: 15px; +} @media (max-width: 767px) { .product-search { width: 100%; - margin-bottom: 13px; } } .borderless td, @@ -124,3 +126,24 @@ border-top: 1px solid #d1d8dd; padding-top: 15px; } +.product-list-link .row { + border-bottom: 1px solid #EBEFF2; +} +.product-list-link .row:hover { + background-color: #fafbfc; +} +.product-list-link .row > div { + padding-top: 15px; + padding-bottom: 15px; +} +.product-list-link:first-child .row { + border-top: 1px solid #EBEFF2; +} +.item-group-nav-buttons { + margin-top: 15px; +} +@media (min-width: 992px) { + .footer-subscribe { + max-width: 350px; + } +} diff --git a/erpnext/public/less/website.less b/erpnext/public/less/website.less index b420ba6d8e..0246caccd5 100644 --- a/erpnext/public/less/website.less +++ b/erpnext/public/less/website.less @@ -50,16 +50,20 @@ padding: 15px 0px; } -.product-label{ +.product-label { padding-bottom: 4px; text-transform: uppercase; font-size: 12px; } +.product-search { + margin-bottom: 15px; +} + + @media (max-width: 767px) { .product-search { width: 100%; - margin-bottom: 13px; } } @@ -157,3 +161,31 @@ } } +.product-list-link { + .row { + border-bottom: 1px solid @light-border-color; + } + + .row:hover { + background-color: @light-bg; + } + + .row > div { + padding-top: 15px; + padding-bottom: 15px; + } +} + +.product-list-link:first-child .row { + border-top: 1px solid @light-border-color; +} + +.item-group-nav-buttons { + margin-top: 15px; +} + +@media (min-width: 992px) { + .footer-subscribe { + max-width: 350px; + } +} diff --git a/erpnext/setup/doctype/item_group/item_group.py b/erpnext/setup/doctype/item_group/item_group.py index 43b88d65f8..4b26cfc347 100644 --- a/erpnext/setup/doctype/item_group/item_group.py +++ b/erpnext/setup/doctype/item_group/item_group.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import frappe import urllib -from frappe.utils import nowdate +from frappe.utils import nowdate, cint, cstr from frappe.utils.nestedset import NestedSet from frappe.website.website_generator import WebsiteGenerator from frappe.website.render import clear_cache @@ -60,7 +60,8 @@ class ItemGroup(NestedSet, WebsiteGenerator): context.update({ "items": get_product_list_for_group(product_group = self.name, start=start, limit=24, search=frappe.form_dict.get("q")), "parent_groups": get_parent_item_groups(self.name), - "title": self.name + "title": self.name, + "products_as_list": cint(frappe.db.get_single_value('Website Settings', 'products_as_list')) }) if self.slideshow: @@ -73,8 +74,8 @@ def get_product_list_for_group(product_group=None, start=0, limit=10, search=Non child_groups = ", ".join(['"' + i[0] + '"' for i in get_child_groups(product_group)]) # base query - query = """select name, item_name, page_name, website_image, thumbnail, item_group, - web_long_description as website_description, + query = """select name, item_name, item_code, page_name, website_image, thumbnail, item_group, + description, web_long_description as website_description, concat(parent_website_route, "/", page_name) as route from `tabItem` where show_in_website = 1 @@ -89,7 +90,7 @@ def get_product_list_for_group(product_group=None, start=0, limit=10, search=Non query += """ and (web_long_description like %(search)s or item_name like %(search)s or name like %(search)s)""" - search = "%" + cstr(search) + "%" + search = "%" + cstr(search) + "%" query += """order by weightage desc, modified desc limit %s, %s""" % (start, limit) @@ -108,7 +109,12 @@ def get_item_for_list_in_html(context): # user may forget it during upload if (context.get("website_image") or "").startswith("files/"): context["website_image"] = "/" + urllib.quote(context["website_image"]) - return frappe.get_template("templates/includes/product_in_grid.html").render(context) + + products_template = 'templates/includes/products_as_grid.html' + if cint(frappe.db.get_single_value('Products Settings', 'products_as_list')): + products_template = 'templates/includes/products_as_list.html' + + return frappe.get_template(products_template).render(context) def get_group_item_count(item_group): child_groups = ", ".join(['"' + i[0] + '"' for i in get_child_groups(item_group)]) @@ -134,4 +140,4 @@ def invalidate_cache_for(doc, item_group=None): d = frappe.get_doc("Item Group", d.name) route = d.get_route() if route: - clear_cache(route) \ No newline at end of file + clear_cache(route) diff --git a/erpnext/templates/generators/item_group.html b/erpnext/templates/generators/item_group.html index 195b3c500c..d01426373b 100644 --- a/erpnext/templates/generators/item_group.html +++ b/erpnext/templates/generators/item_group.html @@ -27,19 +27,19 @@
{% if items %} -
+
{% for item in items %} {{ item }} {% endfor %}
-
- {% if frappe.form_dict.start|int > 0 %} - Prev - {% endif %} - {% if items|length == 24 %} - Next - {% endif %} -
+
+ {% if frappe.form_dict.start|int > 0 %} + Prev + {% endif %} + {% if items|length == 24 %} + Next + {% endif %} +
{% else %}
No items listed.
{% endif %} diff --git a/erpnext/templates/includes/footer/footer_extension.html b/erpnext/templates/includes/footer/footer_extension.html index e32e13ddf8..897a8045d8 100644 --- a/erpnext/templates/includes/footer/footer_extension.html +++ b/erpnext/templates/includes/footer/footer_extension.html @@ -1,10 +1,12 @@ {% if not hide_footer_signup %} - - - + + {% endif %} diff --git a/erpnext/templates/includes/product_in_list.html b/erpnext/templates/includes/product_in_list.html deleted file mode 100644 index 8a4bdf6e16..0000000000 --- a/erpnext/templates/includes/product_in_list.html +++ /dev/null @@ -1,16 +0,0 @@ - - diff --git a/erpnext/templates/includes/product_list.js b/erpnext/templates/includes/product_list.js index f618f9a8fb..28c626f5d4 100644 --- a/erpnext/templates/includes/product_list.js +++ b/erpnext/templates/includes/product_list.js @@ -22,14 +22,14 @@ window.get_product_list = function() { }, dataType: "json", success: function(data) { - window.render_product_list(data.message); + window.render_product_list(data.message || []); } }) } window.render_product_list = function(data) { + var table = $("#search-list .table"); if(data.length) { - var table = $("#search-list .table"); if(!table.length) var table = $("").appendTo("#search-list"); diff --git a/erpnext/templates/includes/product_in_grid.html b/erpnext/templates/includes/products_as_grid.html similarity index 100% rename from erpnext/templates/includes/product_in_grid.html rename to erpnext/templates/includes/products_as_grid.html diff --git a/erpnext/templates/includes/products_as_list.html b/erpnext/templates/includes/products_as_list.html new file mode 100644 index 0000000000..a5523a99e0 --- /dev/null +++ b/erpnext/templates/includes/products_as_list.html @@ -0,0 +1,18 @@ +{% from "erpnext/templates/includes/macros.html" import product_image_square %} + + +
+
+ {{ product_image_square(thumbnail or website_image) }} +
+
+
{{ item_name }}
+ {% set website_description = website_description or description %} + {% if website_description != item_name %} +
{{ website_description or description }}
+ {% elif item_code != item_name %} +
{{ _('Item Code') }}: {{ item_code }}
+ {% endif %} +
+
+
diff --git a/erpnext/templates/pages/product_search.py b/erpnext/templates/pages/product_search.py index bdfac4fe0c..465fdd5ecf 100644 --- a/erpnext/templates/pages/product_search.py +++ b/erpnext/templates/pages/product_search.py @@ -14,8 +14,8 @@ def get_product_list(search=None, start=0, limit=12): # limit = 12 because we show 12 items in the grid view # base query - query = """select name, item_name, page_name, website_image, thumbnail, item_group, - web_long_description as website_description, parent_website_route + query = """select name, item_name, item_code, page_name, website_image, thumbnail, item_group, + description, web_long_description as website_description, parent_website_route from `tabItem` where show_in_website = 1 and disabled=0