From: <fg...@us...> - 2008-06-23 18:48:28
|
Revision: 853 http://openutils.svn.sourceforge.net/openutils/?rev=853&view=rev Author: fgiust Date: 2008-06-23 11:47:40 -0700 (Mon, 23 Jun 2008) Log Message: ----------- Handling of "link" and "checkbox" column types Modified Paths: -------------- trunk/openutils-mgnlcontrols/src/main/resources/dialogs/grid.ftl trunk/openutils-mgnlcontrols/src/site/changes/changes.xml Added Paths: ----------- trunk/openutils-mgnlcontrols/src/main/resources/mgnl-resources/controls/css/ trunk/openutils-mgnlcontrols/src/main/resources/mgnl-resources/controls/css/grid.css trunk/openutils-mgnlcontrols/src/main/resources/mgnl-resources/controls/css/img/ trunk/openutils-mgnlcontrols/src/main/resources/mgnl-resources/controls/css/img/link-trigger.gif trunk/openutils-mgnlcontrols/src/main/resources/mgnl-resources/controls/js/ trunk/openutils-mgnlcontrols/src/main/resources/mgnl-resources/controls/js/CheckColumn.js trunk/openutils-mgnlcontrols/src/main/resources/mgnl-resources/controls/js/LinkField.js Removed Paths: ------------- trunk/openutils-mgnlcontrols/src/main/resources/mgnl-resources/controls/grid-paste.html Modified: trunk/openutils-mgnlcontrols/src/main/resources/dialogs/grid.ftl =================================================================== --- trunk/openutils-mgnlcontrols/src/main/resources/dialogs/grid.ftl 2008-06-21 08:49:08 UTC (rev 852) +++ trunk/openutils-mgnlcontrols/src/main/resources/dialogs/grid.ftl 2008-06-23 18:47:40 UTC (rev 853) @@ -6,8 +6,11 @@ [#else] <script type="text/javascript" src="${request.contextPath}/.resources/controls/ext/ext-all.js"></script> [/#if] +<script type="text/javascript" src="${request.contextPath}/.resources/controls/js/LinkField.js"></script> +<script type="text/javascript" src="${request.contextPath}/.resources/controls/js/CheckColumn.js"></script> <link rel="stylesheet" type="text/css" href="${request.contextPath}/.resources/controls/ext/css/ext-all.css" /> +<link rel="stylesheet" type="text/css" href="${request.contextPath}/.resources/controls/css/grid.css" /> <input type="hidden" id="${name}" name="${name}" value="${value}"/> @@ -27,35 +30,48 @@ var i, myData = []; for (i = 0; i < numOfRows; i++) { - myData.push(((action != 'delete' && i < rows.length) ? rows[i] : '').split('\t').concat([ undefined, undefined ]).slice(0, 2)); + myData.push(((action != 'delete' && i < rows.length) ? rows[i] : '').split('\t').concat([ undefined, undefined ]).slice(0, ${configuration.columns?size})); } var dataStore = new Ext.data.SimpleStore({ - fields: ['0', '1'] + fields: [ [#list configuration.columns?values as colmap]'${colmap_index}'[#if colmap_has_next],[/#if][/#list] ] }); dataStore.loadData(myData); // shorthand alias var fm = Ext.form, Ed = Ext.grid.GridEditor; - var colModel = new Ext.grid.ColumnModel([ - [#list configuration.columns?values as colmap] - { + var checkColumns = []; + [#list configuration.columns?values as colmap] + [#if (colmap.type?? && colmap.type = 'checkbox')] + checkColumns.push(new Ext.grid.CheckColumn({ header: '${colmap.header}', dataIndex: '${colmap_index}', - sortable: false, + width: 55 + })); + [/#if] + [/#list] - // todo: gestire checkbox + var checkIndex = 0; + var colModel = new Ext.grid.ColumnModel([ + [#list configuration.columns?values as colmap] [#if (colmap.type?? && colmap.type = 'checkbox')] - editor: new Ed(new fm.Checkbox({ - check:false - })) + checkColumns[checkIndex++] [#else] - editor: new Ed(new fm.TextField({ - allowBlank: true - })) - [/#if] - }[#if colmap_has_next],[/#if] + { + header: '${colmap.header}', + dataIndex: '${colmap_index}', + sortable: false, + [#if (colmap.type?? && colmap.type = 'link')] + editor: new Ed(new LinkField({ + })) + [#else] + editor: new Ed(new fm.TextField({ + allowBlank: true + })) + [/#if] + } + [/#if][#if colmap_has_next],[/#if] [/#list] ]); colModel.defaultSortable = true; @@ -66,6 +82,7 @@ selModel: new Ext.grid.CellSelectionModel(), autoSizeColumns: true, enableColLock: false, + plugins: checkColumns, clicksToEdit: 1, renderTo: 'grid-${name}', tbar: [{ Added: trunk/openutils-mgnlcontrols/src/main/resources/mgnl-resources/controls/css/grid.css =================================================================== --- trunk/openutils-mgnlcontrols/src/main/resources/mgnl-resources/controls/css/grid.css (rev 0) +++ trunk/openutils-mgnlcontrols/src/main/resources/mgnl-resources/controls/css/grid.css 2008-06-23 18:47:40 UTC (rev 853) @@ -0,0 +1,4 @@ +.x-form-field-wrap .x-form-link-trigger { + background-image: url(img/link-trigger.gif); + cursor: pointer; +} \ No newline at end of file Property changes on: trunk/openutils-mgnlcontrols/src/main/resources/mgnl-resources/controls/css/grid.css ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native Added: trunk/openutils-mgnlcontrols/src/main/resources/mgnl-resources/controls/css/img/link-trigger.gif =================================================================== (Binary files differ) Property changes on: trunk/openutils-mgnlcontrols/src/main/resources/mgnl-resources/controls/css/img/link-trigger.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Deleted: trunk/openutils-mgnlcontrols/src/main/resources/mgnl-resources/controls/grid-paste.html =================================================================== --- trunk/openutils-mgnlcontrols/src/main/resources/mgnl-resources/controls/grid-paste.html 2008-06-21 08:49:08 UTC (rev 852) +++ trunk/openutils-mgnlcontrols/src/main/resources/mgnl-resources/controls/grid-paste.html 2008-06-23 18:47:40 UTC (rev 853) @@ -1,22 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html> - <head> - <title>Paste from spreadsheet</title> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> - <script type="text/javascript" src="../../.magnolia/pages/javascript.js"></script> - <script type="text/javascript" src="../../.resources/admin-js/dialogs/dialogs.js"></script> - <link rel="stylesheet" type="text/css" href="../../.resources/admin-css/admin-all.css" /> - </head> - <body style="padding:0;margin:0"> - <h1 style="background-color:#F0F2E6; color:#396101; font-size:11pt; border-bottom:1px solid #999;margin:0;padding:3px 10px">Paste from spreadsheet</h1> - <p style="margin: 10px;font-size:9pt">Please paste inside the following box using the keyboard (<strong>Ctrl+V</strong>) and hit <strong>OK</strong>.</p> - <p style="margin: 10px"> - <textarea id="clipboard" name="clipboard" rows="4" cols="20" style="width: 100%;border: 1px solid #999"></textarea> - </p> - <div class="mgnlDialogTabsetSaveBar"> - <span class="mgnlControlButton" - onclick="opener.window['paste${param.name}'](document.getElementById('clipboard').value); mgnlShiftPushButtonClick(this); window.top.close();" - onmouseout="mgnlShiftPushButtonOut(this);" onmousedown="mgnlShiftPushButtonDown(this);">OK</span> - </div> - </body> -</html> \ No newline at end of file Added: trunk/openutils-mgnlcontrols/src/main/resources/mgnl-resources/controls/js/CheckColumn.js =================================================================== --- trunk/openutils-mgnlcontrols/src/main/resources/mgnl-resources/controls/js/CheckColumn.js (rev 0) +++ trunk/openutils-mgnlcontrols/src/main/resources/mgnl-resources/controls/js/CheckColumn.js 2008-06-23 18:47:40 UTC (rev 853) @@ -0,0 +1,42 @@ +Ext.grid.CheckColumn = function(config){ + Ext.apply(this, config); + if(!this.id){ + this.id = Ext.id(); + } + this.renderer = this.renderer.createDelegate(this); +}; + +Ext.grid.CheckColumn.prototype ={ + init : function(grid){ + this.grid = grid; + this.grid.on('render', function(){ + var view = this.grid.getView(); + view.mainBody.on('mousedown', this.onMouseDown, this); + }, this); + }, + + onMouseDown : function(e, t){ + if(t.className && t.className.indexOf('x-grid3-cc-'+this.id) != -1){ + e.stopEvent(); + var index = this.grid.getView().findRowIndex(t); + var record = this.grid.store.getAt(index); + var value = !(String(record.data[this.dataIndex]).trim().toLowerCase() == 'true'); + var e2 = { + grid: this.grid, + record: record, + field: this.dataIndex, + originalValue: record.get(this.dataIndex), + value: value, + row: index, + column: this.grid.colModel.findColumnIndex(t) + }; + record.set(this.dataIndex, value); + this.grid.fireEvent("afteredit", e2); + } + }, + + renderer : function(v, p, record){ + p.css += ' x-grid3-check-col-td'; + return '<div class="x-grid3-check-col'+((String(v).trim().toLowerCase() == 'true')?'-on':'')+' x-grid3-cc-'+this.id+'"> </div>'; + } +}; \ No newline at end of file Property changes on: trunk/openutils-mgnlcontrols/src/main/resources/mgnl-resources/controls/js/CheckColumn.js ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Added: trunk/openutils-mgnlcontrols/src/main/resources/mgnl-resources/controls/js/LinkField.js =================================================================== --- trunk/openutils-mgnlcontrols/src/main/resources/mgnl-resources/controls/js/LinkField.js (rev 0) +++ trunk/openutils-mgnlcontrols/src/main/resources/mgnl-resources/controls/js/LinkField.js 2008-06-23 18:47:40 UTC (rev 853) @@ -0,0 +1,10 @@ +var LinkField = Ext.extend(Ext.form.TriggerField, { + + triggerClass : 'x-form-link-trigger', + + onTriggerClick : function() { + if (this.disabled) return; + mgnlDialogLinkOpenBrowser(this.el.id, 'website', 'html'); + } + +}); Property changes on: trunk/openutils-mgnlcontrols/src/main/resources/mgnl-resources/controls/js/LinkField.js ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Modified: trunk/openutils-mgnlcontrols/src/site/changes/changes.xml =================================================================== --- trunk/openutils-mgnlcontrols/src/site/changes/changes.xml 2008-06-21 08:49:08 UTC (rev 852) +++ trunk/openutils-mgnlcontrols/src/site/changes/changes.xml 2008-06-23 18:47:40 UTC (rev 853) @@ -8,6 +8,9 @@ <author email="fgiust(at)users.sourceforge.net">Fabrizio Giustina</author> </properties> <body> + <release version="3.5.1" date="2008-06-23" description=""> + <action type="new" dev="fgiust">Handling of "link" and "checkbox" column types.</action> + </release> <release version="3.5" date="2008-06-20" description="first release"> <action type="new" dev="fgiust">Initial public release. Version numbering starts from 3.5 to match the compatible magnolia version.</action> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |