<commit_before>(function () {
  var Ext = window.Ext4 || window.Ext;

  /**
   * Iteration Tracking Board App
   * The Iteration Tracking Board can be used to visualize and manage your User Stories and Defects within an Iteration.
   */
  Ext.define('Rally.apps.portfoliodrilldown.PortfolioDrilldownApp', {
    extend: 'Rally.app.App',
    requires: [
      'Rally.data.Ranker',
      'Rally.ui.gridboard.GridBoard',
      'Rally.ui.grid.TreeGrid',
      'Rally.data.wsapi.TreeStoreBuilder',
      'Rally.ui.cardboard.plugin.FixedHeader',
      'Rally.ui.cardboard.plugin.Print',
      'Rally.ui.gridboard.plugin.GridBoardAddNew',
      'Rally.ui.gridboard.plugin.GridBoardOwnerFilter',
      'Rally.ui.gridboard.plugin.GridBoardFilterInfo',
      'Rally.ui.gridboard.plugin.GridBoardArtifactTypeChooser',
      'Rally.ui.gridboard.plugin.GridBoardFieldPicker',
      'Rally.ui.cardboard.plugin.ColumnPolicy',
      'Rally.ui.gridboard.plugin.GridBoardFilterInfo',
      'Rally.ui.gridboard.plugin.GridBoardFilterControl',
      'Rally.ui.gridboard.plugin.GridBoardToggleable',
      'Rally.ui.grid.plugin.TreeGridExpandedRowPersistence',
      'Rally.ui.gridboard.plugin.GridBoardExpandAll',
      'Rally.ui.gridboard.plugin.GridBoardCustomView',
      'Rally.ui.filter.view.ModelFilter',
      'Rally.ui.filter.view.OwnerFilter',
      'Rally.ui.filter.view.OwnerPillFilter',
      'Rally.ui.filter.view.TagPillFilter',
      'Rally.app.Message',
      'Rally.clientmetrics.ClientMetricsRecordable'
    ],

    mixins: [
      'Rally.app.CardFieldSelectable',
      'Rally.clientmetrics.ClientMetricsRecordable'
    ],
    componentCls: 'portfoliotracking',
    alias: 'widget.rallyportfoliotracking',

    settingsScope: 'project',
    //scopeType: 'release',
    autoScroll: false,

    config: {
      defaultSettings: {
        ignoreProjectScoping: true
      }
    },

    eModelNames: ['User Story', 'Defect', 'Defect Suite', 'Test Set'],
    sModelNames: [],

    getSettingsFields: function () {
      var fields = this.callParent(arguments);
      fields.push({
        name: 'ignoreProjectScoping',
        xtype: 'rallycheckboxfield',
        label: 'Show Children in any Project'
      });

      console.log(fields);
      return fields;
    },

    launch: function() {
      if(!this.rendered) {
        this.on('afterrender', this.launch, this, {single: true});
        return;
      }

      var typeStore = Ext.create('Rally.data.wsapi.Store', {
        autoLoad: false,
        model: 'TypeDefinition',
        sorters: [{
          property: 'Ordinal',
          direction: 'ASC'
        }],
        filters: [{
          property: 'Parent.Name',
          operator: '=',
          value: 'Portfolio Item'
        }, {
          property: 'Creatable',
          operator: '=',
          value: true
        }]
      });

      typeStore.load({
        scope: this,
        callback: function (records) {
          this.sModelNames = _.map(records, function (rec) { return rec.get('TypePath'); });

          this._getGridStore().then({
            success: function(gridStore) {
              var model = gridStore.model;
              this._addGridBoard(gridStore);
              gridStore.on('parenttypeschange', function () {
                if (gridStore.isLoading()) {
                  gridStore.on('load', function () {
                    gridStore.reload();
                  }, this, { single: true });
                } else {
                  gridStore.load();
                }
              }, this);
            },
            scope: this
          });
        }
      });

    },

    _getModelNames: function () {
      return _.union(this.sModelNames, this.eModelNames);
    },

    _getGridStore: function() {
      var context = this.getContext(),
      config = {
        models: this._getModelNames(),
        autoLoad: false,
        remoteSort: true,
        root: {expanded: true},
        //filters: [],
        enableHierarchy: true,
        expandingNodesRespectProjectScoping: !this.getSetting('ignoreProjectScoping')
      };

      return Ext.create('Rally.data.wsapi.TreeStoreBuilder').build(config).then({
        success: function (store) {
          return store;
        }
      });
    },

    //_addStatsBanner: function() {
    //this.remove('statsBanner');
    //this.add({
    //xtype: 'statsbanner',
    //itemId: 'statsBanner',
    //context: this.getContext(),
    //margin: '0 0 5px 0',
    //listeners: {
    //resize: this._resizeGridBoardToFillSpace,
    //scope: this
    //}
    //});
    //},

    _addGridBoard: function (gridStore) {<commit_msg>Fixed #3 - Added AppSetting for showing children in other projects<commit_after>(function () {
  var Ext = window.Ext4 || window.Ext;

  /**
   * Iteration Tracking Board App
   * The Iteration Tracking Board can be used to visualize and manage your User Stories and Defects within an Iteration.
   */
  Ext.define('Rally.apps.portfoliodrilldown.PortfolioDrilldownApp', {
    extend: 'Rally.app.App',
    requires: [
      'Rally.data.Ranker',
      'Rally.ui.gridboard.GridBoard',
      'Rally.ui.grid.TreeGrid',
      'Rally.data.wsapi.TreeStoreBuilder',
      'Rally.ui.cardboard.plugin.FixedHeader',
      'Rally.ui.cardboard.plugin.Print',
      'Rally.ui.gridboard.plugin.GridBoardAddNew',
      'Rally.ui.gridboard.plugin.GridBoardOwnerFilter',
      'Rally.ui.gridboard.plugin.GridBoardFilterInfo',
      'Rally.ui.gridboard.plugin.GridBoardArtifactTypeChooser',
      'Rally.ui.gridboard.plugin.GridBoardFieldPicker',
      'Rally.ui.cardboard.plugin.ColumnPolicy',
      'Rally.ui.gridboard.plugin.GridBoardFilterInfo',
      'Rally.ui.gridboard.plugin.GridBoardFilterControl',
      'Rally.ui.gridboard.plugin.GridBoardToggleable',
      'Rally.ui.grid.plugin.TreeGridExpandedRowPersistence',
      'Rally.ui.gridboard.plugin.GridBoardExpandAll',
      'Rally.ui.gridboard.plugin.GridBoardCustomView',
      'Rally.ui.filter.view.ModelFilter',
      'Rally.ui.filter.view.OwnerFilter',
      'Rally.ui.filter.view.OwnerPillFilter',
      'Rally.ui.filter.view.TagPillFilter',
      'Rally.app.Message',
      'Rally.clientmetrics.ClientMetricsRecordable'
    ],

    mixins: [
      'Rally.app.CardFieldSelectable',
      'Rally.clientmetrics.ClientMetricsRecordable'
    ],
    componentCls: 'portfoliotracking',
    alias: 'widget.rallyportfoliotracking',

    settingsScope: 'project',
    //scopeType: 'release',
    autoScroll: false,

    config: {
      defaultSettings: {
        ignoreProjectScoping: true
      }
    },

    eModelNames: ['User Story', 'Defect', 'Defect Suite', 'Test Set'],
    sModelNames: [],

    getSettingsFields: function () {
      var fields = this.callParent(arguments);
      fields.push({
        name: 'ignoreProjectScoping',
        xtype: 'rallycheckboxfield',
        label: 'Show Children in any Project'
      });

      return fields;
    },

    launch: function() {
      if(!this.rendered) {
        this.on('afterrender', this.launch, this, {single: true});
        return;
      }

      var typeStore = Ext.create('Rally.data.wsapi.Store', {
        autoLoad: false,
        model: 'TypeDefinition',
        sorters: [{
          property: 'Ordinal',
          direction: 'ASC'
        }],
        filters: [{
          property: 'Parent.Name',
          operator: '=',
          value: 'Portfolio Item'
        }, {
          property: 'Creatable',
          operator: '=',
          value: true
        }]
      });

      typeStore.load({
        scope: this,
        callback: function (records) {
          this.sModelNames = _.map(records, function (rec) { return rec.get('TypePath'); });

          this._getGridStore().then({
            success: function(gridStore) {
              var model = gridStore.model;
              this._addGridBoard(gridStore);
              gridStore.on('parenttypeschange', function () {
                if (gridStore.isLoading()) {
                  gridStore.on('load', function () {
                    gridStore.reload();
                  }, this, { single: true });
                } else {
                  gridStore.load();
                }
              }, this);
            },
            scope: this
          });
        }
      });

    },

    _getModelNames: function () {
      return _.union(this.sModelNames, this.eModelNames);
    },

    _getGridStore: function() {
      var context = this.getContext(),
      config = {
        models: this._getModelNames(),
        autoLoad: false,
        remoteSort: true,
        root: {expanded: true},
        enableHierarchy: true,
        expandingNodesRespectProjectScoping: !this.getSetting('ignoreProjectScoping')
      };

      return Ext.create('Rally.data.wsapi.TreeStoreBuilder').build(config).then({
        success: function (store) {
          return store;
        }
      });
    },

    //_addStatsBanner: function() {
    //this.remove('statsBanner');
    //this.add({
    //xtype: 'statsbanner',
    //itemId: 'statsBanner',
    //context: this.getContext(),
    //margin: '0 0 5px 0',
    //listeners: {
    //resize: this._resizeGridBoardToFillSpace,
    //scope: this
    //}
    //});
    //},

    _addGridBoard: function (gridStore) {
{'fraction_non_alphanumeric': 0.13561154969179193, 'fraction_numerical': 0.0011895749972964205, 'mean_word_length': 2.188965517241379, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4124284', 'n_tokens_mistral': 2818, 'n_tokens_neox': 2756, 'n_words': 453}