adding block list, part 1
This commit is contained in:
parent
e7ef23d9f6
commit
b6834ef4e7
4 changed files with 36 additions and 38 deletions
|
|
@ -41,7 +41,7 @@ cur_frm.fields_dict.doc_type.get_query = function(doc, dt, dn) {
|
|||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, dt, dn) {
|
||||
cur_frm.disable_save();
|
||||
//cur_frm.disable_save();
|
||||
cur_frm.frm_head.appframe.clear_buttons();
|
||||
|
||||
cur_frm.add_custom_button('Update', function() {
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
[
|
||||
{
|
||||
"creation": "2013-01-10 16:34:01",
|
||||
"creation": "2013-01-29 17:54:08",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-01-22 14:24:07",
|
||||
"modified": "2013-02-05 09:05:02",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"autoname": "DL.####",
|
||||
"doctype": "DocType",
|
||||
"hide_toolbar": 0,
|
||||
"hide_toolbar": 1,
|
||||
"issingle": 1,
|
||||
"module": "Core",
|
||||
"name": "__common__",
|
||||
|
|
@ -24,15 +24,18 @@
|
|||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"name": "__common__",
|
||||
"parent": "Customize Form",
|
||||
"parentfield": "permissions",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"report": 0,
|
||||
"role": "System Manager",
|
||||
"submit": 0
|
||||
"submit": 0,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
|
|
@ -151,13 +154,6 @@
|
|||
"search_index": 0
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 0,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 2
|
||||
"doctype": "DocPerm"
|
||||
}
|
||||
]
|
||||
|
|
@ -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");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,7 +93,6 @@ class Profile:
|
|||
in_create => Not in create
|
||||
|
||||
"""
|
||||
|
||||
self.build_doctype_map()
|
||||
self.build_perm_map()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue