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

353 lines
10 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",
params: dashletInstanceFrm.getForm().getFieldValues(),
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) {
case "OK": window.location.href = "dashletsList";
2011-10-31 20:50:23 -04:00
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: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,
2011-10-31 20:14:05 -04:00
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 {
if (store.getAt(0)) {
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
width: 325,
2011-10-31 20:14:05 -04:00
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
width: 325,
2011-10-31 20:14:05 -04:00
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
width: 325,
2011-10-31 20:14:05 -04:00
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
width: 325,
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()
};
2011-11-14 20:16:13 -04:00
dashletInstance.DAS_INS_OWNER_UID = '';
cboDasInsOwnerUID.store.removeAll();
cboDasInsOwnerUID.clearValue();
cboDasInsOwnerUID.store.reload();
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 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
width: 325,
fieldLabel: "Name",
allowBlank: false
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
width: 325,
2011-10-31 20:14:05 -04:00
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
width: 325,
2011-10-31 20:14:05 -04:00
fieldLabel: "Task"
});
2011-10-31 23:26:42 -04:00
var formFields = [hiddenDasInsUID,
cboDasUID,
cboDasInsType,
cboDasInsContextTime,
//txtDasInsStartDate,
//txtDasInsEndDate,
cboDasInsOwnerType,
cboDasInsOwnerUID
//cboProcess,
//cboTask
];
formFields = formFields.concat(additionaFields);
2011-10-31 20:14:05 -04:00
//------------------------------------------------------------------------------------------------------------------
var dashletInstanceFrm = new Ext.form.FormPanel({
id: "dashletInstanceFrm",
labelWidth: 100,
2011-10-31 20:14:05 -04:00
border: true,
width: 450,
frame: true,
title: "Dashlet Instance Configuration",
items: formFields,
2011-10-31 20:14:05 -04:00
buttonAlign: "right",
buttons: [new Ext.Action({
id: "btnSubmit",
text: "Save",
handler: function () {
if (dashletInstanceFrm.getForm().isValid()) {
dashletInstanceSaveProcessAjax();
}
else {
Ext.MessageBox.alert('Invalid data', 'Please check the fields mark in red.');
}
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
}
}
]
});
dashletInstanceFrm.getForm().setValues(dashletInstance);
dashletInstanceFrm.render(document.body);
2011-10-31 20:14:05 -04:00
}
}
Ext.onReady(dashletInstance.form.init, dashletInstance.form);