2012-08-28 3 views
1

사용자 정의 kanban 보드를 만들었습니다. 보드 안에는 누군가가 카드를 검토 할 때 카드를 쓸 것이라고 주장 할 수있는 단추가 있습니다. 버튼을 클릭하면 라이브 데이터를 확인하여 화면이로드 된 이후에 아무도 요구하지 않도록했습니다.Rally API 2.0 모델 대 모델

나는 그 이야기가 있다면 모든 것을 가지고 있지만, 결함이 있다면 문제가있다. 따라서 코드를 검토 할 때 Rally.data.ModelFactory.getModel을 입력 한 다음 model.load을 입력 한 것으로 나타났습니다.

그래서이 부분을 .getModels으로 변경하고 유형을 변경하여 스토리와 결함을 통합해야한다고 생각합니다. 그러나, 내가 이것을 할 때, 어떻게 그것을 검색에 적절하게 넣을 수 있습니까? 내가 그것을로드하고 확인하는 방법에 붙어지고있다.

코드는 다음과 같습니다

if (this.getRecord().get("StoryStatus") == "Review Ready") { 
        if (this.getRecord().get("CodeReviewedBy") == '') { 
         content.add([{ xtype: 'button', 
          text: 'I will review', 
          scale: 'small', 
          listeners: { 
           click: function (btn, e, eOpts) { 
            // Verify nobody has claimed it yet ! 
            var mod = Rally.data.ModelFactory.getModels({ 
             types: ['HierarchicalRequirement', 'Defect'], 
             success: function (models) { 
              var model; 
              debugger; 
              if (models.Defect) model = models.Defect 
              else model = models.HierarchicalRequirement; 

              model.load(eOpts.scope.record.internalId, { 
               fetch: ['CodeReviewedBy'], 
               success: function (currentRecord) { 
                var currentCRB = currentRecord.get("CodeReviewedBy"); 
                if (currentCRB) { 
                 window.alert('While you were sitting around doing nothing, ' + currentCRB + ' already started reviewing this code'); 
                } else { 
                 var con = Rally.environment.getContext(); 
                 currentRecord.set("CodeReviewedBy", con.context.user._refObjectName); 
                 currentRecord.save(); 
                 location.reload(true); 
                 //eOpts.scope.refresh(); 
                } 

               } 
              }); 
             } 
            }); 
            this.refresh() 
           }, 
           scope: this 
          } 
         }]); 
        } else { 
         content.add([{ xtype: 'label', 
          html: '<b>Being reviewed by: </b>' + this.getRecord().get("CodeReviewedBy") + '<br>' 
         }]); 
        } 
       } 
+0

내가 알 수있는 최고의 코드는 아니지만 잘하면 계속 따라 할 수 있습니다. 그 디버거 문 주위에 문제가 있는데, 모든 이야기와 결함을 반환하는 모델을 가져야 만하는 것처럼 보입니까 ?? 그냥 클릭하지 않고 말이되는 것. 기본적으로 CodeReviewer 필드가 스토리/결함에 대해 실시간으로 데이터베이스에서 비어 있는지 찾아 봅니다. 내가 너무 복잡하게 보이고있는 것 같아요 :) – user1537867

답변

2

당신은 당신이 실제로 당신이 다시 ModelFactory.getModels를 사용하지 저장됩니다 모델 -을 얻기 위해 자기 속성을 사용할 수있는 기록이 있으면.

var model = this.getRecord().self; 
model.load(this.getRecord().get('ObjectID'), { 
    //fetch, success, etc... 
}); 
+0

카일, 고마워요. 실제로 형식을 잡아서 getodels.types에서 사용하기 위해 조금 변경했습니다. 필요한 경우에만 모델을로드합니다. 팁 고마워 ! – user1537867