From 31979dbe4f608d012ffb28170b1f981736cec40b Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Wed, 19 Oct 2016 10:19:44 +0800 Subject: [PATCH] Pman.Tab.AdminOffice.bjs Pman.Tab.AdminOffice.js --- Pman.Tab.AdminOffice.bjs | 14 +++++++------- Pman.Tab.AdminOffice.js | 7 ++++++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Pman.Tab.AdminOffice.bjs b/Pman.Tab.AdminOffice.bjs index eab7d55..96a2221 100644 --- a/Pman.Tab.AdminOffice.bjs +++ b/Pman.Tab.AdminOffice.bjs @@ -23,9 +23,9 @@ "listeners" : { "|activate" : "function() {\n _this.panel = this;\n if (_this.grid) {\n _this.grid.footer.onClick('first');\n }\n}" }, + "background" : true, "region" : "south", "fitToframe" : true, - "background" : true, "title" : "Offices / Departments / Sub-Companies", "xtype" : "GridPanel", "fitContainer" : true, @@ -55,8 +55,8 @@ "items" : [ { "$ url" : "baseURL + '/Roo/Office.php'", - "xtype" : "HttpProxy", "method" : "GET", + "xtype" : "HttpProxy", "$ xns" : "Roo.data", "* prop" : "proxy" }, @@ -87,7 +87,7 @@ "items" : [ { "listeners" : { - "|click" : "function()\n{\n if (!_this.dialog) {\n return;\n }\n var cdata = Pman.Tab.AdminCompanies.grid.getSelectionModel().getSelected().data;\n _dialog.show( { \n id : 0 ,\n company_name : cdata.name,\n company_id : cdata.id,\n address : cdata.address,\n phone : cdata.tel,\n fax : cdata.fax,\n email : cdata.email\n } , function() {\n _this.grid.footer.onClick('first');\n });\n}" + "|click" : "function()\n{\n if (!_this.dialog) {\n return;\n }\n var sd = Pman.Tab.AdminCompanies.grid.getSelectionModel().getSelected();\n if (!sd) {\n Roo.MessageBox.alert(\"Error\", \"Select an company to add an office to\");\n return;\n }\n var cdata = sd.data;\n _dialog.show( { \n id : 0 ,\n company_name : cdata.name,\n company_id : cdata.id,\n address : cdata.address,\n phone : cdata.tel,\n fax : cdata.fax,\n email : cdata.email\n } , function() {\n _this.grid.footer.onClick('first');\n });\n}" }, "text" : "Add", "xtype" : "Button", @@ -129,8 +129,8 @@ }, { "xtype" : "ColumnModel", - "width" : 100, "header" : "Phone", + "width" : 100, "$ renderer" : "function(v) { return String.format('{0}', v); }", "$ xns" : "Roo.grid", "* prop" : "colModel[]", @@ -138,8 +138,8 @@ }, { "xtype" : "ColumnModel", - "width" : 100, "header" : "Fax", + "width" : 100, "$ renderer" : "function(v) { return String.format('{0}', v); }", "$ xns" : "Roo.grid", "* prop" : "colModel[]", @@ -147,8 +147,8 @@ }, { "xtype" : "ColumnModel", - "width" : 200, "header" : "Email", + "width" : 200, "$ renderer" : "function (v) {\n return (v.length && v.indexOf('@') > 0 ) ? \n String.format('{0}',v) : v;\n \n}", "$ xns" : "Roo.grid", "* prop" : "colModel[]", @@ -156,8 +156,8 @@ }, { "xtype" : "ColumnModel", - "width" : 300, "header" : "Address", + "width" : 300, "$ renderer" : "function(v) { return String.format('{0}', v); }", "$ xns" : "Roo.grid", "* prop" : "colModel[]", diff --git a/Pman.Tab.AdminOffice.js b/Pman.Tab.AdminOffice.js index ab343d7..d282c9b 100644 --- a/Pman.Tab.AdminOffice.js +++ b/Pman.Tab.AdminOffice.js @@ -99,7 +99,12 @@ Pman.Tab.AdminOffice = new Roo.XComponent({ if (!_this.dialog) { return; } - var cdata = Pman.Tab.AdminCompanies.grid.getSelectionModel().getSelected().data; + var sd = Pman.Tab.AdminCompanies.grid.getSelectionModel().getSelected(); + if (!sd) { + Roo.MessageBox.alert("Error", "Select an company to add an office to"); + return; + } + var cdata = sd.data; _dialog.show( { id : 0 , company_name : cdata.name, -- 2.39.2