dojo.provide("kfc.kwo.ToDoGrid");
dojo.require("kfc.kwo._ToDo");
dojo.require("kfc.kwo._GridBase");
dojo.require("dojox.grid._CheckBoxSelector");
//dojo.require("kfc.form.PopupTextBox");
//dojo.require("kfc.form.MultiPopupTextBox");
//dojo.require("kfc.form.CurrencyTextBox");
//dojo.require("kfc.form.NumberTextBox");
//dojo.require("kfc.form.OracleDateTextBox");
//dojo.require("kfc.form.ValidationTextarea");
//dojo.require("kfc.form.CurrencyTextBox");
//dojo.require("dijit.form.TextBox");
//dojo.require("dijit.form.Form");
//dojo.require("dijit.form.ValidationTextBox");
//dojo.require("dijit.form.DateTextBox");
//dojo.require("dijit.form.Textarea");
//dojo.require("dijit.InlineEditBox");
dojo.require("dijit.Dialog");
dojo.require("dijit.form.FilteringSelect");
dojo.require("dijit.form.Button");
dojo.declare("kfc.kwo.ToDoGrid", [kfc.kwo._ToDo, kfc.kwo._GridBase], {
templateString: dojo.cache("kfc.kwo","templates/ToDoGrid.html")
,widgetsInTemplate: true
,loadStore: "server/getWorkOrder.php"
,typeFile: "server/getLookupValues.php?P_NAME=WORK_ORDER_TYPE"
,statusFile: "server/getLookupValues.php?P_NAME=WORK_ORDER_STATUS&P_IDENTIFIER=P_LOOKUP_VALUE_ID"
,priorityFile: "server/getLookupValues.php?P_NAME=PRIORITY&P_IDENTIFIER=P_LOOKUP_VALUE_ID"
/** Return the structure for the todo grid. */
,_getGridStructure: function () {
return [
{ type: "dojox.grid._CheckBoxSelector" }
,{ cells: [[
{ name: "Work Order", field: "P_WO_NO", width: "6em"/*, formatter: this._formatWoCell*/ }
,{ name: "Description", field: "P_DESCRIPTION", width: "25em" }
,{ name: "Category", field: "P_CATEGORY", width: "7em" }
,{ name: "Value", field: "P_SOURCE_VALUE", width: "7em" }
,{ name: "Type", field: "P_TYPE", width: "7em" }
,{ name: "Status", field: "P_STATUS", width: "7em" }
/*
,type: dojox.grid.cells._Widget, widgetClass: dijit.form.FilteringSelect
,widgetProps: { store: , searchAttr: , pageSize: 25, uppercase: true }
*/
,{ name: "Priority", field: "P_PRIORITY", width: "7em" }
,{ name: "Location", field: "P_LOCATION", width: "7em" }
,{ name: "Assigned To", field: "P_ASSIGNED_TO", width: "10em" }
,{ name: "Est Hours", field: "P_EST_HOURS", width: "6em" }
,{ name: "Complete By", field: "P_COMPLETE_BY_DATE", width: "8em" }
,{ name: "Completed Date", field: "P_COMPLETED_DATE", width: "8em" }
,{ name: "Last Print", field: "P_LAST_PRINTED_DATE", width: "8em" }
]]}
];
}
/***/
,_formatWoCell: function (p_value ,p_row, p_cell) {
console.log("_formatWo("+p_value+")");
return "" + p_value + "";
//return "" + p_value + "";
}
/***/
,openFilterWin: function () {
this.f_filter_win.show();
}
/***/
,filterWinOnOk: function () {
this.filterGrid();
this.f_filter_win.hide();
}
/***/
,filterWinOnClear: function () {
this.f_fw_form.reset();
}
/***/
,filterWinOnCancel: function () {
this.f_filter_win.hide();
}
/***/
,openEditWin: function () {
if (this.f_grid.selection.getSelected().length == 0) {
alert("No row(s) selected.");
return;
}
this.f_ew_form.reset();
this.f_edit_win.show();
}
/***/
,editWinOnOk: function () {
var status_item = this.f_ew_status.item;
var priority_item = this.f_ew_priority.item;
var selected = this.f_grid.selection.getSelected();
for (var i in selected) {
var item = selected[i];
if (status_item) {
this.store.setValue(item, "P_STATUS", status_item.P_VALUE[0]);
this.store.setValue(item, "P_STATUS_LOOKUP_VALUE_ID", status_item.P_LOOKUP_VALUE_ID[0]);
}
if (priority_item) {
this.store.setValue(item, "P_PRIORITY", priority_item.P_VALUE[0]);
this.store.setValue(item, "P_PRIORITY_LOOKUP_VALUE_ID", priority_item.P_LOOKUP_VALUE_ID[0]);
}
}
this.f_edit_win.hide();
}
/***/
,editWinOnClear: function () {
this.f_ew_form.reset();
}
/***/
,editWinOnCancel: function () {
this.f_edit_win.hide();
}
/** Narrow grid rows down by the filtering selects. */
,filterGrid: function () {
console.log("filterGrid");
//TODO: why doesn't this work after a work order gets loaded?
var p_type = this.f_type_filter.attr("displayedValue");
var p_status = this.f_status_filter.attr("displayedValue");
var p_priority = this.f_priority_filter.attr("displayedValue");
var q = {};
//if the filteringselect is invalid, clear it out
if (this.f_type_filter.isValid()) {
q.P_TYPE = p_type;
}
if (this.f_status_filter.isValid()) {
q.P_STATUS = p_status;
}
if (this.f_priority_filter.isValid()) {
q.P_PRIORITY = p_priority;
}
//if the filter value is invalid, default it to * (i.e. all values)
this.f_grid.filter(q);
this.f_grid.render();
}
/** Fetch the stores need on startup. Set them to their components onComplete. */
,_loadStores: function () {
var _this = this;
var todoStore = new dojo.data.ItemFileWriteStore({
url: this.loadStore
});
todoStore.fetch({
onComplete: dojo.hitch(this, function (p_response) {
this.setStore(todoStore);
})
});
var typeStore = new dojo.data.ItemFileWriteStore({
url: this.typeFile
});
typeStore.fetch({
onComplete: dojo.hitch(this, function (p_response) {
this.f_type_filter.attr("store", typeStore);
})
});
var statusStore = new dojo.data.ItemFileWriteStore({
url: this.statusFile
});
statusStore.fetch({
onComplete: dojo.hitch(this, function (p_response) {
this.f_status_filter.attr("store", statusStore);
this.f_ew_status.attr("store", statusStore);
})
});
var priorityStore = new dojo.data.ItemFileWriteStore({
url: this.priorityFile
});
priorityStore.fetch({
onComplete: dojo.hitch(this, function (p_response) {
this.f_priority_filter.attr("store", priorityStore);
this.f_ew_priority.attr("store", priorityStore);
})
});
}
/***/
,_handleCellClick: function (p_cell) {
console.log("_handleCellClick");
console.log(p_cell);
this.inherited("onCellClick", arguments);
}
/***/
,postCreate: function () {
this._loadStores();
//this is required to create the grid
this.inherited("postCreate", arguments);
//this.f_grid.onCellClick = this._handleCellClick;
setTimeout(dojo.hitch(this, function () {
this.f_grid.render();
}, 0));
}
});