Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit a3f0b9a

Browse files
committed
Finished 2.1.1
1 parent 6d2cc37 commit a3f0b9a

File tree

16 files changed

+207
-104
lines changed

16 files changed

+207
-104
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# https://editorconfig.org
2+
3+
root = true
4+
5+
[*]
6+
charset = utf-8
7+
indent_style = space
8+
indent_size = 4
9+
end_of_line = lf
10+
insert_final_newline = true
11+
trim_trailing_whitespace = true
12+
13+
[*.md]
14+
insert_final_newline = false
15+
trim_trailing_whitespace = false

package-lock.json

Lines changed: 49 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/App.vue

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,22 @@
3131
</button>
3232

3333
<button class="btn btn-info mr-2" @click="setRandomData">Set Random Data</button>
34+
35+
<button
36+
class="btn btn-info mr-2"
37+
@click="setReadonly"
38+
>
39+
<span v-show="readOnly">Turn off ReadOnly mode</span>
40+
<span v-show="!readOnly">Turn on ReadOnly mode</span>
41+
</button>
3442
</div>
3543

36-
<FormRenderer :class="{'col-md-9': isShowData, 'col-md-12': !isShowData}"
37-
:form-configuration="formData"
38-
v-model="formInputData" />
44+
<FormRenderer
45+
v-model="formInputData"
46+
:class="{'col-md-9': isShowData, 'col-md-12': !isShowData}"
47+
:form-configuration="formData"
48+
:read-only="readOnly"
49+
/>
3950

4051
<div class="p-0" :class="{'col-md-3': isShowData, 'd-none': !isShowData}">
4152
<h4>Form Input Data</h4>
@@ -63,7 +74,8 @@
6374
isShowDevNote: false,
6475
isRenderer: false,
6576
formInputData: null,
66-
isShowData: false
77+
isShowData: false,
78+
readOnly: false,
6779
}),
6880
methods: {
6981
getData() {
@@ -106,6 +118,16 @@
106118
"total_value": faker.finance.amount()
107119
});
108120
},
121+
122+
setReadonly() {
123+
if (this.readOnly) {
124+
this.readOnly = false;
125+
return;
126+
}
127+
128+
this.setRandomData();
129+
this.readOnly = true;
130+
},
109131
}
110132
}
111133
</script>

src/components/FormRenderer.vue

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
<div :class="[styles.CONTAINER.FLUID, 'form-padding', 'vue-form-renderer']">
33

44
<!-- Render Form Tag Or Not -->
5-
<form v-if="formData.formConfig.renderFormTag"
6-
:action="formData.formConfig.formActionURL"
7-
:method="formData.formConfig.formMethod"
8-
:id="formTagId"
9-
@submit.prevent
5+
<form
6+
v-if="formData.formConfig.renderFormTag"
7+
:action="formData.formConfig.formActionURL"
8+
:method="formData.formConfig.formMethod"
9+
:id="formTagId"
10+
@submit.prevent
1011
>
1112
<!-- form headline -->
1213
<div class="form-headline-container" v-show="formData.formConfig.isShowHeadline">
@@ -15,13 +16,15 @@
1516
</div>
1617

1718
<!-- sections of the form -->
18-
<SectionContainer v-for="(sectionData) in sortedSections"
19-
:section="sectionData"
20-
:rows="formData.rows"
21-
:controls="formData.controls"
22-
:key="sectionData.uniqueId"
23-
:value-container="valueContainer"
24-
:validation-errors="validationErrors"
19+
<SectionContainer
20+
v-for="(sectionData) in sortedSections"
21+
:section="sectionData"
22+
:rows="formData.rows"
23+
:controls="formData.controls"
24+
:key="sectionData.uniqueId"
25+
:value-container="valueContainer"
26+
:validation-errors="validationErrors"
27+
:read-only="readOnly"
2528
/>
2629
</form>
2730
<template v-else>
@@ -33,13 +36,15 @@
3336
</div>
3437

3538
<!-- sections of the form -->
36-
<SectionContainer v-for="(sectionData) in sortedSections"
37-
:section="sectionData"
38-
:rows="formData.rows"
39-
:controls="formData.controls"
40-
:key="sectionData.uniqueId"
41-
:value-container="valueContainer"
42-
:validation-errors="validationErrors"
39+
<SectionContainer
40+
v-for="(sectionData) in sortedSections"
41+
:section="sectionData"
42+
:rows="formData.rows"
43+
:controls="formData.controls"
44+
:key="sectionData.uniqueId"
45+
:value-container="valueContainer"
46+
:validation-errors="validationErrors"
47+
:read-only="readOnly"
4348
/>
4449

4550
</template>

0 commit comments

Comments
 (0)