MDAnalyseDialog.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*******************************************************************************
  2. * IBM Confidential
  3. *
  4. * OCO Source Materials
  5. *
  6. * A and PM: PD
  7. *
  8. * (c) Copyright IBM Corp. 2015
  9. *
  10. * The source code for this program is not published or otherwise divested of
  11. * its trade secrets, irrespective of what has been deposited with the U.S.
  12. * Copyright Office.
  13. ******************************************************************************/
  14. define([
  15. "dojo/_base/declare",
  16. "dojo/parser",
  17. "bux/dialogs/BaseDialog",
  18. "dijit/TitlePane",
  19. "pd/model/deltaSpec",
  20. "dojo/string",
  21. "dojo/dom-construct",
  22. "dojo/dom-attr",
  23. "dijit/layout/BorderContainer",
  24. "dijit/layout/ContentPane"
  25. ],function(declare, parser, Dialog, TitlePane, deltaSpec, string, domConst, domAttr,
  26. BorderContainer, ContentPane){
  27. var MDAnalyseDialog = declare("pd/widgets/MDAnalyseDialog", [Dialog], {
  28. title: PDMSG.ANA.IDS_ANA_DIALOG_TITLE,
  29. style: "width: auto; height: auto;",
  30. showOnOk: true,
  31. _bContainerHeightAuto: true,
  32. createDefaultDialogButtons: function(){
  33. this.createButtons([
  34. {label: BUXMSG.GEN.IDS_GEN_YES_BUTTON, action: dojo.hitch(this, this.onOK), type: "button"},
  35. {label: BUXMSG.GEN.IDS_GEN_NO_BUTTON, action: dojo.hitch(this, this.onCancel), type: "button"}
  36. ]);
  37. },
  38. postCreate: function() {
  39. this.inherited(arguments);
  40. this.createDefaultDialogButtons();
  41. var noChange = true;
  42. var contentDom = domConst.toDom("<div style='min-width:500px;'></div>");
  43. for (var i=0; i<deltaSpec.length; i++){
  44. var section = this.delta[deltaSpec[i].name];
  45. if (section.length > 0) {
  46. var bc = new BorderContainer({
  47. style: "height:100px;"
  48. });
  49. var content = "<table class='dojoxGridRowTable' cellspacing='0' " +
  50. "cellpadding='0' border='0' role='presentation' style='width: 100%;'><tbody>";
  51. for (var j=0; j<section.length; j++){
  52. var className = ((j%2)?"dojoxGridRow":"dojoxGridRowSelected");
  53. content +="<tr><td tabindex='-1' " +
  54. "style='padding: 3px 3px 3px 13px' class='"+className+"'>" + section[j].name;
  55. if (section[j].simpletype && section[j].previoustype) {
  56. content += "&nbsp;" + string.substitute(PDMSG.ANA.IDS_ANA_TYPE_CHANGED_FROM_TO,
  57. {0: section[j].previoustype, 1: section[j].simpletype});
  58. }
  59. content += "</td></tr>";
  60. }
  61. content += "</tbody></table>";
  62. var cp = new ContentPane({
  63. region: "center",
  64. content: content,
  65. "aria-label": deltaSpec[i].contentLabel
  66. });
  67. bc.addChild(cp);
  68. var titlePane = new TitlePane({
  69. title: deltaSpec[i].label + " ("+section.length+")",
  70. content: bc.domNode,
  71. open: false
  72. });
  73. domAttr.set(titlePane.domNode, "aria-label", deltaSpec[i].groupLabel);
  74. domAttr.set(titlePane.containerNode, "role", "group");
  75. domAttr.set(titlePane.containerNode, "aria-label", deltaSpec[i].contentLabel);
  76. contentDom.appendChild(titlePane.domNode);
  77. noChange = false;
  78. }
  79. }
  80. var headerHTML = "<table border='0' role='presentation'><tbody><tr>";
  81. if (!noChange){
  82. headerHTML += "<td class='bux-InformationDialog-Icon bux-informationDialog-warning-icon'>" +
  83. "<div class='bux-InformationDialog-Icon'>&nbsp;</div></td>";
  84. }
  85. headerHTML += "<td><div class='bux-InformationDialog-mainMessage'>";
  86. headerHTML += noChange?PDMSG.ANA.IDS_ANA_NO_META_DATA_CHANGES:PDMSG.ANA.IDS_ANA_META_DATA_CHANGES;
  87. headerHTML += "</div></td></tr></tbody></table></br>"
  88. this.dialogContent.appendChild(domConst.toDom(headerHTML));
  89. this.dialogContent.appendChild(contentDom);
  90. this.dialogContent.appendChild(
  91. domConst.toDom("<br/><div class='bux-InformationDialog-mainMessage'>" +
  92. (!noChange?PDMSG.ANA.IDS_ANA_METADATA_CHANGES_WARNING+"<br/><br/>":"") +
  93. PDMSG.ANA.IDS_ANA_PROCEED_CONFIRM + "</div>"));
  94. },
  95. onOK: function() {
  96. if (this.showOnOk !== true) {
  97. this.hide();
  98. }
  99. if (this._aButtonObjects && this._aButtonObjects[0]) {
  100. this._aButtonObjects[0].focus();
  101. }
  102. if (this.okHandler) {
  103. this.okHandler();
  104. }
  105. },
  106. onCancel: function() {
  107. this.inherited(arguments);
  108. if (this.cancelHandler) {
  109. this.cancelHandler();
  110. }
  111. },
  112. hide: function() {
  113. this.inherited(arguments);
  114. this.destroy();
  115. }
  116. });
  117. return MDAnalyseDialog;
  118. });