Merge pull request #15911 from netchampfaris/marketplace-fixes-3

Hub fixes
This commit is contained in:
Faris Ansari 2018-11-05 19:19:44 +05:30 committed by GitHub
commit bbc1cb274e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 37 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="hub-page-container"> <div class="hub-page-container">
<component :is="current_page"></component> <component :is="current_page.component" :key="current_page.key"></component>
</div> </div>
</template> </template>
@ -100,10 +100,16 @@ export default {
} }
if (!route) { if (!route) {
return NotFound; return {
key: 'not-found',
component: NotFound
};
} }
return route_map[route]; return {
key: curr_route,
component: route_map[route]
}
} }
} }
} }

View File

@ -113,6 +113,10 @@ export default {
content: this.review_content.get_value() content: this.review_content.get_value()
}); });
if (!hub.is_seller_registered()) {
frappe.throw(__('You need to login as a Marketplace User before you can add any reviews.'));
}
hub.call('add_item_review', { hub.call('add_item_review', {
hub_item_name: this.hub_item_name, hub_item_name: this.hub_item_name,
review: JSON.stringify(review) review: JSON.stringify(review)

View File

@ -1,31 +0,0 @@
/**
* Simple EventEmitter which uses jQuery's event system
*/
class EventEmitter {
init() {
this.jq = jQuery(this);
}
trigger(evt, data) {
!this.jq && this.init();
this.jq.trigger(evt, data);
}
once(evt, handler) {
!this.jq && this.init();
this.jq.one(evt, (e, data) => handler(data));
}
on(evt, handler) {
!this.jq && this.init();
this.jq.bind(evt, (e, data) => handler(data));
}
off(evt, handler) {
!this.jq && this.init();
this.jq.unbind(evt, (e, data) => handler(data));
}
}
export default EventEmitter;

View File

@ -8,14 +8,13 @@ import { ProfileDialog } from './components/profile_dialog';
// helpers // helpers
import './hub_call'; import './hub_call';
import EventEmitter from './event_emitter';
frappe.provide('hub'); frappe.provide('hub');
frappe.provide('erpnext.hub'); frappe.provide('erpnext.hub');
frappe.provide('frappe.route'); frappe.provide('frappe.route');
$.extend(erpnext.hub, EventEmitter.prototype); frappe.utils.make_event_emitter(frappe.route);
$.extend(frappe.route, EventEmitter.prototype); frappe.utils.make_event_emitter(erpnext.hub);
erpnext.hub.Marketplace = class Marketplace { erpnext.hub.Marketplace = class Marketplace {
constructor({ parent }) { constructor({ parent }) {

View File

@ -265,6 +265,9 @@ export default {
}, },
report_item() { report_item() {
if (!hub.is_seller_registered()) {
frappe.throw(__('Please login as a Marketplace User to report this item.'));
}
this.report_item_dialog.show(); this.report_item_dialog.show();
}, },