InputPromptView.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. 'use strict';
  2. /**
  3. * Licensed Materials - Property of IBM
  4. *
  5. * IBM Cognos Products: BI UI Commons
  6. *
  7. * Copyright IBM Corp. 2016, 2017
  8. *
  9. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  10. */
  11. define(['../../lib/@waca/core-client/js/core-client/ui/core/View', 'text!./templates/BasePromptView.html', 'text!./templates/InputPromptView.html', 'underscore', 'doT'], function (BaseView, BasePromptViewTemplate, InputPromptViewTemplate, _, dot) {
  12. 'use strict';
  13. /**
  14. * Prompt text box view. This class renders an input box to read prompt value.
  15. *
  16. * @param {String} options.label - The name of the parameter, also used as label of the text box.
  17. *
  18. */
  19. var InputPromptView = BaseView.extend({
  20. events: {
  21. 'keyup .promptInput': '_enableOk'
  22. },
  23. init: function init(options) {
  24. options.height = '100px';
  25. InputPromptView.inherited('init', this, arguments);
  26. _.extend(this, options);
  27. },
  28. render: function render() {
  29. var sBasePromptViewHtml = dot.template(BasePromptViewTemplate)({
  30. promptModuleName: this.promptModuleName
  31. });
  32. this.$el.addClass('promptDialogContainer inputDialog').height(this.height + 'px').width(this.width + 'px').append(sBasePromptViewHtml);
  33. this.$el.attr('role', 'region');
  34. this.$el.attr('aria-label', this.viewTitle);
  35. var sPromptContentHtml = dot.template(InputPromptViewTemplate)({
  36. 'label': this.label,
  37. 'value': this.defaultValues && this.defaultValues[0] ? this.defaultValues[0].d : null
  38. });
  39. this.$('.content').append(sPromptContentHtml);
  40. },
  41. /**
  42. * Get the prompt value
  43. */
  44. getPromptValues: function getPromptValues() {
  45. return [this.$('.promptInput').val()];
  46. },
  47. setFocus: function setFocus() {
  48. this.$('.promptInput').focus();
  49. },
  50. _enableOk: function _enableOk() {
  51. if (this.$('.promptInput').val()) {
  52. this.enableOk(true);
  53. } else {
  54. this.enableOk(false);
  55. }
  56. }
  57. });
  58. return InputPromptView;
  59. });
  60. //# sourceMappingURL=InputPromptView.js.map