MobilePropertyGroup.js 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. //
  2. // IBM Confidential
  3. // OCO Source Materials
  4. // BI and PM: Mobile
  5. // (C) Copyright IBM Corp. 2013
  6. // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. //
  8. dojo.provide('mobileAdmin.serverConfig.control.MobilePropertyGroup');
  9. // dojo dependencies
  10. // Mobile dependencies
  11. dojo.require('mobileAdmin.serverConfig.control.MobilePropertyGrid');
  12. dojo.require('mobileAdmin.serverConfig.control.MobilePropertyGridCell');
  13. dojo.declare('mobileAdmin.serverConfig.control.MobilePropertyGroup', null, {
  14. constructor: function(_this_Fragment, mobileMsgResources) {
  15. this.fragmentResources = _this_Fragment;
  16. this.msgResources = mobileMsgResources;
  17. },
  18. renderGroup: function(parentWidget, propertyGroup, dataModel) {
  19. var dataItems = dataModel.queryGroupProperties(propertyGroup);
  20. var dataGrid = this._buildDataGrid(dataModel, dataItems);
  21. var groupTitlePane = new dijit.TitlePane(
  22. {
  23. "class":'configPropertyGroup',
  24. title:eval(propertyGroup)
  25. }
  26. );
  27. groupTitlePane.set('content', dataGrid);
  28. parentWidget.domNode.appendChild(groupTitlePane.domNode);
  29. //a11y - set the id for the title bar node and the aria-labelledby attribute of the div with role="region"
  30. //a11y - remove the role="group" from the title pane dijit
  31. //mirrors dojo patch fix - https://bugs.dojotoolkit.org/attachment/ticket/15853/TitlePane_a11y_labelledby.patch
  32. var titleBarNodeId = groupTitlePane.domNode.id + '_titleBarNode';
  33. //check if this exists so I don't break IE5 rendering
  34. if(groupTitlePane.domNode.getElementsByClassName){
  35. groupTitlePane.domNode.getElementsByClassName('dijitTitlePaneTitle')[0].id = titleBarNodeId;
  36. document.getElementById(groupTitlePane.domNode.id + '_pane').setAttribute('aria-labelledby', titleBarNodeId);
  37. groupTitlePane.domNode.getElementsByClassName('dojoxGrid')[0].setAttribute('aria-labelledby', titleBarNodeId);
  38. }
  39. groupTitlePane.domNode.removeAttribute('role');
  40. dataGrid.startup();
  41. },
  42. _buildDataGrid: function(dataModel, dataItems) {
  43. var gridStructure =
  44. [
  45. {
  46. name: this.msgResources.ADM.SRV_CONF_PROPERTY_TITLE,
  47. field: 'propertyLabel',
  48. classes: 'clPropertyNameColumn',
  49. width: '70%',
  50. editable: false,
  51. formatter: function(item, rowIndex, cell) {
  52. var property = cell.grid.getItem(rowIndex);
  53. var spanString = '<span title="' + property.propertyName + '">' + eval(property.propertyLabel) + '</span>';
  54. return spanString;
  55. }
  56. },
  57. {
  58. name: this.msgResources.ADM.SRV_CONF_PROPERTY_VALUE,
  59. field: 'propertyValue',
  60. classes: 'clPropertyValueColumn',
  61. type: mobileAdmin.serverConfig.control.MobilePropertyGridCell,
  62. // widgetBuilder: null, // dojo.hitch(this, this.buildWidget),
  63. width: '30%',
  64. editable: true
  65. }
  66. ];
  67. var gridProperties = {
  68. items:dataItems,
  69. store:dataModel.dojoData,
  70. structure:gridStructure,
  71. noDataMessage:this.msgResources.ADM.SRV_CONF_GRID_NO_DATA_MESSAGE,
  72. loadingMessage:this.msgResources.ADM.SRV_CONF_GRID_LOADING_MESSAGE,
  73. autoHeight:true,
  74. width:'100%',
  75. singleClickEdit: true
  76. };
  77. var dataGrid = new mobileAdmin.serverConfig.control.MobilePropertyGrid(gridProperties, null);
  78. this.dataGrid = dataGrid;
  79. return this.dataGrid;
  80. },
  81. prepareForSave : function(){
  82. this.dataGrid.edit.apply();
  83. }
  84. });