'use strict';

module.exports =

/*@ngInject*/
function EditSentence(
  $scope, SentenceWritingService, $state, _
) {
  SentenceWritingService.getSentenceWriting($state.params.id)
    .then(function(s) {
      s.category = _.findWhere($scope.availableCategories, function(o) {
        return o.$id == s.categoryId;
      });
      var tempList = _.chain(s.rules)
        .pluck('ruleId')
        .toArray()
        .map(function(s) {
          return String(s);
        })
        .value();
      s.rules = _.filter($scope.availableRules, function(r) {
        return _.contains(tempList, String(r.$id));
      });
      s.flag = _.findWhere($scope.flags, function(f) {
        return f.$id == s.flagId;
      });
      $scope.editSentence = s;
    });
};

@@ -506,14 +506,13 @@
 = _.
-filter
+chain
 ($sc
@@ -529,18 +529,34 @@
 bleRules
-, 
+)%0A        .filter(
 function
@@ -557,24 +557,26 @@
 nction(r) %7B%0A
+  
         retu
@@ -613,33 +613,181 @@
 (r.$id));%0A      
-%7D
+  %7D)%0A        .map(function(r) %7B%0A          r.quantity = _.findWhere(s.rules, %7BruleId: r.$id%7D).quantity;%0A          return r;%0A        %7D)%0A        .value(
 );%0A      s.flag 

Add quantity into edit rules.