2013-11-01 18 views

回答

0

这是一个AppSDK2示例,它创建一个故事并将其安排到从迭代组合框中选择的迭代中。

<!DOCTYPE html> 
<html> 
<head> 
    <title>Create Story</title> 

    <script type="text/javascript" src="/apps/2.0rc1/sdk.js"></script> 

    <script type="text/javascript"> 
     Rally.onReady(function() { 
      Ext.define('CustomApp', { 
       extend: 'Rally.app.TimeboxScopedApp', 
       componentCls: 'app', 
       scopeType: 'iteration', 
       comboboxConfig: { 
        fieldLabel: 'Select an Iteration:', 
        labelWidth: 100, 
        width: 300 
       }, 

       addContent: function() { 
        this._getIteration(); 
       }, 

       onScopeChange: function() { 
        this._getIteration(); 
       }, 


       _getIteration: function() { 
         var iteration = this.getContext().getTimeboxScope().record.get('_ref'); 
         console.log('iteration',iteration); 

         if (!this.down('#b2')) { 
          var that = this; 
          var cb = Ext.create('Ext.Container', { 

          items: [ 
           { 
            xtype : 'rallybutton', 
            text  : 'create', 
            id: 'b2', 
            handler: function() { 
             that._getModel(iteration); 
            } 
           } 

           ] 
          }); 
         this.add(cb); 
         } 
        }, 


       _getModel: function(iteration){ 
         var that = this; 
         Rally.data.ModelFactory.getModel({ 
          type: 'UserStory', 
          context: { 
           workspace: '/workspace/1111' 
          }, 
          success: function(model) { //success on model retrieved 
           that._model = model; 
           var story = Ext.create(model, { 
            Name: 'story 777', 
            Description: 'created via appsdk2' 
           }); 
           story.save({ 
            callback: function(result, operation) { 
             if(operation.wasSuccessful()) { 
              console.log("_ref",result.get('_ref'), ' ', result.get('Name')); 
              that._record = result; 
              that._readAndUpdate(iteration); 
             } 
             else{ 
              console.log("?"); 
             } 
            } 
           }); 
          } 
         }); 
        }, 

        _readAndUpdate:function(iteration){ 
         var id = this._record.get('ObjectID'); 
         console.log('OID', id); 
         this._model.load(id,{ 
          fetch: ['Name', 'FormattedID', 'ScheduleState', 'Iteration'], 
          callback: function(record, operation){ 
           console.log('ScheduleState prior to update:', record.get('ScheduleState')); 
           console.log('Iteration prior to update:', record.get('Iteration')); 
           record.set('ScheduleState','In-Progress'); 
           record.set('Iteration', iteration); 
           record.save({ 
            callback: function(record, operation) { 
             if(operation.wasSuccessful()) { 
              console.log('ScheduleState after update:', record.get('ScheduleState')); 
              console.log('Iteration after update:', record.get('Iteration')); 
             } 
             else{ 
              console.log("?"); 
             } 
            } 
           }); 
          } 
         }) 
        } 


      }); 

         Rally.launchApp('CustomApp', { 
          name:"Create Story" 
          //parentRepos:"" 
         }); 

        }); 
       </script> 

       <style type="text/css"> 
      .app { 
       /* Add app styles here */ 
      } 
       </style> 
      </head> 
      <body></body> 
      </html> 
0

我们在前面看了一些短跑。我相信你需要将故事导出到csv(在迭代中的“Actions”下)并将它们导入到新的迭代中。

相关问题