feat: update item group website slider

This commit is contained in:
Shivam Mishra 2020-12-30 13:00:35 +05:30
parent 355943c3a0
commit 31a651365d
9 changed files with 55 additions and 12 deletions

View File

@ -222,4 +222,8 @@ body.product-page {
.item-group-description { .item-group-description {
max-width: 800px; max-width: 800px;
} }
.carousel-inner.rounded-carousel {
border-radius: $card-border-radius;
}
} }

View File

@ -24,6 +24,7 @@
"route", "route",
"weightage", "weightage",
"slideshow", "slideshow",
"website_title",
"description", "description",
"website_specifications", "website_specifications",
"website_filters_section", "website_filters_section",
@ -200,6 +201,11 @@
"fieldtype": "Table", "fieldtype": "Table",
"label": "Attributes", "label": "Attributes",
"options": "Website Attribute" "options": "Website Attribute"
},
{
"fieldname": "website_title",
"fieldtype": "Data",
"label": "Title"
} }
], ],
"icon": "fa fa-sitemap", "icon": "fa fa-sitemap",
@ -208,7 +214,7 @@
"is_tree": 1, "is_tree": 1,
"links": [], "links": [],
"max_attachments": 3, "max_attachments": 3,
"modified": "2020-12-29 14:04:26.075008", "modified": "2020-12-30 12:57:38.876956",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Setup", "module": "Setup",
"name": "Item Group", "name": "Item Group",

View File

@ -21,7 +21,8 @@ class ItemGroup(NestedSet, WebsiteGenerator):
website = frappe._dict( website = frappe._dict(
condition_field = "show_in_website", condition_field = "show_in_website",
template = "templates/generators/item_group.html", template = "templates/generators/item_group.html",
no_cache = 1 no_cache = 1,
no_breadcrumbs = 1
) )
def autoname(self): def autoname(self):
@ -100,6 +101,29 @@ class ItemGroup(NestedSet, WebsiteGenerator):
"title": self.name "title": self.name
}) })
if self.slideshow:
values = {
'show_indicators': 1,
'show_controls': 0,
'rounded': 1,
'slider_name': self.slideshow
}
slideshow = frappe.get_doc("Website Slideshow", self.slideshow)
slides = slideshow.get({"doctype":"Website Slideshow Item"})
for index, slide in enumerate(slides):
values[f"slide_{index + 1}_image"] = slide.image
values[f"slide_{index + 1}_title"] = slide.heading
values[f"slide_{index + 1}_subtitle"] = slide.description
values[f"slide_{index + 1}_theme"] = slide.theme or "Light"
values[f"slide_{index + 1}_content_align"] = slide.content_align or "Centre"
values[f"slide_{index + 1}_primary_action_label"] = slide.label
values[f"slide_{index + 1}_primary_action"] = slide.url
context.slideshow = values
context.breadcrumbs = 0
context.title = self.website_title or self.name
return context return context
def delete_child_item_groups_key(self): def delete_child_item_groups_key(self):

View File

@ -73,7 +73,10 @@ class ProductFiltersBuilder:
if selected_attributes: if selected_attributes:
valid_attributes.append( valid_attributes.append(
_dict(item_attribute_values=selected_attributes) _dict(
item_attribute_values=selected_attributes,
name=attr_doc.name
)
) )
return valid_attributes return valid_attributes

View File

@ -1,7 +1,6 @@
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe import frappe
class ProductQuery: class ProductQuery:

View File

@ -37,7 +37,7 @@
{%- endfor -%} {%- endfor -%}
</ol> </ol>
{%- endif -%} {%- endif -%}
<div id="{{ slider_name }}423243" class="carousel-inner"> <div class="carousel-inner {{ resolve_class({'rounded-carousel': rounded }) }}">
{%- for index in ['1', '2', '3', '4', '5'] -%} {%- for index in ['1', '2', '3', '4', '5'] -%}
{%- set image = values['slide_' + index + '_image'] -%} {%- set image = values['slide_' + index + '_image'] -%}
{%- set title = values['slide_' + index + '_title'] -%} {%- set title = values['slide_' + index + '_title'] -%}

View File

@ -1,7 +1,7 @@
{% extends "templates/web.html" %} {% extends "templates/web.html" %}
{% block header %} {% block header %}
<h2 class="mb-6">{{ name }}</h2> <!-- <h2>{{ title }}</h2> -->
{% endblock header %} {% endblock header %}
{% block script %} {% block script %}
@ -12,15 +12,22 @@
<div class="item-group-content" itemscope itemtype="http://schema.org/Product"> <div class="item-group-content" itemscope itemtype="http://schema.org/Product">
<div class="item-group-slideshow"> <div class="item-group-slideshow">
{% if slideshow %}<!-- slideshow --> {% if slideshow %}<!-- slideshow -->
{% include "templates/includes/slideshow.html" %} {{ web_block(
"Hero Slider",
values=slideshow,
add_container=0,
add_top_padding=0,
add_bottom_padding=0,
) }}
{% endif %} {% endif %}
<h2 class="mt-3">{{ title }}</h2>
{% if description %}<!-- description --> {% if description %}<!-- description -->
<div class="item-group-description" itemprop="description">{{ description or ""}}</div> <div class="item-group-description text-muted mb-5" itemprop="description">{{ description or ""}}</div>
{% endif %} {% endif %}
</div> </div>
<div class="row mt-5"> <div class="row">
<div class="col-12 order-2 col-md-9 order-md-2 item-card-group-section"> <div class="col-12 order-2 col-md-9 order-md-2 item-card-group-section">
<div class="row"> <div class="row products-list">
{% if items %} {% if items %}
{% for item in items %} {% for item in items %}
{% include "erpnext/www/all-products/item_row.html" %} {% include "erpnext/www/all-products/item_row.html" %}

View File

@ -31,7 +31,7 @@
<div class="row"> <div class="row">
<div class="col-12 order-2 col-md-9 order-md-2 item-card-group-section"> <div class="col-12 order-2 col-md-9 order-md-2 item-card-group-section">
<div class="row"> <div class="row products-list">
{% if items %} {% if items %}
{% for item in items %} {% for item in items %}
{% include "erpnext/www/all-products/item_row.html" %} {% include "erpnext/www/all-products/item_row.html" %}

View File

@ -54,7 +54,7 @@ $(() => {
field_filters: JSON.stringify(if_key_exists(this.field_filters)), field_filters: JSON.stringify(if_key_exists(this.field_filters)),
attribute_filters: JSON.stringify(if_key_exists(this.attribute_filters)), attribute_filters: JSON.stringify(if_key_exists(this.attribute_filters)),
}); });
window.history.pushState('filters', '', '/all-products?' + query_string); window.history.pushState('filters', '', `${location.pathname}?` + query_string);
$('.page_content input').prop('disabled', true); $('.page_content input').prop('disabled', true);
this.get_items_with_filters() this.get_items_with_filters()