Skip to content

Commit

Permalink
#1852 Allow removing a custom field value from a case
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Mar 18, 2021
1 parent d61dd53 commit cc3cf74
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
value: newValue
});
};
this.removeCustomField = function(fieldId) {
this.removeCustomField = function(id) {
this.onRemove({
fieldId: fieldId
fieldId: id
})
}
},
Expand All @@ -22,6 +22,7 @@
index: '<',
field: '<',
value: '=',
id: '<',
onUpdate: '&',
onRemove: '&',
editable: '<',
Expand Down
9 changes: 9 additions & 0 deletions frontend/app/scripts/controllers/case/CaseDetailsCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@
.then(function () {
return CaseSrv.removeCustomField(fieldId);
})
.then(function() {
var newList = _.reject($scope.caze.customFields, function(item) {
return item._id === fieldId
});

$scope.caze.customFields = newList;

$scope.updateCustomFieldsList();
})
.catch(function(err) {
if(err && !_.isString(err)) {
NotificationSrv.error('Remove custom field', err.data, err.status);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<dl class="dl-horizontal custom-field-input">
<dt class="pull-left">
<span uib-tooltip="{{$ctrl.field.description}}">{{$ctrl.field.name}}</span>
<a ng-if="$ctrl.removable" class="pull-right mr-xxxs" href ng-click="$ctrl.removeCustomField($ctrl.field.id)" uib-tooltip="Delete">
<a ng-if="$ctrl.removable" class="pull-right mr-xxxs" href ng-click="$ctrl.removeCustomField($ctrl.id)" uib-tooltip="Delete">
<i class="fa fa-trash text-danger"></i>
</a>
</dt>
Expand Down
3 changes: 2 additions & 1 deletion frontend/app/views/partials/case/details/custom.fields.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ <h4 class="vpad10 text-primary">
field="customFieldsCache[customField.name]"
on-update="updateField(fieldName, value)"
on-remove="removeField(fieldId)"
value="customField.value"></custom-field-input>
value="customField.value"
id="customField._id"></custom-field-input>
</div>
</div>
</div>
Expand Down

0 comments on commit cc3cf74

Please sign in to comment.