Prevent access of registered routes
This commit is contained in:
parent
2de046fbed
commit
5249307f27
@ -8,6 +8,7 @@ import './pages/register';
|
|||||||
import './pages/profile';
|
import './pages/profile';
|
||||||
import './pages/publish';
|
import './pages/publish';
|
||||||
import './pages/published_products';
|
import './pages/published_products';
|
||||||
|
import './pages/messages';
|
||||||
import './pages/not_found';
|
import './pages/not_found';
|
||||||
|
|
||||||
// helpers
|
// helpers
|
||||||
@ -62,11 +63,17 @@ erpnext.hub.Marketplace = class Marketplace {
|
|||||||
$nav_group.empty();
|
$nav_group.empty();
|
||||||
|
|
||||||
const user_specific_items_html = this.registered
|
const user_specific_items_html = this.registered
|
||||||
? `<li class="hub-sidebar-item text-muted" data-route="marketplace/profile">
|
? `<li class="hub-sidebar-item" data-route="marketplace/favourites">
|
||||||
|
${__('Favorites')}
|
||||||
|
</li>
|
||||||
|
<li class="hub-sidebar-item text-muted" data-route="marketplace/profile">
|
||||||
${__('Your Profile')}
|
${__('Your Profile')}
|
||||||
</li>
|
</li>
|
||||||
<li class="hub-sidebar-item text-muted" data-route="marketplace/publish">
|
<li class="hub-sidebar-item text-muted" data-route="marketplace/publish">
|
||||||
${__('Publish Products')}
|
${__('Publish Products')}
|
||||||
|
</li>
|
||||||
|
<li class="hub-sidebar-item text-muted" data-route="marketplace/messages">
|
||||||
|
${__('Messages')}
|
||||||
</li>`
|
</li>`
|
||||||
|
|
||||||
: `<li class="hub-sidebar-item text-muted" data-route="marketplace/register">
|
: `<li class="hub-sidebar-item text-muted" data-route="marketplace/register">
|
||||||
@ -77,9 +84,6 @@ erpnext.hub.Marketplace = class Marketplace {
|
|||||||
<li class="hub-sidebar-item" data-route="marketplace/home">
|
<li class="hub-sidebar-item" data-route="marketplace/home">
|
||||||
${__('Browse')}
|
${__('Browse')}
|
||||||
</li>
|
</li>
|
||||||
<li class="hub-sidebar-item" data-route="marketplace/favourites">
|
|
||||||
${__('Favorites')}
|
|
||||||
</li>
|
|
||||||
${user_specific_items_html}
|
${user_specific_items_html}
|
||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
@ -148,10 +152,6 @@ erpnext.hub.Marketplace = class Marketplace {
|
|||||||
this.subpages.home = new erpnext.hub.Home(this.$body);
|
this.subpages.home = new erpnext.hub.Home(this.$body);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (route[1] === 'favourites' && !this.subpages.favourites) {
|
|
||||||
this.subpages.favourites = new erpnext.hub.Favourites(this.$body);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (route[1] === 'search' && !this.subpages.search) {
|
if (route[1] === 'search' && !this.subpages.search) {
|
||||||
this.subpages.search = new erpnext.hub.SearchPage(this.$body);
|
this.subpages.search = new erpnext.hub.SearchPage(this.$body);
|
||||||
}
|
}
|
||||||
@ -172,6 +172,11 @@ erpnext.hub.Marketplace = class Marketplace {
|
|||||||
this.subpages.register = new erpnext.hub.Register(this.$body);
|
this.subpages.register = new erpnext.hub.Register(this.$body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// registered seller routes
|
||||||
|
if (route[1] === 'favourites' && !this.subpages.favourites) {
|
||||||
|
this.subpages.favourites = new erpnext.hub.Favourites(this.$body);
|
||||||
|
}
|
||||||
|
|
||||||
if (route[1] === 'profile' && !this.subpages.profile) {
|
if (route[1] === 'profile' && !this.subpages.profile) {
|
||||||
this.subpages.profile = new erpnext.hub.Profile(this.$body);
|
this.subpages.profile = new erpnext.hub.Profile(this.$body);
|
||||||
}
|
}
|
||||||
@ -184,6 +189,17 @@ erpnext.hub.Marketplace = class Marketplace {
|
|||||||
this.subpages['my-products'] = new erpnext.hub.PublishedProducts(this.$body);
|
this.subpages['my-products'] = new erpnext.hub.PublishedProducts(this.$body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (route[1] === 'messages' && !this.subpages['messages']) {
|
||||||
|
this.subpages['messages'] = new erpnext.hub.Messages(this.$body);
|
||||||
|
}
|
||||||
|
|
||||||
|
// dont allow unregistered users to access registered routes
|
||||||
|
const registered_routes = ['favourites', 'profile', 'publish', 'my-products', 'messages'];
|
||||||
|
if (!hub.settings.registered && registered_routes.includes(route[1])) {
|
||||||
|
frappe.set_route('marketplace', 'home');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Object.keys(this.subpages).includes(route[1])) {
|
if (!Object.keys(this.subpages).includes(route[1])) {
|
||||||
if (!this.subpages.not_found) {
|
if (!this.subpages.not_found) {
|
||||||
this.subpages.not_found = new erpnext.hub.NotFound(this.$body);
|
this.subpages.not_found = new erpnext.hub.NotFound(this.$body);
|
||||||
|
@ -2,11 +2,6 @@ import SubPage from './subpage';
|
|||||||
import { get_rating_html } from '../helpers';
|
import { get_rating_html } from '../helpers';
|
||||||
|
|
||||||
erpnext.hub.Item = class Item extends SubPage {
|
erpnext.hub.Item = class Item extends SubPage {
|
||||||
make_wrapper() {
|
|
||||||
super.make_wrapper();
|
|
||||||
this.setup_events();
|
|
||||||
}
|
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
this.show_skeleton();
|
this.show_skeleton();
|
||||||
this.hub_item_code = frappe.get_route()[2];
|
this.hub_item_code = frappe.get_route()[2];
|
||||||
@ -45,29 +40,6 @@ erpnext.hub.Item = class Item extends SubPage {
|
|||||||
this.$wrapper.html(skeleton);
|
this.$wrapper.html(skeleton);
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_events() {
|
|
||||||
this.$wrapper.on('click', '.btn-contact-seller', () => {
|
|
||||||
const d = new frappe.ui.Dialog({
|
|
||||||
title: __('Send a message'),
|
|
||||||
fields: [
|
|
||||||
{
|
|
||||||
fieldname: 'to',
|
|
||||||
fieldtype: 'Read Only',
|
|
||||||
label: __('To'),
|
|
||||||
default: this.item.company
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldtype: 'Text',
|
|
||||||
fieldname: 'message',
|
|
||||||
label: __('Message')
|
|
||||||
}
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
d.show();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
get_item(hub_item_code) {
|
get_item(hub_item_code) {
|
||||||
return hub.call('get_item_details', { hub_item_code });
|
return hub.call('get_item_details', { hub_item_code });
|
||||||
}
|
}
|
||||||
@ -150,7 +122,7 @@ erpnext.hub.Item = class Item extends SubPage {
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
<div class="margin-bottom"><a href="#marketplace/seller/${seller}" class="bold">${seller}</a></div>
|
<div class="margin-bottom"><a href="#marketplace/seller/${seller}" class="bold">${seller}</a></div>
|
||||||
<button class="btn btn-xs btn-default text-muted btn-contact-seller">
|
<button class="btn btn-xs btn-default text-muted" data-action="contact_seller">
|
||||||
${__('Contact Seller')}
|
${__('Contact Seller')}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@ -204,6 +176,30 @@ erpnext.hub.Item = class Item extends SubPage {
|
|||||||
this.unpublish_dialog.show();
|
this.unpublish_dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
contact_seller() {
|
||||||
|
const d = new frappe.ui.Dialog({
|
||||||
|
title: __('Send a message'),
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
fieldname: 'to',
|
||||||
|
fieldtype: 'Read Only',
|
||||||
|
label: __('To'),
|
||||||
|
default: this.item.company
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldtype: 'Text',
|
||||||
|
fieldname: 'message',
|
||||||
|
label: __('Message')
|
||||||
|
}
|
||||||
|
],
|
||||||
|
primary_action: ({ message }) => {
|
||||||
|
if (!message) return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
d.show();
|
||||||
|
}
|
||||||
|
|
||||||
make_review_area() {
|
make_review_area() {
|
||||||
this.comment_area = new frappe.ui.ReviewArea({
|
this.comment_area = new frappe.ui.ReviewArea({
|
||||||
parent: this.$wrapper.find('.timeline-head').empty(),
|
parent: this.$wrapper.find('.timeline-head').empty(),
|
||||||
|
7
erpnext/public/js/hub/pages/messages.js
Normal file
7
erpnext/public/js/hub/pages/messages.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import SubPage from './subpage';
|
||||||
|
|
||||||
|
erpnext.hub.Messages = class Messages extends SubPage {
|
||||||
|
refresh() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user