123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- /**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- var App = require('app');
- App.SubSection = DS.Model.extend({
- id: DS.attr('string'),
- /**
- * @type {string}
- */
- name: DS.attr('string'),
- /**
- * @type {string}
- */
- displayName: DS.attr('string'),
- /**
- * @type {boolean}
- */
- border: DS.attr('boolean', {defaultValue: false}),
- /**
- * @type {number}
- */
- rowIndex: DS.attr('number', {defaultValue: 1}),
- /**
- * @type {number}
- */
- columnIndex: DS.attr('number', {defaultValue: 1}),
- /**
- * @type {number}
- */
- rowSpan: DS.attr('number', {defaultValue: 1}),
- /**
- * @type {number}
- */
- columnSpan: DS.attr('number', {defaultValue: 1}),
- /**
- * @type {App.Section}
- */
- section: DS.belongsTo('App.Section'),
- /**
- * @type {String[]}
- */
- configProperties: DS.attr('array', {defaultValue: []}),
- /**
- * @type {App.SubSectionTab[]}
- */
- subSectionTabs: DS.hasMany('App.SubSectionTab'),
- dependsOn: DS.attr('array', {defaultValue: []}),
- /**
- * @type {boolean}
- */
- leftVerticalSplitter: DS.attr('boolean', {defaultValue: true}),
- /**
- * @type {App.ServiceConfigProperty[]}
- */
- configs: [],
- /**
- * @type {boolean}
- */
- hasTabs: Em.computed.bool('subSectionTabs.length'),
- someSubSectionTabIsVisible: Em.computed.someBy('subSectionTabs', 'isVisible', true),
- showTabs: Em.computed.and('hasTabs', 'someSubSectionTabIsVisible'),
- /**
- * Number of the errors in all configs
- * @type {number}
- */
- errorsCount: function () {
- var visibleTabs = this.get('subSectionTabs').filterProperty('isVisible');
- var subSectionTabsErrors = visibleTabs.length ? visibleTabs.mapProperty('errorsCount').reduce(Em.sum, 0) : 0;
- return subSectionTabsErrors + this.get('configs').filter(function(config) {
- return config.get('isVisible') && (!config.get('isValid') || (config.get('overrides') || []).someProperty('isValid', false));
- }).length;
- }.property('configs.@each.isValid', 'configs.@each.isVisible', 'configs.@each.overrideErrorTrigger', 'subSectionTabs.@each.isVisible', 'subSectionTabs.@each.errorsCount'),
- /**
- * @type {boolean}
- */
- addLeftVerticalSplitter: Em.computed.and('!isFirstColumn', 'leftVerticalSplitter'),
- /**
- * @type {boolean}
- */
- addRightVerticalSplitter: Em.computed.not('isLastColumn'),
- /**
- * @type {boolean}
- */
- showTopSplitter: Em.computed.and('!isFirstRow', '!border'),
- /**
- * @type {boolean}
- */
- isFirstRow: Em.computed.equal('rowIndex', 0),
- /**
- * @type {boolean}
- */
- isMiddleRow: function () {
- return this.get('rowIndex') != 0 && (this.get('rowIndex') + this.get('rowSpan') < this.get('section.sectionRows'));
- }.property('rowIndex', 'rowSpan', 'section.sectionRows'),
- /**
- * @type {boolean}
- */
- isLastRow: function () {
- return this.get('rowIndex') + this.get('rowSpan') == this.get('section.sectionRows');
- }.property('rowIndex', 'rowSpan', 'section.sectionRows'),
- /**
- * @type {boolean}
- */
- isFirstColumn: Em.computed.equal('columnIndex', 0),
- /**
- * @type {boolean}
- */
- isMiddleColumn: function () {
- return this.get('columnIndex') != 0 && (this.get('columnIndex') + this.get('columnSpan') < this.get('section.sectionColumns'));
- }.property('columnIndex', 'columnSpan', 'section.sectionColumns'),
- /**
- * @type {boolean}
- */
- isLastColumn: function () {
- return this.get('columnIndex') + this.get('columnSpan') == this.get('section.sectionColumns');
- }.property('columnIndex', 'columnSpan', 'section.sectionColumns'),
- /**
- * If the visibility of subsection is dependent on a value of some config
- */
- isHiddenByConfig: false,
- /**
- * Determines if subsection is filtered by checking it own configs
- * If there is no configs, subsection can't be hidden
- * @type {boolean}
- */
- isHiddenByFilter: function () {
- var configs = this.get('configs').filter(function(c) {
- return !c.get('hiddenBySection') && c.get('isVisible');
- });
- return configs.length ? configs.everyProperty('isHiddenByFilter', true) : false;
- }.property('configs.@each.isHiddenByFilter'),
- /**
- * @type {boolean}
- */
- someConfigIsVisible: Em.computed.someBy('configs', 'isVisible', true),
- /**
- * Determines if subsection is visible
- * @type {boolean}
- */
- isSectionVisible: Em.computed.and('!isHiddenByFilter', '!isHiddenByConfig', 'someConfigIsVisible')
- });
- App.SubSection.FIXTURES = [];
|