From cc3cf74ea97dd107efb07d78c92b052588d6310b Mon Sep 17 00:00:00 2001 From: Nabil Adouani Date: Thu, 18 Mar 2021 16:02:37 +0100 Subject: [PATCH] #1852 Allow removing a custom field value from a case --- .../components/common/custom-field-input.component.js | 5 +++-- frontend/app/scripts/controllers/case/CaseDetailsCtrl.js | 9 +++++++++ .../components/common/custom-field-input.component.html | 2 +- .../app/views/partials/case/details/custom.fields.html | 3 ++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/frontend/app/scripts/components/common/custom-field-input.component.js b/frontend/app/scripts/components/common/custom-field-input.component.js index f9deba706d..98353a5fd9 100644 --- a/frontend/app/scripts/components/common/custom-field-input.component.js +++ b/frontend/app/scripts/components/common/custom-field-input.component.js @@ -10,9 +10,9 @@ value: newValue }); }; - this.removeCustomField = function(fieldId) { + this.removeCustomField = function(id) { this.onRemove({ - fieldId: fieldId + fieldId: id }) } }, @@ -22,6 +22,7 @@ index: '<', field: '<', value: '=', + id: '<', onUpdate: '&', onRemove: '&', editable: '<', diff --git a/frontend/app/scripts/controllers/case/CaseDetailsCtrl.js b/frontend/app/scripts/controllers/case/CaseDetailsCtrl.js index 70cbb27cab..b07cc8aaef 100644 --- a/frontend/app/scripts/controllers/case/CaseDetailsCtrl.js +++ b/frontend/app/scripts/controllers/case/CaseDetailsCtrl.js @@ -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); diff --git a/frontend/app/views/components/common/custom-field-input.component.html b/frontend/app/views/components/common/custom-field-input.component.html index 35534b998d..e241299c69 100644 --- a/frontend/app/views/components/common/custom-field-input.component.html +++ b/frontend/app/views/components/common/custom-field-input.component.html @@ -1,7 +1,7 @@
{{$ctrl.field.name}} - +
diff --git a/frontend/app/views/partials/case/details/custom.fields.html b/frontend/app/views/partials/case/details/custom.fields.html index f57c3eb661..7e35868ac9 100644 --- a/frontend/app/views/partials/case/details/custom.fields.html +++ b/frontend/app/views/partials/case/details/custom.fields.html @@ -45,7 +45,8 @@

field="customFieldsCache[customField.name]" on-update="updateField(fieldName, value)" on-remove="removeField(fieldId)" - value="customField.value"> + value="customField.value" + id="customField._id">