plain_config_text_field.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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, App.ValueObserver, {
  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. insertNewline: function() {
  48. this.get('parentView').trigger('toggleWidgetView');
  49. },
  50. didInsertElement: function() {
  51. this._super();
  52. this.initPopover();
  53. this.set('config.displayType', Em.getWithDefault(this, 'config.stackConfigProperty.valueAttributes.type', 'string'));
  54. }
  55. });