I have a switch case statement for my filters. But it throws me complexity issues of 39 can u help me solve it??
Below is my sample code. It includes some more cases.
angular.forEach(docsClone, function(doc) {
var added = false;
angular.forEach($scope.filterOptions, function(opt) {
if (!added) {
switch (opt.AttributeId) {
case 'documentStatus':
if ((doc.documentStatus !== undefined && doc.documentStatus !== null && doc.documentStatus.indexOf(opt.AttributeValue) !== -1)) {
filteredDocs.push(doc);
added = true;
}
break;
case 'planStatus':
if ((doc.planStatus !== undefined && doc.planStatus.indexOf(opt.AttributeValue) !== -1)) {
filteredDocs.push(doc);
added = true;
}
break;
case 'planFamily':
if ((doc.planProductFamily !== undefined && doc.planProductFamily !== null && doc.planProductFamily.indexOf(opt.AttributeValue) !== -1)) {
filteredDocs.push(doc);
added = true;
}
break;
case 'planYear':
planYear(doc, opt.AttributeValue, filteredDocs, added);
break;
case 'documentType':
if ((doc.documentType !== undefined && doc.documentType !== null && doc.documentType.indexOf(opt.AttributeValue) !== -1)) {
filteredDocs.push(doc);
added = true;
}
break;
case 'businessEntity':
if ((doc.businessEntity !== undefined && doc.businessEntity !== null && doc.businessEntity.indexOf(opt.AttributeValue) !== -1)) {
filteredDocs.push(doc);
added = true;
}
break;
case 'productClass':
if ((doc.productClass !== undefined && doc.productClass !== null && doc.productClass !== null && doc.productClass.indexOf(opt.AttributeValue) !== -1) ||
(doc.planProductClass !== undefined && doc.planProductClass.indexOf(opt.AttributeValue) !== -1)) {
filteredDocs.push(doc);
added = true;
}
break;
case 'productType':
if ((doc.productType !== undefined && doc.productType !== null && doc.productType.indexOf(opt.AttributeValue) !== -1) ||
(doc.planProductType !== undefined && doc.planProductType.indexOf(opt.AttributeValue) !== -1)) {
filteredDocs.push(doc);
added = true;
}
break;
}
Aucun commentaire:
Enregistrer un commentaire