[hub] start

This commit is contained in:
Rushabh Mehta
2015-02-18 19:08:57 +05:30
parent 9252002249
commit 4ea1ade7b9
17 changed files with 1355 additions and 767 deletions

View File

View File

View File

@@ -0,0 +1,90 @@
frappe.pages['hub'].on_page_load = function(wrapper) {
var page = frappe.ui.make_app_page({
parent: wrapper,
title: 'Hub',
single_column: true
});
frappe.hub = new frappe.Hub({page:page});
}
frappe.pages['hub'].on_page_show = function() {
frappe.hub.refresh();
}
frappe.Hub = Class.extend({
init: function(args) {
$.extend(this, args);
this.render();
},
refresh: function() {
if(this.hub && this.hub.publish && !this.hub_list) {
this.setup_list();
}
},
render: function() {
this.page.main.empty();
var me = this;
frappe.model.with_doc("Hub Settings", "Hub Settings", function() {
me.hub = locals["Hub Settings"]["Hub Settings"];
if(!me.hub.publish) {
$(frappe.render_template("register_in_hub", {})).appendTo(me.page.main);
} else {
me.setup_list();
}
});
},
setup_list: function() {
var me = this;
$(frappe.render_template("hub_body", {})).appendTo(this.page.main);
this.hub_list = this.page.main.find(".hub-list");
this.search = this.page.main.find("input").on("keypress", function(e) {
if(e.which===13) {
me.reset();
}
});
this.loading = this.page.main.find(".loading");
this.done = this.page.main.find(".done");
this.more = this.page.main.find(".more")
this.more.find(".btn").on("click", function() { me.next_page() });
this.reset();
},
reset: function() {
this.hub_list.empty();
this.start = 0;
this.page_length = 20;
this.next_page();
},
next_page: function() {
var me = this;
this.loading.toggleClass("hide", false);
frappe.call({
method: "erpnext.hub_node.get_items",
args: {
text: this.get_text(),
start: this.start,
limit: this.page_length
},
callback: function(r) {
me.loading.toggleClass("hide", true);
if(!r.message)
r.message = [];
me.start += r.message.length;
$(frappe.render_template("hub_list", {items: r.message})).appendTo(me.hub_list);
if(r.message.length && r.message.length===me.page_length) {
// more
me.more.removeClass("hide");
me.done.addClass("hide");
} else {
// done
me.more.addClass("hide");
me.done.removeClass("hide");
}
}
});
},
get_text: function() {
return this.search.val();
},
})

View File

@@ -0,0 +1,21 @@
{
"content": null,
"creation": "2015-02-18 05:17:17.301735",
"docstatus": 0,
"doctype": "Page",
"modified": "2015-02-18 05:17:17.301735",
"modified_by": "Administrator",
"module": "Hub Node",
"name": "hub",
"owner": "Administrator",
"page_name": "hub",
"roles": [
{
"role": "All"
}
],
"script": null,
"standard": "Yes",
"style": null,
"title": "Hub"
}

View File

@@ -0,0 +1,20 @@
<div class="padding">
<div class="row">
<div class="col-md-4 col-md-offset-4">
<input class="form-control" name="search" placeholder="{%= __("Search") %}">
</div>
</div>
<hr style="margin: 15px -15px">
<div class="hub-list">
</div>
<div class="loading">
<p class="text-muted text-center">{%= __("Loading...") %}</p>
</div>
<div class="more text-center hide">
<button class="btn btn-default btn-sm">{%= __("More") %}</div>
</div>
<div class="done text-center text-extra-muted hide">
<p>{%= __("No more results.") %}</p>
</div>
</div>

View File

@@ -0,0 +1,16 @@
{% for(var i=0, l=items.length; i < l; i++) { %}
<div class="list-item">
<div class="row">
<div class="col-sm-6">
<h6>{%= items[i].item_name %}<h6>
</div>
<div class="col-sm-3">
<h6>{%= items[i].seller_name %}<h6>
</div>
<div class="col-sm-3 text-right">
<h6 class="text-muted">{%= items[i].seller_country %}<h6>
</div>
</div>
<p class="text-muted small">{%= items[i].description %}</p>
</div>
{% } %}

View File

@@ -0,0 +1,19 @@
<div style="padding: 70px 0px;">
<h2 class="text-center">{%= __("Register For ERPNext Hub") %}</h2>
<br>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<ul>
<li>Free listing of your products</li>
<li>Let other ERPNext users discover your products</li>
<li>Discover products quickly</li>
<li>Automate workflow with Supplier from within ERPNext (later)</li>
</ul>
</div>
</div>
<br>
<div class="text-center">
<a class="btn btn-primary" href="#Form/Hub Settings">
Hub Settings</a>
</div>
</div>