Index: main/plugin-forms/i18n/messages_fr.xml =================================================================== --- main/plugin-forms/i18n/messages_fr.xml (revision 17455) +++ main/plugin-forms/i18n/messages_fr.xml (working copy) @@ -33,6 +33,15 @@ Aucun des contenus sélectionnés ne contient de formulaire. Nom + Données de formulaire + Visualisation et export des données du formulaire + + Visualiser les données + Visualiser les données d'un des formulaires des contenus sélectionnés + + Formulaire + Outil de visualisation des données des formulaires + Soumettre dans une nouvelle fenêtre Lorsque le visiteur soumet le formulaire une nouvelle fenêtre s'ouvre avec le message de remerciement ou les erreurs le cas échéant. Il peut ensuite fermer cette fenêtre et continuer sa navigation. URL @@ -263,13 +272,16 @@ Le formulaire contient erreur(s).\nVeuillez la (ou les) corriger avant de recommencer.\n\nEn laissant votre curseur au dessus des champs mis en évidence, vous obtiendrez des messages explicatifs. - Exporter les données d'un formulaire au format Excel - Exporter + Exporter/Visualiser les données d'un formulaire au format Excel + OK Annuler Une erreur est survenue en récupérant la liste des formulaires. Sélection du formulaire Aucun formulaire n'a été trouvé dans les contenus sélectionnés. - Vous devez sélectionner un formulaire à exporter. + Vous devez sélectionner un formulaire à exporter/visualiser. + + Une erreur est survenue lors de la récupération des données du formulaire. + Date et heure de soumission ID Date de soumission Index: main/plugin-forms/i18n/messages_en.xml =================================================================== --- main/plugin-forms/i18n/messages_en.xml (revision 17455) +++ main/plugin-forms/i18n/messages_en.xml (working copy) @@ -33,6 +33,15 @@ None of the selected contents contains a form. Name + Forms data + Show and export form data + + Show form data + Show the user data of a form contained in one of the selected contents + + Form + Tool to show form data + Submit in a new window When the visitor sumbits the form, a new window opens with the thank message or the errors depending on the case. He can then close this window to continue. URL @@ -263,13 +272,15 @@ The form has error(s).\nPlease correct it (them) before proceeding.\n\nYou can let the cursor over a highlighted field to see an explaination. - Export the form data as an excel spreadsheet - Export + Export/Show the form data as an excel spreadsheet + OK Cancel An error occured while getting the form list. Form selection No form was found in the selected contents. - You must select a form to export. + You must select a form to export/show. + An error occured while getting form data. + Submission datetime ID Submission date Index: main/plugin-forms/resources/js/org/ametys/forms/FormsTool.i18n.js =================================================================== --- main/plugin-forms/resources/js/org/ametys/forms/FormsTool.i18n.js (revision 0) +++ main/plugin-forms/resources/js/org/ametys/forms/FormsTool.i18n.js (revision 0) @@ -0,0 +1,208 @@ +/* + * Copyright 2012 Anyware Services + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +Ext.namespace('org.ametys.forms.tool'); + +org.ametys.forms.tool.FormsTool = function(id, pluginName) +{ + org.ametys.forms.tool.FormsTool.superclass.constructor.call(this, id, pluginName); +}; + +Ext.extend(org.ametys.forms.tool.FormsTool, org.ametys.uitool.tool.Tool, {}); + +org.ametys.forms.tool.FormsTool.prototype.createPanel = function () +{ + var store = new Ext.data.ArrayStore({ + fields: [], + data: [] + }); + + this._resultGrid = new Ext.grid.GridPanel({ + columns: [], + store: store, + autoScroll: true, + region: 'center' + }); + + this._mainPanel = new Ext.Panel ({ + layout: 'border', + tool: this, + cls: 'form-results', + items: [this._resultGrid] + }); + + // Listeners + this._mainPanel.addListener('activate', this._onActivate, this); + + return this._mainPanel; +} + +org.ametys.forms.tool.FormsTool.prototype._onActivate = function () +{ + this._mainPanel.ownerCt.doLayout(); +} + +org.ametys.forms.tool.FormsTool.prototype.setParams = function (params) +{ + this.refresh(params['url']); +} + +org.ametys.forms.tool.FormsTool.prototype.refresh = function (url) +{ + this.refreshing(); + + var serverMessage = new org.ametys.servercomm.ServerMessage( + this._pluginName, + url, + {}, + org.ametys.servercomm.ServerComm.PRIORITY_MAJOR, + this._showSelectedForm, + this, + [] + ); + org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); +} + +org.ametys.forms.tool.FormsTool._booleanValue = function(val) +{ + return "<img src='" + getPluginResourcesUrl(org.ametys.forms.ChooseForm._pluginName) + "/img/edition/cmp_input_checkbox_" + val + ".png' alt='" + val + "'/>"; +} + +org.ametys.forms.tool.FormsTool._passwordValue = function(val) +{ + return "********"; +} + +org.ametys.forms.tool.FormsTool.prototype._showSelectedForm = function(response, args) +{ + if (org.ametys.servercomm.ServerComm.handleBadResponse("", response, "org.ametys.forms.tool.FormsTool")) + { + return; + } + + var resourcesUrl = getPluginResourcesUrl(this._pluginName); + var form = response.selectSingleNode("//form"); + var id = form.getAttribute("id"); + var label = unescape(form.getAttribute("label")); + + var columns = []; + var fields = []; + var filefields = []; + + columns.push({ + header: "", + id: "submission-date", + dataIndex: "submission-date", + sortable: true, + hideable: true, + renderer: Ext.util.Format.dateRenderer('d/m/Y h:i'), + align: "right" + }); + fields.push("submission-date"); + var columnNodes = form.selectNodes("columns/column"); + for (var i=0; i < columnNodes.length; i++) + { + var columnNode = columnNodes[i]; + + var header = columnNode.getAttribute("label"); + if (header.length == 0) + { + header = columnNode.getAttribute("field-name"); + } + + var fieldtype = columnNode.getAttribute("type"); + var fieldtypeImg = fieldtype.toLowerCase(); + if (fieldtype == "TEXT" || fieldtype == "RADIO" || fieldtype == "CHECKBOX" || fieldtype == "PASSWORD" || fieldtype == "FILE" || fieldtype == "HIDDEN") + { + fieldtypeImg = "input_" + fieldtypeImg; + } + + if (fieldtype != "") + { + header = "<img style='vertical-align:middle;' src='" + resourcesUrl + "/img/edition/" + fieldtypeImg + "_16.png'/> " + header; + } + + var column = { + header: header, + dataIndex: columnNode.getAttribute("id"), + sortable: true, + hideable: true + }; + if (fieldtype == "TEXT") + { + var valuetype = columnNode.getAttribute("regexptype"); + if (valuetype == "int" || valuetype == "float" || valuetype == "date" || valuetype == "time" || valuetype == "datetime") + { + column.align = "right"; + } + } + else if (fieldtype == "CHECKBOX") + { + column.renderer = org.ametys.forms.tool.FormsTool._booleanValue; + } + else if (fieldtype == "PASSWORD") + { + column.renderer = org.ametys.forms.tool.FormsTool._passwordValue; + } + else if (fieldtype == "FILE") + { + filefields.push(columnNode.getAttribute("id")); + } + columns.push(column); + + fields.push(columnNode.getAttribute("id")); + } + + var results = []; + var resultNodes = form.selectNodes("entry"); + for (var i=0; i < resultNodes.length; i++) + { + var resultNode = resultNodes[i]; + var result = []; + var valueNodes = resultNode.selectNodes("value"); + + result.push(resultNode.getAttribute("submission-date")); + for (var j=0; j < valueNodes.length; j++) + { + var valueId = valueNodes[j].getAttribute("id"); + var valueValue = valueNodes[j][org.ametys.servercomm.ServerComm.xmlTextContent]; + if ($.inArray(valueId, filefields) >= 0) + { + result.push("<a href='" + getPluginDirectUrl(this._pluginName) + "/" + context.parameters.siteName + "/download/" + id + "/" + resultNode.getAttribute("id") + "/" + valueId + "/" + valueValue + "'>" + valueValue + "</a>"); + } + else + { + result.push(valueValue); + } + } + + results.push(result); + } + + var store = new Ext.data.ArrayStore({ + fields: fields, + data: results + }); + + var model = new Ext.grid.ColumnModel({ + columns: columns + }); + + this._resultGrid.reconfigure(store, model); + this._resultGrid.autoExpandColumn = "submission-date"; + + this.upToDate(); +} Index: main/plugin-forms/resources/js/org/ametys/forms/FormsActions.i18n.js =================================================================== --- main/plugin-forms/resources/js/org/ametys/forms/FormsActions.i18n.js (revision 17455) +++ main/plugin-forms/resources/js/org/ametys/forms/FormsActions.i18n.js (working copy) @@ -19,26 +19,27 @@ org.ametys.forms.buttons.Action = {}; -org.ametys.forms.buttons.Action.exportForm = function(controlId, controlConfiguration, controlPluginName) +org.ametys.forms.buttons.Action.exportForm = function (control, configuration, index) { - var control = org.ametys.ribbon.RibbonManager.getInstance().getControls()[controlId]; - - var contents = control._currentContentsId; - - org.ametys.forms.ChooseForm.act(controlId, controlConfiguration, controlPluginName, contents, org.ametys.forms.buttons.Action.selectedForm); + org.ametys.forms.ChooseForm.act(control, org.ametys.forms.buttons.Action.exportSelectedForm); } -org.ametys.forms.buttons.Action.selectedForm = function(id, label) +org.ametys.forms.buttons.Action.showForm = function(control, configuration, index) { - if (id != null) - { - var pluginName = org.ametys.forms.ChooseForm._pluginName; - var url = '/' + context.parameters.siteName + '/export/' + id + '/' + label + '.xls'; - - window.location.href = getPluginDirectUrl(pluginName) + url; - } + org.ametys.forms.ChooseForm.act(control, org.ametys.forms.buttons.Action.showSelectedForm); +} + +org.ametys.forms.buttons.Action.exportSelectedForm = function(url) +{ + window.location.href = getPluginDirectUrl(org.ametys.forms.ChooseForm._pluginName) + url + '.xls'; +} + +org.ametys.forms.buttons.Action.showSelectedForm = function(url) +{ + org.ametys.uitool.ToolsManager.getInstance().openTool('uitool-formresults', { url: url + '.xml' }); } + org.ametys.forms.ChooseForm = {}; /** @@ -61,10 +62,12 @@ org.ametys.forms.ChooseForm._contentIds; -org.ametys.forms.ChooseForm.act = function(id, config, pluginName, contentIds, callback) +org.ametys.forms.ChooseForm.act = function(control, callback) { + var contentIds = control.ribbonControl._currentContentsId; + org.ametys.forms.ChooseForm._currentForm = null; - org.ametys.forms.ChooseForm._pluginName = pluginName; + org.ametys.forms.ChooseForm._pluginName = control.ribbonControl._pluginName; org.ametys.forms.ChooseForm._callback = callback; org.ametys.forms.ChooseForm._contentIds = contentIds; @@ -98,7 +101,7 @@ }), hideHeaders : true, columns: [ - {header: "", width: 380, menuDisabled : true, sortable: true, dataIndex: 'displayName'} + {header: "", width: 380, menuDisabled : true, sortable: true, dataIndex: 'displayName'} ], id: 'select-form-list', baseCls: 'select-form-list', @@ -194,11 +197,13 @@ } org.ametys.forms.ChooseForm._box.hide(); - + var formId = selection[0].id; var formLabel = selection[0].get('name'); - org.ametys.forms.ChooseForm._callback(formId, formLabel); + var url = '/' + context.parameters.siteName + '/export/' + formId + '/' + formLabel; + + org.ametys.forms.ChooseForm._callback(url); } else { Index: main/plugin-forms/resources/js/org/ametys/forms/FormsButton.js =================================================================== --- main/plugin-forms/resources/js/org/ametys/forms/FormsButton.js (revision 17455) +++ main/plugin-forms/resources/js/org/ametys/forms/FormsButton.js (working copy) @@ -21,7 +21,7 @@ org.ametys.forms.buttons.FormsButton.superclass.constructor.call(this, id, configuration, pluginName); }; -Ext.extend(org.ametys.forms.buttons.FormsButton, org.ametys.ribbon.control.button.ActionButton, {}); +Ext.extend(org.ametys.forms.buttons.FormsButton, org.ametys.cms.ribbon.button.Menu, {}); /** * @private Index: main/plugin-forms/resources/js/org/ametys/forms/FormsToolFactory.js =================================================================== --- main/plugin-forms/resources/js/org/ametys/forms/FormsToolFactory.js (revision 0) +++ main/plugin-forms/resources/js/org/ametys/forms/FormsToolFactory.js (revision 0) @@ -0,0 +1,73 @@ +/* + * Copyright 2012 Anyware Services + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +Ext.namespace('org.ametys.forms.tool'); + +/** + * Do not call this constructor. Decalred to and used by the {@see org.ametys.uitool.ToolsManager} + * @constructor + * @class The factory to creates page tools. + * @param {String} id The unique id of the factory + * @param {Map} config Options are : 'url' : the url to use to display page, with a 'path' parameter to place the page path; 'default-location' : where to place the tool; 'description' : the tooltip to display with following parameters 'siteUrl', 'siteTitle', 'lang', 'path'. + * @param {String} pluginName The name of the plugin where the factory was declared + */ +org.ametys.forms.tool.FormsToolFactory = function(id, config, pluginName) +{ + org.ametys.forms.tool.FormsToolFactory.superclass.constructor.call(this, id, config, pluginName); +}; + +Ext.extend(org.ametys.forms.tool.FormsToolFactory, org.ametys.uitool.tool.ToolFactory, {}); + +/** + * Creates a tool of type {@see org.ametys.cms.tool.content.ContentTool} or activate the existing one. + * There is one tool per content. + * @param {Map} params The params used by the factory is 'id' that is the content id. Params are transmited the the content tool. + * @return {Ext.org.ametys.uitool.tool.Tool} The tool to open. + */ +org.ametys.forms.tool.FormsToolFactory.prototype.openTool = function (params) +{ + var idTool = this._id + params['id']; + + if (org.ametys.uitool.ToolsManager.getInstance().getTool(idTool) == null) + { + var tool = new org.ametys.forms.tool.FormsTool(idTool, this.getPluginName()); + tool.setConfiguration(this._config); + tool.setFactory(this); + + org.ametys.uitool.ToolsManager.getInstance().addUITool (tool, this._config['default-location']); + } + else + { + // Tool does already exists => Tool activation + tool = org.ametys.uitool.ToolsManager.getInstance().getTool(idTool); + } + + tool.setParams(params); + tool.activate(); + + return tool; +} + + + +/** + * Destroy the tool. + * @param {org.ametys.uitool.tool.Tool} tool The tool to close. + */ +org.ametys.forms.tool.FormsToolFactory.prototype.closeTool = function (tool) +{ + org.ametys.uitool.ToolsManager.getInstance().removeUITool (tool); +} Index: main/plugin-forms/src/org/ametys/plugins/forms/data/FormsContentClientSideElement.java =================================================================== --- main/plugin-forms/src/org/ametys/plugins/forms/data/FormsContentClientSideElement.java (revision 17455) +++ main/plugin-forms/src/org/ametys/plugins/forms/data/FormsContentClientSideElement.java (working copy) @@ -19,22 +19,24 @@ import java.util.List; import java.util.Map; +import org.apache.avalon.framework.configuration.Configuration; +import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.service.ServiceException; import org.apache.avalon.framework.service.ServiceManager; import org.apache.commons.lang.StringUtils; +import org.ametys.cms.clientsideelement.StaticMenu; import org.ametys.cms.repository.Content; import org.ametys.plugins.forms.Form; import org.ametys.plugins.forms.FormsException; import org.ametys.plugins.forms.jcr.FormPropertiesManager; import org.ametys.plugins.repository.AmetysObjectResolver; -import org.ametys.runtime.ui.impl.StaticContextualClientSideElement; import org.ametys.runtime.util.I18nizableText; /** * This element creates a content button permitting to export the form data. */ -public class FormsContentClientSideElement extends StaticContextualClientSideElement +public class FormsContentClientSideElement extends StaticMenu { /** The form properties manager. */ @@ -52,6 +54,12 @@ } @Override + public void configure(Configuration configuration) throws ConfigurationException + { + super.configure(configuration); + } + + @Override public Map getCurrentParameters(Map parameters) { Map results = new HashMap(); Index: main/plugin-forms/plugin.xml =================================================================== --- main/plugin-forms/plugin.xml (revision 17455) +++ main/plugin-forms/plugin.xml (working copy) @@ -1285,30 +1285,59 @@ - - - org.ametys.forms.buttons.Action.exportForm - - PLUGINS_FORMS_UI_LABEL - PLUGINS_FORMS_UI_DESCRIPTION - - PLUGINS_FORMS_UI_DESCRIPTION - + + PLUGINS_SHOW_OR_EXPORT_FORMS_LABEL + PLUGINS_SHOW_OR_EXPORT_FORMS_DESCRIPTION + PLUGINS_SHOW_OR_EXPORT_FORMS_DESCRIPTION + PLUGINS_FORMS_UI_TOOLTIP PLUGINS_FORMS_UI_NO_FORMS_TOOLTIP - img/forms_16.png - img/forms_32.png - img/forms_50.png - + img/forms_16.png + img/forms_32.png + img/forms_48.png + Runtime_Rights_Forms_Export - - js/org/ametys/forms/FormsButton.js + + org.ametys.forms.buttons.Action.exportForm + + PLUGINS_FORMS_UI_LABEL + PLUGINS_FORMS_UI_DESCRIPTION + img/forms_16.png + + + org.ametys.forms.buttons.Action.showForm + + PLUGINS_SHOW_FORMS_UI_LABEL + PLUGINS_SHOW_FORMS_UI_DESCRIPTION + img/forms_16.png + + + js/org/ametys/forms/FormsButton.js js/org/ametys/forms/FormsActions.i18n.js - - + + + + + + uitool-formresults + UITOOL_FORM_RESULTS_LABEL + UITOOL_FORM_RESULTS_DESCRIPTION + img/forms_16.png + img/forms_32.png + img/forms_48.png + + + + js/org/ametys/forms/FormsTool.i18n.js + js/org/ametys/forms/FormsToolFactory.js + + Index: ivy.xml =================================================================== --- ivy.xml (revision 17455) +++ ivy.xml (working copy) @@ -15,7 +15,7 @@ limitations under the License. --> - + Ametys plugin providing forms creation. @@ -40,7 +40,7 @@ - +