@ -12,8 +12,10 @@ import EventEmitter from './event_emitter';
frappe . provide ( 'hub' ) ;
frappe . provide ( 'erpnext.hub' ) ;
frappe . provide ( 'frappe.route' ) ;
$ . extend ( erpnext . hub , EventEmitter . prototype ) ;
$ . extend ( frappe . route , EventEmitter . prototype ) ;
erpnext . hub . Marketplace = class Marketplace {
constructor ( { parent } ) {
@ -28,15 +30,18 @@ erpnext.hub.Marketplace = class Marketplace {
this . setup_events ( ) ;
this . refresh ( ) ;
if ( ! hub . is_seller_registered ( ) ) {
this . page . set_primary_action ( 'Become a Seller' , this . show_register_dialog . bind ( this ) )
} else {
this . page . set_secondary_action ( 'Add Users' , this . show_add_user_dialog . bind ( this ) ) ;
if ( ! hub . is_server ) {
if ( ! hub . is_seller_registered ( ) ) {
this . page . set_primary_action ( 'Become a Seller' , this . show_register_dialog . bind ( this ) )
} else {
this . page . set_secondary_action ( 'Add Users' , this . show_add_user_dialog . bind ( this ) ) ;
}
}
} ) ;
}
setup_header ( ) {
if ( hub . is_server ) return ;
this . page . set_title ( __ ( 'Marketplace' ) ) ;
}
@ -76,9 +81,11 @@ erpnext.hub.Marketplace = class Marketplace {
render : h => h ( PageContainer )
} ) ;
erpnext . hub . on ( 'seller-registered' , ( ) => {
this . page . clear_primary_action ( ) ;
} ) ;
if ( ! hub . is_server ) {
erpnext . hub . on ( 'seller-registered' , ( ) => {
this . page . clear_primary_action ( ) ;
} ) ;
}
}
refresh ( ) {
@ -182,7 +189,7 @@ erpnext.hub.Marketplace = class Marketplace {
}
update_hub_settings ( ) {
return frappe . db . get_doc ( 'Marketplace Settings' ) . then ( doc => {
return hub . get_settings ( ) . then ( doc => {
hub . settings = doc ;
} ) ;
}
@ -198,6 +205,15 @@ Object.assign(hub, {
. filter ( hub_user => hub_user . user === frappe . session . user )
. length === 1 ;
} ,
get_settings ( ) {
if ( frappe . session . user === 'Guest' ) {
return Promise . resolve ( {
registered : 0
} ) ;
}
return frappe . db . get_doc ( 'Marketplace Settings' ) ;
}
} ) ;
/ * *