diff --git a/js/legacy/form.compressed.js b/js/legacy/form.compressed.js index 10d6fba74b..01e7845c10 100644 --- a/js/legacy/form.compressed.js +++ b/js/legacy/form.compressed.js @@ -240,7 +240,8 @@ _f.TableField.prototype.refresh=function(){if(!this.grid)return;var st=this.get_ this.df['default']='';this.grid.can_add_rows=false;this.grid.can_edit=false if(st=='Write'){if(cur_frm.editable&&this.perm[this.df.permlevel]&&this.perm[this.df.permlevel][WRITE]){this.grid.can_edit=true;if(this.df['default'].toLowerCase()!='no toolbar') this.grid.can_add_rows=true;} -if(cur_frm.editable&&this.df.allow_on_submit&&cur_frm.doc.docstatus==1&&this.df['default'].toLowerCase()!='no toolbar'){this.grid.can_add_rows=true;this.grid.can_edit=true;}} +if(cur_frm.editable&&cur_frm.doc.docstatus>0){if(this.df.allow_on_submit&&cur_frm.doc.docstatus==1){this.grid.can_edit=true;if(this.df['default'].toLowerCase()=='no toolbar'){this.grid.can_add_rows=false;}else{this.grid.can_add_rows=true;}}else{this.grid.can_add_rows=false;this.grid.can_edit=false;}} +if(this.df['default'].toLowerCase()=='no add rows'){this.grid.can_add_rows=false;}} if(this.old_status!=st){if(st=='Write'){this.grid.show();}else if(st=='Read'){this.grid.show();}else{this.grid.hide();} this.old_status=st;} this.grid.refresh();} @@ -256,7 +257,7 @@ _f.cur_grid_cell=null;_f.Grid=function(parent){} _f.Grid.prototype.init=function(parent,row_height){this.col_idx_by_name={} this.alt_row_bg='#F2F2FF';this.row_height=row_height;if(!row_height)this.row_height='26px';this.make_ui(parent);this.insert_column('','','Int','Sr','50px','',[1,0,0]);if(this.oninit)this.oninit();keypress_observers.push(this);} _f.Grid.prototype.make_ui=function(parent){var ht=make_table($a(parent,'div'),1,2,'100%',['60%','40%']);this.main_title=$td(ht,0,0);this.main_title.className='columnHeading';$td(ht,0,1).style.textAlign='right';this.tbar_div=$a($td(ht,0,1),'div','grid_tbarlinks');if(isIE)$y(this.tbar_div,{width:'200px'});this.tbar_tab=make_table(this.tbar_div,1,4,'100%',['25%','25%','25%','25%']);this.wrapper=$a(parent,'div','grid_wrapper');$h(this.wrapper,cint(screen.width*0.5)+'px');this.head_wrapper=$a(this.wrapper,'div','grid_head_wrapper');this.head_tab=$a(this.head_wrapper,'table','grid_head_table');this.head_row=this.head_tab.insertRow(0);this.tab_wrapper=$a(this.wrapper,'div','grid_tab_wrapper');this.tab=$a(this.tab_wrapper,'table','grid_table');var me=this;this.wrapper.onscroll=function(){me.head_wrapper.style.top=me.wrapper.scrollTop+'px';}} -_f.Grid.prototype.show=function(){if(this.can_add_rows){$ds(this.tbar_div);}else{$dh(this.tbar_div);} +_f.Grid.prototype.show=function(){if(this.can_edit&&this.field.df['default'].toLowerCase()!='no toolbar'){$ds(this.tbar_div);if(this.can_add_rows){$td(this.tbar_tab,0,0).style.display='table-cell';$td(this.tbar_tab,0,1).style.display='table-cell';}else{$td(this.tbar_tab,0,0).style.display='none';$td(this.tbar_tab,0,1).style.display='none';}}else{$dh(this.tbar_div);} $ds(this.wrapper);} _f.Grid.prototype.hide=function(){$dh(this.wrapper);$dh(this.tbar_div);} _f.Grid.prototype.insert_column=function(doctype,fieldname,fieldtype,label,width,options,perm,reqd){var idx=this.head_row.cells.length;if(!width)width='100px';if((width+'').slice(-2)!='px'){width=width+'px';} diff --git a/js/legacy/widgets/form/form_fields.js b/js/legacy/widgets/form/form_fields.js index 1b90d3a86e..be5e14e932 100644 --- a/js/legacy/widgets/form/form_fields.js +++ b/js/legacy/widgets/form/form_fields.js @@ -285,12 +285,24 @@ _f.TableField.prototype.refresh = function() { if(this.df['default'].toLowerCase()!='no toolbar') this.grid.can_add_rows = true; } - if(cur_frm.editable - && this.df.allow_on_submit - && cur_frm.doc.docstatus == 1 - && this.df['default'].toLowerCase()!='no toolbar') { - this.grid.can_add_rows = true; + + // submitted or cancelled + if(cur_frm.editable && cur_frm.doc.docstatus > 0) { + if(this.df.allow_on_submit && cur_frm.doc.docstatus==1) { this.grid.can_edit = true; + if(this.df['default'].toLowerCase()=='no toolbar') { + this.grid.can_add_rows = false; + } else { + this.grid.can_add_rows = true; + } + } else { + this.grid.can_add_rows = false; + this.grid.can_edit = false; + } + } + + if(this.df['default'].toLowerCase()=='no add rows') { + this.grid.can_add_rows = false; } } diff --git a/js/legacy/widgets/form/grid.js b/js/legacy/widgets/form/grid.js index 1c3bde0c92..9d48159601 100644 --- a/js/legacy/widgets/form/grid.js +++ b/js/legacy/widgets/form/grid.js @@ -48,8 +48,15 @@ _f.Grid.prototype.make_ui = function(parent) { } _f.Grid.prototype.show = function() { - if(this.can_add_rows) { + if(this.can_edit && this.field.df['default'].toLowerCase()!='no toolbar') { $ds(this.tbar_div); + if(this.can_add_rows) { + $td(this.tbar_tab, 0, 0).style.display = 'table-cell'; + $td(this.tbar_tab, 0, 1).style.display = 'table-cell'; + } else { + $td(this.tbar_tab, 0, 0).style.display = 'none'; + $td(this.tbar_tab, 0, 1).style.display = 'none'; + } } else { $dh(this.tbar_div); } diff --git a/py/core/doctype/doclayer/doclayer.js b/py/core/doctype/doclayer/doclayer.js index c71c310fc0..9afe4a8623 100644 --- a/py/core/doctype/doclayer/doclayer.js +++ b/py/core/doctype/doclayer/doclayer.js @@ -1,18 +1,11 @@ cur_frm.cscript.doc_type = function(doc, dt, dn) { - //console.log(doc); - //console.log(doc_type); - $c_obj(make_doclist(dt, dn), 'get', '', function(r, rt) { cur_frm.refresh(); - //console.log(arguments); }); } cur_frm.cscript.onload = function(doc, dt, dn) { cur_frm.grids[0].grid.tbar_div.style.width = "30%"; - p = cur_frm.grids[0].grid.tbar_tab.children[0].children[0]; - p.removeChild(p.children[0]) - p.removeChild(p.children[0]) cur_frm.tip_wrapper.id = 'tip_wrapper'; cur_frm.add_fields_help(); } @@ -24,6 +17,7 @@ cur_frm.cscript.refresh = function(doc, dt, dn) { cur_frm.page_layout.footer.hidden = true; if(doc.doc_type) { $('#tip_wrapper').slideUp('slow'); } + //cur_frm.grids[0].grid.tab.rows[cur_frm.grids[0].grid.tab.rows.length-1].hidden = true; cur_frm.add_custom_button('Update', function() { if(cur_frm.fields_dict['doc_type'].value) { $c_obj(make_doclist(dt, dn), 'post', '', function(r, rt) { @@ -34,7 +28,6 @@ cur_frm.cscript.refresh = function(doc, dt, dn) { 'Saved'; - //console.log(arguments); } }); } diff --git a/py/core/doctype/doclayer/doclayer.txt b/py/core/doctype/doclayer/doclayer.txt index 139a3a2463..b0932994c7 100644 --- a/py/core/doctype/doclayer/doclayer.txt +++ b/py/core/doctype/doclayer/doclayer.txt @@ -3,16 +3,16 @@ # These values are common in all dictionaries { - 'creation': '2011-11-16 16:09:34', + 'creation': '2011-12-21 11:07:56', 'docstatus': 0, - 'modified': '2011-11-24 12:59:42', + 'modified': '2012-01-09 11:56:53', 'modified_by': 'Administrator', 'owner': 'Administrator' }, # These values are common for all DocType { - '_last_update': '1322119618', + '_last_update': '1325570719', 'autoname': 'DL.####', 'colour': 'White:FFF', 'doctype': 'DocType', @@ -23,7 +23,7 @@ 'search_fields': 'doc_type', 'section_style': 'Simple', 'show_in_menu': 0, - 'version': 95 + 'version': 96 }, # These values are common for all DocField @@ -215,6 +215,7 @@ # DocField { + 'default': 'no add rows', 'doctype': 'DocField', 'fieldname': 'fields', 'fieldtype': 'Table',