Hub Seller Profile and Timeline
- profile details fetched from server - timeline updates on publishing items
This commit is contained in:
parent
6f05ea124e
commit
d27b27f88a
@ -93,22 +93,23 @@ def item_sync_preprocess():
|
|||||||
})
|
})
|
||||||
|
|
||||||
if response:
|
if response:
|
||||||
# frappe.db.set_value("Hub Settings", "Hub Settings", "sync_in_progress", 1)
|
frappe.db.set_value("Hub Settings", "Hub Settings", "sync_in_progress", 1)
|
||||||
return response
|
return response
|
||||||
else:
|
else:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
def item_sync_postprocess(obj):
|
def item_sync_postprocess(obj):
|
||||||
response = call_hub_method('update_activity_for_seller', {
|
response = call_hub_method('update_activity_for_seller', {
|
||||||
'hub_seller': frappe.db.get_value("Hub Settings", "Hub Settings", "company_email"),
|
'hub_seller': frappe.db.get_value('Hub Settings', 'Hub Settings', 'company_email'),
|
||||||
'name': obj["remote_id"],
|
'name': obj['remote_id'],
|
||||||
'status': obj["status"]
|
'status': obj['status'],
|
||||||
|
'stats': obj['stats']
|
||||||
})
|
})
|
||||||
|
|
||||||
if response:
|
if response:
|
||||||
frappe.db.set_value("Hub Settings", "Hub Settings", "sync_in_progress", 0)
|
frappe.db.set_value('Hub Settings', 'Hub Settings', 'sync_in_progress', 0)
|
||||||
else:
|
else:
|
||||||
frappe.throw("Unable to update remote activity")
|
frappe.throw('Unable to update remote activity')
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_item_favourites(start=0, limit=20, fields=["*"], order_by=None):
|
def get_item_favourites(start=0, limit=20, fields=["*"], order_by=None):
|
||||||
|
@ -724,9 +724,36 @@ erpnext.hub.Register = class Register extends SubPage {
|
|||||||
erpnext.hub.Profile = class Profile extends SubPage {
|
erpnext.hub.Profile = class Profile extends SubPage {
|
||||||
make_wrapper() {
|
make_wrapper() {
|
||||||
super.make_wrapper();
|
super.make_wrapper();
|
||||||
|
}
|
||||||
|
|
||||||
// Shorthand for profile data;
|
refresh() {
|
||||||
const p = hub.settings;
|
this.get_hub_seller_profile(this.keyword)
|
||||||
|
.then(profile => this.render(profile));
|
||||||
|
}
|
||||||
|
|
||||||
|
get_hub_seller_profile() {
|
||||||
|
return hub.call('get_hub_seller_profile', { hub_seller: hub.settings.company_email });
|
||||||
|
}
|
||||||
|
|
||||||
|
render(profile) {
|
||||||
|
const p = profile;
|
||||||
|
const content_by_log_type = this.get_content_by_log_type();
|
||||||
|
|
||||||
|
let activity_logs = (p.hub_seller_activity || []).sort((a, b) => {
|
||||||
|
return new Date(b.creation) - new Date(a.creation);
|
||||||
|
});
|
||||||
|
|
||||||
|
const timeline_items_html = activity_logs
|
||||||
|
.map(log => {
|
||||||
|
const stats = JSON.parse(log.stats);
|
||||||
|
const no_of_items = stats && stats.push_update || '';
|
||||||
|
|
||||||
|
const content = content_by_log_type[log.type];
|
||||||
|
const message = content.get_message(no_of_items);
|
||||||
|
const icon = content.icon;
|
||||||
|
return this.get_timeline_log_item(log.pretty_date, message, icon);
|
||||||
|
})
|
||||||
|
.join('');
|
||||||
|
|
||||||
const profile_html = `<div class="hub-item-container">
|
const profile_html = `<div class="hub-item-container">
|
||||||
<div class="row visible-xs">
|
<div class="row visible-xs">
|
||||||
@ -737,33 +764,58 @@ erpnext.hub.Profile = class Profile extends SubPage {
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<div class="hub-item-image">
|
<div class="hub-item-image">
|
||||||
<img src="${'gd'}">
|
<img src="${p.logo}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<h2>${'title'}</h2>
|
<h2>${p.company}</h2>
|
||||||
<div class="text-muted">
|
<div class="text-muted">
|
||||||
<p>${'where'}${'dot_spacer'}${'when'}</p>
|
<p>${p.country}</p>
|
||||||
<p>${'rating_html'}${'rating_count'}</p>
|
<p>${p.site_name}</p>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="hub-item-description">
|
<div class="hub-item-description">
|
||||||
${'description' ?
|
${'description'
|
||||||
`<b>${__('Description')}</b>
|
? `<p>${p.company_description}</p>`
|
||||||
<p>${'description'}</p>
|
: `<p>__('No description')</p`
|
||||||
` : __('No description')
|
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="timeline">
|
||||||
|
<div class="timeline-items">
|
||||||
|
${timeline_items_html}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
this.$wrapper.html(profile_html);
|
this.$wrapper.html(profile_html);
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh() {}
|
get_timeline_log_item(pretty_date, message, icon) {
|
||||||
|
return `<div class="media timeline-item notification-content">
|
||||||
|
<div class="small">
|
||||||
|
<i class="octicon ${icon} fa-fw"></i>
|
||||||
|
<span title="Administrator"><b>${pretty_date}</b> ${message}</span>
|
||||||
|
</div>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
render() {}
|
get_content_by_log_type() {
|
||||||
|
return {
|
||||||
|
"Created": {
|
||||||
|
icon: 'octicon-heart',
|
||||||
|
get_message: () => 'Joined Marketplace'
|
||||||
|
},
|
||||||
|
"Items Publish": {
|
||||||
|
icon: 'octicon-bookmark',
|
||||||
|
get_message: (no_of_items) =>
|
||||||
|
`Published ${no_of_items} product${no_of_items > 1 ? 's' : ''} to Marketplace`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
erpnext.hub.Publish = class Publish extends SubPage {
|
erpnext.hub.Publish = class Publish extends SubPage {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user