plain_config_text_field.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. /**
  19. * Default input control
  20. * @type {*}
  21. */
  22. var App = require('app');
  23. require('views/common/controls_view');
  24. App.PlainConfigTextField = Ember.View.extend(App.SupportsDependentConfigs, App.WidgetPopoverSupport, {
  25. templateName: require('templates/common/configs/widgets/plain_config_text_field'),
  26. valueBinding: 'config.value',
  27. classNames: ['widget-config-plain-text-field'],
  28. placeholderBinding: 'config.savedValue',
  29. disabled: Em.computed.not('config.isEditable'),
  30. configLabel: Em.computed.firstNotBlank('config.stackConfigProperty.displayName', 'config.displayName', 'config.name'),
  31. /**
  32. * @type {string|boolean}
  33. */
  34. unit: function() {
  35. return Em.getWithDefault(this, 'config.stackConfigProperty.valueAttributes.unit', false);
  36. }.property('config.stackConfigProperty.valueAttributes.unit'),
  37. /**
  38. * @type {string}
  39. */
  40. displayUnit: function() {
  41. var unit = this.get('unit');
  42. if ('milliseconds' == unit) {
  43. unit = 'ms';
  44. }
  45. return unit;
  46. }.property('unit'),
  47. focusOut: function () {
  48. this.sendRequestRorDependentConfigs(this.get('config'));
  49. },
  50. insertNewline: function() {
  51. this.get('parentView').trigger('toggleWidgetView');
  52. },
  53. didInsertElement: function() {
  54. this._super();
  55. this.initPopover();
  56. this.set('config.displayType', Em.getWithDefault(this, 'config.stackConfigProperty.valueAttributes.type', 'string'));
  57. }
  58. });