From 541bb378ddece2eab135a8066a16994e94436dea Mon Sep 17 00:00:00 2001 From: Giulio Cesare Solaroli Date: Mon, 03 Oct 2011 16:04:12 +0000 Subject: Merge pull request #1 from gcsolaroli/master First version of the restructured repository --- (limited to 'frontend/beta/js/Clipperz/PM/Components/Import/CSVImport') diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportColumns.js b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportColumns.js new file mode 100644 index 0000000..18b36da --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportColumns.js @@ -0,0 +1,174 @@ +/* + +Copyright 2008-2011 Clipperz Srl + +This file is part of Clipperz's Javascript Crypto Library. +Javascript Crypto Library provides web developers with an extensive +and efficient set of cryptographic functions. The library aims to +obtain maximum execution speed while preserving modularity and +reusability. +For further information about its features and functionalities please +refer to http://www.clipperz.com + +* Javascript Crypto Library is free software: you can redistribute + it and/or modify it under the terms of the GNU Affero General Public + License as published by the Free Software Foundation, either version + 3 of the License, or (at your option) any later version. + +* Javascript Crypto Library is distributed in the hope that it will + be useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Affero General Public License for more details. + +* You should have received a copy of the GNU Affero General Public + License along with Javascript Crypto Library. If not, see + . + +*/ + +if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } +if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } +if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } +if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; } +if (typeof(Clipperz.PM.Components.Import.CSVImport) == 'undefined') { Clipperz.PM.Components.Import.CSVImport = {}; } + +//############################################################################# + +Clipperz.PM.Components.Import.CSVImport.CSVImportColumns = function(anElement, args) { + args = args || {}; + + Clipperz.PM.Components.Import.CSVImport.CSVImportColumns.superclass.constructor.call(this, anElement, args); + this._mainComponent = args.mainComponent; + + return this; +} + +//============================================================================= + +YAHOO.extendX(Clipperz.PM.Components.Import.CSVImport.CSVImportColumns, Clipperz.PM.Components.BaseComponent, { + + 'toString': function() { + return "Clipperz.PM.Components.Import.CSVImport.CSVImportColumns component"; + }, + + //------------------------------------------------------------------------- + + 'mainComponent': function() { + return this._mainComponent; + }, + + //------------------------------------------------------------------------- + + 'render': function() { + var i,c; + var columnSelectorCheckboxCells; + var checkboxes; + var data; + +//MochiKit.Logging.logDebug(">>> CSVImportColumns.render"); + Clipperz.NotificationCenter.unregister(this); + MochiKit.Signal.disconnectAllTo(this); + + this.element().update(""); + + data = this.mainComponent().parsedValues(); + columnSelectorCheckboxCells = []; + + c = data[0].length; + for (i=0; i>> CSVImportColumns.renderData"); +// anElement.update(""); + MochiKit.DOM.replaceChildNodes(anElement.dom); + + config = MochiKit.Base.map(MochiKit.Base.bind(function(aRowData) { + var result; + var i,c; + + result = {tag:'tr', children:[]}; + c = aRowData.length; + for (i=0; i') : ' ')}); + } + + return result; + }, this), someData); + + MochiKit.Base.map(function(aRowConfig) {Clipperz.YUI.DomHelper.append(anElement, aRowConfig);}, config); + + Clipperz.Style.applyZebraStylesToTable(this.getId('previewDada')); +//MochiKit.Logging.logDebug("<<< CSVImportColumns.renderData"); + }, + + //------------------------------------------------------------------------- + + 'renderDataHandler': function(anEvent) { + var thElement; + + thElement = YAHOO.ext.Element.get(anEvent.src().parentNode); + + if (anEvent.src().checked == true) { + this.mainComponent().skippedColumns().remove(anEvent.src().value); + thElement.addClass('selectedColumn'); + thElement.removeClass('skippedColumn'); + } else { + this.mainComponent().skippedColumns().add(anEvent.src().value); + thElement.removeClass('selectedColumn'); + thElement.addClass('skippedColumn'); + } + + if (this.mainComponent().skippedColumns().allItems().length == this.mainComponent().parsedValues()[0].length) { + this.mainComponent().nextButton().disable(); + } else { + this.mainComponent().nextButton().enable(); + } + + this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues()); + }, + + //------------------------------------------------------------------------- + __syntaxFix__: "syntax fix" +}); + diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportFields.js b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportFields.js new file mode 100644 index 0000000..a368747 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportFields.js @@ -0,0 +1,247 @@ +/* + +Copyright 2008-2011 Clipperz Srl + +This file is part of Clipperz's Javascript Crypto Library. +Javascript Crypto Library provides web developers with an extensive +and efficient set of cryptographic functions. The library aims to +obtain maximum execution speed while preserving modularity and +reusability. +For further information about its features and functionalities please +refer to http://www.clipperz.com + +* Javascript Crypto Library is free software: you can redistribute + it and/or modify it under the terms of the GNU Affero General Public + License as published by the Free Software Foundation, either version + 3 of the License, or (at your option) any later version. + +* Javascript Crypto Library is distributed in the hope that it will + be useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Affero General Public License for more details. + +* You should have received a copy of the GNU Affero General Public + License along with Javascript Crypto Library. If not, see + . + +*/ + +if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } +if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } +if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } +if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; } +if (typeof(Clipperz.PM.Components.Import.CSVImport) == 'undefined') { Clipperz.PM.Components.Import.CSVImport = {}; } + +//############################################################################# + +Clipperz.PM.Components.Import.CSVImport.CSVImportFields = function(anElement, args) { + args = args || {}; + + Clipperz.PM.Components.Import.CSVImport.CSVImportFields.superclass.constructor.call(this, anElement, args); + this._mainComponent = args.mainComponent; + + return this; +} + +//============================================================================= + +YAHOO.extendX(Clipperz.PM.Components.Import.CSVImport.CSVImportFields, Clipperz.PM.Components.BaseComponent, { + + 'toString': function() { + return "Clipperz.PM.Components.Import.CSVImport.CSVImportFields component"; + }, + + //------------------------------------------------------------------------- + + 'mainComponent': function() { + return this._mainComponent; + }, + + //------------------------------------------------------------------------- + + 'render': function() { + var fieldsHeaderCells; + var titleColumnIndex; + var notesColumnIndex; + var i,c; + + Clipperz.NotificationCenter.unregister(this); + MochiKit.Signal.disconnectAllTo(this); + + this.element().update(""); + + titleColumnIndex = this.mainComponent().titleColumnIndex() + notesColumnIndex = this.mainComponent().notesColumnIndex() + + fieldsHeaderCells = []; + fieldsHeaderCells.push({tag:'td', valign:'top', cls:'title', html:this.mainComponent().labelForColumn(titleColumnIndex)}); + + c = this.mainComponent().parsedValues()[0].length; + for (i=0; i>> renderDataRowsHandler") + columnIndex = anEvent.src().name; + this.mainComponent().setTypeForColumn(anEvent.src().value, columnIndex); + + tdElement = this.getElement('fieldHeaderTD_' + columnIndex); + + if (this.isColumnSetup(columnIndex)) { + tdElement.removeClass('unconfiguredColumn'); + tdElement.addClass('configuredColumn'); + } else { + tdElement.addClass('unconfiguredColumn'); + tdElement.removeClass('configuredColumn'); + } + + this.renderDataRows(this.getElement('previewData_tbody')); + }, + + //------------------------------------------------------------------------- + + 'renderDataRows': function(anElement) { + var titleColumnIndex; + var notesColumnIndex; + var data + var i,c; + +//MochiKit.Logging.logDebug("#### >> renderDataRows"); +// anElement.update(""); + MochiKit.DOM.replaceChildNodes(anElement.dom); + + if (this.mainComponent().isFirstRowHeader()) { + data = this.mainComponent().parsedValues().slice(1); + } else { + data = this.mainComponent().parsedValues(); + } + + + titleColumnIndex = this.mainComponent().titleColumnIndex(); + notesColumnIndex = this.mainComponent().notesColumnIndex(); + + c = data.length; + for (i=0; i') : ' ')} + ]}; + + cc = rowData.length; + for (ii=0; ii') : ' ') + }); + } + } + if (notesColumnIndex != -1) { + rowConfig.children.push({tag:'td', valign:'top', cls:'notes', html:(MochiKit.Base.isNotEmpty(rowData[notesColumnIndex]) ? rowData[notesColumnIndex].replace(/\n/g, '
') : ' ')}); + } + + this.domHelper().append(anElement, rowConfig); + } + + Clipperz.Style.applyZebraStylesToTable(this.getId('previewDada')); + + this.checkWetherToEnableNextButton(); +//MochiKit.Logging.logDebug("#### << renderDataRows"); + }, + + //------------------------------------------------------------------------- + + 'checkWetherToEnableNextButton': function() { + var result; + var titleColumnIndex; + var notesColumnIndex; + var i,c; + + titleColumnIndex = this.mainComponent().titleColumnIndex() + notesColumnIndex = this.mainComponent().notesColumnIndex() + + result = true; + c = this.mainComponent().parsedValues()[0].length; + for (i=0; i. + +*/ + +if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } +if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } +if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } +if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; } +if (typeof(Clipperz.PM.Components.Import.CSVImport) == 'undefined') { Clipperz.PM.Components.Import.CSVImport = {}; } + +//############################################################################# + +Clipperz.PM.Components.Import.CSVImport.CSVImportHeader = function(anElement, args) { + args = args || {}; + + Clipperz.PM.Components.Import.CSVImport.CSVImportHeader.superclass.constructor.call(this, anElement, args); + this._mainComponent = args.mainComponent; + + this._pendingDeferredLabelFieldHandlerEvents = 0; + + return this; +} + +//============================================================================= + +YAHOO.extendX(Clipperz.PM.Components.Import.CSVImport.CSVImportHeader, Clipperz.PM.Components.BaseComponent, { + + 'toString': function() { + return "Clipperz.PM.Components.Import.CSVImport.CSVImportHeader component"; + }, + + //------------------------------------------------------------------------- + + 'mainComponent': function() { + return this._mainComponent; + }, + + //------------------------------------------------------------------------- + + 'render': function() { + var thConfigs; + var i,c; + +//MochiKit.Logging.logDebug(">>> CSVImportHeader.render"); + Clipperz.NotificationCenter.unregister(this); + MochiKit.Signal.disconnectAllTo(this); + + thConfigs = []; + c = this.mainComponent().parsedValues()[0].length; + for (i=0; i') : ' ')}); + } + } + + return result; + }, this), data); + + MochiKit.Base.map(function(aRowConfig) {Clipperz.YUI.DomHelper.append(anElement, aRowConfig);}, trConfigs); + + Clipperz.Style.applyZebraStylesToTable(this.getId('previewDada')); + }, + + //------------------------------------------------------------------------- + + 'toggleFirstRowHeaderCheckboxHandler': function() { + var firstRowData; + var i,c; + +//MochiKit.Logging.logDebug(">>> toggleFirstRowHeaderCheckboxHandler"); + this.mainComponent().setIsFirstRowHeader(this.getDom('isFirstRowHeader_checkbox').checked); + + firstRowData = this.mainComponent().parsedValues()[0]; + + c = firstRowData.length; + for (i=0; i>> updateInputFieldValues"); + c = this.mainComponent().parsedValues()[0].length; + for (i=0; i>> labelFieldHandler"); + inputField = anEvent.src(); + + this.mainComponent().setLabelForColumn(inputField.value, aColumnIndex); +//MochiKit.Logging.logDebug("##### [" + anEvent.src().id + "] -> label[" + aColumnIndex + "]: '" + inputField.value + "'"); +//MochiKit.Logging.logDebug("<<< labelFieldHandler"); + }, + + 'deferredLabelFieldHandler': function(aColumnIndex, anEvent) { +//MochiKit.Logging.logDebug(">>> deferredLabelFieldHandler"); + this._pendingDeferredLabelFieldHandlerEvents ++; + MochiKit.Async.callLater(1, MochiKit.Base.partial(MochiKit.Base.method(this, 'deferredLabelFieldHandlerCatcher'), aColumnIndex, anEvent)); +//MochiKit.Logging.logDebug("<<< deferredLabelFieldHandler"); + }, + + 'deferredLabelFieldHandlerCatcher': function(aColumnIndex, anEvent) { +//MochiKit.Logging.logDebug(">>> deferredLabelFieldHandlerCatcher"); + this._pendingDeferredLabelFieldHandlerEvents --; + if (this._pendingDeferredLabelFieldHandlerEvents == 0) { + this.labelFieldHandler(aColumnIndex, anEvent); + } +//MochiKit.Logging.logDebug("<<< deferredLabelFieldHandlerCatcher"); + }, + + //------------------------------------------------------------------------- + __syntaxFix__: "syntax fix" +}); + diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportNotes.js b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportNotes.js new file mode 100644 index 0000000..a53c531 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportNotes.js @@ -0,0 +1,212 @@ +/* + +Copyright 2008-2011 Clipperz Srl + +This file is part of Clipperz's Javascript Crypto Library. +Javascript Crypto Library provides web developers with an extensive +and efficient set of cryptographic functions. The library aims to +obtain maximum execution speed while preserving modularity and +reusability. +For further information about its features and functionalities please +refer to http://www.clipperz.com + +* Javascript Crypto Library is free software: you can redistribute + it and/or modify it under the terms of the GNU Affero General Public + License as published by the Free Software Foundation, either version + 3 of the License, or (at your option) any later version. + +* Javascript Crypto Library is distributed in the hope that it will + be useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Affero General Public License for more details. + +* You should have received a copy of the GNU Affero General Public + License along with Javascript Crypto Library. If not, see + . + +*/ + +if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } +if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } +if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } +if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; } +if (typeof(Clipperz.PM.Components.Import.CSVImport) == 'undefined') { Clipperz.PM.Components.Import.CSVImport = {}; } + +//############################################################################# + +Clipperz.PM.Components.Import.CSVImport.CSVImportNotes = function(anElement, args) { + args = args || {}; + + Clipperz.PM.Components.Import.CSVImport.CSVImportNotes.superclass.constructor.call(this, anElement, args); + this._mainComponent = args.mainComponent; + + return this; +} + +//============================================================================= + +YAHOO.extendX(Clipperz.PM.Components.Import.CSVImport.CSVImportNotes, Clipperz.PM.Components.BaseComponent, { + + 'toString': function() { + return "Clipperz.PM.Components.Import.CSVImport.CSVImportNotes component"; + }, + + //------------------------------------------------------------------------- + + 'mainComponent': function() { + return this._mainComponent; + }, + + //------------------------------------------------------------------------- + + 'render': function() { + var notesSelectorCheckboxCells; + var totalNumberOfColumns; + var titleColumnIndex; + var notesColumnIndex; + var i,c; + + Clipperz.NotificationCenter.unregister(this); + MochiKit.Signal.disconnectAllTo(this); + + this.element().update(""); + + titleColumnIndex = this.mainComponent().titleColumnIndex() + notesColumnIndex = this.mainComponent().notesColumnIndex() + + totalNumberOfColumns = this.mainComponent().parsedValues()[0].length; + + notesSelectorCheckboxCells = [{tag:'th', cls:'title', html:this.mainComponent().labelForColumn(titleColumnIndex)}]; + c = totalNumberOfColumns; + for (i=0; i= totalNumberOfColumns) || (notesColumnIndex == titleColumnIndex) || !(this.mainComponent().isColumnSelected(notesColumnIndex))) { + this.mainComponent().setNotesColumnIndex(-1); + notesColumnIndex = -1; + } + + c = totalNumberOfColumns; + for (i=0; i') : ' ')}]}; + c = aRowData.length; + for (i=0; i') : ' ')}); + } + } + + return result; + }, this, titleColumnIndex), data); + + MochiKit.Base.map(function(aRowConfig) {Clipperz.YUI.DomHelper.append(anElement, aRowConfig);}, config); + + Clipperz.Style.applyZebraStylesToTable(this.getId('previewDada')); + }, + + //------------------------------------------------------------------------- + + 'renderDataHandler': function(anEvent) { + var titleColumnIndex; + var i,c; + + this.mainComponent().setNotesColumnIndex(anEvent.src().value); + titleColumnIndex = this.mainComponent().titleColumnIndex(); + + c = this.mainComponent().parsedValues()[0].length; + for (i=0; i. + +*/ + +if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } +if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } +if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } +if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; } +if (typeof(Clipperz.PM.Components.Import.CSVImport) == 'undefined') { Clipperz.PM.Components.Import.CSVImport = {}; } + +//############################################################################# + +Clipperz.PM.Components.Import.CSVImport.CSVImportTitle = function(anElement, args) { + args = args || {}; + + Clipperz.PM.Components.Import.CSVImport.CSVImportTitle.superclass.constructor.call(this, anElement, args); + this._mainComponent = args.mainComponent; + + return this; +} + +//============================================================================= + +YAHOO.extendX(Clipperz.PM.Components.Import.CSVImport.CSVImportTitle, Clipperz.PM.Components.BaseComponent, { + + 'toString': function() { + return "Clipperz.PM.Components.Import.CSVImport.CSVImportTitle component"; + }, + + //------------------------------------------------------------------------- + + 'mainComponent': function() { + return this._mainComponent; + }, + + //------------------------------------------------------------------------- + + 'render': function() { + var titleSelectorCheckboxCells; + var titleColumnIndex; + var i,c; + + Clipperz.NotificationCenter.unregister(this); + MochiKit.Signal.disconnectAllTo(this); + + this.element().update(""); + + titleColumnIndex = this.mainComponent().titleColumnIndex() + titleSelectorCheckboxCells = []; + c = this.mainComponent().parsedValues()[0].length; + for (i=0; i= titleSelectorCheckboxCells.length) { + this.mainComponent().setTitleColumnIndex(-1); + } + + this.domHelper().append(this.element(), {tag:'div', children:[ + {tag:'div', cls:'importStepDescription', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Title']}, + {tag:'div', id:this.getId('dataDiv'), cls:'csvImportPreview', children:[ + {tag:'table', id:this.getId('previewDada'), cls:'csvImportPreview', cellspacing:'0', children:[ + {tag:'thead', id:this.getId('previewData_thead'), children:[ + {tag:'tr', children:titleSelectorCheckboxCells} + ]}, + {tag:'tbody', id:this.getId('previewData_tbody'), children:[]} + ]} + ]} + ]}); + + this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues()); + + c = this.mainComponent().parsedValues()[0].length; + for (i=0; i') : ' ')}); + } + } + + return result; + }, this), data); + + MochiKit.Base.map(function(aRowConfig) {Clipperz.YUI.DomHelper.append(anElement, aRowConfig);}, config); + + Clipperz.Style.applyZebraStylesToTable(this.getId('previewDada')); + }, + + //------------------------------------------------------------------------- + + 'renderDataHandler': function(anEvent) { + var i,c; + + this.mainComponent().setTitleColumnIndex(anEvent.src().value); + + c = this.mainComponent().parsedValues()[0].length; + for (i=0; i