From: Chris Date: Thu, 4 Jul 2013 10:06:21 +0000 (+0800) Subject: Pman.Dialog.AdminEnumImages.bjs X-Git-Url: http://git.roojs.org/?p=Pman.Admin;a=commitdiff_plain;h=a10ab95a7a0db5634b23aa050d6b4dd5fffdc311 Pman.Dialog.AdminEnumImages.bjs Pman.Dialog.AdminEnumImages.js --- diff --git a/Pman.Dialog.AdminEnumImages.bjs b/Pman.Dialog.AdminEnumImages.bjs index 812fde6..fd4de93 100644 --- a/Pman.Dialog.AdminEnumImages.bjs +++ b/Pman.Dialog.AdminEnumImages.bjs @@ -13,6 +13,138 @@ "|xns": "Roo", "xtype": "LayoutRegion", "*prop": "center" + }, + { + "listeners": { + "|activate": "function() {\n _this.panel = this;\n if (_this.grid) {\n _this.grid.footer.onClick('first');\n }\n}" + }, + "region": "center", + "background": true, + "fitContainer": true, + "fitToframe": true, + "tableName": "Images", + "title": "Images", + "xtype": "GridPanel", + "|xns": "Roo", + "items": [ + { + "*prop": "grid", + "xtype": "Grid", + "autoExpandColumn": "title", + "loadMask": true, + "listeners": { + "|render": "function() { \n _this.grid = this; \n //_this.dialog = Pman.Dialog.FILL_IN\n if (_this.panel.active) {\n this.footer.onClick('first');\n }\n}", + "|rowdblclick": "function (_self, rowIndex, e)\n{\n \n var s = _self.getDataSource().getAt(rowIndex);\n Pman.Dialog.PressReleaseImage.show(s.data, function() {\n _this.grid.footer.onClick('first');\n }); \n}" + }, + "|xns": "Roo.grid", + "items": [ + { + "listeners": { + "|beforeload": "function (_self, o)\n{\n o.params.ontable = 'Companies';\n o.params['query[imagesize]'] = '150x150';\n o.params['query[imageBaseURL]'] = rootURL + '/release.php';\n \n var sel = Pman.Tab.PressReleaseCompanies ? Pman.Tab.PressReleaseCompanies.grid.getSelectionModel().getSelected() : false\n // o.params.imgtype = 'PressRelease';\n o.params.onid = sel ? sel.data.id : 0;\n if (!o.params.onid) {\n if (!_this.isBuilder) {\n _this.panel.el.mask('select company');\n }\n return false;\n }\n \n \n}", + "|load": "function (_self, records, options)\n{\n _this.panel.el.unmask();\n}" + }, + "*prop": "dataSource", + "remoteSort": true, + "xtype": "Store", + "|sortInfo": "{ field: 'created' , direction: 'DESC' }", + "|xns": "Roo.data", + "items": [ + { + "*prop": "reader", + "id": "id", + "root": "data", + "totalProperty": "total", + "xtype": "JsonReader", + "|fields": "[\n {\n 'name': 'id',\n 'type': 'int'\n },\n {\n 'name': 'filename',\n 'type': 'string'\n },\n {\n 'name': 'ontable',\n 'type': 'string'\n },\n {\n 'name': 'onid',\n 'type': 'int'\n },\n {\n 'name': 'mimetype',\n 'type': 'string'\n },\n {\n 'name': 'width',\n 'type': 'int'\n },\n {\n 'name': 'height',\n 'type': 'int'\n },\n {\n 'name': 'filesize',\n 'type': 'int'\n },\n {\n 'name': 'displayorder',\n 'type': 'int'\n },\n {\n 'name': 'language',\n 'type': 'string'\n },\n {\n 'name': 'parent_image_id',\n 'type': 'int'\n },\n {\n 'name': 'created',\n 'type': 'date',\n 'dateFormat' : 'Y-m-d H:i:s'\n },\n {\n 'name': 'imgtype',\n 'type': 'string'\n },\n {\n 'name': 'linkurl',\n 'type': 'string'\n },\n {\n 'name': 'descript',\n 'type': 'string'\n },\n {\n 'name': 'title',\n 'type': 'string'\n }\n]", + "|xns": "Roo.data" + }, + { + "*prop": "proxy", + "xtype": "HttpProxy", + "method": "GET", + "|url": "baseURL + '/Roo/Images.php'", + "|xns": "Roo.data" + } + ] + }, + { + "*prop": "footer", + "xtype": "PagingToolbar", + "pageSize": 25, + "displayInfo": true, + "displayMsg": "Displaying Images {0} - {1} of {2}", + "emptyMsg": "No Images found", + "|xns": "Roo" + }, + { + "*prop": "toolbar", + "xtype": "Toolbar", + "|xns": "Roo", + "items": [ + { + "listeners": { + "|click": "function()\n {\n \n var sel = Pman.Tab.PressReleaseCompanies ? Pman.Tab.PressReleaseCompanies.grid.getSelectionModel().getSelected() : false\n \n Pman.Dialog.Image.show( {\n id : 0, \n ontable: 'Companies', \n onid: sel.data.id,\n imgtype : 'PressRelease'\n }, \n function(data) {\n if (!data) { return; } \n Pman.Dialog.PressReleaseImage.show( data, function() {\n _this.grid.footer.onClick('first');\n\n }); \n }); \n\n }\n " + }, + "cls": "x-btn-text-icon", + "text": "Add", + "xtype": "Button", + "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'", + "|xns": "Roo.Toolbar" + }, + { + "listeners": { + "|click": "function()\n{\n var s = _this.grid.getSelectionModel().getSelections();\n if (!s || s.length != 1) {\n Roo.MessageBox.alert(\"Error\", \"Select a single image to edit\");\n return;\n }\n var data = _this.grid.getDataSource().getById(s[0].data.id).data;\n \n Pman.Dialog.PressReleaseImage.show(data, function() {\n _this.grid.footer.onClick('first');\n }); \n \n }\n " + }, + "cls": "x-btn-text-icon", + "text": "Edit", + "xtype": "Button", + "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'", + "|xns": "Roo" + }, + { + "listeners": { + "|click": "function()\n {\n Pman.genericDelete(_this, 'Images'); \n }\n " + }, + "cls": "x-btn-text-icon", + "text": "Delete", + "xtype": "Button", + "|icon": "rootURL + '/Pman/templates/images/trash.gif'", + "|xns": "Roo.Toolbar" + } + ] + }, + { + "xtype": "ColumnModel", + "header": "Created", + "width": 100, + "dataIndex": "created", + "|renderer": "function(v,x,r) {\n return String.format('{0}
{1}
{2}
{3}x{4}',\n v.format('d/M/Y'), r.data.mimetype, r.data.filename,\n r.data.width, r.data.height\n ); \n}\n ", + "listeners": {}, + "sortable": true, + "|xns": "Roo.grid", + "*prop": "colModel[]" + }, + { + "*prop": "colModel[]", + "dataIndex": "id", + "header": "Image", + "width": 100, + "xtype": "ColumnModel", + "|renderer": "function(v,x,r) { return String.format('', baseURL, v, r.data.filename); }", + "|xns": "Roo.grid" + }, + { + "*prop": "colModel[]", + "dataIndex": "title", + "header": "Details", + "width": 100, + "xtype": "ColumnModel", + "|renderer": "function(v,x,r) {\n var surl = r.json.url.replace(/\\/release.php\\/Images\\//, '/i/').replace(/\\/([0-9]+)\\/.*$/, '/$1');;\n var svurl = r.json.url_view.replace(/\\/release.php\\/Images\\//, '/i/').replace(/\\/([0-9]+)\\/.*$/, '/$1');;\n return String.format(\n 'Download Url : http://{0}{1}' + \n '
View Url : http://{0}{2}' + \n '
{3}
{4}', \n window.location.host, surl, svurl,\n v, r.json.descript); \n \n }", + "|xns": "Roo.grid" + } + ] + } + ] } ] } diff --git a/Pman.Dialog.AdminEnumImages.js b/Pman.Dialog.AdminEnumImages.js index cd793d8..e386aae 100644 --- a/Pman.Dialog.AdminEnumImages.js +++ b/Pman.Dialog.AdminEnumImages.js @@ -30,6 +30,280 @@ Pman.Dialog.AdminEnumImages = { this.dialog = Roo.factory({ xtype: 'LayoutDialog', xns: Roo, + items : [ + { + xtype: 'GridPanel', + xns: Roo, + listeners : { + activate : function() { + _this.panel = this; + if (_this.grid) { + _this.grid.footer.onClick('first'); + } + } + }, + region : 'center', + background : true, + fitContainer : true, + fitToframe : true, + tableName : 'Images', + title : "Images", + grid : { + xtype: 'Grid', + xns: Roo.grid, + autoExpandColumn : 'title', + loadMask : true, + listeners : { + render : function() { + _this.grid = this; + //_this.dialog = Pman.Dialog.FILL_IN + if (_this.panel.active) { + this.footer.onClick('first'); + } + }, + rowdblclick : function (_self, rowIndex, e) + { + + var s = _self.getDataSource().getAt(rowIndex); + Pman.Dialog.PressReleaseImage.show(s.data, function() { + _this.grid.footer.onClick('first'); + }); + } + }, + dataSource : { + xtype: 'Store', + xns: Roo.data, + listeners : { + beforeload : function (_self, o) + { + o.params.ontable = 'Companies'; + o.params['query[imagesize]'] = '150x150'; + o.params['query[imageBaseURL]'] = rootURL + '/release.php'; + + var sel = Pman.Tab.PressReleaseCompanies ? Pman.Tab.PressReleaseCompanies.grid.getSelectionModel().getSelected() : false + // o.params.imgtype = 'PressRelease'; + o.params.onid = sel ? sel.data.id : 0; + if (!o.params.onid) { + if (!_this.isBuilder) { + _this.panel.el.mask('select company'); + } + return false; + } + + + }, + load : function (_self, records, options) + { + _this.panel.el.unmask(); + } + }, + remoteSort : true, + sortInfo : { field: 'created' , direction: 'DESC' }, + reader : { + xtype: 'JsonReader', + xns: Roo.data, + id : 'id', + root : 'data', + totalProperty : 'total', + fields : [ + { + 'name': 'id', + 'type': 'int' + }, + { + 'name': 'filename', + 'type': 'string' + }, + { + 'name': 'ontable', + 'type': 'string' + }, + { + 'name': 'onid', + 'type': 'int' + }, + { + 'name': 'mimetype', + 'type': 'string' + }, + { + 'name': 'width', + 'type': 'int' + }, + { + 'name': 'height', + 'type': 'int' + }, + { + 'name': 'filesize', + 'type': 'int' + }, + { + 'name': 'displayorder', + 'type': 'int' + }, + { + 'name': 'language', + 'type': 'string' + }, + { + 'name': 'parent_image_id', + 'type': 'int' + }, + { + 'name': 'created', + 'type': 'date', + 'dateFormat' : 'Y-m-d H:i:s' + }, + { + 'name': 'imgtype', + 'type': 'string' + }, + { + 'name': 'linkurl', + 'type': 'string' + }, + { + 'name': 'descript', + 'type': 'string' + }, + { + 'name': 'title', + 'type': 'string' + } + ] + }, + proxy : { + xtype: 'HttpProxy', + xns: Roo.data, + method : 'GET', + url : baseURL + '/Roo/Images.php' + } + }, + footer : { + xtype: 'PagingToolbar', + xns: Roo, + pageSize : 25, + displayInfo : true, + displayMsg : "Displaying Images {0} - {1} of {2}", + emptyMsg : "No Images found" + }, + toolbar : { + xtype: 'Toolbar', + xns: Roo, + items : [ + { + xtype: 'Button', + xns: Roo.Toolbar, + listeners : { + click : function() + { + + var sel = Pman.Tab.PressReleaseCompanies ? Pman.Tab.PressReleaseCompanies.grid.getSelectionModel().getSelected() : false + + Pman.Dialog.Image.show( { + id : 0, + ontable: 'Companies', + onid: sel.data.id, + imgtype : 'PressRelease' + }, + function(data) { + if (!data) { return; } + Pman.Dialog.PressReleaseImage.show( data, function() { + _this.grid.footer.onClick('first'); + + }); + }); + + } + }, + cls : 'x-btn-text-icon', + text : "Add", + icon : Roo.rootURL + 'images/default/dd/drop-add.gif' + }, + { + xtype: 'Button', + xns: Roo, + listeners : { + click : function() + { + var s = _this.grid.getSelectionModel().getSelections(); + if (!s || s.length != 1) { + Roo.MessageBox.alert("Error", "Select a single image to edit"); + return; + } + var data = _this.grid.getDataSource().getById(s[0].data.id).data; + + Pman.Dialog.PressReleaseImage.show(data, function() { + _this.grid.footer.onClick('first'); + }); + + } + }, + cls : 'x-btn-text-icon', + text : "Edit", + icon : Roo.rootURL + 'images/default/tree/leaf.gif' + }, + { + xtype: 'Button', + xns: Roo.Toolbar, + listeners : { + click : function() + { + Pman.genericDelete(_this, 'Images'); + } + }, + cls : 'x-btn-text-icon', + text : "Delete", + icon : rootURL + '/Pman/templates/images/trash.gif' + } + ] + }, + colModel : [ + { + xtype: 'ColumnModel', + xns: Roo.grid, + header : 'Created', + width : 100, + dataIndex : 'created', + renderer : function(v,x,r) { + return String.format('{0}
{1}
{2}
{3}x{4}', + v.format('d/M/Y'), r.data.mimetype, r.data.filename, + r.data.width, r.data.height + ); + }, + sortable : true + }, + { + xtype: 'ColumnModel', + xns: Roo.grid, + dataIndex : 'id', + header : 'Image', + width : 100, + renderer : function(v,x,r) { return String.format('', baseURL, v, r.data.filename); } + }, + { + xtype: 'ColumnModel', + xns: Roo.grid, + dataIndex : 'title', + header : 'Details', + width : 100, + renderer : function(v,x,r) { + var surl = r.json.url.replace(/\/release.php\/Images\//, '/i/').replace(/\/([0-9]+)\/.*$/, '/$1');; + var svurl = r.json.url_view.replace(/\/release.php\/Images\//, '/i/').replace(/\/([0-9]+)\/.*$/, '/$1');; + return String.format( + 'Download Url : http://{0}{1}' + + '
View Url : http://{0}{2}' + + '
{3}
{4}', + window.location.host, surl, svurl, + v, r.json.descript); + + } + } + ] + } + } + ], center : { xtype: 'LayoutRegion', xns: Roo