Fix issue with repeatedly adding and removing
This commit is contained in:
parent
fbba3034fc
commit
b3d0b7ce1b
|
@ -20,6 +20,7 @@ class NotificationInputSchema(LemurInputSchema):
|
||||||
description = fields.String()
|
description = fields.String()
|
||||||
active = fields.Boolean()
|
active = fields.Boolean()
|
||||||
plugin = fields.Nested(PluginInputSchema, required=True)
|
plugin = fields.Nested(PluginInputSchema, required=True)
|
||||||
|
certificates = fields.Nested(AssociatedCertificateSchema, many=True, missing=[])
|
||||||
added_certificates = fields.Nested(AssociatedCertificateSchema, many=True, missing=[])
|
added_certificates = fields.Nested(AssociatedCertificateSchema, many=True, missing=[])
|
||||||
removed_certificates = fields.Nested(AssociatedCertificateSchema, many=True, missing=[])
|
removed_certificates = fields.Nested(AssociatedCertificateSchema, many=True, missing=[])
|
||||||
|
|
||||||
|
|
|
@ -242,7 +242,7 @@ class Notifications(AuthenticatedResource):
|
||||||
"""
|
"""
|
||||||
.. http:get:: /notifications/1
|
.. http:get:: /notifications/1
|
||||||
|
|
||||||
Get a specific account
|
Get a specific notification
|
||||||
|
|
||||||
**Example request**:
|
**Example request**:
|
||||||
|
|
||||||
|
|
|
@ -11,26 +11,31 @@ angular.module('lemur')
|
||||||
if (this.addedCertificates === undefined) {
|
if (this.addedCertificates === undefined) {
|
||||||
this.addedCertificates = [];
|
this.addedCertificates = [];
|
||||||
}
|
}
|
||||||
|
if (_.some(this.addedCertificates, function (cert) {
|
||||||
|
return cert.id === certificate.id;
|
||||||
|
})) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.certificates.push(certificate);
|
this.certificates.push(certificate);
|
||||||
this.addedCertificates.push(certificate);
|
this.addedCertificates.push(certificate);
|
||||||
if (this.removedCertificates !== undefined) {
|
if (this.removedCertificates !== undefined) {
|
||||||
const removedIndex = this.removedCertificates.indexOf(certificate);
|
const indexInRemovedList = _.findIndex(this.removedCertificates, function (cert) {
|
||||||
if (removedIndex > -1) {
|
return cert.id === certificate.id;
|
||||||
this.removedCertificates.splice(removedIndex, 1);
|
});
|
||||||
}
|
this.removedCertificates.splice(indexInRemovedList, 1);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
removeCertificate: function (index) {
|
removeCertificate: function (index) {
|
||||||
if (this.removedCertificates === undefined) {
|
if (this.removedCertificates === undefined) {
|
||||||
this.removedCertificates = [];
|
this.removedCertificates = [];
|
||||||
}
|
}
|
||||||
const removedCert = this.certificates.splice(index, 1);
|
const removedCert = this.certificates.splice(index, 1)[0];
|
||||||
this.removedCertificates.push(removedCert);
|
this.removedCertificates.push(removedCert);
|
||||||
if (this.addedCertificates !== undefined) {
|
if (this.addedCertificates !== undefined) {
|
||||||
const addedIndex = this.addedCertificates.indexOf(removedCert);
|
const indexInAddedList = _.findIndex(this.addedCertificates, function (cert) {
|
||||||
if (addedIndex > -1) {
|
return cert.id === removedCert.id;
|
||||||
this.addedCertificates.splice(addedIndex, 1);
|
});
|
||||||
}
|
this.addedCertificates.splice(indexInAddedList, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -72,7 +77,9 @@ angular.module('lemur')
|
||||||
};
|
};
|
||||||
|
|
||||||
NotificationService.update = function (notification) {
|
NotificationService.update = function (notification) {
|
||||||
this.certificates = [];
|
// this.certificates = [];
|
||||||
|
// this.removedCertificates = [];
|
||||||
|
// this.addedCertificates = [];
|
||||||
return notification.put();
|
return notification.put();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue