Как заполнить историю изменений пользовательской истории в сетке

Я нашел ответ, связанный с историей изменений "Запрос версий пользовательской истории в ралли"

У меня возникли проблемы с определением того, как заполнить им сетку. Могу ли я использовать модель и заполнить историю, на которую ссылается гирд?


person Philip Johnston    schedule 20.03.2018    source источник


Ответы (1)


Вот рабочий пример, использующий другие примеры. Мне пришлось заполнить массив информацией об истории изменений и добавить ее в историю. Затем история заполнила сетку.

    // Also referenced 
    //  https://stackoverflow.com/questions/22334745/does-rally-data-custom-store-have-magic-uniqueness
    //
    Ext.define('CustomApp', 
    {
        extend: 'Rally.app.App',
        componentCls: 'app',
        launch: function() 
        {
            var panel = Ext.create('Ext.panel.Panel', 
            {
                layout: 'hbox',
            itemId: 'parentPanel',
            componentCls: 'panel',
            items: [
            {
                    xtype: 'panel',
                    title: 'Artifacts updated in the last two days',
                width: 600,
                itemId: 'childPanel1'
            },
            {
                xtype: 'panel',
                title: 'Last Revision',
                width: 600,
                itemId: 'childPanel2'
            }]
          });

          this.add(panel);

          var artifacts = Ext.create('Rally.data.wsapi.artifact.Store', 
          {
                models: ['UserStory','Defect', 'TestCase'],
            fetch: ['Owner', 'FormattedID','Name','ScheduleState','RevisionHistory','Revisions','Description','CreationDate','User'],
              autoLoad: true,
            listeners: 
            {
                    load: this._onDataLoaded,
                    scope: this
            }
          });
        },

        _onDataLoaded: function(store, data) 
        {
            this._customRecords = [];
          _.each(data, function(artifact, index) 
          {
                    this._customRecords.push(
            {
                _ref: artifact.get('_ref'),
                    FormattedID: artifact.get('FormattedID'),
                Name: artifact.get('Name'),
              RevisionID: Rally.util.Ref.getOidFromRef(artifact.get('RevisionHistory')),
              RevisionNumber: 'not loaded'
            });
          }, this);

                this._createGrid(store,data);
        },

        _createGrid: function(store,data)
        {
            var that = this;
            var g = Ext.create('Rally.ui.grid.Grid', 
            {
                itemId: 'g',
                store: store,
              enableEditing: false,
              showRowActionsColumn: false,
            columnCfgs: 
              [{text: 'Formatted ID', dataIndex: 'FormattedID'},
            {text: 'Name', dataIndex: 'Name'},
            {text: 'ScheduleState', dataIndex: 'ScheduleState'},
            {text: 'Last Revision', 
                            renderer: function (v, m, r)
                {
                    var id = Ext.id();
                Ext.defer(function () 
                {
                        Ext.widget('button', 
                    {
                            renderTo: id,
                            text: 'see',
                            width: 50,
                        handler: function () 
                        {
                            that._getRevisionHistory(data, r.data);
                        }
                      });
                }, 50);

                    return Ext.String.format('<div id="{0}"></div>', id);   
                        }
              }], height: 400,
            });

            this.down('#childPanel1').add(g);
            },

            _getRevisionHistory: function(artifactList, artifact) 
        {
                this._artifact = artifact;
            this._revisionModel = Rally.data.ModelFactory.getModel(
            {
                type: 'RevisionHistory',
                scope: this,
                success: this._onModelCreated
            });
            },

            _onModelCreated: function(model) 
        {
            model.load(Rally.util.Ref.getOidFromRef(this._artifact.RevisionHistory._ref),
            {
                scope: this,
                success: this._onModelLoaded
            });
        },

            _onModelLoaded: function(record, operation) 
        {
            var list = [];

            record.getCollection('Revisions').load(
            {
                fetch: true,
                scope: this,
                callback: function(revisions, operation, success) 
            {
                    _.each(revisions, function(artifact, index)
                    {
                        var creationdate;
                            if (Rally.environment.useSystemTimezone || Rally.environment.useWorkspaceTimeZone)
                            {
                            creationdate = Rally.util.DateTime.formatDate(artifact.data.CreationDate, true);
                        }
                            else
                            {
                                creationdate = Rally.util.DateTime.formatWithDefaultDateTime(artifact.data.CreationDate);       
                            }

                            var nodedata = 
                            {
                            rev_num: artifact.data.RevisionNumber,
                            descript: artifact.data.Description,
                            author: artifact.data.User._refObjectName,
                            creationdate: creationdate
                            };

                            if(nodedata.descript.indexOf('SCHEDULE STATE') > -1) 
                            {
                                list.push(nodedata);
                            }
                            else
                            {
                                if(nodedata.descript .indexOf('PLAN ESTIMATE') > -1) 
                                {
                                    list.push(nodedata);
                                }
                            }
                    }, this);

                    var myStore = Ext.create("Rally.data.custom.Store", 
                    {
                            autoLoad: true,
                    data : list,
                        });

                        var revGrid = Ext.create('Rally.ui.grid.Grid', 
                    {
                        itemId: 'revGrid ',
                        store: myStore,
                    enableEditing: false,
                    showRowActionsColumn: false,
                    height: 400,
                    columnCfgs:
                    [
                        {text: 'Rev #', dataIndex: 'rev_num'},
                        {text: 'Description', dataIndex: 'descript'},
                        {text: 'Author', dataIndex: 'author'},
                        {text: 'Change Date', dataIndex: 'creationdate'}
                    ]
                    });

                    this.down('#childPanel2').add(revGrid);
            }
            });
        },
    });
person Philip Johnston    schedule 21.03.2018