plain_config_text_field.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. //TODO should use only "serviceConfig" binding instead of "config"
  25. App.PlainConfigTextField = Ember.View.extend(App.SupportsDependentConfigs, App.WidgetPopoverSupport, App.ValueObserver, {
  26. templateName: require('templates/common/configs/widgets/plain_config_text_field'),
  27. valueBinding: 'config.value',
  28. classNames: ['widget-config-plain-text-field'],
  29. placeholderBinding: 'config.placeholder',
  30. disabled: Em.computed.not('config.isEditable'),
  31. configLabel: Em.computed.firstNotBlank('config.stackConfigProperty.displayName', 'config.displayName', 'config.name'),
  32. /**
  33. * @type {string|boolean}
  34. */
  35. unit: function() {
  36. return Em.getWithDefault(this, 'config.stackConfigProperty.valueAttributes.unit', false);
  37. }.property('config.stackConfigProperty.valueAttributes.unit'),
  38. /**
  39. * @type {string}
  40. */
  41. displayUnit: function() {
  42. var unit = this.get('unit');
  43. if ('milliseconds' == unit) {
  44. unit = 'ms';
  45. }
  46. return unit;
  47. }.property('unit'),
  48. insertNewline: function() {
  49. this.get('parentView').trigger('toggleWidgetView');
  50. },
  51. didInsertElement: function() {
  52. this._super();
  53. this.initPopover();
  54. this.set('config.displayType', Em.getWithDefault(this, 'config.stackConfigProperty.valueAttributes.type', 'string'));
  55. }
  56. });