[hub] registered vs read-only views

This commit is contained in:
Prateeksha Singh 2018-07-26 01:12:00 +05:30
parent cf2d2a5c75
commit 9685d7c37a

View File

@ -8,7 +8,8 @@ erpnext.hub.Marketplace = class Marketplace {
frappe.db.get_doc('Hub Settings') frappe.db.get_doc('Hub Settings')
.then(doc => { .then(doc => {
this.hub_settings = doc; this.hub_settings = doc;
this.registered = doc.registered;
this.setup_header(); this.setup_header();
this.make_sidebar(); this.make_sidebar();
this.make_body(); this.make_body();
@ -26,7 +27,7 @@ erpnext.hub.Marketplace = class Marketplace {
const $target = $(e.currentTarget); const $target = $(e.currentTarget);
const route = $target.data().route; const route = $target.data().route;
frappe.set_route(route); frappe.set_route(route);
e.stopPropagation(); e.stopPropagation();
}); });
} }
@ -34,6 +35,18 @@ erpnext.hub.Marketplace = class Marketplace {
make_sidebar() { make_sidebar() {
this.$sidebar = this.$parent.find('.layout-side-section').addClass('hidden-xs'); this.$sidebar = this.$parent.find('.layout-side-section').addClass('hidden-xs');
const user_specific_items_html = this.registered
? `<li class="hub-sidebar-item text-muted" data-route="marketplace/profile">
${__('Your Profile')}
</li>
<li class="hub-sidebar-item text-muted" data-route="marketplace/publish">
${__('Publish Products')}
</li>`
: `<li class="hub-sidebar-item text-muted" data-route="marketplace/register">
${__('Become a seller')}
</li>`;
this.$sidebar.append(` this.$sidebar.append(`
<ul class="list-unstyled hub-sidebar-group"> <ul class="list-unstyled hub-sidebar-group">
<li class="hub-sidebar-item" data-route="marketplace/home"> <li class="hub-sidebar-item" data-route="marketplace/home">
@ -42,15 +55,7 @@ erpnext.hub.Marketplace = class Marketplace {
<li class="hub-sidebar-item" data-route="marketplace/favourites"> <li class="hub-sidebar-item" data-route="marketplace/favourites">
${__('Favorites')} ${__('Favorites')}
</li> </li>
<li class="hub-sidebar-item text-muted" data-route="marketplace/register"> ${user_specific_items_html}
${__('Become a seller')}
</li>
<li class="hub-sidebar-item text-muted" data-route="marketplace/profile">
${__('Your Profile')}
</li>
<li class="hub-sidebar-item text-muted" data-route="marketplace/publish">
${__('Publish Products')}
</li>
</ul> </ul>
`); `);
@ -68,9 +73,11 @@ erpnext.hub.Marketplace = class Marketplace {
`<li class="hub-sidebar-item active" data-route="marketplace/home"> `<li class="hub-sidebar-item active" data-route="marketplace/home">
${__('All')} ${__('All')}
</li>`, </li>`,
`<li class="hub-sidebar-item" data-route="marketplace/published"> ...(this.registered
${__('Your Products')} ? [`<li class="hub-sidebar-item active" data-route="marketplace/my-products">
</li>`, ${__('Your Products')}
</li>`]
: []),
...categories.map(category => ` ...categories.map(category => `
<li class="hub-sidebar-item text-muted" data-route="marketplace/category/${category}"> <li class="hub-sidebar-item text-muted" data-route="marketplace/category/${category}">
${__(category)} ${__(category)}
@ -480,7 +487,7 @@ erpnext.hub.Register = class Register extends SubPage {
.appendTo(this.$wrapper); .appendTo(this.$wrapper);
this.$form_container = $('<div class="col-md-8 col-md-offset-1 form-container">') this.$form_container = $('<div class="col-md-8 col-md-offset-1 form-container">')
.appendTo(this.$wrapper); .appendTo(this.$wrapper);
// const title = __('Become a Seller'); // const title = __('Become a Seller');
// this.$register_container.append($(`<h5>${title}</h5>`)); // this.$register_container.append($(`<h5>${title}</h5>`));
} }
@ -493,7 +500,7 @@ erpnext.hub.Register = class Register extends SubPage {
// make_input() { // make_input() {
// // // //
// } // }
render() { render() {
this.make_field_group(); this.make_field_group();
} }
@ -583,11 +590,11 @@ erpnext.hub.Publish = class Publish extends SubPage {
render(items) { render(items) {
const html = get_item_card_container_html( const html = get_item_card_container_html(
items, items,
__('Select Products to Publish'), __('Select Products to Publish'),
__(`Only products with an image and description can be published. __(`Only products with an image and description can be published.
Please update them if an item in your inventory does not appear.`), Please update them if an item in your inventory does not appear.`),
`<div class="hub-search-container"> `<div class="hub-search-container">
@ -648,13 +655,13 @@ function get_item_card_html(item) {
// Decide item link // Decide item link
const isLocal = item.source_type === "local"; const isLocal = item.source_type === "local";
const route = !isLocal const route = !isLocal
? `marketplace/item/${item.hub_item_code}` ? `marketplace/item/${item.hub_item_code}`
: `Form/Item/${item.item_name}`; : `Form/Item/${item.item_name}`;
const card_route = isLocal ? '' : `data-route='${route}'`; const card_route = isLocal ? '' : `data-route='${route}'`;
const show_local_item_button = isLocal const show_local_item_button = isLocal
? `<div class="overlay button-overlay" data-route='${route}' onclick="event.preventDefault();"> ? `<div class="overlay button-overlay" data-route='${route}' onclick="event.preventDefault();">
<button class="btn btn-default zoom-view"> <button class="btn btn-default zoom-view">
<i class="octicon octicon-eye"></i> <i class="octicon octicon-eye"></i>