#parse ("timemanager.vm")
#set ($demand_table_title = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demandtable.title"))
#set ($table_refresh = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demandtable.refresh"))
#set ($table_refresh_tooltip = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demandtable.refresh.tooltip"))
#set ($answer_question_text = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demandtable.answer.question"))
#set ($table_add_title_text = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "Demand", "demandtable.add.title"))
#set ($table_update_title_text = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "Demand", "demandtable.update.title"))
#set ($table_desc_text = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "Demand", "demandtable.desc"))
#set ($table_save_text = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "Demand", "demandtable.save"))
#set ($table_cancel_text = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "Demand", "demandtable.cancel"))
#set ($table_error = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demandtable.error"))
#set ($table_warning = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demandtable.warning"))
#set ($table_save_msg = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demandtable.save.msg"))
#set ($table_add_text = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "Demand", "demandtable.add"))
#set ($table_add_tooltip_text = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "Demand", "demandtable.add.tooltip"))
#set ($table_delete_text = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "Demand", "demandtable.delete"))
#set ($table_delete_tooltip_text = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "Demand", "demandtable.delete.tooltip"))
#set ($table_load_msg = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "Demand", "demandtable.load.msg"))
#set ($table_demandname_text = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "Demand", "demandtable.name"))
#set ($table_submittedby_text = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "Demand", "demandtable.submittedby"))
#set ($table_requesttime_text = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "Demand", "demandtable.requesttime"))
#set ($table_submittedto_text = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "Demand", "demandtable.submittedto"))
#set ($table_requesttype_text = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "Demand", "demandtable.requesttype"))
#set ($table_demandstatus_text = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "Demand", "demandtable.demandstatus"))
#set ($table_association_text = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "Demand", "demandtable.demandassociation"))
#set ($table_demandfor_text = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "Demand", "demandtable.demandrequestfor"))
#set ($table_filter_title = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "Demand", "demandtable.filter.title"))
#set ($table_filter_select = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "Demand", "demandtable.filter.select"))
#set ($table_filter_all_mine = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "Demand", "demandtable.filter.all.mine"))
#set ($table_filter_submitted_to = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "Demand", "demandtable.filter.submitted.to"))
#set ($table_filter_submitted_by = $CommonFunctions.getEncodedTermFromResourceBundle($currentUserId, "Demand", "demandtable.filter.submitted.by"))
#set ($emptytext_demandtype = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demanddlg.general.emptytextdemandtype"))
#set ($emptytext_submittedto = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demanddlg.general.emptytextsubmittedto"))
#set ($emptytext_status = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demanddlg.general.emptytextstatus"))
#set ($emptytext_association = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demanddlg.general.emptytextassociaiton"))
#set ($emptytext_reqfor = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demanddlg.general.emptytextrequestfor"))
#set ($general_title = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demanddlg.general.title"))
#set ($associations_title = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demanddlg.associations.title"))
#set ($forms_title = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demandforms.title"))
#set ($collaboration_title = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demanddlg.collaboration.title"))
#set ($artifact_title = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demanddlg.artifacts.title"))
#set ($promote_artifact_tooltip = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demand.artifact.promote.tooltip"))
#set ($promote_button = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demand.artifact.promote.button"))
#set ($field_required_text = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demand.fieldrequired"))
#set ($true_text = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Controls","controls.common.true"))
#set ($false_text = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Controls","controls.common.false"))
#set ($instructions_text = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demandforms.instructions"))
#set ($collaboration_discussiongridexpander_title = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demand.collaboration.discussiongridexpander.title"))
#set ($collaboration_commentcolumn_header = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demand.collaboration.commentcolumn.header"))
#set ($collaboration_usercolumn_header = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demand.collaboration.usercolumn.header"))
#set ($collaboration_timecolumn_header = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demand.collaboration.timecolumn.header"))
#set ($collaboration_discussiongrid_title = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demand.collaboration.discussiongrid.title"))
#set ($collaboration_addcomment_btn = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demand.collaboration.addcomment.btn"))
#set ($collaboration_errordlg_title = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demand.collaboration.errordlg.title"))
#set ($collaboration_errordlg_msg = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demand.collaboration.errordlg.msg"))
#set ($delete_demand_title = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demand.delete.title"))
#set ($delete_demand_message = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demand.delete.message"))
#set ($not_set_text = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demand.notset"))
#set ($required_response_title = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demandquestions.responserequired.title"))
#set ($required_response_message = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demandquestions.responserequired.message"))
#set ($required_toanswer_text = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"ProjectDialogs","wizard.questionspage.requiresquestion.hint"))
#set ($forms_not_answered_text = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"AdminDialogs","responsetypetype.notanswered"))
#set ($parent_delete_demand_message = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","parent.delete.demand.message"))
#set ($duplicates_warning_title = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demand.duplicates.warning.title"))
#set ($duplicates_warning_message = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demand.duplicates.warning.message"))
#set ($promote_error_message = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demand.artifact.promote.error.message"))
#set ($select_artifact_message = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demandtable.select.artifact.message"))
#set ($select_project_message = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demandtable.select.project.message"))
#set ($valid_artifact_type_message = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demandtable.valid.artifact.type"))
#set ($table_delete_form_title = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demandtable.delete.form.title"))
#set ($table_delete_form_message = $CommonFunctions.displayTermFromResourceBundle($currentUserId,"Demand","demandtable.delete.form.message"))
var FORM_LOAD_ALL = "FORM_LOAD_ALL";
var FORM_LOAD = "FORM_LOAD";
Ext.namespace('Ext.gemini');
Ext.BLANK_IMAGE_URL = '../common/ext3/resources/images/default/s.gif';
#if ($viewId == "trackedDemandList")
Ext.gemini.filterTypes = [['0', '$table_filter_all_mine'],
['1', '$table_filter_submitted_to'],
['2', '$table_filter_submitted_by']
];
#end
var demandTable = {
demandId : null,
formGroupMap : [],
oldQuestionResponses : null,
requestTypeId : null,
requestForId : null,
detailDialog : null,
dataFilter : null,
userFilter : null,
demandUserRec: null,
statusFilter: null,
statusArray: null,
addButton : null,
deleteButton : null,
refreshButton : null,
descPanel : null,
ds : null,
gridCtrl : null,
toolbar : null,
requestTypeCombo: null,
submittedToCombo: null,
requestForCombo: null,
deafaultSubmittedTo: null,
manualSubmittedTo: null,
defaultSubmittedToText: null,
submittedToComboLabel: null,
statusCombo: null,
demandUserFilterDS: null,
requestTypeDS: null,
submittedToDS: null,
requestForDS: null,
loadDlgComponents: null,
demandStatusDS: null,
demandStatusRec: null,
commentsDS: null,
commentEditor: null,
associationUserDS: null,
associationRoleDS: null,
associationRoleRec: null,
associationsGridCtrl: null,
artifactsDS: null,
artifactRec: null,
artifactsGridCtrl: null,
discussionGridCtrl: null,
projectsDS: null,
statusDS: null,
isLoaded : false,
storyName: null,
storyDesc: null,
numFields: [],
dateFields: [],
demandTableRecord: null,
init : function() {
TimeManager.init();
Ext.QuickTips.init();
BxtLoadUtil.loadWidget(
'ajax2/Gemini?action=demand.web.ajax.GetDemandFiltersAction&viewId=$viewId',
{
statusFilter: true,
#if ($viewId == "trackedDemandList")
demandFilter: 'demandFilter',
#else
userDemandFilter: 'userDemandFilter',
#end
statusDemandFilter: 'statusDemandFilter'
},
null,
null,
demandTable.loadDlgComponents
);
demandTable.demandTableRecord = Ext.data.Record.create([
{name: 'demandId'},
{name: 'requestType', sortType:'asUCString'},
{name: 'status', sortType:'asUCString'},
{name: 'submittedBy', sortType:'asUCString'},
{name: 'requestTime', sortType:'asUCString'},
{name: 'requestTimeDisplay', sortType:'asDate'},
{name: 'submittedTo', sortType:'asUCString'},
{name: 'name', sortType:'asUCString'},
{name: 'useManual', sortType:'asUCString'},
#if ( ($dfList.size() == 0) || (!$canManageDemandItems) )
{name: 'description'}
#else
{name: 'description'},
#end
#if ($canManageDemandItems)
#set ($i = 1)
#foreach($col in $dfList)
#if ($i == $dfList.size())
{name: '$col.getFormId()', sortType:'asFloat'}
#else
{name: '$col.getFormId()', sortType:'asFloat'},
#end
#set ($i = $i + 1)
#end
#end
]);
var ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'ajax2/Gemini?action=demand.web.ajax.GetAllDemandsAction&viewId=$viewId&dependsProjectId=$dependsProjectId',
params : {start:0, limit:25, viewId: '$viewId'}
}),
reader: new Ext.data.JsonReader(
{
sortField: 'sortField',
sortDirection: 'sortDirection',
root: 'rows',
#if ($viewId == "trackedDemandList")
demandFilter: 'demandFilter',
#else
userDemandFilter: 'userDemandFilter',
#end
statusDemandFilter: 'statusDemandFilter',
deleteMsg :'deleteMsg'
},
demandTable.demandTableRecord
)
});
ds.load({waitMsg:'$table_load_msg'});
ds.on('loadexception', function(proxy, data, arg, e) {
Ext.MessageBox.show({
title: 'Error',
msg: arg.responseText,
buttons: Ext.MessageBox.OK
});
});
ds.on('load', function(store, records, options){
var deleteMessage = store.reader.jsonData.deleteMsg;
if(deleteMessage){
Ext.Msg.show({
title:'$delete_demand_title',
msg: ''+deleteMessage+' $parent_delete_demand_message',
buttons: Ext.Msg.OK,
icon: Ext.MessageBox.INFO
});
}
demandTable.ds.sort( store.reader.jsonData.sortField, store.reader.jsonData.sortDirection );
});
demandTable.ds = ds;
var xg = Ext.grid;
// row expander
var expander = new xg.RowExpander({
tpl : new Ext.Template(
'
$table_desc_text: {description}
'
)
});
demandTable.gridCtrl = new xg.GridPanel({
ds: ds,
autoExpandColumn: 'name',
cm: new xg.ColumnModel([
expander,
{id:'name', header: '$table_demandname_text', width: 200, sortable: true, dataIndex: 'name', renderer: this.containerName},
{header: '$table_requesttype_text', width: 80, sortable: true, dataIndex: 'requestType'},
{header: '$table_demandstatus_text', width: 100, sortable: true, dataIndex: 'status'},
{header: '$table_submittedby_text', width: 120, sortable: true, dataIndex: 'submittedBy'},
{header: '$table_requesttime_text', width: 100, sortable: true, dataIndex: 'requestTimeDisplay'},
#if ( ($dfList.size() == 0) || (!$canManageDemandItems) )
{header: '$table_submittedto_text', width: 140, sortable: true, dataIndex: 'submittedTo'}
#else
{header: '$table_submittedto_text', width: 140, sortable: true, dataIndex: 'submittedTo'},
#end
#if ($canManageDemandItems)
#set ($i = 1)
#foreach($col in $dfList)
#if ($i == $dfList.size())
{header: "$col.getSummaryLabel()", width: 75, sortable: true, dataIndex: '$col.getFormId()'}
#else
{header: "$col.getSummaryLabel()", width: 75, sortable: true, dataIndex: '$col.getFormId()'},
#end
#set ($i = $i + 1)
#end
#end
]),
loadMask: {msg:'$table_load_msg'},
frame:false,
collapsible: false,
animCollapse: false,
#if ($dependsProjectId == "notset")
tbar:[],
title:'$demand_table_title',
headerAsText:true,
#end
layout:'fit',
renderTo: document.body,
enableHdMenu: false,
plugins: expander
});
demandTable.gridCtrl.on('sortchange', function(grid, sortInfo){
Ext.Ajax.request({
url : 'ajax2/Gemini?action=common.admin.user.web.ajax.SaveUserSettingsAction',
params : {start:0, limit:25, viewId: '$viewId', key: 'sort', value: sortInfo.field+","+sortInfo.direction}});
});
demandTable.demandStatusRec = Ext.data.Record.create( [
{ name:'statusId' },
{ name:'name', sortType:'asUCString' }
]);
demandTable.demandStatusDS = new Ext.data.Store({
id : 0,
proxy: new Ext.data.HttpProxy({url:'ajax2/Gemini?action=demand.web.ajax.GetDemandFiltersAction&viewId=statusFilter'}),
reader: new Ext.data.JsonReader({
root: 'statuses'
}, demandTable.demandStatusRec)
});
demandTable.demandStatusDS.on('load', function() {
demandTable.demandStatusArray = new Array();
var ds = demandTable.demandStatusDS;
for (var i = 0;i < ds.getCount();i++) {
var status = ds.getAt(i);
demandTable.demandStatusArray[i] = {
'statusId' : status.get('statusId'),
'name' : status.get('name')
};
}
});
demandTable.statusFilter = new Ext.form.ComboBox({
id: 'statusFilter',
fieldLabel: '$table_demandstatus_text',
name:'name',
hiddenName:'name',
store: demandTable.demandStatusDS,
valueField:'statusId',
displayField:'name',
triggerAction: 'all',
emptyText:'$emptytext_status',
editable: false,
width: 235,
mode: 'local',
allowBlank:false
});
#if ($viewId == "trackedDemandList")
demandTable.dataFilter = new Ext.form.ComboBox({
id: 'dataFilter',
fieldLabel: '$table_filter_title',
hiddenName:'dataFilterId',
store: new Ext.data.SimpleStore({
fields: ['typeId', 'typeName'],
data : Ext.gemini.filterTypes
}),
valueField:'typeId',
displayField:'typeName',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'$table_filter_select',
editable: false,
selectOnFocus:true,
grow: false,
resizable:false,
width:175,
allowBlank:false
});
#else
demandTable.demandUserRec = Ext.data.Record.create( [
{ name:'userId' },
{ name:'name', sortType:'asUCString' }
]);
demandTable.demandUserFilterDS = new Ext.data.Store({
id : 0,
proxy: new Ext.data.HttpProxy({url:'ajax2/Gemini?action=demand.web.ajax.GetDemandFiltersAction'}),
reader: new Ext.data.JsonReader({
root: 'users'
}, demandTable.demandUserRec),
sortInfo:{field: 'name', direction: "ASC"}
});
demandTable.demandUserFilterDS.on('load', function() {
demandTable.demandUserArray = new Array();
var ds = demandTable.demandUserFilterDS;
for (var i = 0;i < ds.getCount();i++) {
var user = ds.getAt(i);
demandTable.demandUserArray[i] = {
'userId' : user.get('userId'),
'name' : user.get('name')
};
}
});
demandTable.userFilter = new Ext.form.ComboBox({
id: 'userFilter',
fieldLabel: '$table_filter_title',
hiddenName:'name',
store: demandTable.demandUserFilterDS,
valueField:'userId',
displayField:'name',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'$table_filter_select',
editable: true,
selectOnFocus:true,
grow: false,
resizable:false,
width:175,
allowBlank:false
});
#end
#if ($viewId == "trackedDemandList")
demandTable.dataFilter.on('select', function(){
ds .reload( {params : {start:0, limit:25, filterDemands:demandTable.dataFilter.getValue(), statusFilterDemands:demandTable.statusFilter.getValue()}} );
Ext.Ajax.request({
url : 'ajax2/Gemini?action=common.admin.user.web.ajax.SaveUserSettingsAction',
params : {start:0, limit:25, viewId: '$viewId', key: 'demandFilter', value: demandTable.dataFilter.getValue()}
});
});
demandTable.statusFilter.on('select', function(){
ds .reload( {params : {start:0, limit:25, filterDemands:demandTable.dataFilter.getValue(), statusFilterDemands:demandTable.statusFilter.getValue()}} );
Ext.Ajax.request({
url : 'ajax2/Gemini?action=common.admin.user.web.ajax.SaveUserSettingsAction',
params : {start:0, limit:25, viewId: '$viewId', key: 'statusDemandFilter', value: demandTable.statusFilter.getValue()}
});
});
#else
demandTable.userFilter.on('select', function(){
ds .reload( {params : {start:0, limit:25, userFilterDemands:demandTable.userFilter.getValue(), statusFilterDemands:demandTable.statusFilter.getValue()}} );
Ext.Ajax.request({
url : 'ajax2/Gemini?action=common.admin.user.web.ajax.SaveUserSettingsAction',
params : {start:0, limit:25, viewId: '$viewId', key: 'userDemandFilter', value: demandTable.userFilter.getValue()}
});
});
demandTable.statusFilter.on('select', function(){
ds .reload( {params : {start:0, limit:25, userFilterDemands:demandTable.userFilter.getValue(), statusFilterDemands:demandTable.statusFilter.getValue()}} );
Ext.Ajax.request({
url : 'ajax2/Gemini?action=common.admin.user.web.ajax.SaveUserSettingsAction',
params : {start:0, limit:25, viewId: '$viewId', key: 'statusDemandFilter', value: demandTable.statusFilter.getValue()}
});
});
#end
#if ($dependsProjectId == "notset")
demandTable.addButton = new Ext.Toolbar.Button({
text:'$table_add_text',
tooltip:'$table_add_tooltip_text',
id:'addDemand',
iconCls:'add' #if (!$canManageDemandItems && !$canMakeRequests),
disabled: true #end
});
demandTable.deleteButton = new Ext.Toolbar.Button({
text:'$table_delete_text',
tooltip:'$table_delete_tooltip_text',
iconCls:'remove' #if (!$canManageDemandItems),
disabled: true #end
});
demandTable.refreshButton = new Ext.Toolbar.Button({
text:'$table_refresh',
tooltip:'$table_refresh_tooltip',
iconCls:'refresh'
});
demandTable.toolbar = demandTable.gridCtrl.getTopToolbar();
demandTable.refreshButton.on('click', function(){
demandTable.ds.reload({waitMsg:'$table_load_msg',params:{start:0, limit:25, #if ($viewId == "trackedDemandList") filterDemands:demandTable.dataFilter.getValue(), #else filterDemands:demandTable.userFilter.getValue(), #end statusFilterDemands:demandTable.statusFilter.getValue(), action:'LOADTASKS'}});
});
demandTable.addButton.on('click', function() {
demandTable.formPanel.form.reset();
demandTable.showFormDetails('');
demandTable.oldQuestionResponses = null;
});
demandTable.deleteButton.on('click', function() {
var selections = demandTable.gridCtrl.selModel.getSelections();
var selectlen = selections.length;
if(selectlen > 0) {
Ext.Msg.show({
title:'$delete_demand_title',
msg: '$delete_demand_message',
buttons: Ext.Msg.YESNO,
fn: demandTable.onRemove,
icon: Ext.MessageBox.QUESTION,
animEl : demandTable.deleteButton.getEl()
});
}
});
demandTable.toolbar.add('->');
demandTable.toolbar.add(demandTable.statusFilter);
demandTable.toolbar.add(' ');
demandTable.toolbar.add(' ');
demandTable.toolbar.add(' ');
#if ($viewId == "trackedDemandList")
demandTable.toolbar.add(demandTable.dataFilter);
#else
demandTable.toolbar.add(demandTable.userFilter);
#end
demandTable.toolbar.add('-');
demandTable.toolbar.add(demandTable.addButton);
demandTable.toolbar.add(demandTable.deleteButton);
demandTable.toolbar.add(demandTable.refreshButton);
#end // $dependsProjectId == "notset"
#parse("demandgeneraltab.vm")
#parse("demandassociationstab.vm")
#parse("demandformstab.vm")
#parse("demandcollaborationtab.vm")
#parse("demandartifactstab.vm")
#parse("demandDuplicateTab.vm")
demandTable.tabPanel = new Ext.TabPanel({
deferredRender:false,
id: 'tabPanel',
height: 450,
activeTab: 0,
items:[
{ title: '$general_title',
tabId: 0,
id: 'generalTab',
items: [
demandTable.descTabPanel
]
},
{
title: '$associations_title',
tabId : 1,
id: 'associationsTab',
autoScroll: true,
listeners:{
activate : function(panel){
demandTable.associationsGridCtrl.syncSize();
}
},
items: [
demandTable.associationsTabPanel
]
},
{
title: '$forms_title',
tabId : 2,
id: 'formsTab',
autoScroll: true,
items: [
demandTable.formsTabPanel
]
},
{
title: '$collaboration_title',
tabId : 3,
id: 'collaborationTab',
listeners:{
activate : function(panel){
demandTable.discussionGridCtrl.syncSize();
}
},
items: [
demandTable.collaborationTabPanel
]
},
{
title: '$artifact_title',
tabId : 4,
id: 'artifactsTab',
listeners:{
activate : function(panel){
demandTable.artifactsGridCtrl.syncSize();
}
},
items: [
demandTable.artifactsTabPanel
]
},
{ title: '$duplicates_title',
tabId: 5,
id: 'duplicatesTab',
autoScroll: true,
listeners:{
activate : function(panel){
demandTable.duplicateDemandgrid.syncSize();
}
},
items: [
demandTable.duplicatesTabPanel
]
}
]
});
demandTable.formPanel = new Ext.FormPanel({
buttonAlign: 'right',
labelAlign: 'right',
labelWidth: 75,
frame:true,
defaultType: 'textfield',
//defaults: {width: 170},
waitMsgTarget: true,
reader: new Ext.data.JsonReader({id: 'demandId'},
['demandId', 'requestTypeId', 'requestForId', 'defaultSubmittedToId', 'submittedToId', 'defaultSubmittedToName', 'submittedBy', 'submittedById', 'statusId', 'name', 'description' ]),
items:[ demandTable.tabPanel ],
buttons:[
{
text: '$table_save_text',
id: 'saveDemand',
#if (!$canManageDemandItems && !$canMakeRequests)
disabled: true,
#end
handler: function() {
//if default submitted to, set the submittedTo combo box value to blank, so that it returns true for validation
if(!demandTable.descTabPanel.findById('manualSubmittedToPanel').isVisible()){
demandTable.descTabPanel.findById('submittedTo').setValue(' ');
}
if (!demandTable.formPanel.getForm().isValid()) {
demandTable.tabPanel.setActiveTab( 0 );
return;
}
if (!demandTable.isAssociationsValid()) {
demandTable.tabPanel.setActiveTab( 1 );
return;
}
if (!demandTable.isFormTabValid()) {
demandTable.tabPanel.setActiveTab( 2 );
return;
}
if (!demandTable.isArtifactsTabValid()) {
demandTable.tabPanel.setActiveTab( 4 );
return;
}
if(demandTable.statusCombo.getValue() == '000000000000'
&& (!demandTable.descTabPanel.findById('origDemandId').getValue()
|| demandTable.descTabPanel.findById('origDemandId').getValue()=="")){
Ext.MessageBox.show({
title: '$duplicates_warning_title',
msg: '$duplicates_warning_message',
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.WARNING
});
return;
}
var associations = [];
var i = 0;
demandTable.associationRoleDS.each ( function (item) {
associations[i] = {
'demandAssociationId' : item.get('demandAssociationId'),
'roleId' : item.get('roleId'),
'role' : item.get('role'),
'userId' : item.get('userId'),
'userName' : item.get('userName')
};
i = i + 1;
});
var comments = [];
var i = 0;
demandTable.commentsDS.each ( function (item) {
if (item.get('commentId') == '') {
comments[i] = {
'commentId' : '',
'commentTitle': item.get('commentTitle'),
'comment': item.get('comment'),
'userId': item.get('userId'),
'user': '',
'timeStamp': item.get('timeStamp')
};
i = i + 1;
}
});
var artifacts = [];
var i = 0;
demandTable.artifactsDS.each ( function (item) {
var desc = item.get('description');
if (desc == null) {
desc = "";
}
artifacts[i] = {
'artifactId' : item.get('artifactId'),
'name': item.get('name'),
'description': desc,
'typeId': item.get('typeId'),
'projectId': item.get('projectId')
};
i = i + 1;
});
var dFields = demandTable.dateFields;
for (var i = 0; i < dFields.length; i++) {
var d = dFields[i].getValue();
dFields[i].format = 'Y-m-d';
dFields[i].setValue(d);
}
// This is to support the European number separator ','.
// If NumberField contains a ',' separator, it will be replaced with a '.' separator.
var nFields = demandTable.numFields;
for (var i = 0; i < nFields.length; i++) {
nFields[i].setRawValue(nFields[i].getValue());
}
// This hides the fact that the '.' shows up with the above code.
demandTable.tabPanel.setActiveTab( 0 );
var submittedTo;
var useManual = "N";
//if its's manual submitted to or request for is not set, get the combobox value
if((demandTable.descTabPanel.findById('manualSubmittedTo').getValue()) ||(demandTable.descTabPanel.findById('demandId').getValue()=="") && (demandTable.requestForCombo.getValue()==""))
submittedTo = demandTable.descTabPanel.findById('submittedTo').getValue();
else
submittedTo = demandTable.defaultSubmittedToDS.getAt(0).get('defaultSubmittedToId');
//if it's a new demand with manual submitted to or in edit mode with manual selection or an existing demand(in which case this will be null)
if((demandTable.descTabPanel.findById('manualSubmittedTo').getValue())||((demandTable.descTabPanel.findById('demandId').getValue()=="") && (demandTable.requestForCombo.getValue()==""))||useManual=="")
useManual = "Y";
//Enable forms tab so the values can be persisted in action class
demandTable.formsTabEnable();
demandTable.formPanel.form.submit({url:'ajax2/Gemini',
waitMsg: '$table_save_msg',
params: {action:'demand.web.ajax.SaveDemandAction',
name: demandTable.descTabPanel.findById('demandName').getValue(),
description: demandTable.descTabPanel.findById('demandDescription').getValue(),
requestTypeId: demandTable.requestTypeCombo.getValue(),
requestForId: demandTable.requestForCombo.getValue(),
//submittedToId: demandTable.submittedToCombo.getValue(),
submittedToId: submittedTo,
useManual: useManual,
associations: Ext.util.JSON.encode(associations),
comments: Ext.util.JSON.encode(comments),
artifacts: Ext.util.JSON.encode(artifacts)},
success: function(form, action) {
demandTable.detailDialog.hide();
demandTable.ds.load(
{waitMsg:'$table_load_msg',
params:{start:0, limit:25, #if ($viewId == "trackedDemandList") filterDemands:demandTable.dataFilter.getValue(), #else filterDemands:demandTable.userFilter.getValue(), #end statusFilterDemands:demandTable.statusFilter.getValue()}});
},
failure:function(form, action) {
if(demandTable.statusCombo.getValue() == '000000000000'){
demandTable.formsTabDisable();
}
if (action.result) {
Ext.MessageBox.show({
title: '$table_error',
msg: action.result.data[0].msg,
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.ERROR
});
}
}
});
}
},
{
text: '$table_cancel_text',
id: 'cancelDemand',
handler: function() {
demandTable.detailDialog.hide();
}
}
]
});
if (!demandTable.detailDialog) {
demandTable.detailDialog = new Ext.Window({
title: '$table_update_title_text',
layout: 'fit',
width:680,
height:500,
closeAction:'hide',
plain: true,
items: demandTable.formPanel,
modal: true,
resizable : false,
renderTo: document.body
});
};
//demandTable.requestTypeDS.load({waitMsg:'$loadmsg_text'});
},
// ---------- Delete Form ----------
onDeleteForm : function(formId, name, el) {
Ext.Msg.show({
title:'$table_delete_form_title',
msg: "$table_delete_form_message '" + name + "'?",
buttons: Ext.Msg.OKCANCEL,
fn: formstable.deleteForm,
icon: Ext.MessageBox.QUESTION,
animEl : el
});
},
onRemove : function(val) {
if(val == "yes"){
var selections = demandTable.gridCtrl.selModel.getSelections();
var ids = "";
for (i = 0; i < selections.length; i++) {
var record = selections[i];
if (ids != "") {
ids += ",";
}
ids += record.data.demandId;
}
demandTable.deleteForms( ids );
}
},
deleteForms : function (ids, dupliRecordDS) {
demandTable.ds.load({
waitMsg: '$deletemsg',
params:{start:0, limit:25, group:'YES', subAction: 'DELETE', deleteids:ids, #if ($viewId == "trackedDemandList") filterDemands:demandTable.dataFilter.getValue(), #else filterDemands:demandTable.userFilter.getValue(), #end statusFilterDemands:demandTable.statusFilter.getValue()},
callback: function(records, options, success){
if(dupliRecordDS){
dupliRecordDS.load({waitMsg:'$loadmsg_text', params:{demandId:demandTable.demandId}});
}
}
});
},
loadFormsData : function (demandId, requestTypeId, statusId, associationIds, associationUserIds, submittedToId) {
Ext.Ajax.request({
url : 'ajax2/Gemini?action=demand.web.ajax.GetAllApplicableFormsAction',
params : {start:0, limit:25, requestTypeId: requestTypeId, demandId: demandId,
statusId: statusId, associationIds: associationIds,
associationUserIds: associationUserIds, submittedToId: submittedToId },
success: function (response, options) {
demandTable.initForms( Ext.util.JSON.decode( response.responseText ) );
if(demandTable.statusCombo.getValue() == '000000000000'){
disableOnDuplicate();
} else {
enableOnNonDuplicate();
}
}
});
},
loadData : function(demandId) {
demandTable.projectsDS.load({waitMsg:'$loadmsg_text', params:{demandId:demandId},
callback: function (records, options, success) {
if (success) {
demandTable.loadFormDetails( options.params.demandId );
}
}
});
demandTable.associationRoleDS.load({waitMsg:'$loadmsg_text', params:{demandId:demandId}});
demandTable.associationUserDS.load({waitMsg:'$loadmsg_text'});
demandTable.commentsDS.load({waitMsg:'$loadmsg_text', params:{demandId:demandId}});
demandTable.artifactsDS.load({waitMsg:'$loadmsg_text', params:{demandId:demandId}});
demandTable.dupliDemandDs.load({waitMsg:'$loadmsg_text', params:{demandId:demandId}});
},
containerName : function(value, metadata, record, rowindex, colindex, store) {
var title = value;
var demandId = record.get('demandId');
var useManual = record.get('useManual');
return "