Skip to content

Commit

Permalink
Se agregó el filtro de la propia institución en la carga de una solic…
Browse files Browse the repository at this point in the history
…itud.
  • Loading branch information
jogianotti committed Mar 16, 2016
1 parent 683720b commit 1aa9146
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ orderControllers.controller('OrderCtrl', function ($scope, $http, Upload, $filte

$scope.instance_id = instance_id;
$scope.assets_version = assets_version_admin_order;
$scope.mustFilterOwnInstance = false;

$(document).ready(function () {
$('#request-modal').on('show.bs.modal', function () {
$scope.mustFilterOwnInstance = true;
});

$('#request-modal').on('hide.bs.modal', function () {
$scope.mustFilterOwnInstance = false;
});
});

$scope.contains = function (list, item) {
return _.contains(list, item);
Expand Down Expand Up @@ -1070,4 +1081,6 @@ orderControllers.controller('OrderCtrl', function ($scope, $http, Upload, $filte
}
$('#institution-modal').modal('show');
}


});
18 changes: 14 additions & 4 deletions src/Celsius3/CoreBundle/Resources/public/ng/CCI/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,35 @@ cciWidget.directive('cciWidget', function ($translate, Country, City, Institutio
}
};

scope.filterOwnInstance = function (institutions) {
return institutions.filter(function (obj) {
if (!_.isUndefined(obj.celsius_instance)) {
return (parseInt(obj.celsius_instance.id) !== parseInt(instance_id));
}
return true;
});
};

scope.countryChanged = function () {
console.log(scope.mustFilterOwnInstance);
scope.cities = City.query({country_id: scope.select.country});
scope.institutions = Institution.query({country_id: scope.select.country, filter: scope.select.filter}, function (institutions) {
_.first(scope.select.tree).institutions = institutions;
_.first(scope.select.tree).institutions = (scope.mustFilterOwnInstance) ? scope.filterOwnInstance(institutions) : institutions;
});
};
scope.cityChanged = function () {
scope.institutions = Institution.query({country_id: scope.select.country, city_id: scope.select.city, filter: scope.select.filter}, function (institutions) {
_.first(scope.select.tree).institutions = institutions;
_.first(scope.select.tree).institutions = (scope.mustFilterOwnInstance) ? scope.filterOwnInstance(institutions) : institutions;
});
};
scope.institutionChanged = function (data) {
Institution.parent({parent_id: data.institution}, function (institutions) {
if (data.child.length === 0 && institutions.length > 0) {
var node = new Node(++scope.select_count);
node.institutions = institutions;
node.institutions = (scope.mustFilterOwnInstance) ? scope.filterOwnInstance(institutions) : institutions;
data.child = [node];
} else if (data.child.length > 0) {
_.first(data.child).institutions = institutions;
_.first(data.child).institutions = (scope.mustFilterOwnInstance) ? scope.filterOwnInstance(institutions) : institutions;
}
});
};
Expand Down

0 comments on commit 1aa9146

Please sign in to comment.