| Mateusz Gapski | 2224ece | 2020-09-02 17:00:06 +0200 | [diff] [blame] | 1 | <template> |
| 2 | <b-modal |
| 3 | id="configure-connection" |
| 4 | ref="modal" |
| 5 | @ok="onOk" |
| 6 | @hidden="resetForm" |
| 7 | @show="initModal" |
| 8 | > |
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 9 | <template #modal-title> |
| Mateusz Gapski | 2224ece | 2020-09-02 17:00:06 +0200 | [diff] [blame] | 10 | {{ $t('pageVirtualMedia.modal.title') }} |
| 11 | </template> |
| 12 | <b-form> |
| 13 | <b-form-group |
| 14 | :label="$t('pageVirtualMedia.modal.serverUri')" |
| 15 | label-for="serverUri" |
| 16 | > |
| 17 | <b-form-input |
| 18 | id="serverUri" |
| 19 | v-model="form.serverUri" |
| 20 | type="text" |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 21 | :state="getValidationState(v$.form.serverUri)" |
| Mateusz Gapski | 2224ece | 2020-09-02 17:00:06 +0200 | [diff] [blame] | 22 | data-test-id="configureConnection-input-serverUri" |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 23 | @input="v$.form.serverUri.$touch()" |
| Mateusz Gapski | 2224ece | 2020-09-02 17:00:06 +0200 | [diff] [blame] | 24 | /> |
| 25 | <b-form-invalid-feedback role="alert"> |
| Surya Venkatesan | 69be824 | 2024-09-23 19:55:06 +0530 | [diff] [blame] | 26 | <template v-if="v$.form.serverUri.required.$invalid"> |
| Mateusz Gapski | 2224ece | 2020-09-02 17:00:06 +0200 | [diff] [blame] | 27 | {{ $t('global.form.fieldRequired') }} |
| 28 | </template> |
| 29 | </b-form-invalid-feedback> |
| 30 | </b-form-group> |
| 31 | <b-form-group |
| 32 | :label="$t('pageVirtualMedia.modal.username')" |
| 33 | label-for="username" |
| 34 | > |
| 35 | <b-form-input |
| 36 | id="username" |
| 37 | v-model="form.username" |
| 38 | type="text" |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 39 | autocomplete="username" |
| Mateusz Gapski | 2224ece | 2020-09-02 17:00:06 +0200 | [diff] [blame] | 40 | data-test-id="configureConnection-input-username" |
| 41 | /> |
| 42 | </b-form-group> |
| 43 | <b-form-group |
| 44 | :label="$t('pageVirtualMedia.modal.password')" |
| 45 | label-for="password" |
| 46 | > |
| 47 | <b-form-input |
| 48 | id="password" |
| 49 | v-model="form.password" |
| 50 | type="password" |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 51 | autocomplete="current-password" |
| Mateusz Gapski | 2224ece | 2020-09-02 17:00:06 +0200 | [diff] [blame] | 52 | data-test-id="configureConnection-input-password" |
| 53 | /> |
| 54 | </b-form-group> |
| 55 | <b-form-group> |
| 56 | <b-form-checkbox |
| 57 | v-model="form.isRW" |
| 58 | data-test-id="configureConnection-input-isRW" |
| 59 | name="check-button" |
| 60 | > |
| 61 | RW |
| 62 | </b-form-checkbox> |
| 63 | </b-form-group> |
| 64 | </b-form> |
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 65 | <template #modal-ok> |
| Mateusz Gapski | 2224ece | 2020-09-02 17:00:06 +0200 | [diff] [blame] | 66 | {{ $t('global.action.save') }} |
| 67 | </template> |
| Sukanya Pandey | 3835713 | 2020-12-22 13:40:59 +0530 | [diff] [blame] | 68 | <template #modal-cancel> |
| 69 | {{ $t('global.action.cancel') }} |
| 70 | </template> |
| Mateusz Gapski | 2224ece | 2020-09-02 17:00:06 +0200 | [diff] [blame] | 71 | </b-modal> |
| 72 | </template> |
| 73 | |
| 74 | <script> |
| Ed Tanous | 7d6b44c | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 75 | import { required } from '@vuelidate/validators'; |
| SurenNeware | 6185909 | 2020-10-01 09:37:32 +0530 | [diff] [blame] | 76 | import VuelidateMixin from '@/components/Mixins/VuelidateMixin.js'; |
| Ed Tanous | 7d6b44c | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 77 | import { useVuelidate } from '@vuelidate/core'; |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 78 | import { useI18n } from 'vue-i18n'; |
| Mateusz Gapski | 2224ece | 2020-09-02 17:00:06 +0200 | [diff] [blame] | 79 | |
| 80 | export default { |
| 81 | mixins: [VuelidateMixin], |
| 82 | props: { |
| 83 | connection: { |
| 84 | type: Object, |
| 85 | default: null, |
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 86 | }, |
| Mateusz Gapski | 2224ece | 2020-09-02 17:00:06 +0200 | [diff] [blame] | 87 | }, |
| Hariharan Rangasamy | c5d60f5 | 2025-10-31 12:58:56 +0530 | [diff] [blame] | 88 | emits: ['ok'], |
| Ed Tanous | 7d6b44c | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 89 | setup() { |
| 90 | return { |
| 91 | v$: useVuelidate(), |
| 92 | }; |
| 93 | }, |
| Mateusz Gapski | 2224ece | 2020-09-02 17:00:06 +0200 | [diff] [blame] | 94 | data() { |
| 95 | return { |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 96 | $t: useI18n().t, |
| Mateusz Gapski | 2224ece | 2020-09-02 17:00:06 +0200 | [diff] [blame] | 97 | form: { |
| 98 | serverUri: null, |
| 99 | username: null, |
| 100 | password: null, |
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 101 | isRW: false, |
| 102 | }, |
| Mateusz Gapski | 2224ece | 2020-09-02 17:00:06 +0200 | [diff] [blame] | 103 | }; |
| 104 | }, |
| 105 | watch: { |
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 106 | connection: function (value) { |
| Mateusz Gapski | 2224ece | 2020-09-02 17:00:06 +0200 | [diff] [blame] | 107 | if (value === null) return; |
| 108 | Object.assign(this.form, value); |
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 109 | }, |
| Mateusz Gapski | 2224ece | 2020-09-02 17:00:06 +0200 | [diff] [blame] | 110 | }, |
| 111 | validations() { |
| 112 | return { |
| 113 | form: { |
| 114 | serverUri: { |
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 115 | required, |
| 116 | }, |
| 117 | }, |
| Mateusz Gapski | 2224ece | 2020-09-02 17:00:06 +0200 | [diff] [blame] | 118 | }; |
| 119 | }, |
| 120 | methods: { |
| 121 | handleSubmit() { |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 122 | this.v$.$touch(); |
| 123 | if (this.v$.$invalid) return; |
| Mateusz Gapski | 2224ece | 2020-09-02 17:00:06 +0200 | [diff] [blame] | 124 | let connectionData = {}; |
| 125 | Object.assign(connectionData, this.form); |
| 126 | this.$emit('ok', connectionData); |
| 127 | this.closeModal(); |
| 128 | }, |
| 129 | initModal() { |
| 130 | if (this.connection) { |
| 131 | Object.assign(this.form, this.connection); |
| 132 | } |
| 133 | }, |
| 134 | closeModal() { |
| 135 | this.$nextTick(() => { |
| 136 | this.$refs.modal.hide(); |
| 137 | }); |
| 138 | }, |
| 139 | resetForm() { |
| 140 | this.form.serverUri = null; |
| 141 | this.form.username = null; |
| 142 | this.form.password = null; |
| 143 | this.form.isRW = false; |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 144 | this.v$.$reset(); |
| Mateusz Gapski | 2224ece | 2020-09-02 17:00:06 +0200 | [diff] [blame] | 145 | }, |
| 146 | onOk(bvModalEvt) { |
| 147 | bvModalEvt.preventDefault(); |
| 148 | this.handleSubmit(); |
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 149 | }, |
| 150 | }, |
| Mateusz Gapski | 2224ece | 2020-09-02 17:00:06 +0200 | [diff] [blame] | 151 | }; |
| 152 | </script> |