|
|
@@ -85,18 +85,19 @@ _f.FrmHeader = Class.extend({ |
|
|
|
this.$w.find('.avatar img').centerImage(); |
|
|
|
}, |
|
|
|
refresh_labels: function() { |
|
|
|
cur_frm.doc = wn.model.get_doc(cur_frm.doc.doctype, cur_frm.doc.name); |
|
|
|
var me = this; |
|
|
|
this.frm.doc = wn.model.get_doc(this.frm.doc.doctype, this.frm.doc.name); |
|
|
|
var labinfo = { |
|
|
|
0: [wn._('Saved'), 'label-success'], |
|
|
|
1: [wn._('Submitted'), 'label-info'], |
|
|
|
2: [wn._('Cancelled'), 'label-important'] |
|
|
|
}[cint(cur_frm.doc.docstatus)]; |
|
|
|
}[cint(this.frm.doc.docstatus)]; |
|
|
|
|
|
|
|
if(labinfo[0]==wn._('Saved') && cur_frm.meta.is_submittable) { |
|
|
|
if(labinfo[0]==wn._('Saved') && this.frm.meta.is_submittable) { |
|
|
|
labinfo[0]=wn._('Saved, to Submit'); |
|
|
|
} |
|
|
|
|
|
|
|
if(cur_frm.doc.__unsaved || cur_frm.doc.__islocal) { |
|
|
|
if(this.frm.doc.__unsaved || this.frm.doc.__islocal) { |
|
|
|
labinfo[0] = wn._('Not Saved'); |
|
|
|
labinfo[1] = 'label-warning' |
|
|
|
} |
|
|
@@ -104,9 +105,9 @@ _f.FrmHeader = Class.extend({ |
|
|
|
this.set_label(labinfo); |
|
|
|
|
|
|
|
// show update button if unsaved |
|
|
|
if(cur_frm.doc.__unsaved && cint(cur_frm.doc.docstatus)==1 && cur_frm.perm[0][SUBMIT]) { |
|
|
|
if(this.frm.doc.__unsaved && cint(this.frm.doc.docstatus)==1 && this.frm.perm[0][SUBMIT]) { |
|
|
|
this.appframe.add_button('Update', function() { |
|
|
|
cur_frm.save('Update', null, this); |
|
|
|
me.frm.save('Update', null, this); |
|
|
|
}, '').html(wn._('Update')) |
|
|
|
} |
|
|
|
|
|
|
@@ -114,7 +115,9 @@ _f.FrmHeader = Class.extend({ |
|
|
|
}, |
|
|
|
set_label: function(labinfo) { |
|
|
|
this.$w.find('.label').remove(); |
|
|
|
if(cur_frm.meta.hide_toolbar) return; |
|
|
|
if(this.frm.meta.hide_toolbar || this.frm.save_disabled) |
|
|
|
return; |
|
|
|
console.log(labinfo) |
|
|
|
$(repl('<span class="label %(lab_class)s">\ |
|
|
|
%(lab_status)s</span>', { |
|
|
|
lab_status: labinfo[0], |
|
|
@@ -123,48 +126,48 @@ _f.FrmHeader = Class.extend({ |
|
|
|
}, |
|
|
|
refresh_toolbar: function() { |
|
|
|
// clear |
|
|
|
|
|
|
|
if(cur_frm.meta.hide_toolbar) { |
|
|
|
var me = this; |
|
|
|
if(this.frm.meta.hide_toolbar) { |
|
|
|
this.appframe.$w.find('.appframe-toolbar').toggle(false); |
|
|
|
cur_frm.save_disabled = true; |
|
|
|
this.frm.save_disabled = true; |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
this.appframe.clear_buttons(); |
|
|
|
var p = cur_frm.perm[0]; |
|
|
|
var p = this.frm.perm[0]; |
|
|
|
|
|
|
|
// Edit |
|
|
|
if(cur_frm.meta.read_only_onload && !cur_frm.doc.__islocal) { |
|
|
|
if(this.frm.meta.read_only_onload && !this.frm.doc.__islocal) { |
|
|
|
this.appframe.add_button('Print View', function() { |
|
|
|
cur_frm.last_view_is_edit[cur_frm.docname] = 0; |
|
|
|
cur_frm.refresh(); }, 'icon-print' ).html(wn._('Print View')); |
|
|
|
me.frm.last_view_is_edit[me.frm.docname] = 0; |
|
|
|
me.frm.refresh(); }, 'icon-print' ).html(wn._('Print View')); |
|
|
|
} |
|
|
|
|
|
|
|
var docstatus = cint(cur_frm.doc.docstatus); |
|
|
|
var docstatus = cint(this.frm.doc.docstatus); |
|
|
|
|
|
|
|
// Save |
|
|
|
if(docstatus==0 && p[WRITE] && !cur_frm.read_only) { |
|
|
|
if(docstatus==0 && p[WRITE] && !this.read_only) { |
|
|
|
this.appframe.add_button('Save', function() { |
|
|
|
cur_frm.save('Save', null, this);}, 'icon-save'); |
|
|
|
me.frm.save('Save', null, this);}, 'icon-save'); |
|
|
|
this.appframe.buttons['Save'].addClass("btn-save") |
|
|
|
.html("<i class='icon-save'></i> "+wn._("Save")); |
|
|
|
} |
|
|
|
|
|
|
|
// Submit |
|
|
|
if(!wn.model.get("Workflow", {document_type: cur_frm.doctype}).length) { |
|
|
|
if(docstatus==0 && p[SUBMIT] && (!cur_frm.doc.__islocal)) |
|
|
|
if(!wn.model.get("Workflow", {document_type: me.frm.doctype}).length) { |
|
|
|
if(docstatus==0 && p[SUBMIT] && (!me.frm.doc.__islocal)) |
|
|
|
this.appframe.add_button('Submit', function() { |
|
|
|
cur_frm.savesubmit(this);}, 'icon-lock').html(wn._('Submit')); |
|
|
|
me.frm.savesubmit(this);}, 'icon-lock').html(wn._('Submit')); |
|
|
|
|
|
|
|
// Cancel |
|
|
|
if(docstatus==1 && p[CANCEL]) |
|
|
|
this.appframe.add_button('Cancel', function() { |
|
|
|
cur_frm.savecancel(this) }, 'icon-remove').html(wn._('Cancel')); |
|
|
|
me.frm.savecancel(this) }, 'icon-remove').html(wn._('Cancel')); |
|
|
|
|
|
|
|
// Amend |
|
|
|
if(docstatus==2 && p[AMEND]) |
|
|
|
this.appframe.add_button('Amend', function() { |
|
|
|
cur_frm.amend_doc() }, 'icon-pencil').html(wn._('Amend')); |
|
|
|
me.frm.amend_doc() }, 'icon-pencil').html(wn._('Amend')); |
|
|
|
} |
|
|
|
this.set_primary_button(); |
|
|
|
}, |
|
|
@@ -181,11 +184,11 @@ _f.FrmHeader = Class.extend({ |
|
|
|
} |
|
|
|
|
|
|
|
// highlight submit button |
|
|
|
if(buttons["Submit"] && !cur_frm.doc.__unsaved) { |
|
|
|
if(buttons["Submit"] && !this.frm.doc.__unsaved) { |
|
|
|
this.appframe.toolbar.find("button").removeClass("btn-info"); |
|
|
|
buttons["Submit"].addClass("btn-info"); |
|
|
|
// highlight update button |
|
|
|
} else if(buttons["Update"] && cur_frm.doc.__unsaved) { |
|
|
|
} else if(buttons["Update"] && this.frm.doc.__unsaved) { |
|
|
|
this.appframe.toolbar.find("button").removeClass("btn-info"); |
|
|
|
buttons["Update"].addClass("btn-info"); |
|
|
|
} |
|
|
|