AlignPropertiesProvider.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. /**
  4. * Licensed Materials - Property of IBM
  5. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2019, 2020
  6. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. */
  8. define(['underscore', '../../../lib/@waca/dashboard-common/dist/api/PropertiesProviderAPI', '../../../lib/@waca/dashboard-common/dist/core/APIFactory', '../../../app/nls/StringResources'], function (_, PropertiesProviderAPI, APIFactory, stringResources) {
  9. var AlignPropertiesProvider = function () {
  10. function AlignPropertiesProvider(options) {
  11. _classCallCheck(this, AlignPropertiesProvider);
  12. this.content = options.content;
  13. this.dashboardApi = options.dashboardAPI;
  14. this._api = APIFactory.createAPI(this, [PropertiesProviderAPI]);
  15. // register self as a properties provider contributing align properties
  16. this.content.getFeature('Properties').registerProvider(this.getAPI());
  17. this._icons = options.features['Dashboard.Icons'];
  18. }
  19. AlignPropertiesProvider.prototype.getAPI = function getAPI() {
  20. return this._api;
  21. };
  22. AlignPropertiesProvider.prototype.destroy = function destroy() {
  23. this.dashboardApi = null;
  24. };
  25. AlignPropertiesProvider.prototype.getPropertyLayoutList = function getPropertyLayoutList() {
  26. return [{
  27. id: 'general',
  28. type: 'Group',
  29. label: stringResources.get('tabName_general')
  30. }, {
  31. id: 'layout',
  32. type: 'Section',
  33. label: stringResources.get('sectionName_layout'),
  34. position: 2
  35. }].concat(this.getPropertyLayoutControlList());
  36. };
  37. AlignPropertiesProvider.prototype.getPropertyList = function getPropertyList() {
  38. return [];
  39. };
  40. AlignPropertiesProvider.prototype.getPropertyLayoutControlList = function getPropertyLayoutControlList() {
  41. var selectedContent = this.dashboardApi.getCanvas().getSelectedContentList();
  42. var isReadOnly = selectedContent.length <= 1;
  43. var alignAction = this.dashboardApi.getFeature('alignAction');
  44. return [{
  45. id: 'alignWidget',
  46. editor: {
  47. sectionId: 'general.layout',
  48. readOnly: isReadOnly,
  49. position: 1,
  50. uiControl: {
  51. type: 'IconPicker',
  52. label: stringResources.get('toolbarActionAlign'),
  53. items: [{
  54. name: 'left',
  55. label: stringResources.get('alignWidgetLeft'),
  56. value: this._icons.getIcon('align-left').id
  57. }, {
  58. name: 'center',
  59. label: stringResources.get('alignWidgetCenter'),
  60. value: this._icons.getIcon('align-horizontally').id
  61. }, {
  62. name: 'right',
  63. label: stringResources.get('alignWidgetRight'),
  64. value: this._icons.getIcon('align-right').id
  65. }, {
  66. name: 'top',
  67. label: stringResources.get('alignWidgetTop'),
  68. value: this._icons.getIcon('align-top').id
  69. }, {
  70. name: 'middle',
  71. label: stringResources.get('alignWidgetMiddle'),
  72. value: this._icons.getIcon('align-vertically').id
  73. }, {
  74. name: 'bottom',
  75. label: stringResources.get('alignWidgetBottom'),
  76. value: this._icons.getIcon('align-bottom').id
  77. }],
  78. onChange: function onChange(name, selection) {
  79. alignAction.applyAction(_.map(selection, function (entry) {
  80. return _.extend(entry, {
  81. layoutIds: _.map(selectedContent, function (content) {
  82. return content.getId();
  83. })
  84. });
  85. }));
  86. }
  87. }
  88. }
  89. }];
  90. };
  91. return AlignPropertiesProvider;
  92. }();
  93. return AlignPropertiesProvider;
  94. });
  95. //# sourceMappingURL=AlignPropertiesProvider.js.map