ocket8888 commented on a change in pull request #4423: Deprecate 
cachegroup/:id/unassigned_parameters
URL: https://github.com/apache/trafficcontrol/pull/4423#discussion_r392364882
 
 

 ##########
 File path: 
traffic_portal/app/src/common/modules/table/cacheGroupParameters/TableCacheGroupParamsUnassignedController.js
 ##########
 @@ -17,22 +17,26 @@
  * under the License.
  */
 
-var TableCacheGroupParamsUnassignedController = function(cg, parameters, 
$scope, $uibModalInstance) {
+var TableCacheGroupParamsUnassignedController = function(cg, allParams, 
assignedParams, $scope, $uibModalInstance) {
 
        var selectedParams = [];
 
        $scope.cg = cg;
 
-       $scope.unassignedParams = parameters;
+       $scope.unassignedParams = allParams.filter(
+               function(p) {
+                       return !assignedParams.has(p.id);
+               }
+       );
 
        var addParam = function(paramId) {
-               if (_.indexOf(selectedParams, paramId) == -1) {
+               if (selectedParams.indexOf(paramId) == -1) {
                        selectedParams.push(paramId);
                }
        };
 
        var removeParam = function(paramId) {
-               selectedParams = _.without(selectedParams, paramId);
+               selectedParams = selectedParams.without(paramId);
 
 Review comment:
   > ``` TypeError: Array.prototype.without is not a function ```
   
   There isn't a 1:1 correspondence between `_` and ES6 collection types in 
terms of exact function names, just functionality. The equivalent in this case 
is just a negative filter:
   
   ```javascript
   selectedParams = selectedParams.filter(x=>x!==paramId);
   ```
   
   Or, without "fat-arrow" functions
   
   ```javascript
   selectedParams = selectedParams.filter(
        function (param) {
                return param !== paramId;
        }
   );
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to