TopBottomLabel.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. 'use strict';
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2016, 2017
  5. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  6. */
  7. define(['../../../widgets/livewidget/nls/StringResources', '../../../lib/@waca/core-client/js/core-client/ui/core/Class'], function (StringResources, Class) {
  8. 'use strict';
  9. var topBottomParams = function topBottomParams(topBottom) {
  10. var retval = {};
  11. retval.columnLabel = topBottom.limit.factColumnLabel;
  12. retval.operator = topBottom.limit.op === 'top' ? StringResources.get('topOperator') : StringResources.get('bottomOperator');
  13. retval.value = topBottom.limit.val;
  14. retval.percent = topBottom.limit.percent ? '%' : '';
  15. return retval;
  16. };
  17. var operator = {
  18. fact: {
  19. template: 'topBottomFact',
  20. params: function params(topBottom) {
  21. return topBottomParams(topBottom);
  22. }
  23. },
  24. dimension: {
  25. template: 'topBottomDimension',
  26. params: function params(topBottom) {
  27. return topBottomParams(topBottom);
  28. }
  29. }
  30. };
  31. var TopBottomLabel = Class.extend({
  32. getTopBottomLabel: function getTopBottomLabel(topBottom) {
  33. var op = topBottom.limit && topBottom.limit.fact ? operator.fact : operator.dimension;
  34. return StringResources.get(op.template, op.params(topBottom));
  35. }
  36. });
  37. return TopBottomLabel;
  38. });
  39. //# sourceMappingURL=TopBottomLabel.js.map