mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-01 11:19:09 +00:00
updates to item, item_group and website
This commit is contained in:
@@ -23,6 +23,9 @@
|
||||
.login-box td {
|
||||
padding: 8px;
|
||||
}
|
||||
.login-box td input {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
.login-footer {
|
||||
text-align: center;
|
||||
padding: 15px;
|
||||
|
||||
@@ -35,7 +35,11 @@
|
||||
<ul class="dropdown-menu">
|
||||
{% for child in page.child_items %}
|
||||
<li data-label="{{ child.label }}">
|
||||
<a href="{{ child.url }}" {{ child.target or '' }}>
|
||||
<a {% if child.indent %}
|
||||
style="padding-left:
|
||||
{{(int(child.indent)+1)*15 }}px"
|
||||
{% endif %}
|
||||
href="{{ child.url }}" {{ child.target or '' }}>
|
||||
{{ child.label }}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@@ -1,7 +1,19 @@
|
||||
{% extends "html/page.html" %}
|
||||
|
||||
{% block javascript %}
|
||||
{% include "js/product_list.js" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
window.start = 0;
|
||||
window.product_group = "{{ name }}";
|
||||
window.get_product_list();
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="layout-wrapper layout-wrapper-background">
|
||||
<div class="web-content" id="content-product_group">
|
||||
<div class="layout-main" style="padding: 30px;">
|
||||
@@ -22,12 +34,17 @@
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if obj.doclist.get({"doctype":"Featured Item"}) %}
|
||||
<hr>
|
||||
<h3>Featured Products</h3>
|
||||
|
||||
{% endif %}
|
||||
|
||||
<h3>Products</h3>
|
||||
<div id="search-list">
|
||||
|
||||
</div>
|
||||
<div style="text-align: center;">
|
||||
<div class="more-btn"
|
||||
style="display: none; text-align: center;">
|
||||
<button class="btn">More...</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<script>
|
||||
// redirect to product search page
|
||||
$(document).ready(function() {
|
||||
$('.dropdown-toggle').dropdown()
|
||||
$("#btn-product-search").click(function() {
|
||||
var txt = $("#product-search").val();
|
||||
if(txt) {
|
||||
|
||||
69
website/templates/js/product_list.js
Normal file
69
website/templates/js/product_list.js
Normal file
@@ -0,0 +1,69 @@
|
||||
window.get_product_list = function() {
|
||||
$(".more-btn .btn").click(function() {
|
||||
window.get_product_list()
|
||||
});
|
||||
|
||||
if(window.start==undefined) {
|
||||
throw "product list not initialized (no start)"
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "server.py",
|
||||
dataType: "json",
|
||||
data: {
|
||||
cmd: "website.helpers.product.get_product_list",
|
||||
start: window.start,
|
||||
search: window.search,
|
||||
product_group: window.product_group
|
||||
},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
window.render_product_list(data.message);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
window.render_product_list = function(data) {
|
||||
if(data.length) {
|
||||
var table = $("#search-list .table");
|
||||
if(!table.length)
|
||||
var table = $("<table class='table'>").appendTo("#search-list");
|
||||
|
||||
$.each(data, function(i, d) {
|
||||
if(!d.web_short_description)
|
||||
d.web_short_description = "No description given."
|
||||
var $tr = $(repl('<tr>\
|
||||
<td style="width: 30%;">\
|
||||
<img class="product-image" \
|
||||
style="width: 80%;" src="files/%(website_image)s">\
|
||||
</td>\
|
||||
<td>\
|
||||
<h4><a href="%(page_name)s">%(item_name)s</a></h4>\
|
||||
<p class="help">Item Code: %(name)s</p>\
|
||||
<p>%(website_description)s</p>\
|
||||
</td>\
|
||||
</tr>', d)).appendTo(table);
|
||||
|
||||
if(!d.website_image) {
|
||||
$tr.find(".product-image").replaceWith("<div\
|
||||
style='background-color: #eee; padding: 40px; \
|
||||
width: 32px; font-size: 32px; color: #888;'>\
|
||||
<i class='icon-camera'></i></div>");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
if(data.length < 10) {
|
||||
if(!table) {
|
||||
$(".more-btn")
|
||||
.replaceWith("<div class='alert'>No products found.</div>");
|
||||
} else {
|
||||
$(".more-btn")
|
||||
.replaceWith("<div class='alert'>Nothing more to show.</div>");
|
||||
}
|
||||
} else {
|
||||
$(".more-btn").toggle(true)
|
||||
}
|
||||
window.start += (data.length || 0);
|
||||
}
|
||||
@@ -2,77 +2,18 @@
|
||||
|
||||
{% block title %}Product Search{% endblock %}
|
||||
|
||||
{% block javascript %}
|
||||
{% include "js/product_list.js" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var txt = get_url_arg("q");
|
||||
$(".search-results").html("Search results for: " + txt);
|
||||
|
||||
window.search = txt;
|
||||
window.start = 0;
|
||||
var get_list = function() {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "server.py",
|
||||
dataType: "json",
|
||||
data: {
|
||||
cmd: "website.helpers.product.get_product_list",
|
||||
start: window.start,
|
||||
search: txt
|
||||
},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
render(data.message);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
var render = function(data) {
|
||||
if(data.length) {
|
||||
var table = $("#search-list .table");
|
||||
if(!table.length)
|
||||
var table = $("<table class='table'>").appendTo("#search-list");
|
||||
|
||||
$.each(data, function(i, d) {
|
||||
if(!d.web_short_description)
|
||||
d.web_short_description = "No description given."
|
||||
var $tr = $(repl('<tr>\
|
||||
<td style="width: 30%;">\
|
||||
<img class="product-image" style="width: 80%;" src="files/%(website_image)s">\
|
||||
</td>\
|
||||
<td>\
|
||||
<h4><a href="%(page_name)s">%(item_name)s</a></h4>\
|
||||
<p class="help">Item Code: %(name)s</p>\
|
||||
<p>%(web_short_description)s</p>\
|
||||
</td>\
|
||||
</tr>', d)).appendTo(table);
|
||||
|
||||
if(!d.website_image) {
|
||||
$tr.find(".product-image").replaceWith("<div\
|
||||
style='background-color: #eee; padding: 40px; \
|
||||
width: 32px; font-size: 32px; color: #888;'>\
|
||||
<i class='icon-camera'></i></div>");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
if(data.length < 10) {
|
||||
if(!table) {
|
||||
$(".more-btn")
|
||||
.replaceWith("<div class='alert'>No results found for your search.</div>");
|
||||
} else {
|
||||
$(".more-btn")
|
||||
.replaceWith("<div class='alert'>Nothing more to show.</div>");
|
||||
}
|
||||
} else {
|
||||
$(".more-btn").toggle(true)
|
||||
}
|
||||
window.start += (data.length || 0);
|
||||
}
|
||||
|
||||
get_list();
|
||||
$(".more-btn .btn").click(function() {
|
||||
get_list()
|
||||
});
|
||||
window.get_product_list();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user