SelectSnapshotDialog.js 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| IBM Cognos Products: Viewer
  5. *| (C) Copyright IBM Corp. 2001, 2012
  6. *|
  7. *| US Government Users Restricted Rights - Use, duplication or
  8. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. *|
  10. *+------------------------------------------------------------------------+
  11. */
  12. dojo.provide("bux.dialogs.SelectSnapshot");
  13. dojo.require("bux.dialogs.BaseCustomContentDialog");
  14. dojo.require("bux.layout.TableContainer");
  15. dojo.require("dijit.form.NumberTextBox");
  16. dojo.require("dijit.form.Button");
  17. dojo.declare("viewer.dialogs.SelectSnapshot", bux.dialogs.BaseCustomContentDialog, {
  18. sTitle: null,
  19. sLabel: null, /*String the lablel of the calculation dialog*/
  20. okHandler: null, /*Function?*/
  21. cancelHandler:null, /*Function?*/
  22. startup: function() {
  23. this.updateTitle(this.sTitle);
  24. this.inherited(arguments);
  25. var tableContainer = new bux.layout.TableContainer({
  26. // TODO remove this class
  27. classname: "bux-InformationDialog"
  28. },this.contentContainer);
  29. var row = new bux.layout.TableContainerRow({
  30. parentContainer: tableContainer
  31. });
  32. var cell = new bux.layout.TableContainerCell({
  33. classname: "bux-dialog-label",
  34. parentContainer: row
  35. });
  36. this.createSnapshotsControl();
  37. var _label = document.createElement("label");
  38. _label.appendChild(document.createTextNode(this.sLabel));
  39. _label.setAttribute("for", this._snapshots.id);
  40. cell.addContent(_label);
  41. row = new bux.layout.TableContainerRow({
  42. parentContainer: tableContainer
  43. });
  44. cell = new bux.layout.TableContainerCell({
  45. classname: "bux-dialog-field",
  46. parentContainer: row
  47. });
  48. cell.addContent(this._snapshots);
  49. },
  50. onOK : function()
  51. {
  52. this.inherited(arguments);
  53. var selectedIndex = this._snapshots.selectedIndex;
  54. var selectionOption = this._snapshots.options[selectedIndex];
  55. this.okHandler(selectionOption.getAttribute("storeID"), selectionOption.value);
  56. this.hide();
  57. },
  58. createSnapshotsControl : function()
  59. {
  60. this._snapshots = document.createElement("select");
  61. this._snapshots.id = this.dialogId + "snapshots";
  62. this._snapshots.setAttribute("size", "8");
  63. this._snapshots.setAttribute("name", this.dialogId + "snapshots");
  64. var queryResult = XMLHelper_FindChildByTagName(this.cmResponse, "result", true);
  65. var queryItems = XMLHelper_FindChildrenByTagName(queryResult, "item", false);
  66. for (var iIndex=0; iIndex < queryItems.length; iIndex++) {
  67. var queryItem = queryItems[iIndex];
  68. var sItemLabel = XMLHelper_GetText(XMLHelper_FindChildByTagName(queryItem, "creationTime_localized", true));
  69. var storeIDNode = XMLHelper_FindChildByTagName(queryItem, "storeID", true);
  70. var sStoreID = XMLHelper_GetText(XMLHelper_FindChildByTagName(storeIDNode, "value", true));
  71. var creationTimeNode = XMLHelper_FindChildByTagName(queryItem, "creationTime", true);
  72. var sCreationTime = XMLHelper_GetText(XMLHelper_FindChildByTagName(creationTimeNode, "value", true));
  73. this._snapshots.options[iIndex] = new Option(sItemLabel, sCreationTime);
  74. this._snapshots.options[iIndex].setAttribute("storeID", sStoreID);
  75. if (this.currentSnapshotCreationTime == sCreationTime) {
  76. this._snapshots.options[iIndex].selected = true;
  77. }
  78. }
  79. }
  80. });