This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git


The following commit(s) were added to refs/heads/develop by this push:
     new 621e599b AIRAVATA-3662 Adding checkbox label text input to user 
agreement field editor
621e599b is described below

commit 621e599bcc9e9dccd24266ab6f785edcf3f9d93e
Author: Marcus Christie <[email protected]>
AuthorDate: Mon Oct 24 17:01:27 2022 -0400

    AIRAVATA-3662 Adding checkbox label text input to user agreement field 
editor
---
 .../ExtendedUserProfileFieldEditor.vue             | 31 +++++++++++++++++++++-
 .../src/store/modules/extendedUserProfile.js       |  3 +++
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git 
a/django_airavata/apps/admin/static/django_airavata_admin/src/components/users/field-editors/ExtendedUserProfileFieldEditor.vue
 
b/django_airavata/apps/admin/static/django_airavata_admin/src/components/users/field-editors/ExtendedUserProfileFieldEditor.vue
index 95dd6dc3..965fdd06 100644
--- 
a/django_airavata/apps/admin/static/django_airavata_admin/src/components/users/field-editors/ExtendedUserProfileFieldEditor.vue
+++ 
b/django_airavata/apps/admin/static/django_airavata_admin/src/components/users/field-editors/ExtendedUserProfileFieldEditor.vue
@@ -6,6 +6,19 @@
         >This field is required.</b-form-invalid-feedback
       >
     </b-form-group>
+    <b-form-group
+      label="Checkbox Label"
+      label-cols="3"
+      v-if="extendedUserProfileField.field_type === 'user_agreement'"
+    >
+      <b-form-input
+        v-model="checkbox_label"
+        :state="validateState($v.checkbox_label)"
+      />
+      <b-form-invalid-feedback :state="validateState($v.checkbox_label)"
+        >This field is required.</b-form-invalid-feedback
+      >
+    </b-form-group>
     <b-form-group label="Help text" label-cols="3">
       <b-form-input v-model="help_text" />
     </b-form-group>
@@ -190,7 +203,7 @@
 <script>
 import { mapGetters, mapMutations } from "vuex";
 import { validationMixin } from "vuelidate";
-import { required } from "vuelidate/lib/validators";
+import { required, requiredIf } from "vuelidate/lib/validators";
 import { errors } from "django-airavata-common-ui";
 export default {
   mixins: [validationMixin],
@@ -206,6 +219,15 @@ export default {
         this.$v.name.$touch();
       },
     },
+    checkbox_label: {
+      get() {
+        return this.extendedUserProfileField.checkbox_label;
+      },
+      set(value) {
+        this.setCheckboxLabel({ value, field: this.extendedUserProfileField });
+        this.$v.checkbox_label.$touch();
+      },
+    },
     help_text: {
       get() {
         return this.extendedUserProfileField.help_text;
@@ -250,12 +272,18 @@ export default {
     valid() {
       return !this.$v.$invalid;
     },
+    checkboxLabelIsRequired() {
+      return this.extendedUserProfileField.field_type === "user_agreement";
+    },
   },
   validations() {
     return {
       name: {
         required,
       },
+      checkbox_label: {
+        required: requiredIf("checkboxLabelIsRequired"),
+      },
       choices: {
         $each: {
           display_text: {
@@ -278,6 +306,7 @@ export default {
   methods: {
     ...mapMutations("extendedUserProfile", [
       "setName",
+      "setCheckboxLabel",
       "setHelpText",
       "setRequired",
       "setOther",
diff --git 
a/django_airavata/apps/admin/static/django_airavata_admin/src/store/modules/extendedUserProfile.js
 
b/django_airavata/apps/admin/static/django_airavata_admin/src/store/modules/extendedUserProfile.js
index a058bee1..1c0d456c 100644
--- 
a/django_airavata/apps/admin/static/django_airavata_admin/src/store/modules/extendedUserProfile.js
+++ 
b/django_airavata/apps/admin/static/django_airavata_admin/src/store/modules/extendedUserProfile.js
@@ -94,6 +94,9 @@ const mutations = {
   setName(state, { value, field }) {
     setFieldProp(state, field, "name", value);
   },
+  setCheckboxLabel(state, { value, field }) {
+    setFieldProp(state, field, "checkbox_label", value);
+  },
   setHelpText(state, { value, field }) {
     setFieldProp(state, field, "help_text", value);
   },

Reply via email to