From 917ecaeda8d68bb89f954ca873bd2070d63b1ee3 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 1 Jul 2013 17:15:17 +0530 Subject: [PATCH] [moduleview] added top bar --- public/css/ui/common.css | 35 ++++++++++++ public/js/wn/form/toolbar.js | 1 + public/js/wn/views/moduleview.js | 91 +++++++++++++++++++++++++------- public/js/wn/views/pageview.js | 12 ++--- 4 files changed, 112 insertions(+), 27 deletions(-) diff --git a/public/css/ui/common.css b/public/css/ui/common.css index 37ac220b81..985335a6fd 100644 --- a/public/css/ui/common.css +++ b/public/css/ui/common.css @@ -45,6 +45,41 @@ a { text-align: right; } +/* module */ + +.module-top .alert { + padding-right: 15px; + margin-bottom: 10px; +} + +.module-top a, .module-top a:hover { + color: black; + font-size: 120%; + font-weight: bold; +} + +.module-top .badge { + margin-top: 3px; +} + +.module-item-progress { + margin-bottom: 10px; + height: 17px; +} + +.module-item-progress-total { + height: 7px; + background-color: #999999; + width: 0px; +} + +.module-item-progress-open { + height: 7px; + background-color: red; + width: 0px; +} + + /* fixed navbar in appframe */ .appframe .navbar { diff --git a/public/js/wn/form/toolbar.js b/public/js/wn/form/toolbar.js index c6e8bdb00b..730d132c7a 100644 --- a/public/js/wn/form/toolbar.js +++ b/public/js/wn/form/toolbar.js @@ -146,6 +146,7 @@ wn.ui.form.Toolbar = Class.extend({ var status_bar_parent = this.frm.appframe.$w.find(".status-bar").empty(); if(this.frm.meta.is_submittable && !this.frm.doc.__islocal) { var status_bar = $("

") + .css({"margin": "0px"}) .appendTo(status_bar_parent); switch(this.frm.doc.docstatus) { diff --git a/public/js/wn/views/moduleview.js b/public/js/wn/views/moduleview.js index 73289ffe25..6acfa52210 100644 --- a/public/js/wn/views/moduleview.js +++ b/public/js/wn/views/moduleview.js @@ -33,6 +33,8 @@ wn.views.show_open_count_list = function(element) { wn.views.moduleview.ModuleView = Class.extend({ init: function(wrapper, module) { this.doctypes = []; + this.top_item_total = {}; + this.top_item_open = {}; $(wrapper).empty(); wn.ui.make_app_page({ parent: wrapper, @@ -55,7 +57,8 @@ wn.views.moduleview.ModuleView = Class.extend({ make_body: function() { var wrapper = this.wrapper; // make columns - $(wrapper).find(".layout-main").html("
\ + $(wrapper).find(".layout-main").html("
\ +
\
\
\
") @@ -71,35 +74,83 @@ wn.views.moduleview.ModuleView = Class.extend({ }, add_section: function(section) { section._title = wn._(section.title); - var list_group = $('
    \ -
  • \ -

    ' - + wn._(section.title) +'

    \ -
  • \ -
"').appendTo(section.right - ? $(this.wrapper).find(".side-section") - : $(this.wrapper).find(".main-section")); + if(section.top) { + var list_group = $('
') + .appendTo($(this.wrapper).find(".module-top")); + } else { + var list_group = $('
    \ +
  • \ +

    ' + + wn._(section.title) +'

    \ +
  • \ +
"').appendTo(section.right + ? $(this.wrapper).find(".side-section") + : $(this.wrapper).find(".main-section")); + } section.list_group = list_group; }, add_item: function(item, section) { if(!item.description) item.description = ""; if(item.count==null) item.count = ""; + if(section.top) { + var $parent = $(repl('
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
', {doctype:item.doctype})) + .appendTo(section.list_group) + .find(".alert"); + this.top_item_total[item.doctype] = 0; + } else { + var $parent = $('
  • ').appendTo(section.list_group); + } - $(repl('
  • \ - %(link)s" - + (item.description + + ((item.description && !section.top) ? " %(description)s" : "") + ((section.right || !item.doctype) ? '' - : '\ - ') - + "
  • ", item)) - .appendTo(section.list_group); + : ''), item)) + .appendTo($parent); + + if(!section.top) { + $('').appendTo($parent); + } + }, + set_top_item_count: function(doctype, count, open_count) { + var me = this; + if(this.top_item_total[doctype]!=null) { + + if(count!=null) + this.top_item_total[doctype] = count; + if(open_count!=null) + this.top_item_open[doctype] = open_count; + + var maxtop = Math.max.apply(this, values(this.top_item_total)); + + $.each(this.top_item_total, function(doctype, item_count) { + $(me.wrapper).find(".module-item-progress[data-doctype='"+ doctype +"']") + .find(".module-item-progress-total") + .css("width", cint(flt(item_count)/maxtop*100) + "%") + }) + + $.each(this.top_item_open, function(doctype, item_count) { + $(me.wrapper).find(".module-item-progress[data-doctype='"+ doctype +"']") + .find(".module-item-progress-open") + .css("width", cint(flt(item_count)/me.top_item_total[doctype]*100) + "%") + }) + } }, render_static: function() { // render sections @@ -177,8 +228,9 @@ wn.views.moduleview.ModuleView = Class.extend({ $.each(r.message.item_count, function(doctype, count) { $(me.wrapper).find("[data-doctype-count='"+doctype+"']") .html(count) - .addClass("badge badge-count") + .addClass("badge badge-count pull-right") .css({cursor:"pointer"}); + me.set_top_item_count(doctype, count) }) } @@ -194,12 +246,13 @@ wn.views.moduleview.ModuleView = Class.extend({ if(wn.boot.notification_info.open_count_doctype) { $.each(wn.boot.notification_info.open_count_doctype, function(doctype, count) { if(in_list(me.doctypes, doctype)) { + me.set_top_item_count(doctype, null, count); $('') .css({ "cursor": "pointer", "margin-right": "0px" }) - .addClass("badge badge-important") + .addClass("badge badge-important pull-right") .html(count) .attr("data-doctype", doctype) .insertAfter($(me.wrapper) diff --git a/public/js/wn/views/pageview.js b/public/js/wn/views/pageview.js index 71f14bf0a2..a7da3ccb21 100644 --- a/public/js/wn/views/pageview.js +++ b/public/js/wn/views/pageview.js @@ -81,14 +81,10 @@ wn.views.Page = Class.extend({ }, trigger: function(eventname) { var me = this; - try { - if(pscript[eventname+'_'+this.name]) { - pscript[eventname+'_'+this.name](me.wrapper); - } else if(me.wrapper[eventname]) { - me.wrapper[eventname](me.wrapper); - } - } catch(e) { - console.log(e); + if(pscript[eventname+'_'+this.name]) { + pscript[eventname+'_'+this.name](me.wrapper); + } else if(me.wrapper[eventname]) { + me.wrapper[eventname](me.wrapper); } } })