1
0
Fork 0
mirror of synced 2024-06-14 00:34:51 +12:00

fix: ui for array/required attributes creation

This commit is contained in:
Torsten Dittmann 2021-12-15 14:57:29 +01:00
parent 55426042dc
commit a29d66d8ac
3 changed files with 16 additions and 74 deletions

View file

@ -589,14 +589,6 @@ $logs = $this->getParam('logs', null);
(() => {
const form = document.getElementById("add-string-attribute");
const fields = {
required: {
array: ["disable", "uncheck"],
required: ["enable"]
},
array: {
required: ["disable", "uncheck"],
array: ["enable"]
},
xdefault: {
oneOf: {
if: ["array", "required"],
@ -680,14 +672,6 @@ $logs = $this->getParam('logs', null);
(() => {
const form = document.getElementById("add-integer-attribute");
const fields = {
required: {
array: ["disable", "uncheck"],
required: ["enable"]
},
array: {
required: ["disable", "uncheck"],
array: ["enable"]
},
xdefault: {
oneOf: {
if: ["array", "required"],
@ -769,14 +753,6 @@ $logs = $this->getParam('logs', null);
(() => {
const form = document.getElementById("add-float-attribute");
const fields = {
required: {
array: ["disable", "uncheck"],
required: ["enable"]
},
array: {
required: ["disable", "uncheck"],
array: ["enable"]
},
xdefault: {
oneOf: {
if: ["array", "required"],
@ -847,14 +823,6 @@ $logs = $this->getParam('logs', null);
(() => {
const form = document.getElementById("add-email-attribute");
const fields = {
required: {
array: ["disable", "uncheck"],
required: ["enable"]
},
array: {
required: ["disable", "uncheck"],
array: ["enable"]
},
xdefault: {
oneOf: {
if: ["array", "required"],
@ -927,14 +895,6 @@ $logs = $this->getParam('logs', null);
(() => {
const form = document.getElementById("add-boolean-attribute");
const fields = {
required: {
array: ["disable", "uncheck"],
required: ["enable"]
},
array: {
required: ["disable", "uncheck"],
array: ["enable"]
},
xdefault: {
oneOf: {
if: ["array", "required"],
@ -1006,14 +966,6 @@ $logs = $this->getParam('logs', null);
(() => {
const form = document.getElementById("add-ip-attribute");
const fields = {
required: {
array: ["disable", "uncheck"],
required: ["enable"]
},
array: {
required: ["disable", "uncheck"],
array: ["enable"]
},
xdefault: {
oneOf: {
if: ["array", "required"],
@ -1084,14 +1036,6 @@ $logs = $this->getParam('logs', null);
(() => {
const form = document.getElementById("add-url-attribute");
const fields = {
required: {
array: ["disable", "uncheck"],
required: ["enable"]
},
array: {
required: ["disable", "uncheck"],
array: ["enable"]
},
xdefault: {
oneOf: {
if: ["array", "required"],
@ -1179,14 +1123,6 @@ $logs = $this->getParam('logs', null);
(() => {
const form = document.getElementById("add-enum-attribute");
const fields = {
required: {
array: ["disable", "uncheck"],
required: ["enable"]
},
array: {
required: ["disable", "uncheck"],
array: ["enable"]
},
xdefault: {
oneOf: {
if: ["array", "required"],

View file

@ -280,15 +280,6 @@ $logs = $this->getParam('logs', null);
<button type="button" class="margin-end margin-bottom-small reverse" @click="doc = addAttribute(doc, attr.key)"> Add Attribute </button>
</div>
</template>
<script type="text/javascript">
function addAttribute(doc, key) {
if (!Array.isArray(doc[key])) {
doc[key] = [];
}
doc[key].push(null);
return doc;
}
</script>
</li>
</template>
</ul>

View file

@ -207,5 +207,20 @@ window.formValidation = (form, fields) => {
element.dispatchEvent(new Event("change"));
}
}
});
});
};
/**
* Method to add attribute for the UI on array attributes.
*
* Needs to be global - since client side routing will break it.
* @param {*} doc
* @param {*} key
* @returns
*/
function addAttribute(doc, key) {
if (!Array.isArray(doc[key])) {
doc[key] = [];
}
doc[key].push(null);
return doc;
}