[projects] added ganttview, removed old timesheet
This commit is contained in:
parent
8f6ed35101
commit
a2c248addd
11 changed files with 136 additions and 33 deletions
|
|
@ -49,6 +49,7 @@ a {
|
|||
margin-bottom: 0px;
|
||||
border-radius: 0px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
min-height: 51px;
|
||||
}
|
||||
|
||||
.appframe .navbar-form select,
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -16,4 +16,8 @@ Download modules
|
|||
Changes images urls
|
||||
|
||||
- from: url(images
|
||||
- to: url(../lib/js/lib/jquery/bootstrap_theme/images
|
||||
- to: url(../lib/js/lib/jquery/bootstrap_theme/images
|
||||
|
||||
## JQuery Gantt
|
||||
|
||||
Not a very mature project. Please check css / js after updating
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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!
|
||||
|
|
|
|||
|
|
@ -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 = $('<div class="appframe-header col col-lg-12">\
|
||||
<div class="row appframe-title">\
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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('<div class="alert">No Tasks Yet.</div>');
|
||||
$(parent).html('<div class="alert">Nothing to show.</div>');
|
||||
} else {
|
||||
var gantt_area = $('<div class="gantt">').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 + "<br>" + 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;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue