From 372516b37e3f1148065d580245c989891039f9a8 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 3 Aug 2022 07:41:06 +0200 Subject: [PATCH] Bug 32030: Unique - Prevent same relationships for agreements Signed-off-by: Jonathan Field Signed-off-by: Martin Renvoize Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- .../prog/js/vue/components/ERM/AgreementsFormAdd.vue | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormAdd.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormAdd.vue index 81de526bf3..0aef2ba742 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormAdd.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormAdd.vue @@ -294,6 +294,17 @@ export default { errors.push(this.$t("A license is used several times")) } + const related_agreement_ids = agreement.agreement_relationships.map(rs => rs.related_agreement_id) + const duplicate_related_agreement_ids = related_agreement_ids.filter((id, i) => related_agreement_ids.indexOf(id) !== i) + + if (duplicate_related_agreement_ids.length) { + errors.push(this.$t("An agreement is used as relationship several times")) + } + + if (agreement_licenses.filter(al => al.status == 'controlling').length > 1) { + errors.push(this.$t("Only one controlling license is allowed")) + } + errors.forEach(function (e) { setWarning(e) }) -- 2.39.5