PlotOutputForm.js 2.24 KB
/**
 * Project   : AMDA-NG
 * Name      : PlotOutputForm.js
 * @class   amdaPlotComp.PlotOutputForm
 * @extends amdaPlotComp.PlotStandardForm
 * @brief   Form to define output options
 * @author  Benjamin Renard
 * @version $Id: PlotOutputForm.js benjamin $
 */

Ext.define('amdaPlotComp.PlotOutputForm', {
	extend: 'amdaPlotComp.PlotStandardForm',
	
	title: 'Output options',
	
	updateOneFilePerIntOption : function() {
		var formatField = this.getForm().findField('file-format');
		var oneFilePerIntField = this.getForm().findField('one-file-per-interval');
    	
    	oneFilePerIntField.setDisabled((formatField.getValue() == 'PNG') || (formatField.getValue() == 'SVG'));
	},
	
	updateFilePrefixOption : function() {
		var prefixField = this.getForm().findField('file-prefix');
		var outputField = this.getForm().findField('file-output');
		
		if (outputField.getValue() == 'INTERACTIVE')
			prefixField.setValue("");
		prefixField.setDisabled(outputField.getValue() == 'INTERACTIVE');
	},
	
	updateOutputOption : function() {
		var formatField = this.getForm().findField('file-format');
		var outputField = this.getForm().findField('file-output');
		
    	if (formatField.getValue() == 'PNG')
    	{
    		outputField.getStore().loadData(amdaPlotObj.PlotObjectConfig.availableFileOutputsForPng);
    		outputField.setValue('INTERACTIVE');
    	}
    	else
    	{
    		outputField.getStore().loadData(amdaPlotObj.PlotObjectConfig.availableFileOutputsForOtherFormats);
    		if (outputField.getValue() == 'INTERACTIVE')
    			outputField.setValue('TGZ');
    	}
	},
	
	getFormItems: function() {
		var me = this;
		
		return [
		        this.addStandardCombo('file-format', 'File format', amdaPlotObj.PlotObjectConfig.availableFileFormats, function(name, value, oldValue) {
		        	me.updateOutputOption();
		        	me.updateOneFilePerIntOption();
		        }),
		        this.addStandardCombo('file-output', 'File output', amdaPlotObj.PlotObjectConfig.availableFileOutputs, function(name, value, oldValue) {
		        	me.updateFilePrefixOption();
		        }),
		        this.addStandardText('file-prefix', 'File prefix'),
		        this.addStandardCheck('one-file-per-interval', 'One file per interval'),
		        this.addStandardText('name', 'Request name')     
		];
	}
});