Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-08-09 21:09:34 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-08-09 21:09:34 +0300
commit7d112a9002182130f6a06f890bb17450b03406f9 (patch)
treeaaf42b63098935ad2f854a09d244e35352c60713 /app/assets
parentd56569ff3e73ae1dbcf93d2530925c4ecb8fd185 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets')
-rw-r--r--app/assets/javascripts/vue_shared/components/form/index.js59
1 files changed, 59 insertions, 0 deletions
diff --git a/app/assets/javascripts/vue_shared/components/form/index.js b/app/assets/javascripts/vue_shared/components/form/index.js
new file mode 100644
index 00000000000..65bc14dd807
--- /dev/null
+++ b/app/assets/javascripts/vue_shared/components/form/index.js
@@ -0,0 +1,59 @@
+import Vue from 'vue';
+import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
+import InputCopyToggleVisibility from './input_copy_toggle_visibility.vue';
+
+export function initInputCopyToggleVisibility() {
+ const els = document.getElementsByClassName('js-input-copy-visibility');
+
+ Array.from(els).forEach((el) => {
+ const {
+ name,
+ value,
+ initialVisibility,
+ showToggleVisibilityButton,
+ showCopyButton,
+ copyButtonTitle,
+ readonly,
+ formInputGroupProps,
+ formGroupAttributes,
+ } = el.dataset;
+
+ const parsedFormInputGroupProps = convertObjectPropsToCamelCase(
+ JSON.parse(formInputGroupProps || '{}'),
+ );
+ const parsedFormGroupAttributes = convertObjectPropsToCamelCase(
+ JSON.parse(formGroupAttributes || '{}'),
+ );
+
+ return new Vue({
+ el,
+ data() {
+ return {
+ value,
+ };
+ },
+ render(createElement) {
+ return createElement(InputCopyToggleVisibility, {
+ props: {
+ value: this.value,
+ initialVisibility,
+ showToggleVisibilityButton,
+ showCopyButton,
+ copyButtonTitle,
+ readonly,
+ formInputGroupProps: {
+ name,
+ ...parsedFormInputGroupProps,
+ },
+ },
+ attrs: parsedFormGroupAttributes,
+ on: {
+ input: (newValue) => {
+ this.value = newValue;
+ },
+ },
+ });
+ },
+ });
+ });
+}