From a2c248addddd654bfcd712a59d87f458b6161e87 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 7 Jun 2013 12:58:27 +0530 Subject: [PATCH 1/3] [projects] added ganttview, removed old timesheet --- public/css/ui/common.css | 1 + public/js/legacy/widgets/form/form.js | 6 +- public/js/lib/README.md | 6 +- public/js/lib/jQuery.Gantt/css/style.css | 6 +- public/js/wn/form/control.js | 2 + public/js/wn/router.js | 2 + public/js/wn/ui/appframe.js | 17 +++- public/js/wn/views/doclistview.js | 25 +++++- public/js/wn/views/formview.js | 2 +- public/js/wn/views/ganttview.js | 98 +++++++++++++++++++----- webnotes/model/bean.py | 4 +- 11 files changed, 136 insertions(+), 33 deletions(-) diff --git a/public/css/ui/common.css b/public/css/ui/common.css index 9cde02fb61..b1aecf7984 100644 --- a/public/css/ui/common.css +++ b/public/css/ui/common.css @@ -49,6 +49,7 @@ a { margin-bottom: 0px; border-radius: 0px; border-bottom: 1px solid #ddd; + min-height: 51px; } .appframe .navbar-form select, diff --git a/public/js/legacy/widgets/form/form.js b/public/js/legacy/widgets/form/form.js index 9c8a72adb6..4a738971d3 100644 --- a/public/js/legacy/widgets/form/form.js +++ b/public/js/legacy/widgets/form/form.js @@ -293,7 +293,7 @@ _f.Frm.prototype.set_footnote = function(txt) { _f.Frm.prototype.add_custom_button = function(label, fn, icon) { - this.appframe.add_button(label, fn, icon || "icon-arrow-right", true); + this.appframe.add_button(label, fn, icon || "icon-arrow-right"); } _f.Frm.prototype.clear_custom_buttons = function() { this.toolbar.refresh() @@ -440,9 +440,7 @@ _f.Frm.prototype.refresh = function(docname) { } // header - if(!this.meta.istable) { - this.refresh_header(); - } + this.refresh_header(); // call trigger this.script_manager.trigger("refresh"); diff --git a/public/js/lib/README.md b/public/js/lib/README.md index 72ac015780..58e09e9516 100644 --- a/public/js/lib/README.md +++ b/public/js/lib/README.md @@ -16,4 +16,8 @@ Download modules Changes images urls - from: url(images -- to: url(../lib/js/lib/jquery/bootstrap_theme/images \ No newline at end of file +- to: url(../lib/js/lib/jquery/bootstrap_theme/images + +## JQuery Gantt + +Not a very mature project. Please check css / js after updating \ No newline at end of file diff --git a/public/js/lib/jQuery.Gantt/css/style.css b/public/js/lib/jQuery.Gantt/css/style.css index 6089ff1859..9ed6779055 100644 --- a/public/js/lib/jQuery.Gantt/css/style.css +++ b/public/js/lib/jQuery.Gantt/css/style.css @@ -45,7 +45,7 @@ overflow: hidden; border-right: 1px solid #DDD; position: relative; - z-index: 20; + z-index: 2; } .fn-gantt .row, .row .fn-gantt .row { @@ -178,7 +178,7 @@ padding: 10px; position: absolute; display: none; - z-index: 11; + z-index: 2; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; @@ -189,7 +189,7 @@ height: 18px; margin: 4px 3px 3px 3px; position: absolute; - z-index: 10; + z-index: 1; text-align: center; -webkit-box-shadow: 0 0 1px rgba(0,0,0,0.25) inset; -moz-box-shadow: 0 0 1px rgba(0,0,0,0.25) inset; diff --git a/public/js/wn/form/control.js b/public/js/wn/form/control.js index da0126f8c1..7f119b966b 100644 --- a/public/js/wn/form/control.js +++ b/public/js/wn/form/control.js @@ -236,6 +236,8 @@ wn.ui.form.ControlData = wn.ui.form.ControlInput.extend({ .attr("placeholder", this.df.placeholder || "") if(this.doctype) this.$input.attr("data-doctype", this.doctype); + if(this.df.input_css) + this.$input.css(this.df.input_css); }, bind_change_event: function() { var me = this; diff --git a/public/js/wn/router.js b/public/js/wn/router.js index 5a2d79923e..de0e4b1483 100644 --- a/public/js/wn/router.js +++ b/public/js/wn/router.js @@ -3,6 +3,7 @@ // re-route map (for rename) wn.re_route = {}; wn.route_titles = {}; +wn.route_history = []; wn.view_factory = {}; wn.view_factories = []; @@ -27,6 +28,7 @@ wn.route = function() { wn._cur_route = window.location.hash; route = wn.get_route(); + wn.route_history.push(route); if(route[0] && wn.views[route[0] + "Factory"]) { // has a view generator, generate! diff --git a/public/js/wn/ui/appframe.js b/public/js/wn/ui/appframe.js index 9b15c1f2e6..b42abec47a 100644 --- a/public/js/wn/ui/appframe.js +++ b/public/js/wn/ui/appframe.js @@ -7,6 +7,7 @@ wn.ui.AppFrame = Class.extend({ init: function(parent, title, module) { this.set_document_title = true; this.buttons = {}; + this.fields_dict = {}; this.$w = $('
\
\ @@ -121,14 +122,22 @@ wn.ui.AppFrame = Class.extend({ }); } - if(meta.__calendar_js) { + if(wn.views.calendar[doctype]) { views.push({ icon: "icon-calendar", route: "Calendar/" + doctype, type: "calendar" }); } - + + if(wn.views.calendar[doctype] && wn.views.calendar[doctype]) { + views.push({ + icon: "icon-tasks", + route: "Gantt/" + doctype, + type: "gantt" + }); + } + if(wn.model.can_get_report(doctype)) { views.push({ icon: "icon-table", @@ -273,7 +282,9 @@ wn.ui.AppFrame = Class.extend({ "margin-left": "4px" }) .attr("title", df.label).tooltip(); - + if(df["default"]) + f.set_input(df["default"]) + this.fields_dict[df.fieldname || df.label] = f; return f; }, add_ripped_paper_effect: function(wrapper) { diff --git a/public/js/wn/views/doclistview.js b/public/js/wn/views/doclistview.js index ad64d8ef24..1febd07321 100644 --- a/public/js/wn/views/doclistview.js +++ b/public/js/wn/views/doclistview.js @@ -36,7 +36,7 @@ wn.views.DocListView = wn.ui.Listing.extend({ var me = this; $(this.page).on("show", function() { - me.dirty && me.run(); + me.refresh(); }); }, @@ -152,7 +152,27 @@ wn.views.DocListView = wn.ui.Listing.extend({ (me.listview.make_new_doc || me.make_new_doc)(me.doctype); }); - if((auto_run !== false) && (auto_run !== 0)) this.run(); + if((auto_run !== false) && (auto_run !== 0)) + this.refresh(); + }, + + refresh: function() { + var me = this; + if(wn.route_options) { + me.filter_list.clear_filters(); + $.each(wn.route_options, function(key, value) { + me.filter_list.add_filter(me.doctype, key, "=", value); + }) + wn.route_options = null; + me.run(); + } else if(me.dirty) { + me.run(); + } else { + if(new Date() - (me.last_updated_on || 0) > 30000) { + // older than 5 mins, refresh + me.run(); + } + } }, run: function(more) { @@ -164,6 +184,7 @@ wn.views.DocListView = wn.ui.Listing.extend({ me.set_filter(key, val, true); }); } + this.last_updated_on = new Date(); this._super(more); }, diff --git a/public/js/wn/views/formview.js b/public/js/wn/views/formview.js index 14bd06c19a..1119342203 100644 --- a/public/js/wn/views/formview.js +++ b/public/js/wn/views/formview.js @@ -47,7 +47,7 @@ wn.views.FormFactory = wn.views.Factory.extend({ } wn.container.change_to("Form/" + dt); - me.page.frm.refresh(dn); + wn.views.formview[dt].frm.refresh(dn); }); } diff --git a/public/js/wn/views/ganttview.js b/public/js/wn/views/ganttview.js index 46b16cabff..f5c47b749e 100644 --- a/public/js/wn/views/ganttview.js +++ b/public/js/wn/views/ganttview.js @@ -4,13 +4,18 @@ wn.views.GanttFactory = wn.views.Factory.extend({ make: function(route) { var me = this; wn.model.with_doctype(route[1], function() { + var page = me.make_page(); + $(page).on("show", function() { + me.set_filters_from_route_options(); + }); + var options = { doctype: route[1], - page: me.make_page() + page: page }; $.extend(options, wn.views.calendar[route[1]] || {}); - new wn.views.Gantt(options); + page.ganttview = new wn.views.Gantt(options); }); } }); @@ -23,16 +28,36 @@ wn.views.Gantt = Class.extend({ wn.require('lib/js/lib/jQuery.Gantt/js/jquery.fn.gantt.js'); this.make_page(); - this.make_chart(); - + wn.route_options ? + this.set_filters_from_route_options() : + this.refresh(); }, make_page: function() { - var module = locals.DocType[this.doctype].module; - this.page.appframe.set_title(wn._("Gantt Chart") + " - " + wn._(this.doctype)); - this.page.appframe.add_module_icon(module) - this.page.appframe.set_views_for(this.doctype, "gantt"); + var module = locals.DocType[this.doctype].module, + me = this; + + this.appframe = this.page.appframe; + this.appframe.set_title(wn._("Gantt Chart") + " - " + wn._(this.doctype)); + this.appframe.add_module_icon(module) + this.appframe.set_views_for(this.doctype, "gantt"); + + this.appframe.add_button("Refresh", + function() { me.refresh(); }, "icon-refresh") + + this.appframe.add_field({fieldtype:"Date", label:"From", + fieldname:"start", "default": wn.datetime.month_start(), input_css: {"z-index": 3}}); + + this.appframe.add_field({fieldtype:"Date", label:"To", + fieldname:"end", "default": wn.datetime.month_end(), input_css: {"z-index": 3}}); + + if(this.filters) { + $.each(this.filters, function(i, df) { + me.appframe.add_field(df); + return false; + }); + } }, - make_chart: function() { + refresh: function() { var parent = $(this.page) .find(".layout-main") .empty() @@ -45,19 +70,20 @@ wn.views.Gantt = Class.extend({ type: "GET", args: { doctype: this.doctype, - start: "2013-01-01", - end: "2014-01-01" + start: this.appframe.fields_dict.start.get_parsed_value(), + end: this.appframe.fields_dict.end.get_parsed_value(), + filters: this.get_filters() }, callback: function(r) { $(parent).empty(); if(!r.message.length) { - $(parent).html('
No Tasks Yet.
'); + $(parent).html('
Nothing to show.
'); } else { var gantt_area = $('
').appendTo(parent); gantt_area.gantt({ source: me.get_source(r), navigate: "scroll", - scale: "weeks", + scale: "day", minScale: "day", maxScale: "months", onItemClick: function(data) { @@ -72,6 +98,27 @@ wn.views.Gantt = Class.extend({ }) }, + set_filter: function(doctype, value) { + var me = this; + if(this.filters) { + $.each(this.filters, function(i, df) { + if(df.options===value) + me.appframe.fields_dict[df.fieldname].set_input(value); + return false; + }); + } + }, + get_filters: function() { + var filter_vals = {}, + me = this; + if(this.filters) { + $.each(this.filters, function(i, df) { + filter_vals[df.fieldname || df.label] = + me.appframe.fields_dict[df.fieldname || df.label].get_parsed_value(); + }); + } + return filter_vals; + }, get_source: function(r) { var source = [], me = this; @@ -85,11 +132,11 @@ wn.views.Gantt = Class.extend({ if(v.start && v.end) { source.push({ - name: v.project || " ", - desc: v.subject, + name: v.title, + desc: v.status, values: [{ name: v.title, - desc: v.status, + desc: v.title + "
" + v.status, from: '/Date("'+v.start+'")/', to: '/Date("'+v.end+'")/', customClass: { @@ -98,12 +145,27 @@ wn.views.Gantt = Class.extend({ 'info':'ganttBlue', 'success':'ganttGreen', '':'ganttGray' - }[me.style_map[v.status]], + }[me.style_map ? + me.style_map[v.status] : + wn.utils.guess_style(v.status, "standard")], dataObj: v }] }) } }); return source - } + }, + set_filters_from_route_options: function() { + var me = this; + if(wn.route_options) { + $.each(wn.route_options, function(k, value) { + if(me.appframe.fields_dict[k]) { + me.appframe.fields_dict[k].set_input(value); + me.refresh(); + return false; + }; + }) + wn.route_options = null; + } + } }); diff --git a/webnotes/model/bean.py b/webnotes/model/bean.py index 45c6344f86..82d4ab92f7 100644 --- a/webnotes/model/bean.py +++ b/webnotes/model/bean.py @@ -100,8 +100,10 @@ class Bean: self.obj.doc = self.doc def make_obj(self): - if self.obj: return self.obj + if self.obj: + return self.obj self.obj = webnotes.get_obj(doc=self.doc, doclist=self.doclist) + self.obj.bean = self self.controller = self.obj return self.obj From 681743c21131d1065d1e33a97fc58a2703253c8b Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 7 Jun 2013 14:57:29 +0530 Subject: [PATCH 2/3] [form] [status] fix #172 --- public/js/wn/form/toolbar.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/js/wn/form/toolbar.js b/public/js/wn/form/toolbar.js index 56356e2d1f..19f810ab86 100644 --- a/public/js/wn/form/toolbar.js +++ b/public/js/wn/form/toolbar.js @@ -140,9 +140,10 @@ wn.ui.form.Toolbar = Class.extend({ return this.appframe.add_dropdown(label); }, set_docstatus_label: function() { + 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 = $("

") - .appendTo(this.frm.appframe.$w.find(".status-bar").empty()); + .appendTo(status_bar_parent); switch(this.frm.doc.docstatus) { case 0: From b0210acd0a18678082883d34da5b0a21e14a0ac1 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 7 Jun 2013 15:09:44 +0530 Subject: [PATCH 3/3] [profile] removed themes --- core/doctype/profile/profile.js | 1 - core/doctype/profile/profile.txt | 11 ++---- public/build.json | 1 - public/js/wn/app.js | 3 -- public/js/wn/form/layout.js | 3 ++ public/js/wn/misc/user.js | 5 +++ public/js/wn/ui/themes.js | 60 -------------------------------- webnotes/profile.py | 4 +-- 8 files changed, 11 insertions(+), 77 deletions(-) delete mode 100644 public/js/wn/ui/themes.js diff --git a/core/doctype/profile/profile.js b/core/doctype/profile/profile.js index d4d6eca93b..71de1169c8 100644 --- a/core/doctype/profile/profile.js +++ b/core/doctype/profile/profile.js @@ -31,7 +31,6 @@ cur_frm.cscript.refresh = function(doc) { if(user==doc.name) { // update display settings - wn.ui.set_theme(doc.theme); if(doc.background_image) { wn.ui.set_user_background(doc.background_image); } diff --git a/core/doctype/profile/profile.txt b/core/doctype/profile/profile.txt index e8b53df461..61f091781d 100644 --- a/core/doctype/profile/profile.txt +++ b/core/doctype/profile/profile.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-03-07 12:26:21", + "creation": "2013-03-07 11:54:44", "docstatus": 0, - "modified": "2013-03-01 10:18:03", + "modified": "2013-06-07 15:06:00", "modified_by": "Administrator", "owner": "Administrator" }, @@ -199,13 +199,6 @@ "label": "Background Image", "options": "attach_files:" }, - { - "doctype": "DocField", - "fieldname": "theme", - "fieldtype": "Select", - "label": "Theme", - "options": "Default\nDesert\nFloral\nOcean\nSky\nSnow\nSunny\nTropic" - }, { "doctype": "DocField", "fieldname": "cb21", diff --git a/public/build.json b/public/build.json index 507400e1f4..7a4adb3c6c 100644 --- a/public/build.json +++ b/public/build.json @@ -96,7 +96,6 @@ "lib/public/js/legacy/webpage/loaders.js", "lib/public/js/wn/upload.js", - "lib/public/js/wn/ui/themes.js", "lib/public/js/wn/ui/filters.js", "lib/public/js/wn/ui/search.js", "lib/public/js/wn/ui/tree.js", diff --git a/public/js/wn/app.js b/public/js/wn/app.js index 17dd6892cb..61f17d5526 100644 --- a/public/js/wn/app.js +++ b/public/js/wn/app.js @@ -76,9 +76,6 @@ wn.Application = Class.extend({ if(wn.boot.profile.background_image) { wn.ui.set_user_background(wn.boot.profile.background_image); } - if(wn.boot.profile.theme) { - wn.ui.set_theme(wn.boot.profile.theme); - } }, load_bootinfo: function() { diff --git a/public/js/wn/form/layout.js b/public/js/wn/form/layout.js index b56487ff03..3a56d0a340 100644 --- a/public/js/wn/form/layout.js +++ b/public/js/wn/form/layout.js @@ -82,6 +82,9 @@ wn.ui.form.Layout = Class.extend({ // for bc this.section.row = {wrapper: this.section}; this.column = null; + if(df && df.hidden) { + this.section.toggle(false); + } return this.section; }, setup_tabbing: function() { diff --git a/public/js/wn/misc/user.js b/public/js/wn/misc/user.js index 28792dce2f..3bd2ec2a90 100644 --- a/public/js/wn/misc/user.js +++ b/public/js/wn/misc/user.js @@ -28,6 +28,11 @@ wn.avatar = function(user, large, title) { }); } +wn.ui.set_user_background = function(src) { + wn.dom.set_style(repl('body { background: url("%(src)s") repeat fixed;}', + {src:src})) +} + wn.provide('wn.user'); $.extend(wn.user, { diff --git a/public/js/wn/ui/themes.js b/public/js/wn/ui/themes.js deleted file mode 100644 index 2ff70e42fa..0000000000 --- a/public/js/wn/ui/themes.js +++ /dev/null @@ -1,60 +0,0 @@ -// for license information please see license.txt - -wn.provide("wn.ui"); - -wn.ui.set_user_background = function(src) { - wn.dom.set_style(repl('body { background: url("%(src)s") repeat fixed;}', - {src:src})) -} - -wn.ui.themes = { - "Default": { - sidebar: "#f2f2f2", - titlebar: "#d2d2d2", - toolbar: "#e9e9e9" - }, - Desert: { - sidebar: "#FFFDF7", - titlebar: "#DAD4C2", - toolbar: "#FAF6E9" - }, - Tropic: { - sidebar: "#FAFFF7", - toolbar: "#EEFAE9", - titlebar: "#D7ECD1" - }, - Sky: { - sidebar: "#F7FFFE", - toolbar: "#E9F9FA", - titlebar: "#D7F5F7" - }, - Snow: { - sidebar: "#fff", - titlebar: "#fff", - toolbar: "#fff" - }, - Sunny: { - sidebar: "#FFFFEF", - titlebar: "#FFFDCA", - toolbar: "lightYellow" - }, - Floral: { - sidebar: "#FFF7F7", - titlebar: "#F7CBCB", - toolbar: "#FAE9EA" - }, - Ocean: { - sidebar: "#F2FFFE", - titlebar: "#8ACFC7", - toolbar: "#C3F3EE" - } -} - -wn.ui.set_theme = function(theme) { - return; - var t = wn.ui.themes[theme]; - t.title_gradient = wn.get_gradient_css(t.titlebar); - var css = repl(".appframe-toolbar { \ - background-color: %(toolbar)s !important; }", t); - wn.dom.set_style(css); -} \ No newline at end of file diff --git a/webnotes/profile.py b/webnotes/profile.py index 089787b67b..1969cf5b04 100644 --- a/webnotes/profile.py +++ b/webnotes/profile.py @@ -156,7 +156,7 @@ class Profile: def load_profile(self): d = webnotes.conn.sql("""select email, first_name, last_name, - email_signature, theme, background_image + email_signature, background_image from tabProfile where name = %s""", self.name, as_dict=1)[0] if not self.can_read: @@ -164,8 +164,6 @@ class Profile: d.name = self.name d.recent = json.dumps(webnotes.cache().get_value("recent:" + self.name) or []) - if not d.theme: - d.theme = "Default" d['roles'] = self.get_roles() d['defaults'] = self.get_defaults()