Skip to content

Commit

Permalink
Potential fix for monarc-project/MonarcAppFO#94
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricbonhomme committed Jul 9, 2018
1 parent fbc5aec commit 4cded3c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
13 changes: 13 additions & 0 deletions src/AnrLayoutCtrl.js
Expand Up @@ -1402,6 +1402,19 @@
});
};

$scope.onEditCustomColumn = function (id, newValue) {
AnrService.patchScaleType($scope.model.anr.id, id, newValue, $scope.scales.language, function () {
$scope.updateScaleTypes(function () {
$timeout(function () {
var scroller = document.getElementById('horiz-scrollable');
scroller.scrollLeft = scroller.scrollWidth;
}, 0, false);
});
// $scope.column.name = newValue;
$scope.$broadcast('scales-impacts-type-changed');
});
};

$scope.setImpactVisibility = function (id, visible) {
AnrService.patchScaleType($scope.model.anr.id, id, {isHidden: visible ? 0 : 1}, function () {
$scope.updateScaleTypes();
Expand Down
9 changes: 7 additions & 2 deletions src/AnrService.js
Expand Up @@ -267,8 +267,13 @@
}
};

var patchScaleType = function (anr_id, scale_type_id, data, success, error) {
self.ScalesTypesResource.patch({anrId: anr_id, scaleTypeId: scale_type_id}, data, success, error);
var patchScaleType = function (anr_id, scale_type_id, data, langue = null, success, error) {
if ($rootScope.OFFICE_MODE == "FO") {
langue = $rootScope.getAnrLanguage().toString();
}
var new_data = {};
new_data['label' + langue] = data
self.ScalesTypesResource.patch({anrId: anr_id, scaleTypeId: scale_type_id}, new_data, success, error);
};

var deleteScaleType = function (anr_id, scale_type_id, success, error) {
Expand Down
3 changes: 2 additions & 1 deletion views/_anr.evalscales.html
Expand Up @@ -33,7 +33,8 @@ <h4 ng-if="(OFFICE_MODE == 'FO' && !scalesCanChange ) || isAnrReadOnly"><span tr
<tr>
<th></th>
<th ng-show="!type.isHidden || display.show_hidden_impacts" ng-repeat="type in scales_types">
{{ type['label' + scales.language] }}
<span class="text-blue" ng-if="type.type == 'CUS' && !isAnrReadOnly" inline-edit="column.name" inline-edit-callback="onEditCustomColumn(type.id, newValue)" inline-edit-btn-edit="" inline-edit-on-blur="save" inline-edit-on-click inline-edit-placeholder="{{ type['label' + scales.language]? type['label' + scales.language] : '...' }}"></span>
<span class="text-blue" ng-if="type.type != 'CUS' && !isAnrReadOnly">{{ type['label' + scales.language] }}</span>
<md-button class="md-icon-button md-warn" ng-if="type.type == 'CUS' && !isAnrReadOnly" ng-click="deleteCustomScaleType(type.id)">
<md-icon>delete</md-icon></md-button>
<md-button class="md-icon-button md-primary" ng-if="type.type != 'CUS' && !isAnrReadOnly" ng-click="setImpactVisibility(type.id, !!type.isHidden)">
Expand Down

0 comments on commit 4cded3c

Please sign in to comment.