/**
* Project : AMDA-NG
* Name : FeedbackUI.js
* @plugin amdaUI.FeedbackUI
* @extends Ext.panel.Panel
* @brief Feedback view
* @author Benjamin
* @version $Id: FeedbackUI.js 2031 2014-01-22 11:28:34Z elena $
*/
Ext.define('amdaUI.FeedbackUI', {
extend: 'Ext.form.Panel',
alias: 'widget.panelFeedback',
constructor: function(config) {
this.init(config);
this.callParent(arguments);
},
getInfoMsg : function()
{
return '
Welcome,
' +
'You have problems/comments'+
'Please select an item[s] from a list below and describe the problem...';
},
getBrowserInfo : function()
{
return Ext.browser.name+' - '+Ext.browser.engineName+' - '+Ext.browser.engineVersion;
},
getUser : function()
{
return sessionID;
},
getInterfaceList : function()
{
return [
['General','General'],
['Plot_Data','Plot Data'],
['Data_mining','Data mining'],
['My_Parameters','Parameters'],
['My_Time_Tables','Time Tables'],
['My_Catalogs','Catalogs'],
['Statistics', 'Statistics'],
['Download_Data','Download Data'],
['Upload_Data','Upload Data'],
['Interoperability','Interoperability'],
['Add_External_Data','External Data']
];
},
onSendFinish : function(result, e){
var t = e.getTransaction();
if (e.status)
{
if (result && result == 'none')
{
// SUCCESS
var win = myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.feedback.id);
Ext.MessageBox.show({
title: 'Feedback sent',
msg: 'Thanks for your feedback',
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.INFO,
fn: function (btn){
win.close();
}
});
}
else
{
//ERROR
var msgErr = 'Unknown error';
switch (result)
{
case 'err_user' :
msgErr = 'User not defined';
break;
case 'err_file' :
msgErr = 'Feedback file error';
break;
}
Ext.Msg.show({title:'Error', msg: msgErr, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK});
}
}
else
{
// FAILURE
Ext.Msg.show({title:'Error System', msg: e.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK});
}
},
onSendIssue : function(b,e){
//get links to components
var fieldset = this.getComponent('feedback_fieldset');
var fieldsubject = fieldset.getComponent('subject_checkboxgroup');
var fielduser = fieldset.getComponent('user_displayfield');
var fieldbrowser = fieldset.getComponent('browser_displayfield');
var fieldattach = fieldset.getComponent('attach_filefield');
var fieldinterface = fieldset.getComponent('interface_combo');
var fielddes = fieldset.getComponent('desc_textarea');
//test if some fields are valid
if (!fieldsubject.isValid() || !fielddes.isValid())
{
Ext.Msg.show({title:'Error', msg: 'Some field are required', icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK});
return;
}
//generate subject message (a list of all checked boxes)
var subjectMsg = '';
fieldsubject.items.each(function (item){
if (!item.checked)
return;
if (subjectMsg != '')
subjectMsg += ' - ';
subjectMsg += item.boxLabel;
},this);
//make the object to send
var feed = {user : fielduser.getValue(),
interface : fieldinterface.getValue(),
subject : subjectMsg,
userText : fielddes.getValue(),
userAgent : fieldbrowser.getValue(),
attach : fieldattach.getValue()};
if (feed.attach != '')
{
this.submit({
scope : this,
url: 'php/uploadFile.php',
waitMsg: 'Uploading your file...',
success: function(form, o)
{
feed.attach = o.result.file;
//call action
AmdaAction.sendFeedback(feed,this.onSendFinish,this);
},
failure: function(form, o)
{
Ext.Msg.show( {
title : 'Feedback - Upload attachment',
msg : 'Error '+o.result.error,
modal : true,
icon : Ext.Msg.ERROR,
buttons : Ext.Msg.OK
});
}
});
}
else
//call action
AmdaAction.sendFeedback(feed,this.onSendFinish,this);
},
init : function(config)
{
var myConf = {
layout: 'fit',
bodyStyle: { background: '#ddecfe'},
items : [{
xtype: 'fieldset',
itemId: 'feedback_fieldset',
layout: 'anchor',
anchor: '100%',
items : [
{
xtype: 'displayfield',
itemId: 'info_displayfield',
name: 'information',
height : 80,
fieldLabel: '',
anchor: '100%',
value: this.getInfoMsg()
},
{
xtype: 'checkboxgroup',
itemId: 'subject_checkboxgroup',
fieldLabel: 'Subject',
anchor: '100%',
columns : 3,
vertical: true,
allowBlank: false,
items: [
{boxLabel: 'Bug', inputValue: 'bug', checked: true},
{boxLabel: 'Question', inputValue: 'question'},
{boxLabel: 'Data', inputValue: 'data'},
{boxLabel: 'Comment', inputValue: 'comment'},
{boxLabel: 'Other', inputValue: 'other'}
]
},
{
xtype: 'displayfield',
itemId: 'user_displayfield',
fieldLabel: 'User',
anchor: '100%',
name: 'user',
value: this.getUser()
},
{
xtype: 'displayfield',
itemId: 'browser_displayfield',
fieldLabel: 'Browser',
anchor: '100%',
name: 'browser',
value: this.getBrowserInfo()
},
{
xtype: 'filefield',
itemId: 'attach_filefield',
anchor: '100%',
name: 'attachment',
fieldLabel: 'Attachment',
buttonText: 'Select File...',
emptyText : 'none'
},
{
xtype: 'combo',
itemId: 'interface_combo',
fieldLabel: 'Interface',
name: 'interface',
store: this.getInterfaceList(),
value: 'General',
forceSelection: true,
anchor: '100%',
autoSelect: true,
allowBlanck: false
},
{
xtype : 'textareafield',
itemId: 'desc_textarea',
anchor: '100%',
height : 200,
name: 'description',
fieldLabel: 'Description',
allowBlank: false
},
{
xtype : 'hiddenfield',
name: 'MAX_FILE_SIZE',
value: '3000000' // 3MB
}
]
}],
dockedItems: [{
xtype: 'toolbar',
dock: 'bottom',
items: [
'->',
{
iconCls: 'icon-feedback',
text: 'Send',
scope: this,
tooltip: 'Send feeback',
handler: this.onSendIssue
}
]
}]
}
Ext.apply (this , Ext.apply (arguments, myConf));
}
});