Files
luos/workflow/engine/templates/dashboard/dashletInstanceForm.js

408 lines
12 KiB
JavaScript
Raw Normal View History

2011-10-31 20:14:05 -04:00
Ext.namespace("dashletInstance");
dashletInstance.form = {
init: function () {
dashletInstanceSaveProcessAjax = function () {
var myMask = new Ext.LoadMask(Ext.getBody(), {msg: "Saving. Please wait..."});
myMask.show();
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
Ext.Ajax.request({
url: "saveDashletInstance",
method: "POST",
2011-10-31 20:50:23 -04:00
params:{"DAS_INS_UID": hiddenDasInsUID.getValue(),
2011-10-31 20:14:05 -04:00
"DAS_UID": cboDasUID.getValue(),
"DAS_INS_TYPE": cboDasInsType.getValue(),
"DAS_INS_CONTEXT_TIME": cboDasInsContextTime.getValue(),
//"DAS_INS_START_DATE": txtDasInsStartDate.getValue().format(txtDasInsStartDate.format),
//"DAS_INS_END_DATE": txtDasInsEndDate.getValue().format(txtDasInsEndDate.format),
"DAS_INS_OWNER_TYPE": cboDasInsOwnerType.getValue(),
"DAS_INS_OWNER_UID": cboDasInsOwnerUID.getValue()
//,
//"DAS_INS_PROCESSES": cboProcess.getValue(),
//"DAS_INS_TASKS": cboTask.getValue()
},
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
success:function (result, request) {
myMask.hide();
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
var dataResponse = Ext.util.JSON.decode(result.responseText)
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
switch (dataResponse.status) {
2011-10-31 20:50:23 -04:00
case "OK": //Ext.MessageBox.alert("Message", "Dashboard Instance registered correctly");
window.location.href = "dashletsList";
break;
default: Ext.MessageBox.alert("Alert", "Dashboard Instance registered failed");
break;
2011-10-31 20:14:05 -04:00
}
},
failure:function (result, request) {
myMask.hide();
Ext.MessageBox.alert("Alert", "Ajax communication failed");
}
});
}
2011-10-31 23:26:42 -04:00
2011-10-31 20:50:23 -04:00
dashletInstanceFrmLoad = function () {
2011-10-31 21:37:46 -04:00
if (dashletInstance.DAS_INS_UID) {
2011-10-31 22:10:56 -04:00
hiddenDasInsUID.setValue(dashletInstance.DAS_INS_UID)
2011-10-31 21:37:46 -04:00
cboDasUID.setValue(dashletInstance.DAS_UID);
cboDasInsType.setValue(dashletInstance.DAS_INS_TYPE);
cboDasInsContextTime.setValue(dashletInstance.DAS_INS_CONTEXT_TIME);
cboDasInsOwnerType.setValue(dashletInstance.DAS_INS_OWNER_TYPE);
2011-10-31 23:26:42 -04:00
2011-10-31 21:53:45 -04:00
//cboDasInsOwnerUID.setValue(dashletInstance.DAS_INS_OWNER_UID);
2011-10-31 20:14:05 -04:00
}
}
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
//------------------------------------------------------------------------------------------------------------------
var storeDasUID = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: "getDashlets",
2011-10-31 20:14:05 -04:00
method: "POST"
}),
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
baseParams: {"option": "DASHLST"},
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
reader: new Ext.data.JsonReader({
totalProperty: "total",
root: "dashlets",
2011-10-31 20:14:05 -04:00
fields:[{name: "DAS_UID", type: "string"},
{name: "DAS_TITLE", type: "string"}
]
}),
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
autoLoad: true, //First call
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
listeners: {
load: function (store, record, option) {
cboDasUID.setValue(store.getAt(0).get(cboDasUID.valueField));
}
}
});
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
var storeDasInsType = new Ext.data.ArrayStore({
idIndex: 0, //definimos la posicion del ID de cada registro
fields: ["id", "value"],
data: [["OPEN_CASES", "Open Cases"]
]
});
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
var storeDasInsContextTime = new Ext.data.ArrayStore({
idIndex: 0,
fields: ["id", "value"],
data: [//["RANGE", "Date Ranges"],
2011-10-31 21:29:55 -04:00
["TODAY", "Today"],
["YESTERDAY", "Yesterday"],
["THIS_WEEK", "This Week"],
["PREVIOUS_WEEK", "Previous Week"],
["THIS_MONTH", "This Month"],
["PREVIOUS_MONTH", "Previous Month"],
//["THIS_QUARTER", "This Quarter"],
//["PREVIOUS_QUARTER", "Previous Quarter"],
2011-10-31 21:29:55 -04:00
["THIS_YEAR", "This Year"],
["PREVIOUS_YEAR", "Previous Year"]
2011-10-31 20:14:05 -04:00
]
});
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
var storeDasInsOwnerType = new Ext.data.ArrayStore({
idIndex: 0,
fields: ["id", "value"],
data: [["USER", "User"],
["DEPARTMENT", "Department"],
["GROUP", "Group"]
2011-10-31 20:14:05 -04:00
]
});
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
var storeDasInsOwnerUID = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: "getOwnersByType",
2011-10-31 20:14:05 -04:00
method: "POST"
}),
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
reader: new Ext.data.JsonReader({
totalProperty: "total",
root: "owners",
fields:[{name: "OWNER_UID", type: "string"},
{name: "OWNER_NAME", type: "string"}
2011-10-31 20:14:05 -04:00
]
}),
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
autoLoad: true, //First call
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
listeners: {
beforeload: function (store) {
storeDasInsOwnerUID.baseParams = {"option": "OWNERTYPE",
"type": cboDasInsOwnerType.getValue()
};
},
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
load: function (store, record, option) {
2011-10-31 22:15:31 -04:00
if (dashletInstance.DAS_INS_UID) {
cboDasInsOwnerUID.setValue(dashletInstance.DAS_INS_OWNER_UID);
}
else {
2011-10-31 23:26:42 -04:00
cboDasInsOwnerUID.setValue(store.getAt(0).get(cboDasInsOwnerUID.valueField));
2011-10-31 22:15:31 -04:00
}
2011-10-31 20:14:05 -04:00
}
}
});
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
var storeProcess = new Ext.data.ArrayStore({
idIndex: 0,
fields: ["id", "value"],
data: [["ALL", "All"]
//,
//["SEL", "Selection"]
]
});
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
var storeTask = new Ext.data.ArrayStore({
idIndex: 0,
fields: ["id", "value"],
data: [["ALL", "All"]
//,
//["SEL", "Selection"]
]
});
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
//------------------------------------------------------------------------------------------------------------------
var hiddenDasInsUID = new Ext.form.Hidden({
id: "hiddenDasInsUID",
2011-10-31 20:53:51 -04:00
name: "DAS_INS_UID"
2011-10-31 20:14:05 -04:00
});
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
var cboDasUID = new Ext.form.ComboBox({
id: "cboDasUID",
name: "DAS_UID",
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
valueField: "DAS_UID",
displayField: "DAS_TITLE",
store: storeDasUID,
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
triggerAction: "all",
mode: "local",
editable: false,
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
width: 200,
fieldLabel: "Dashboard"
});
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
var cboDasInsType = new Ext.form.ComboBox({
id: "cboDasInsType",
name: "DAS_INS_TYPE",
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
valueField: "id",
displayField: "value",
value: "OPEN_CASES",
store: storeDasInsType,
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
triggerAction: "all",
mode: "local",
editable: false,
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
width: 200,
fieldLabel: "Type"
});
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
var cboDasInsContextTime = new Ext.form.ComboBox({
id: "cboDasInsContextTime",
name: "DAS_INS_CONTEXT_TIME",
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
valueField: "id",
displayField: "value",
2011-10-31 23:26:42 -04:00
value: "TODAY",
2011-10-31 20:14:05 -04:00
store: storeDasInsContextTime,
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
triggerAction: "all",
mode: "local",
editable: false,
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
width: 200,
fieldLabel: "Period"
});
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
var txtDasInsStartDate = new Ext.form.DateField({
id: "txtDasInsStartDate",
name: "DAS_INS_START_DATE",
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
value: new Date(2011, 0, 1), //january=0, february=1, etc
width: 100,
format: "Y/m/d",
editable: false,
fieldLabel: "Start Date"
});
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
var txtDasInsEndDate = new Ext.form.DateField({
id: "txtDasInsEndDate",
name: "DAS_INS_END_DATE",
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
value: new Date(2011, 0, 1),
width: 100,
format: "Y/m/d",
editable: false,
fieldLabel: "Finish Date"
});
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
var cboDasInsOwnerType = new Ext.form.ComboBox({
id: "cboDasInsOwnerType",
name: "DAS_INS_OWNER_TYPE",
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
valueField: "id",
displayField: "value",
value: "DEPARTMENT",
store: storeDasInsOwnerType,
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
triggerAction: "all",
mode: "local",
editable: false,
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
width: 200,
fieldLabel: "Assign To",
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
listeners: {
select: function (combo, record, index) {
storeDasInsOwnerUID.baseParams = {"option": "OWNERTYPE",
"type": combo.getValue()
};
cboDasInsOwnerUID.store.removeAll();
2011-10-31 20:14:05 -04:00
cboDasInsOwnerUID.store.load();
}
}
});
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
var cboDasInsOwnerUID = new Ext.form.ComboBox({
id: "cboDasInsOwnerUID",
name: "DAS_INS_OWNER_UID",
2011-10-31 23:26:42 -04:00
valueField: "OWNER_UID",
displayField: "OWNER_NAME",
2011-10-31 20:14:05 -04:00
store: storeDasInsOwnerUID,
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
triggerAction: "all",
mode: "local",
editable: false,
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
width: 200,
fieldLabel: "Name"
2011-10-31 20:14:05 -04:00
});
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
var cboProcess = new Ext.form.ComboBox({
id: "cboProcess",
name: "DAS_INS_PROCESSES",
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
valueField: "id",
displayField: "value",
value: "ALL",
store: storeProcess,
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
triggerAction: "all",
mode: "local",
editable: false,
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
width: 200,
fieldLabel: "Process"
});
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
var cboTask = new Ext.form.ComboBox({
id: "cboTask",
name: "DAS_INS_TASKS",
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
valueField: "id",
displayField: "value",
value: "ALL",
store: storeTask,
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
triggerAction: "all",
mode: "local",
editable: false,
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
width: 200,
fieldLabel: "Task"
});
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
//------------------------------------------------------------------------------------------------------------------
var dashletInstanceFrm = new Ext.form.FormPanel({
id: "dashletInstanceFrm",
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
style: "margin: 0 auto 0 auto;",
//labelAlign: "top",
labelWidth: 115, //The width of labels in pixels
bodyStyle: "padding:0.5em;",
border: true,
//cls: "class1",
width: 400,
//height: 400,
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
title: "New Dashboard Instance",
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
items: [hiddenDasInsUID,
cboDasUID,
cboDasInsType,
cboDasInsContextTime,
//txtDasInsStartDate,
//txtDasInsEndDate,
cboDasInsOwnerType,
2011-10-31 20:14:05 -04:00
cboDasInsOwnerUID
//,
//cboProcess,
//cboTask
],
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
buttonAlign: "right",
buttons: [new Ext.Action({
id: "btnSubmit",
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
text: "Save",
//scope: this,
handler: function () {
dashletInstanceSaveProcessAjax();
}
}),
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
//{xtype: "button",
// id: "btnReset",
// text: "Reset",
// handler: function () {
// //Ext.getCmp("dashletInstanceFrm").getForm().reset();
// dashletInstanceFrm.getForm().reset();
// //cboProcess.store.load();
// }
//},
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
{xtype: "button",
id: "btnCancel",
text: "Cancel",
handler: function () {
2011-10-31 20:31:27 -04:00
window.location.href = "dashletsList";
2011-10-31 20:14:05 -04:00
}
}
]
});
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
//------------------------------------------------------------------------------------------------------------------
2011-10-31 21:37:46 -04:00
dashletInstanceFrmLoad();
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
//------------------------------------------------------------------------------------------------------------------
var pnlMain = new Ext.Panel({
id: "pnlMain",
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
region: "center",
margins: {top:3, right:3, bottom:3, left:0},
//bodyStyle: "padding:0.5em;", //propiedades ... //no aceptaba para la derecha
bodyStyle: "padding: 25px 25px 25px 25px;", //propiedades ...
border: false,
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
items: [dashletInstanceFrm]
});
2011-10-31 23:26:42 -04:00
2011-10-31 20:14:05 -04:00
//------------------------------------------------------------------------------------------------------------------
//LOAD ALL PANELS
var viewport = new Ext.Viewport({
layout:"fit",
items:[pnlMain]
});
}
}
Ext.onReady(dashletInstance.form.init, dashletInstance.form);