sub_section_tab.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. var App = require('app');
  19. App.SubSectionTab = DS.Model.extend({
  20. id: DS.attr('string'),
  21. /**
  22. * @type {string}
  23. */
  24. name: DS.attr('string'),
  25. /**
  26. * @type {string}
  27. */
  28. displayName: DS.attr('string'),
  29. /**
  30. * @type {App.Section}
  31. */
  32. subSection: DS.belongsTo('App.SubSection'),
  33. /**
  34. * @type {String[]}
  35. */
  36. configProperties: DS.attr('array', {defaultValue: []}),
  37. /**
  38. * @type {App.ServiceConfigProperty[]}
  39. */
  40. configs: [],
  41. dependsOn: DS.attr('array', {defaultValue: []}),
  42. /**
  43. * @type {boolean}
  44. */
  45. isActive: DS.attr('boolean', {defaultValue: false}),
  46. /**
  47. * Number of the errors in all configs
  48. * @type {number}
  49. */
  50. errorsCount: function () {
  51. return this.get('configs').filter(function(config) {
  52. return config.get('isVisible') && (!config.get('isValid') || (config.get('overrides') || []).someProperty('isValid', false));
  53. }).length;
  54. }.property('configs.@each.isVisible', 'configs.@each.isValid', 'configs.@each.overrideErrorTrigger'),
  55. /**
  56. * If the visibility of subsection is dependent on a value of some config
  57. */
  58. isHiddenByConfig: false,
  59. /**
  60. * Determines if subsection is filtered by checking it own configs
  61. * If there is no configs, subsection can't be hidden
  62. * @type {boolean}
  63. */
  64. isHiddenByFilter: function () {
  65. var configs = this.get('configs').filter(function(c) {
  66. return !c.get('hiddenBySection') && c.get('isVisible');
  67. });
  68. return configs.length ? configs.everyProperty('isHiddenByFilter', true) : false;
  69. }.property('configs.@each.isHiddenByFilter'),
  70. /**
  71. * Determines if subsection is visible
  72. * @type {boolean}
  73. */
  74. isVisible: function () {
  75. return !this.get('isHiddenByFilter') && !this.get('isHiddenByConfig') && this.get('configs').someProperty('isVisible', true);
  76. }.property('isHiddenByFilter', 'isHiddenByConfig', 'configs.@each.isVisible')
  77. });
  78. App.SubSectionTab.FIXTURES = [];