Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/monarc-project/ng-anr
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricbonhomme committed Sep 15, 2022
2 parents dc2f21c + 888c624 commit 2eef504
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 24 deletions.
21 changes: 8 additions & 13 deletions src/RiskRecommendationPartialCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
ClientRecommandationService.attachToRisk($scope.model.anr.id, data.id, riskId, isOpRiskMode,
function () {
toastr.success(gettextCatalog.getString("The recommendation has been attached to this risk."));
updateRecommandations();
$scope.updateRecommandations();
});
})
}, function (reject) {
Expand Down Expand Up @@ -71,7 +71,7 @@
rec.recommandation.anr = $scope.model.anr.id;
ClientRecommandationService.updateRecommandation(rec.recommandation, function () {
toastr.success(gettextCatalog.getString("The recommendation has been edited successfully"));
updateRecommandations();
$scope.updateRecommandations();
});
}, function (reject) {
$scope.handleRejectionDialog(reject);
Expand All @@ -98,7 +98,7 @@
function () {
toastr.success(gettextCatalog.getString("The recommendation has been attached to this risk."));
$scope.rec_edit.rec = null;
updateRecommandations();
$scope.updateRecommandations();
});
};

Expand All @@ -114,7 +114,7 @@
$mdDialog.show(confirm).then(function() {
ClientRecommandationService.detachFromRisk($scope.model.anr.id, recommandation.id,
function () {
updateRecommandations();
$scope.updateRecommandations();
toastr.success(gettextCatalog.getString('The recommendation has been detached.'),
gettextCatalog.getString('Operation successful'));
}
Expand All @@ -141,7 +141,7 @@

ClientRecommandationService.attachToRisk($scope.model.anr.id, data.id, riskId, isOpRiskMode,
function () {
updateRecommandations();
$scope.updateRecommandations();
toastr.success(gettextCatalog.getString("The recommendation has been attached to this risk."));
});
})
Expand All @@ -162,7 +162,7 @@
$mdDialog.show(confirm).then(function() {
ClientRecommandationService.deleteRecommandation({anr: $scope.model.anr.id, id: recommandation.recommandation.uuid},
function () {
updateRecommandations();
$scope.updateRecommandations();
toastr.success(gettextCatalog.getString('The recommendation has been deleted successfully'),
gettextCatalog.getString('Operation successful'));
}
Expand All @@ -172,12 +172,12 @@
});
}

var updateRecommandations = function () {
$scope.updateRecommandations = function () {
// We need to debounce the update here as the view uses twice the controller. The data is shared
// through the broadcast event, but we have no way to know which controller will take care of the actual
// API request. The first one will "lock" updateDebounce in the scope, and the other one will skip
// the request.
if (!$rootScope.updateDebounce) {
if (!$rootScope.updateDebounce && riskId) {
$rootScope.updateDebounce = true;

ClientRecommandationService.getRiskRecommandations($scope.model.anr.id, riskId, isOpRiskMode).then(function (data) {
Expand All @@ -193,11 +193,6 @@
$rootScope.$on('recommandations-loaded', function (ev, recs) {
$scope.recommandations = recs;
})

$timeout(function () {
updateRecommandations();
})

}

function CreateRecommandationDialog($scope, $mdDialog, ClientRecommandationService, gettextCatalog, toastr, $q, anrId,
Expand Down
6 changes: 1 addition & 5 deletions views/_oprisk_sheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
{{opsheet_risk.comment}}
</td>
</tr>
<tr ng-if="OFFICE_MODE == 'FO'" ng-controller="RiskRecommendationPartialCtrl" monarc-mode="operational">
<tr ng-if="OFFICE_MODE == 'FO'" ng-controller="RiskRecommendationPartialCtrl" monarc-mode="operational" ng-init="updateRecommandations()">
<td class="bold" style="vertical-align:top;">
<span translate>Recommendations</span>
<div layout="row" layout-align="center center">
Expand Down Expand Up @@ -189,8 +189,4 @@
<md-icon>chevron_right</md-icon>
</md-button>
</div>

<!-- <ng-include ng-if="OFFICE_MODE == 'FO'" monarc-mode="operational" ng-controller="RiskRecommendationPartialCtrl" src="'views/anr/_risk_rec_create_form.html'"></ng-include>
<ng-include ng-if="OFFICE_MODE == 'FO'" monarc-mode="operational" ng-controller="RiskRecommendationPartialCtrl" src="'views/anr/_risk_rec_form.html'"></ng-include> -->

</div>
7 changes: 1 addition & 6 deletions views/_risk_sheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
<td class="bold" translate>Existing controls</td>
<td colspan="3">{{ sheet_risk.comment }}</td>
</tr>
<tr ng-if="OFFICE_MODE == 'FO'" ng-controller="RiskRecommendationPartialCtrl" monarc-mode="information">
<tr ng-if="OFFICE_MODE == 'FO'" ng-controller="RiskRecommendationPartialCtrl" monarc-mode="information" ng-init="updateRecommandations()">
<td class="bold" style="vertical-align:top;">
<span translate>Recommendations</span>
<div layout="row" layout-align="center center">
Expand Down Expand Up @@ -198,10 +198,5 @@
{{ 'Next' | translate }}
<md-icon>chevron_right</md-icon>
</md-button>

</div>


<!-- <ng-include ng-if="OFFICE_MODE == 'FO'" monarc-mode="information" ng-controller="RiskRecommendationPartialCtrl" src="'views/anr/_risk_rec_create_form.html'"></ng-include>
<ng-include ng-if="OFFICE_MODE == 'FO'" monarc-mode="information" ng-controller="RiskRecommendationPartialCtrl" src="'views/anr/_risk_rec_form.html'"></ng-include> -->
</div>

0 comments on commit 2eef504

Please sign in to comment.