@@ -59,7 +59,7 @@ | |||||
max-height: 200px; | max-height: 200px; | ||||
border-right: 1px solid #d1d8dd; | border-right: 1px solid #d1d8dd; | ||||
} | } | ||||
.grid-static-col.bold { | |||||
.editable-form .grid-static-col.bold { | |||||
font-weight: bold; | font-weight: bold; | ||||
background-color: #fffdf4; | background-color: #fffdf4; | ||||
} | } | ||||
@@ -59,7 +59,7 @@ frappe.form.formatters = { | |||||
if(value) { | if(value) { | ||||
return '<i class="octicon octicon-check" style="margin-right: 3px;"></i>'; | return '<i class="octicon octicon-check" style="margin-right: 3px;"></i>'; | ||||
} else { | } else { | ||||
return '<i class="fa fa-square-o text-extra-muted" style="margin-right: 3px; margin-bottom: -2px; font-size: 14px;"></i>'; | |||||
return '<i class="fa fa-square text-extra-muted" style="margin-right: 3px; margin-bottom: -2px;"></i>'; | |||||
} | } | ||||
}, | }, | ||||
Link: function(value, docfield, options, doc) { | Link: function(value, docfield, options, doc) { | ||||
@@ -25,6 +25,7 @@ frappe.standard_pages["query-report"] = function() { | |||||
frappe.views.QueryReport = Class.extend({ | frappe.views.QueryReport = Class.extend({ | ||||
init: function(opts) { | init: function(opts) { | ||||
$.extend(this, opts); | $.extend(this, opts); | ||||
this.flags = {}; | |||||
// globalify for slickgrid | // globalify for slickgrid | ||||
this.page = this.parent.page; | this.page = this.parent.page; | ||||
this.parent.query_report = this; | this.parent.query_report = this; | ||||
@@ -298,6 +299,10 @@ frappe.views.QueryReport = Class.extend({ | |||||
// run report on change | // run report on change | ||||
f.$input.on("change", function() { | f.$input.on("change", function() { | ||||
if(!me.flags.filter_set) { | |||||
// don't trigger change while setting filters | |||||
return; | |||||
} | |||||
f.$input.blur(); | f.$input.blur(); | ||||
if (f.on_change) { | if (f.on_change) { | ||||
f.on_change(me); | f.on_change(me); | ||||
@@ -314,10 +319,11 @@ frappe.views.QueryReport = Class.extend({ | |||||
$(this.parent).find('.page-form').toggle($filters.length ? true : false); | $(this.parent).find('.page-form').toggle($filters.length ? true : false); | ||||
this.setting_filters = true; | this.setting_filters = true; | ||||
this.set_route_filters() | |||||
this.set_route_filters(); | |||||
this.setting_filters = false; | this.setting_filters = false; | ||||
this.set_filters_by_name(); | this.set_filters_by_name(); | ||||
this.flags.filters_set = true; | |||||
}, | }, | ||||
clear_filters: function() { | clear_filters: function() { | ||||
this.filters = []; | this.filters = []; | ||||
@@ -121,21 +121,6 @@ get_field_obj = function(fn) { | |||||
return cur_frm.fields_dict[fn]; | return cur_frm.fields_dict[fn]; | ||||
} | } | ||||
// set missing values in given doc | |||||
set_missing_values = function(doc, dict) { | |||||
// dict contains fieldname as key and "default value" as value | |||||
var fields_to_set = {}; | |||||
for (var i in dict) { | |||||
var v = dict[i]; | |||||
if (!doc[i]) { | |||||
fields_to_set[i] = v; | |||||
} | |||||
} | |||||
if (fields_to_set) { set_multiple(doc.doctype, doc.name, fields_to_set); } | |||||
} | |||||
_f.Frm.prototype.get_doc = function() { | _f.Frm.prototype.get_doc = function() { | ||||
return locals[this.doctype][this.docname]; | return locals[this.doctype][this.docname]; | ||||
} | } | ||||
@@ -204,15 +189,15 @@ _f.Frm.prototype.get_docfield = function(fieldname1, fieldname2) { | |||||
_f.Frm.prototype.set_df_property = function(fieldname, property, value, docname, table_field) { | _f.Frm.prototype.set_df_property = function(fieldname, property, value, docname, table_field) { | ||||
if (!docname && !table_field){ | if (!docname && !table_field){ | ||||
var field = this.get_docfield(fieldname); | |||||
var df = this.get_docfield(fieldname); | |||||
} else { | } else { | ||||
var grid = cur_frm.fields_dict[table_field].grid, | var grid = cur_frm.fields_dict[table_field].grid, | ||||
fname = frappe.utils.filter_dict(grid.docfields, {'fieldname': fieldname}); | fname = frappe.utils.filter_dict(grid.docfields, {'fieldname': fieldname}); | ||||
if (fname && fname.length) | if (fname && fname.length) | ||||
var field = frappe.meta.get_docfield(fname[0].parent, fieldname, docname); | |||||
var df = frappe.meta.get_docfield(fname[0].parent, fieldname, docname); | |||||
} | } | ||||
if(field) { | |||||
field[property] = value; | |||||
if(df && df[property] != value) { | |||||
df[property] = value; | |||||
refresh_field(fieldname, table_field); | refresh_field(fieldname, table_field); | ||||
}; | }; | ||||
} | } | ||||
@@ -500,3 +485,13 @@ _f.Frm.prototype.make_new = function(doctype) { | |||||
}); | }); | ||||
} | } | ||||
} | } | ||||
_f.Frm.prototype.update_in_all_rows = function(table_fieldname, fieldname, value) { | |||||
// update the child value in all tables where it is missing | |||||
if(!value) return; | |||||
var cl = doc[table_fieldname] || []; | |||||
for(var i = 0; i < cl.length; i++){ | |||||
if(!cl[i][fieldname]) cl[i][fieldname] = value; | |||||
} | |||||
refresh_field("items"); | |||||
} |
@@ -85,6 +85,7 @@ _f.Frm.prototype.setup = function() { | |||||
// wrapper | // wrapper | ||||
this.wrapper = this.parent; | this.wrapper = this.parent; | ||||
this.$wrapper = $(this.wrapper); | |||||
frappe.ui.make_app_page({ | frappe.ui.make_app_page({ | ||||
parent: this.wrapper, | parent: this.wrapper, | ||||
single_column: this.meta.hide_toolbar | single_column: this.meta.hide_toolbar | ||||
@@ -124,7 +125,7 @@ _f.Frm.prototype.setup = function() { | |||||
_f.Frm.prototype.setup_drag_drop = function() { | _f.Frm.prototype.setup_drag_drop = function() { | ||||
var me = this; | var me = this; | ||||
$(this.wrapper).on('dragenter dragover', false) | |||||
this.$wrapper.on('dragenter dragover', false) | |||||
.on('drop', function (e) { | .on('drop', function (e) { | ||||
var dataTransfer = e.originalEvent.dataTransfer; | var dataTransfer = e.originalEvent.dataTransfer; | ||||
if (!(dataTransfer && dataTransfer.files && dataTransfer.files.length > 0)) { | if (!(dataTransfer && dataTransfer.files && dataTransfer.files.length > 0)) { | ||||
@@ -457,7 +458,6 @@ _f.Frm.prototype.refresh = function(docname) { | |||||
} | } | ||||
if(is_a_different_doc) { | if(is_a_different_doc) { | ||||
$(this.wrapper).removeClass('validated-form') | |||||
if(this.show_print_first && this.doc.docstatus===1) { | if(this.show_print_first && this.doc.docstatus===1) { | ||||
// show print view | // show print view | ||||
this.print_doc(); | this.print_doc(); | ||||
@@ -472,6 +472,12 @@ _f.Frm.prototype.refresh = function(docname) { | |||||
} | } | ||||
} | } | ||||
// set status classes | |||||
this.$wrapper.removeClass('validated-form') | |||||
.toggleClass('editable-form', this.doc.docstatus===0) | |||||
.toggleClass('submitted-form', this.doc.docstatus===1) | |||||
.toggleClass('cancelled-form', this.doc.docstatus===2); | |||||
this.show_if_needs_refresh(); | this.show_if_needs_refresh(); | ||||
} | } | ||||
} | } | ||||
@@ -537,7 +543,7 @@ _f.Frm.prototype.render_form = function(is_a_different_doc) { | |||||
this.refresh_header(is_a_different_doc); | this.refresh_header(is_a_different_doc); | ||||
} | } | ||||
$(this.wrapper).trigger('render_complete'); | |||||
this.$wrapper.trigger('render_complete'); | |||||
if(!this.hidden) { | if(!this.hidden) { | ||||
this.layout.show_empty_form_message(); | this.layout.show_empty_form_message(); | ||||
@@ -555,7 +561,7 @@ _f.Frm.prototype.refresh_field = function(fname) { | |||||
_f.Frm.prototype.refresh_fields = function() { | _f.Frm.prototype.refresh_fields = function() { | ||||
this.layout.refresh(this.doc); | this.layout.refresh(this.doc); | ||||
this.layout.primary_button = $(this.wrapper).find(".btn-primary"); | |||||
this.layout.primary_button = this.$wrapper.find(".btn-primary"); | |||||
// cleanup activities after refresh | // cleanup activities after refresh | ||||
this.cleanup_refresh(this); | this.cleanup_refresh(this); | ||||
@@ -842,7 +848,7 @@ _f.Frm.prototype.save_or_update = function() { | |||||
_f.Frm.prototype.dirty = function() { | _f.Frm.prototype.dirty = function() { | ||||
this.doc.__unsaved = 1; | this.doc.__unsaved = 1; | ||||
$(this.wrapper).trigger('dirty'); | |||||
this.$wrapper.trigger('dirty'); | |||||
} | } | ||||
_f.Frm.prototype.get_docinfo = function() { | _f.Frm.prototype.get_docinfo = function() { | ||||
@@ -75,7 +75,7 @@ | |||||
border-right: 1px solid @border-color; | border-right: 1px solid @border-color; | ||||
} | } | ||||
.grid-static-col.bold { | |||||
.editable-form .grid-static-col.bold { | |||||
font-weight: bold; | font-weight: bold; | ||||
background-color: @extra-light-yellow; | background-color: @extra-light-yellow; | ||||
} | } | ||||