From c7ee4d8c19762a201ea2c9003b9f98352bf4d86b Mon Sep 17 00:00:00 2001
From: Francis Lachapelle
Date: Mon, 21 Mar 2022 10:12:21 -0400
Subject: [PATCH] fix(addressbook(web)): update card on save when certificate
is removed
---
UI/Contacts/UIxContactActions.m | 6 +++++-
UI/Contacts/UIxContactEditor.m | 5 +++++
.../ContactsUI/UIxContactEditorTemplate.wox | 9 ++++++++-
UI/WebServerResources/js/Contacts/Card.service.js | 13 +++++++++----
UI/WebServerResources/js/Contacts/CardController.js | 5 +++++
5 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/UI/Contacts/UIxContactActions.m b/UI/Contacts/UIxContactActions.m
index 1defa6c3c..01460668c 100644
--- a/UI/Contacts/UIxContactActions.m
+++ b/UI/Contacts/UIxContactActions.m
@@ -186,7 +186,11 @@
- (WOResponse *) removeCertificateAction
{
- [[[self clientObject] vCard] setCertificate: nil];
+ SOGoContactGCSEntry *contact;
+
+ contact = [self clientObject];
+ [[contact vCard] setCertificate: nil];
+ [contact save];
return [self responseWith204];
}
diff --git a/UI/Contacts/UIxContactEditor.m b/UI/Contacts/UIxContactEditor.m
index e7741fc1d..e01475d87 100644
--- a/UI/Contacts/UIxContactEditor.m
+++ b/UI/Contacts/UIxContactEditor.m
@@ -240,6 +240,7 @@ static Class SOGoContactGCSEntryK = Nil;
NSCalendarDate *date;
CardElement *element;
id o;
+ BOOL hasCertificate;
unsigned int i, year, month, day;
@@ -418,6 +419,10 @@ static Class SOGoContactGCSEntryK = Nil;
}
}
+ hasCertificate = [[attributes objectForKey: @"hasCertificate"] boolValue];
+ if (!hasCertificate)
+ [card setCertificate: nil];
+
[card cleanupEmptyChildren];
}
diff --git a/UI/Templates/ContactsUI/UIxContactEditorTemplate.wox b/UI/Templates/ContactsUI/UIxContactEditorTemplate.wox
index d96e9037b..9f59610c4 100644
--- a/UI/Templates/ContactsUI/UIxContactEditorTemplate.wox
+++ b/UI/Templates/ContactsUI/UIxContactEditorTemplate.wox
@@ -145,7 +145,7 @@
{{::'S/MIME Certificate' | loc}}
+ ng-click="editor.removeCertificate(contactForm)">
expand_more
@@ -154,6 +154,13 @@
+
diff --git a/UI/WebServerResources/js/Contacts/Card.service.js b/UI/WebServerResources/js/Contacts/Card.service.js
index e0a73189c..af2c8050e 100644
--- a/UI/WebServerResources/js/Contacts/Card.service.js
+++ b/UI/WebServerResources/js/Contacts/Card.service.js
@@ -575,12 +575,17 @@
* @desc Remove any S/MIME certificate associated with the account.
* @returns a promise of the HTTP operation
*/
- Card.prototype.$removeCertificate = function() {
+ Card.prototype.$removeCertificate = function(immediate) {
var _this = this;
- return Card.$$resource.fetch(this.$path(), 'removeCertificate').then(function() {
- _this.hasCertificate = false;
- });
+ if (immediate) {
+ return Card.$$resource.fetch(this.$path(), 'removeCertificate').then(function() {
+ _this.hasCertificate = false;
+ });
+ }
+ else {
+ this.hasCertificate = false;
+ }
};
/**
diff --git a/UI/WebServerResources/js/Contacts/CardController.js b/UI/WebServerResources/js/Contacts/CardController.js
index f4241251c..9d2c1a307 100644
--- a/UI/WebServerResources/js/Contacts/CardController.js
+++ b/UI/WebServerResources/js/Contacts/CardController.js
@@ -79,6 +79,11 @@
focus('org_' + i);
};
+ this.removeCertificate = function (form) {
+ this.card.$removeCertificate();
+ form.$setDirty();
+ };
+
this.addBirthday = function () {
this.card.birthday = new Date();
};