用于集会的自定义HTML页面,显示基于视图的待办事项

时间:2017-04-28 17:34:51

标签: javascript html rally

我尝试创建一个根据特定条件显示积压的页面,但是当我保存或更改视图时,它不会自动更新,我需要刷新页面,任何人都可以帮助我吗?我是拉力赛应用开发的新手 这是代码:

<!DOCTYPE html>
<html>
<head>
<title>UserStory Defect List</title>

<script type="text/javascript" src="https://rally1.rallydev.com/apps/2.1/sdk-debug.js"></script>
<script type="text/javascript">

Rally.onReady(function() {
  Ext.define('UserStory.Defect.CustomizableColumnsGridBoard', {
    extend: 'Rally.app.App',
    componentCls: 'app',
    launch: function() {

      Ext.create('Rally.data.wsapi.TreeStoreBuilder').build({
        models: ['defect', 'userstory'],
        autoLoad: true,
        enableHierarchy: true
      }).then({
        success: this._onStoreBuilt,
        scope: this,
        listeners: {
                            select: this._onSelect,
                            ready: this._onLoad,
                            scope: this
                        }
    });

  },
                  _onSelect: function() {
                    var grid = this.down('rallygridboardsharedviewcontrol'),
                        store = grid.getStore();

                    store.clearFilter(true);
                    store.filter(this._getStateFilter());
                },                
                _onLoad: function() {
                },


  _onStoreBuilt: function(store) {
    var modelNames = ['defect', 'userstory'],
    context = this.getContext();
    this.add({
      xtype: 'rallygridboard',
      context: context,
      modelNames: modelNames,
      toggleState: 'grid',
      stateful: false,
      plugins: [
        'rallygridboardaddnew',
        {
          ptype: 'rallygridboardinlinefiltercontrol',
          inlineFilterButtonConfig: {
            stateful: true,
            stateId: context.getScopedStateId('filters'),
            modelNames: modelNames,
            inlineFilterPanelConfig: {
              quickFilterPanelConfig: {
                defaultFields: [
                  'ArtifactSearch',
                   'Owner',
                    'ModelType',
                     'Tags'
                ],
                addQuickFilterConfig: {

                                    whiteListFields: ['Tags','Milestones']
                                }
              },
              advancedFilterPanelConfig:
              {
              advancedFilterRowsConfig: {
                                    propertyFieldConfig: {

                                        whiteListFields: ['Tags','Milestones']
                                    }
                                }
              }
            }
          }
        },
        {
          ptype: 'rallygridboardfieldpicker',
          headerPosition: 'left',
          modelNames: modelNames,
          stateful: true,
          stateId: context.getScopedStateId('columns-example')
        },
        {
            ptype: 'rallygridboardsharedviewcontrol',
            sharedViewConfig: {
                stateful: true,
                stateId: context.getScopedStateId('custom-list-shared-view'),
                enableUrlSharing: this.isFullPageApp !== false
            }
        },
        {
          ptype: 'rallygridboardactionsmenu',
          menuItems: [
            {
              text: 'Export...',
              handler: function() {
                window.location = Rally.ui.gridboard.Export.buildCsvExportUrl(
                  this.down('rallygridboard').getGridOrBoard()
                );
              },
              scope: this
            }
          ],
          buttonConfig: {
            iconCls: 'icon-export'
          }
        },
        'rallygridboardtoggleable'
      ],
      cardBoardConfig: {
        attribute: 'ScheduleState'
      },
      gridConfig: {
        store: store,
        columnCfgs: [
          'Name',
          'ScheduleState',
          'State',
          'Iteration',
          'Release'
        ]
      },
      height: this.getHeight()-20
    });
  }
});

Rally.launchApp('UserStory.Defect.CustomizableColumnsGridBoard', {
  name: 'UserStory Defect List'
});
});
rally.nLoad(function (){location.reload();});
</script>

<style type="text/css">

</style>
</head>
<body></body>
</html>

1 个答案:

答案 0 :(得分:0)

我将代码更改为有效,但视图无法保存过滤。

    <!DOCTYPE html>
<html>
<head>
<title>UserStory Defect List</title>

<script type="text/javascript" src="https://rally1.rallydev.com/apps/2.1/sdk-debug.js"></script>
<script type="text/javascript">

Rally.onReady(function () {
    var Ext = window.Ext4 || window.Ext;

    Ext.define('Rally.apps.backlog', {
        extend: 'Rally.app.GridBoardApp',
        alias: 'widget.backlogapp',
        columnNames: ['FormattedID', 'Name', 'PlanEstimate', 'Priority', 'Owner'],
        requires: [
            'Rally.data.Ranker',
            'Rally.data.wsapi.Filter',
            'Rally.ui.gridboard.plugin.GridBoardInlineFilterControl',
            'Rally.ui.gridboard.plugin.GridBoardSharedViewControl'
        ],
        modelNames: ['hierarchicalrequirement', 'defect', 'defectsuite'],
        statePrefix: 'backlog',

        getAddNewConfig: function () {
            var config = {};
            if (this.getContext().isFeatureEnabled('S107862_TEAM_PLANNING_EXPANDED_BACKLOG_HOTNESS_PHASE_1')) {
                config.margin = 0;
            }

            return _.merge(this.callParent(arguments), config);
        },

        getPermanentFilters: function (types) {
            types = (types === undefined ? ['hierarchicalrequirement', 'defect', 'defectSuite'] : types);

            var typeCriteria = [];
            if (_.contains(types, 'defect')) {
                typeCriteria.push(Rally.data.wsapi.Filter.and([
                    { property: 'State', operator: '!=', value: 'Closed' },
                    { property: 'TypeDefOid', operator: '=', value: this._getModelFor('defect').typeDefOid }
                ]));
            }
            if (_.contains(types, 'hierarchicalrequirement')) {
                typeCriteria.push(Rally.data.wsapi.Filter.and([
                    { property: 'DirectChildrenCount', operator: '=', value: 0 },
                    { property: 'TypeDefOid', operator: '=', value: this._getModelFor('hierarchicalrequirement').typeDefOid }
                ]));
            }

            var defectSuiteModel = this._getModelFor('defectsuite');
            return [
                Rally.data.wsapi.Filter.and([
                    { property: 'Release', operator: '=', value: null },
                    { property: 'Iteration', operator: '=', value: null }
                ]),
                Rally.data.wsapi.Filter.or(typeCriteria.concat(defectSuiteModel ? [{ property: 'TypeDefOid', operator: '=', value: defectSuiteModel.typeDefOid }] : []))
            ];
        },

        getGridConfig: function () {
            return _.merge(this.callParent(arguments), {
                inlineAddConfig: {
                    listeners: {
                        beforeeditorshow: function (addNewCmp, params) {
                            params.Iteration = 'u'; // explicitly set iteration to unscheduled so it doesn't default to current iteration on TPS editor.
                        }
                    }
                }
            });
        },

        getGridStoreConfig: function () {
            return {
                enableHierarchy: false
            };
        },

        getGridBoardCustomFilterControlConfig: function () {
            var context = this.getContext();
            var blackListFields = ['Iteration', 'PortfolioItem', 'Release'];
            var whiteListFields = ['Milestones', 'Tags'];

            if (context.isFeatureEnabled('S107862_TEAM_PLANNING_EXPANDED_BACKLOG_HOTNESS_PHASE_1')) {
                return {
                    ptype: 'rallygridboardinlinefiltercontrol',
                    inlineFilterButtonConfig: {
                        stateful: true,
                        stateId: context.getScopedStateId('backlog-inline-filter'),
                        filterChildren: true,
                        modelNames: this.modelNames,
                        inlineFilterPanelConfig: {
                            quickFilterPanelConfig: {
                                defaultFields: [
                                    'ArtifactSearch',
                                    'Owner',
                                    'ModelType'
                                ],
                                addQuickFilterConfig: {
                                    blackListFields: blackListFields,
                                    whiteListFields: whiteListFields
                                }
                            },
                            advancedFilterPanelConfig: {
                                advancedFilterRowsConfig: {
                                    propertyFieldConfig: {
                                        blackListFields: blackListFields,
                                        whiteListFields: whiteListFields
                                    }
                                }
                            }
                        }
                    }
                };
            }

            return {
                showOwnerFilter: false,
                showIdFilter: true,
                idFilterConfig: {
                    stateful: true,
                    stateId: this.getScopedStateId('backlog-id-filter'),
                    storeConfig: {
                        autoLoad: true,
                        pageSize: 25,
                        fetch: ['FormattedID', '_refObjectName'],
                        filters: this.getPermanentFilters()
                    }
                }
            };
        },

        getSharedViewConfig: function() {
            var context = this.getContext();

            if (true) {
                return {
                    ptype: 'rallygridboardsharedviewcontrol',
                    sharedViewConfig: {
                        stateful: true,
                        stateId: context.getScopedStateId('backlog-shared-view'),
                        defaultViews: _.map(this._getDefaultViews(), function(view) {
                            Ext.apply(view, {
                                Value: Ext.JSON.encode(view.Value, true)
                            });
                            return view;
                        }, this),
                        enableUrlSharing: this.isFullPageApp !== false
                    },
                    enableGridEditing: context.isFeatureEnabled('S91174_ISP_SHARED_VIEWS_MAKE_PREFERENCE_NAMES_UPDATABLE')
                };
            }

            return {};
        },

        _getDefaultViews: function() {
            var rankColumnDataIndex = this.getContext().getWorkspace().WorkspaceConfiguration.DragDropRankingEnabled ? Rally.data.Ranker.RANK_FIELDS.DND : Rally.data.Ranker.RANK_FIELDS.MANUAL;

            return [
                {
                    Name: 'Default View',
                    identifier: 1,
                    Value: {
                        toggleState: 'grid',
                        columns: _.flatten([
                            { dataIndex: rankColumnDataIndex },
                            _.map(this.columnNames, function(columnName) {
                                return { dataIndex: columnName }
                            })
                        ]),
                        sorters:[{ property: rankColumnDataIndex, direction: 'ASC' }]
                    }
                }
            ];
        },

        getGridBoardConfig: function () {
            var config = this.callParent(arguments);
            return _.merge(config, {
                listeners: {
                    viewchange: function() {
                        this.loadGridBoard();
                    },
                    scope: this
                }
            });
        },

        _getModelFor: function(type) {
            return _.find(this.models, { typePath: type });
        },

        onFilterTypesChange: function(types) {
            this.gridboard.gridConfig.storeConfig.filters = this.getPermanentFilters(types);
        }
    });
    Rally.launchApp('Rally.apps.backlog', {
  name: 'UserStory Defect List'
});
});
</script>

<style type="text/css">

</style>
</head>
<body></body>
</html>