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

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

commit 9f9760ea6bca7a4cae9a59a624be26ea33cca580
Author: Marcus Christie <[email protected]>
AuthorDate: Tue Apr 26 13:38:44 2022 -0400

    AIRAVATA-3565 Ext User Profile UI with load/saving user_agreement values
---
 .../js/components/ExtendedUserProfileEditor.vue    |  2 ++
 ...ExtendedUserProfileUserAgreementFieldEditor.vue | 36 ++++++++++++++++++++++
 .../js/store/modules/extendedUserProfile.js        | 20 ++++++++++++
 3 files changed, 58 insertions(+)

diff --git 
a/django_airavata/apps/auth/static/django_airavata_auth/js/components/ExtendedUserProfileEditor.vue
 
b/django_airavata/apps/auth/static/django_airavata_auth/js/components/ExtendedUserProfileEditor.vue
index 052d2893..4ab87d89 100644
--- 
a/django_airavata/apps/auth/static/django_airavata_auth/js/components/ExtendedUserProfileEditor.vue
+++ 
b/django_airavata/apps/auth/static/django_airavata_auth/js/components/ExtendedUserProfileEditor.vue
@@ -15,6 +15,7 @@ import { mapGetters } from "vuex";
 import ExtendedUserProfileMultiChoiceFieldEditor from 
"./ExtendedUserProfileMultiChoiceFieldEditor.vue";
 import ExtendedUserProfileSingleChoiceFieldEditor from 
"./ExtendedUserProfileSingleChoiceFieldEditor.vue";
 import ExtendedUserProfileTextFieldEditor from 
"./ExtendedUserProfileTextFieldEditor.vue";
+import ExtendedUserProfileUserAgreementFieldEditor from 
'./ExtendedUserProfileUserAgreementFieldEditor.vue';
 export default {
   computed: {
     ...mapGetters("extendedUserProfile", ["extendedUserProfileFields"]),
@@ -25,6 +26,7 @@ export default {
         text: ExtendedUserProfileTextFieldEditor,
         single_choice: ExtendedUserProfileSingleChoiceFieldEditor,
         multi_choice: ExtendedUserProfileMultiChoiceFieldEditor,
+        user_agreement: ExtendedUserProfileUserAgreementFieldEditor,
       };
 
       if (extendedUserProfileField.field_type in fieldTypeEditors) {
diff --git 
a/django_airavata/apps/auth/static/django_airavata_auth/js/components/ExtendedUserProfileUserAgreementFieldEditor.vue
 
b/django_airavata/apps/auth/static/django_airavata_auth/js/components/ExtendedUserProfileUserAgreementFieldEditor.vue
new file mode 100644
index 00000000..4857c4e3
--- /dev/null
+++ 
b/django_airavata/apps/auth/static/django_airavata_auth/js/components/ExtendedUserProfileUserAgreementFieldEditor.vue
@@ -0,0 +1,36 @@
+<template>
+  <b-form-group
+    :label="extendedUserProfileField.name"
+    :description="extendedUserProfileField.help_text"
+  >
+    <b-form-checkbox v-model="value" :unchecked-value="false">
+      {{ extendedUserProfileField.checkbox_label }}
+    </b-form-checkbox>
+  </b-form-group>
+</template>
+
+<script>
+import { mapGetters, mapMutations } from "vuex";
+export default {
+  props: ["extendedUserProfileField"],
+  computed: {
+    ...mapGetters("extendedUserProfile", ["getUserAgreementValue"]),
+    value: {
+      get() {
+        return this.getUserAgreementValue(this.extendedUserProfileField.id);
+      },
+      set(value) {
+        this.setUserAgreementValue({
+          value,
+          id: this.extendedUserProfileField.id,
+        });
+      },
+    },
+  },
+  methods: {
+    ...mapMutations("extendedUserProfile", ["setUserAgreementValue"]),
+  },
+};
+</script>
+
+<style></style>
diff --git 
a/django_airavata/apps/auth/static/django_airavata_auth/js/store/modules/extendedUserProfile.js
 
b/django_airavata/apps/auth/static/django_airavata_auth/js/store/modules/extendedUserProfile.js
index e55c5353..b58e9ca4 100644
--- 
a/django_airavata/apps/auth/static/django_airavata_auth/js/store/modules/extendedUserProfile.js
+++ 
b/django_airavata/apps/auth/static/django_airavata_auth/js/store/modules/extendedUserProfile.js
@@ -34,6 +34,12 @@ const getters = {
       return null;
     }
   },
+  getUserAgreementValue: (state) => (id) => {
+    const value = state.extendedUserProfileValues.find(
+      (v) => v.ext_user_profile_field === id
+    );
+    return value && value.agreement_value;
+  },
 };
 
 const actions = {
@@ -114,6 +120,20 @@ const mutations = {
       });
     }
   },
+  setUserAgreementValue(state, { value, id }) {
+    const profileValue = state.extendedUserProfileValues.find(
+      (v) => v.ext_user_profile_field === id
+    );
+    if (profileValue) {
+      profileValue.agreement_value = value;
+    } else {
+      state.extendedUserProfileValues.push({
+        value_type: "user_agreement",
+        ext_user_profile_field: id,
+        agreement_value: value,
+      });
+    }
+  },
   updateExperimentInputValue(state, { extendedUserProfileValue }) {
     const index = state.extendedUserProfileValues.findIndex(
       (v) =>

Reply via email to