]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6582 update web
authorStas Vilchik <vilchiks@gmail.com>
Fri, 19 Jun 2015 10:12:47 +0000 (12:12 +0200)
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Fri, 19 Jun 2015 12:57:08 +0000 (14:57 +0200)
server/sonar-web/src/main/js/apps/issues/models/issues.js
server/sonar-web/src/main/js/apps/issues/templates/issues-issue-filter-form.hbs
server/sonar-web/src/main/js/components/issue/collections/issues.js
server/sonar-web/src/main/js/components/issue/models/issue.js
server/sonar-web/src/main/js/components/issue/templates/issue.hbs
server/sonar-web/src/main/js/components/issue/views/assign-form-view.js

index 5c340c9ef2a54acf848d6d22fcccfd8670c0dca8..66be85a7464ead19b457e53c392bae192d3dca6d 100644 (file)
@@ -9,7 +9,24 @@ define([
       return baseUrl + '/api/issues/search';
     },
 
+    _injectRelational: function (issue, source, baseField, lookupField) {
+      var baseValue = issue[baseField];
+      if (baseValue != null && _.size(source)) {
+        var lookupValue = _.find(source, function (candidate) {
+          return candidate[lookupField] === baseValue;
+        });
+        if (lookupValue != null) {
+          Object.keys(lookupValue).forEach(function (key) {
+            var newKey = baseField + key.charAt(0).toUpperCase() + key.slice(1);
+            issue[newKey] = lookupValue[key];
+          });
+        }
+      }
+      return issue;
+    },
+
     parseIssues: function (r) {
+      var that = this;
       var find = function (source, key, keyField) {
         var searchDict = {};
         searchDict[keyField || 'key'] = key;
@@ -45,6 +62,7 @@ define([
             ruleName: rule.name
           });
         }
+        issue = that._injectRelational(issue, r.users, 'assignee', 'login');
         return issue;
       });
     },
index c0c360619693190bcaa31d94cc0ecbcca1149bce..607fd95430eca6d271c54d66cf01f959b80558dd 100644 (file)
@@ -28,9 +28,9 @@
   </li>
 
   <li>
-    {{#if assignee.login}}
-      <a href="#" class="issue-action-option" data-property="assignees" data-value="{{assignee.login}}">
-      {{t "assigned_to"}} {{assignee.name}}
+    {{#if assignee}}
+      <a href="#" class="issue-action-option" data-property="assignees" data-value="{{assignee}}">
+      {{t "assigned_to"}} {{assigneeName}}
       </a>
     {{else}}
       <a href="#" data-property="assigned" data-value="false">
index 890e00306cded0a402237bcf4b32e79e66ba02f9..f749dc448a7c5567f6bf83b3b357da9d899385c9 100644 (file)
@@ -9,7 +9,24 @@ define([
       return baseUrl + '/api/issues/search';
     },
 
+    _injectRelational: function (issue, source, baseField, lookupField) {
+      var baseValue = issue[baseField];
+      if (baseValue != null && _.size(source)) {
+        var lookupValue = _.find(source, function (candidate) {
+          return candidate[lookupField] === baseValue;
+        });
+        if (lookupValue != null) {
+          Object.keys(lookupValue).forEach(function (key) {
+            var newKey = baseField + key.charAt(0).toUpperCase() + key.slice(1);
+            issue[newKey] = lookupValue[key];
+          });
+        }
+      }
+      return issue;
+    },
+
     parse: function (r) {
+      var that = this;
       function find (source, key, keyField) {
         var searchDict = {};
         searchDict[keyField || 'key'] = key;
@@ -42,6 +59,7 @@ define([
         if (rule) {
           _.extend(issue, { ruleName: rule.name });
         }
+        issue = that._injectRelational(issue, r.users, 'assignee', 'login');
         return issue;
       });
     }
index 6f4d9cfe0c7ebbd66c7d4abd3556e608b922b1f2..cdc821785c852bfaf04652ee817426b356fa9473 100644 (file)
@@ -12,7 +12,27 @@ define(function () {
     },
 
     parse: function (r) {
-      return r.issue ? r.issue : r;
+      if (r.issue) {
+        return this._injectRelational(r.issue, r.users, 'assignee', 'login');
+      } else {
+        return r;
+      }
+    },
+
+    _injectRelational: function (issue, source, baseField, lookupField) {
+      var baseValue = issue[baseField];
+      if (baseValue != null && _.size(source)) {
+        var lookupValue = _.find(source, function (candidate) {
+          return candidate[lookupField] === baseValue;
+        });
+        if (lookupValue != null) {
+          Object.keys(lookupValue).forEach(function (key) {
+            var newKey = baseField + key.charAt(0).toUpperCase() + key.slice(1);
+            issue[newKey] = lookupValue[key];
+          });
+        }
+      }
+      return issue;
     },
 
     sync: function (method, model, options) {
index 5f79fd7671ee2fb8341e8ea3e2d4c509e1765005..bc4233d51b0591b11e27cb0bdd7c2d2cd0f5e033 100644 (file)
           <li class="issue-meta">
             {{#inArray actions "assign"}}
               <button class="button-link issue-action issue-action-with-options js-issue-assign">
-                {{#if assignee.login}}
+                {{#if assignee}}
                   {{#ifShowAvatars}}
-                    <span class="text-top">{{avatarHelper assignee.email 16}}</span>
+                    <span class="text-top">{{avatarHelper assigneeEmail 16}}</span>
                   {{/ifShowAvatars}}
                 {{/if}}
-                <span class="issue-meta-label">{{#if assignee.login}}{{assignee.name}}{{else}}{{t 'unassigned'}}{{/if}}</span>&nbsp;<i class="icon-dropdown"></i>
+                <span class="issue-meta-label">{{#if assignee}}{{assigneeName}}{{else}}{{t 'unassigned'}}{{/if}}</span>&nbsp;<i class="icon-dropdown"></i>
               </button>
             {{else}}
-              {{#if assignee.login}}
+              {{#if assignee}}
                 {{#ifShowAvatars}}
-                  <span class="text-top">{{avatarHelper assignee.email 16}}</span>
+                  <span class="text-top">{{avatarHelper assigneeEmail 16}}</span>
                 {{/ifShowAvatars}}
               {{/if}}
-              <span class="issue-meta-label">{{#if assignee.login}}{{assignee.name}}{{else}}{{t 'unassigned'}}{{/if}}</span>
+              <span class="issue-meta-label">{{#if assignee}}{{assigneeName}}{{else}}{{t 'unassigned'}}{{/if}}</span>
             {{/inArray}}
           </li>
 
index 72392d51559ce4f47b5339507ac021dbafb0ef4b..c4cd0e5b0f947e21357afc3bf3215035b4512331 100644 (file)
@@ -24,11 +24,11 @@ define([
     },
 
     getAssignee: function () {
-      return this.model.get('assignee').login;
+      return this.model.get('assignee');
     },
 
     getAssigneeName: function () {
-      return this.model.get('assignee').name;
+      return this.model.get('assigneeName');
     },
 
     onRender: function () {