[hub] add register as a seller page
This commit is contained in:
parent
0fbaa72504
commit
bc8caefc19
@ -31,6 +31,13 @@ def get_list(doctype, start=0, limit=20, fields=["*"], filters="{}", order_by=No
|
||||
|
||||
return listing
|
||||
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_valid_items():
|
||||
items = frappe.get_list('Item')
|
||||
return items
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_item_favourites(start=0, limit=20, fields=["*"], order_by=None):
|
||||
doctype = 'Hub Item'
|
||||
|
@ -14,243 +14,21 @@
|
||||
"fields": [
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "enabled",
|
||||
"fieldname": "registered",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 1,
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Enabled",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "suspended",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 1,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Suspended",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "enabled",
|
||||
"fieldname": "hub_username",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Hub Username",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "user",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "User",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "User",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "column_break_0",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "enabled",
|
||||
"fieldname": "hub_user_status",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Status",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "enabled",
|
||||
"fieldname": "language",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Language",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 1,
|
||||
"collapsible_depends_on": "eval:(!doc.enabled)",
|
||||
"columns": 0,
|
||||
"depends_on": "",
|
||||
"fieldname": "seller_profile_section",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Company and Seller Profile",
|
||||
"label": "Registered",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
@ -268,6 +46,7 @@
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
@ -299,6 +78,7 @@
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
@ -331,6 +111,7 @@
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
@ -362,6 +143,7 @@
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
@ -394,11 +176,44 @@
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "company_logo",
|
||||
"fieldname": "currency",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Currency",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "logo",
|
||||
"fieldtype": "Attach Image",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
@ -425,11 +240,12 @@
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "seller_description",
|
||||
"fieldname": "company_description",
|
||||
"fieldtype": "Text Editor",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
@ -456,6 +272,7 @@
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
@ -487,38 +304,7 @@
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "users",
|
||||
"fieldtype": "Table",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Users",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Hub Users",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
@ -551,6 +337,7 @@
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
@ -582,6 +369,7 @@
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
@ -614,6 +402,7 @@
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
@ -647,6 +436,7 @@
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
@ -679,6 +469,7 @@
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
@ -711,6 +502,7 @@
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
@ -744,6 +536,7 @@
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 1,
|
||||
@ -777,6 +570,7 @@
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
@ -817,8 +611,8 @@
|
||||
"issingle": 1,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2018-03-26 00:55:17.929140",
|
||||
"modified_by": "test1@example.com",
|
||||
"modified": "2018-07-24 18:53:09.442523",
|
||||
"modified_by": "cave@aperture.com",
|
||||
"module": "Hub Node",
|
||||
"name": "Hub Settings",
|
||||
"name_case": "",
|
||||
@ -826,7 +620,6 @@
|
||||
"permissions": [
|
||||
{
|
||||
"amend": 0,
|
||||
"apply_user_permissions": 0,
|
||||
"cancel": 0,
|
||||
"create": 1,
|
||||
"delete": 0,
|
||||
|
@ -10,9 +10,10 @@ from frappe import _
|
||||
from erpnext.utilities.product import get_price, get_qty_in_stock
|
||||
from six import string_types
|
||||
|
||||
hub_url = "https://hubmarket.org"
|
||||
# hub_url = "https://hubmarket.org"
|
||||
# hub_url = "http://159.89.175.122"
|
||||
# hub_url = "http://erpnext.hub:8001"
|
||||
hub_url = "http://hub.market:8000"
|
||||
|
||||
class OAuth2Session():
|
||||
def __init__(self, headers):
|
||||
@ -80,20 +81,20 @@ class HubSettings(Document):
|
||||
def register(self):
|
||||
""" Create a User on hub.erpnext.org and return username/password """
|
||||
data = {
|
||||
'email': frappe.session.user
|
||||
'profile': self.as_json()
|
||||
}
|
||||
post_url = hub_url + '/api/method/hub.hub.api.register'
|
||||
|
||||
response = requests.post(post_url, data=data)
|
||||
response = requests.post(post_url, data=data, headers = {'accept': 'application/json'})
|
||||
|
||||
response.raise_for_status()
|
||||
message = response.json().get('message')
|
||||
|
||||
if response.ok:
|
||||
message = response.json().get('message')
|
||||
else:
|
||||
frappe.throw(json.loads(response.text))
|
||||
|
||||
if message and message.get('password'):
|
||||
self.user = frappe.session.user
|
||||
self.create_hub_connector(message)
|
||||
self.company = frappe.defaults.get_user_default('company')
|
||||
self.enabled = 1
|
||||
self.save()
|
||||
return message.get('password') if message else None
|
||||
|
||||
def unregister(self):
|
||||
""" Disable the User on hub.erpnext.org"""
|
||||
@ -143,3 +144,16 @@ def reset_hub_settings(last_sync_datetime = ""):
|
||||
def sync():
|
||||
hub_settings = frappe.get_doc('Hub Settings')
|
||||
hub_settings.sync()
|
||||
|
||||
@frappe.whitelist()
|
||||
def register_seller(**kwargs):
|
||||
settings = frappe.get_doc('Hub Settings')
|
||||
settings.update(kwargs)
|
||||
password = settings.register()
|
||||
|
||||
print(password)
|
||||
|
||||
# if password:
|
||||
# self.create_hub_connector(message)
|
||||
# self.registered = 1
|
||||
# self.save()
|
||||
|
@ -5,11 +5,16 @@ erpnext.hub.Marketplace = class Marketplace {
|
||||
this.$parent = $(parent);
|
||||
this.page = parent.page;
|
||||
|
||||
this.setup_header();
|
||||
this.make_sidebar();
|
||||
this.make_body();
|
||||
this.setup_events();
|
||||
this.refresh();
|
||||
frappe.db.get_doc('Hub Settings')
|
||||
.then(doc => {
|
||||
this.hub_settings = doc;
|
||||
|
||||
this.setup_header();
|
||||
this.make_sidebar();
|
||||
this.make_body();
|
||||
this.setup_events();
|
||||
this.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
setup_header() {
|
||||
@ -35,7 +40,7 @@ erpnext.hub.Marketplace = class Marketplace {
|
||||
<li class="hub-sidebar-item" data-route="marketplace/favourites">
|
||||
${__('Favorites')}
|
||||
</li>
|
||||
<li class="hub-sidebar-item text-muted">
|
||||
<li class="hub-sidebar-item text-muted" data-route="marketplace/register">
|
||||
${__('Become a seller')}
|
||||
</li>
|
||||
</ul>
|
||||
@ -110,6 +115,11 @@ erpnext.hub.Marketplace = class Marketplace {
|
||||
this.subpages.item = new erpnext.hub.Item(this.$body);
|
||||
}
|
||||
|
||||
if (route[1] === 'register' && !this.subpages.register) {
|
||||
this.subpages.register = new erpnext.hub.Register(this.$body);
|
||||
}
|
||||
|
||||
|
||||
if (!Object.keys(this.subpages).includes(route[1])) {
|
||||
frappe.show_not_found();
|
||||
return;
|
||||
@ -189,7 +199,7 @@ erpnext.hub.Home = class Home extends SubPage {
|
||||
|
||||
render(items) {
|
||||
const html = get_item_card_container_html(items, __('Recently Published'));
|
||||
this.$wrapper.html(html)
|
||||
this.$wrapper.append(html)
|
||||
}
|
||||
}
|
||||
|
||||
@ -412,7 +422,6 @@ erpnext.hub.Item = class Item extends SubPage {
|
||||
<span class="pull-left avatar avatar-medium hidden-xs" style="margin-top: 1px">
|
||||
${image_html}
|
||||
</span>
|
||||
|
||||
<div class="pull-left media-body">
|
||||
<div class="media-content-wrapper">
|
||||
<div class="action-btns">${edit_html}</div>
|
||||
@ -449,6 +458,176 @@ erpnext.hub.Item = class Item extends SubPage {
|
||||
</div>`;
|
||||
}
|
||||
}
|
||||
erpnext.hub.Register = class Register extends SubPage {
|
||||
make_wrapper() {
|
||||
super.make_wrapper();
|
||||
this.$register_container = $(`<div class="row register-container">`)
|
||||
.appendTo(this.$wrapper);
|
||||
this.$form_container = $('<div class="col-md-8 col-md-offset-1 form-container">')
|
||||
.appendTo(this.$wrapper);
|
||||
|
||||
// const title = __('Become a Seller');
|
||||
// this.$register_container.append($(`<h5>${title}</h5>`));
|
||||
}
|
||||
|
||||
refresh() {
|
||||
// company, company_email, logo, description
|
||||
this.render();
|
||||
}
|
||||
|
||||
// make_input() {
|
||||
// //
|
||||
// }
|
||||
|
||||
render() {
|
||||
this.make_field_group();
|
||||
}
|
||||
|
||||
make_field_group() {
|
||||
const fields = [
|
||||
{
|
||||
fieldtype: 'Link',
|
||||
fieldname: 'company',
|
||||
label: __('Company'),
|
||||
options: 'Company',
|
||||
onchange: () => {
|
||||
const value = this.field_group.get_value('company');
|
||||
|
||||
if (value) {
|
||||
frappe.db.get_doc('Company', value)
|
||||
.then(company => {
|
||||
this.field_group.set_values({
|
||||
country: company.country,
|
||||
company_email: company.email,
|
||||
currency: company.default_currency
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
fieldname: 'company_email',
|
||||
label: __('Email'),
|
||||
fieldtype: 'Data'
|
||||
},
|
||||
{
|
||||
fieldname: 'country',
|
||||
label: __('Country'),
|
||||
fieldtype: 'Read Only'
|
||||
},
|
||||
{
|
||||
fieldname: 'currency',
|
||||
label: __('Currency'),
|
||||
fieldtype: 'Read Only'
|
||||
},
|
||||
{
|
||||
fieldtype: 'Text',
|
||||
label: __('About your Company'),
|
||||
fieldname: 'company_description'
|
||||
}
|
||||
];
|
||||
|
||||
this.field_group = new frappe.ui.FieldGroup({
|
||||
parent: this.$form_container,
|
||||
fields
|
||||
});
|
||||
|
||||
this.field_group.make();
|
||||
|
||||
this.$form_container.find('.form-column').append(`
|
||||
<div class="text-right">
|
||||
<button type="submit" class="btn btn-primary btn-register btn-sm">${__('Submit')}</button>
|
||||
</div>
|
||||
`);
|
||||
|
||||
this.$form_container.find('.form-message').removeClass('hidden small').addClass('h4').text(__('Become a Seller'))
|
||||
|
||||
this.$form_container.on('click', '.btn-register', () => {
|
||||
const form_values = this.field_group.get_values();
|
||||
frappe.call('erpnext.hub_node.doctype.hub_settings.hub_settings.register_seller', form_values)
|
||||
.then(() => {
|
||||
// Reload page and things ... but for now
|
||||
frappe.msgprint('Registered successfully.');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
make_form() {
|
||||
const form_html = `<form class="register-form">
|
||||
<div class="register-title margin-bottom margin-top">
|
||||
<b>Become a Seller</b>
|
||||
</div>
|
||||
|
||||
<div class="flex">
|
||||
<div style="flex: 0 0 140px" class="margin-right">
|
||||
<div>
|
||||
<div class="missing-image attach-missing-image">
|
||||
<i class="octicon octicon-device-camera"></i>
|
||||
</div><div class="img-container" style="display: none;">
|
||||
<img class="img-responsive attach-image-display">
|
||||
<div class="img-overlay">
|
||||
<span class="overlay-text">Change</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="flex: 1; font-size: 12px;">
|
||||
<div class="form-group">
|
||||
<input class="form-control" placeholder="Company" name="company" required="required">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<input class="form-control" placeholder="Country" name="country" required="required">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<input class="form-control" placeholder="Company Email" name="company_email" required="required">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<textarea class="form-control" placeholder="About Your Company" name="company_description" required="required">
|
||||
</textarea>
|
||||
</div>
|
||||
|
||||
<div class="text-right">
|
||||
<button type="submit" class="btn btn-primary btn-sm">${__('Submit')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>`;
|
||||
|
||||
|
||||
|
||||
this.$form_container.append(form_html);
|
||||
|
||||
this.$form_container.on('submit', (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
const formValues = this.$form_container.find('form').serializeArray();
|
||||
|
||||
console.log(formValues);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
erpnext.hub.PublishItems = class PublishItems extends SubPage {
|
||||
refresh() {
|
||||
this.get_favourites()
|
||||
.then(r => {
|
||||
this.render(r.message);
|
||||
});
|
||||
}
|
||||
|
||||
render(items) {
|
||||
const html = get_item_card_container_html(items, __(this.category));
|
||||
this.$wrapper.html(html);
|
||||
}
|
||||
|
||||
get_valid_items() {
|
||||
return frappe.call('erpnext.hub_node.get_valid_items');
|
||||
}
|
||||
}
|
||||
|
||||
function get_item_card_container_html(items, title) {
|
||||
const html = (items || []).map(item => get_item_card_html(item)).join('');
|
||||
@ -1335,4 +1514,4 @@ erpnext.hub.CompanyListing = class CompanyListing extends erpnext.hub.HubListing
|
||||
return item_html;
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
@ -17,6 +17,10 @@ body[data-route^="marketplace/"] {
|
||||
}
|
||||
}
|
||||
|
||||
input, textarea {
|
||||
font-size: @text-medium;
|
||||
}
|
||||
|
||||
.hub-card {
|
||||
border: 1px solid @border-color;
|
||||
margin-bottom: 25px;
|
||||
@ -58,7 +62,6 @@ body[data-route^="marketplace/"] {
|
||||
margin-bottom: 20px;
|
||||
|
||||
input {
|
||||
font-size: @text-medium;
|
||||
height: 32px;
|
||||
}
|
||||
}
|
||||
@ -101,6 +104,28 @@ body[data-route^="marketplace/"] {
|
||||
border-radius: 4px;
|
||||
border: 1px solid @border-color;
|
||||
}
|
||||
|
||||
.register-title {
|
||||
font-size: @text-regular;
|
||||
}
|
||||
|
||||
.register-form {
|
||||
border: 1px solid @border-color;
|
||||
border-radius: 4px;
|
||||
padding: 15px 25px;
|
||||
}
|
||||
|
||||
.form-container {
|
||||
.frappe-control {
|
||||
max-width: 100% !important;
|
||||
}
|
||||
}
|
||||
|
||||
.form-message {
|
||||
padding-top: 0;
|
||||
padding-bottom: 0;
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
body[data-route^="Hub/"] {
|
||||
|
Loading…
x
Reference in New Issue
Block a user