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
|
||||
|
||||
@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()
|
||||
filters = {
|
||||
'hub_category': category,
|
||||
}
|
||||
if text:
|
||||
filters.update({'item_name': ('like', '%' + text + '%')})
|
||||
if company:
|
||||
filters.update({'company_name': company})
|
||||
|
||||
response = connection.get_list('Hub Item',
|
||||
limit_start=start, limit_page_length=limit,
|
||||
filters=filters)
|
||||
|
@ -215,7 +215,7 @@ erpnext.hub.Hub = class Hub {
|
||||
.on('click', '.company-link a', function(e) {
|
||||
e.preventDefault();
|
||||
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) {
|
||||
e.preventDefault();
|
||||
@ -475,10 +475,13 @@ erpnext.hub.Hub = class Hub {
|
||||
}
|
||||
|
||||
get_company_details(company_id) {
|
||||
this.company_cache = this.company_cache || {};
|
||||
|
||||
return new Promise(resolve => {
|
||||
// get from cache if exists
|
||||
let company_details = this.company_cache[company_id];
|
||||
if(this.company_cache[company_id]) {
|
||||
this.go_to_company_page(company_details);
|
||||
if(company_details) {
|
||||
resolve(company_details);
|
||||
return;
|
||||
}
|
||||
frappe.call({
|
||||
@ -486,15 +489,20 @@ erpnext.hub.Hub = class Hub {
|
||||
args: {hub_sync_id: company_id}
|
||||
}).then((r) => {
|
||||
if (r.message) {
|
||||
const company_details = r.message.company_details;
|
||||
const company_details = r.message;
|
||||
this.company_cache[company_id] = company_details;
|
||||
this.go_to_company_page(company_details)
|
||||
resolve(company_details)
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
go_to_company_page(company_details) {
|
||||
frappe.set_route('hub', 'Company', company_details.company_name);
|
||||
go_to_company_page(company_id) {
|
||||
this.get_company_details(company_id)
|
||||
.then(this.show_company_page.bind(this));
|
||||
}
|
||||
|
||||
show_company_page(company_details) {
|
||||
this.$hub_main_section.empty();
|
||||
|
||||
let $company_page =
|
||||
@ -573,10 +581,10 @@ erpnext.hub.Hub = class Hub {
|
||||
<h2>${ company_details.company_name }</h2>
|
||||
</div>
|
||||
<div class="company">
|
||||
<span class="">${ company_details.seller_city }</span>
|
||||
<span class="">${ company_details.country }</span>
|
||||
</div>
|
||||
<div class="description">
|
||||
<span class="small">${ company_details.seller_description }</span>
|
||||
<span class="small">${ company_details.site_name }</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -835,7 +843,7 @@ erpnext.hub.HubList = class HubList {
|
||||
</div>
|
||||
</a>
|
||||
<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>${ item.formatted_price ? item.formatted_price : ''}</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user