diff --git a/frappe/public/js/frappe/views/gantt.js b/frappe/public/js/frappe/views/gantt.js index 27776591d0..e63a6965a9 100755 --- a/frappe/public/js/frappe/views/gantt.js +++ b/frappe/public/js/frappe/views/gantt.js @@ -307,7 +307,7 @@ var Gantt = Class.extend({ secondary_text_y = me.opts.header_height - 25; if(me.view_mode === 'Month') { - primary_text_x += me.opts.column_width/2; + primary_text_x += (date.daysInMonth() * me.opts.column_width/30)/2; secondary_text_x += (me.opts.column_width * 12)/2; } if(me.view_mode === 'Week') { @@ -315,6 +315,7 @@ var Gantt = Class.extend({ secondary_text_x += (me.opts.column_width * 4)/2; } if(me.view_mode === 'Day') { + primary_text_x += me.opts.column_width/2; secondary_text_x += (me.opts.column_width * 30)/2; } if(me.view_mode === 'Quarter Day') { @@ -511,10 +512,8 @@ var Bar = Class.extend({ prepare_values: function() { this.x = this.compute_x(); this.y = this.compute_y(); - this.duration = this.task._end.diff(this.task._start, 'hours')/this.gantt.step; + this.duration = (this.task._end.diff(this.task._start, 'hours') + 24)/this.gantt.step; this.width = this.gantt.unit_width * this.duration; - if(this.gantt.view_mode === 'Month') - this.width = (this.gantt.unit_width/30) * (this.duration*this.gantt.step/24); this.progress_width = this.gantt.unit_width * this.duration * (this.task.progress/100) || 0; this.group = this.canvas.group().addClass('bar-wrapper'); this.bar_group = this.canvas.group().addClass('bar-group').appendTo(this.group); diff --git a/frappe/public/js/frappe/views/ganttview.js b/frappe/public/js/frappe/views/ganttview.js deleted file mode 100644 index 93c73b4dc8..0000000000 --- a/frappe/public/js/frappe/views/ganttview.js +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors -// MIT License. See license.txt - -frappe.provide("frappe.views.calendar"); - -frappe.views.GanttFactory = frappe.views.Factory.extend({ - make: function(route) { - var me = this; - me.doctype = route[1]; - - frappe.require(['assets/frappe/js/lib/jQuery.Gantt/css/style.css', - 'assets/frappe/js/lib/jQuery.Gantt/js/jquery.fn.gantt.js'], function() { - - frappe.model.with_doctype(me.doctype, function() { - var page = me.make_page(); - $(page).on("show", function() { - page.ganttview.set_filters_from_route_options(); - }); - - var options = { - doctype: me.doctype, - parent: page - }; - $.extend(options, frappe.views.calendar[me.doctype] || {}); - - page.ganttview = new frappe.views.Gantt(options); - }); - }); - } -}); - -frappe.views.Gantt = frappe.views.CalendarBase.extend({ - init: function(opts) { - $.extend(this, opts); - this.make_page(); - frappe.route_options ? - this.set_filters_from_route_options() : - this.refresh(); - }, - make_page: function() { - var module = locals.DocType[this.doctype].module, - me = this; - - this.page = this.parent.page; - this.page.set_title(__("Gantt Chart") + " - " + __(this.doctype)); - frappe.breadcrumbs.add(module, this.doctype); - - this.page.set_secondary_action(__("Refresh"), - function() { me.refresh(); }, "icon-refresh") - - this.page.add_field({fieldtype:"Date", label:"From", - fieldname:"start", "default": frappe.datetime.month_start(), - change: function() { me.refresh(); }, - input_css: {"z-index": 3}}); - - this.page.add_field({fieldtype:"Date", label:"To", - fieldname:"end", "default": frappe.datetime.month_end(), - change: function() { me.refresh(); }, - input_css: {"z-index": 3}}); - - this.add_filters(); - this.wrapper = $("
").appendTo(this.page.main); - - }, - refresh: function() { - var me = this; - return frappe.call({ - method: this.get_events_method, - type: "GET", - args: { - doctype: this.doctype, - start: this.page.fields_dict.start.get_parsed_value(), - end: this.page.fields_dict.end.get_parsed_value(), - filters: this.get_filters() - }, - callback: function(r) { - $(me.wrapper).empty(); - if(!r.message || !r.message.length) { - $(me.wrapper).html('' + __('Nothing to show for this selection') + '
'); - } else { - var gantt_area = $('