Merge pull request #11154 from netchampfaris/hub-item-image
[hub] fix company page routing
This commit is contained in:
commit
638e3f9fa6
@ -15,13 +15,16 @@ def enable_hub():
|
|||||||
return hub_settings
|
return hub_settings
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_items(start=0, limit=20, category=None, order_by=None, text=None):
|
def get_items(start=0, limit=20, category=None, order_by=None, company=None, text=None):
|
||||||
connection = get_connection()
|
connection = get_connection()
|
||||||
filters = {
|
filters = {
|
||||||
'hub_category': category,
|
'hub_category': category,
|
||||||
}
|
}
|
||||||
if text:
|
if text:
|
||||||
filters.update({'item_name': ('like', '%' + text + '%')})
|
filters.update({'item_name': ('like', '%' + text + '%')})
|
||||||
|
if company:
|
||||||
|
filters.update({'company_name': company})
|
||||||
|
|
||||||
response = connection.get_list('Hub Item',
|
response = connection.get_list('Hub Item',
|
||||||
limit_start=start, limit_page_length=limit,
|
limit_start=start, limit_page_length=limit,
|
||||||
filters=filters)
|
filters=filters)
|
||||||
|
@ -215,7 +215,7 @@ erpnext.hub.Hub = class Hub {
|
|||||||
.on('click', '.company-link a', function(e) {
|
.on('click', '.company-link a', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const company_name = $(this).attr('data-company-name');
|
const company_name = $(this).attr('data-company-name');
|
||||||
me.get_company_details(company_name);
|
frappe.set_route('hub', 'Company', company_name);
|
||||||
})
|
})
|
||||||
.on('click', '.breadcrumb li', function(e) {
|
.on('click', '.breadcrumb li', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@ -475,26 +475,34 @@ erpnext.hub.Hub = class Hub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get_company_details(company_id) {
|
get_company_details(company_id) {
|
||||||
// get from cache if exists
|
this.company_cache = this.company_cache || {};
|
||||||
let company_details = this.company_cache[company_id];
|
|
||||||
if(this.company_cache[company_id]) {
|
return new Promise(resolve => {
|
||||||
this.go_to_company_page(company_details);
|
// get from cache if exists
|
||||||
return;
|
let company_details = this.company_cache[company_id];
|
||||||
}
|
if(company_details) {
|
||||||
frappe.call({
|
resolve(company_details);
|
||||||
method: 'erpnext.hub_node.get_company_details',
|
return;
|
||||||
args: {hub_sync_id: company_id}
|
|
||||||
}).then((r) => {
|
|
||||||
if (r.message) {
|
|
||||||
const company_details = r.message.company_details;
|
|
||||||
this.company_cache[company_id] = company_details;
|
|
||||||
this.go_to_company_page(company_details)
|
|
||||||
}
|
}
|
||||||
});
|
frappe.call({
|
||||||
|
method: 'erpnext.hub_node.get_company_details',
|
||||||
|
args: {hub_sync_id: company_id}
|
||||||
|
}).then((r) => {
|
||||||
|
if (r.message) {
|
||||||
|
const company_details = r.message;
|
||||||
|
this.company_cache[company_id] = company_details;
|
||||||
|
resolve(company_details)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
go_to_company_page(company_details) {
|
go_to_company_page(company_id) {
|
||||||
frappe.set_route('hub', 'Company', company_details.company_name);
|
this.get_company_details(company_id)
|
||||||
|
.then(this.show_company_page.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
show_company_page(company_details) {
|
||||||
this.$hub_main_section.empty();
|
this.$hub_main_section.empty();
|
||||||
|
|
||||||
let $company_page =
|
let $company_page =
|
||||||
@ -573,10 +581,10 @@ erpnext.hub.Hub = class Hub {
|
|||||||
<h2>${ company_details.company_name }</h2>
|
<h2>${ company_details.company_name }</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="company">
|
<div class="company">
|
||||||
<span class="">${ company_details.seller_city }</span>
|
<span class="">${ company_details.country }</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="description">
|
<div class="description">
|
||||||
<span class="small">${ company_details.seller_description }</span>
|
<span class="small">${ company_details.site_name }</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -835,7 +843,7 @@ erpnext.hub.HubList = class HubList {
|
|||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
<div class="company-link">
|
<div class="company-link">
|
||||||
<a data-company-name="${ item.company_id }" class="">${ item.company_name }</a>
|
<a data-company-name="${ item.company_name }" class="">${ item.company_name }</a>
|
||||||
</div>
|
</div>
|
||||||
<div>${ item.formatted_price ? item.formatted_price : ''}</div>
|
<div>${ item.formatted_price ? item.formatted_price : ''}</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user