fix circular JSON dep

This commit is contained in:
Jordan Blasenhauer 2024-07-23 14:45:11 +02:00
parent ceb936946b
commit 6f9e7fe7e9
2 changed files with 26 additions and 6 deletions

View file

@ -79,10 +79,11 @@ const data = reactive({
jsonReady = "{" + jsonReady.slice(0, -1) + "}";
try {
const data = JSON.parse(jsonReady);
rawForm.setTemplate(data);
const json = JSON.parse(jsonReady);
rawForm.setTemplate(json);
return true;
} catch (e) {
console.log(e);
return false;
}
}),
@ -116,7 +117,6 @@ function json2raw(json) {
}
const editorData = {
value: data.str,
name: `raw-editor-${uuidv4()}`,
label: `raw-editor-${uuidv4()}`,
hideLabel: true,
@ -150,7 +150,11 @@ onBeforeMount(() => {
<Subtitle type="card" :subtitle="'dashboard_raw_mode_subtitle'" />
<Container class="form-raw-editor-container layout-settings">
<Editor @inp="(v) => (data.str = v)" v-bind="editorData" />
<Editor
@inp="(v) => (data.str = v)"
v-bind="editorData"
:value="data.str"
/>
</Container>
<Button :disabled="data.isValid ? false : true" v-bind="buttonSave" />

View file

@ -30,10 +30,24 @@ export const createFormStore = (storeName, formType) => {
*/
function setTemplate(template) {
if (!_isFormTypeAllowed(["advanced", "easy", "raw"])) return;
template.value = template;
templateBase.value = template;
templateUI.value = JSON.parse(JSON.stringify(template));
templateUIFormat.value = JSON.parse(JSON.stringify(template));
templateUI.value = template;
templateUIFormat.value = template;
// console.log("template", type.value, template);
// console.log(typeof template);
// const formattedData = {};
// // Loop dict items
// for (const [key, value] of Object.entries(template)) {
// // Case key "value" is here, we are directly on the right level (and maybe on the raw mode)
// if (value?.value) {
// }
// console.log(key, value);
// formattedData[key] = value;
// if (!value?.settings || value?.multiples) continue;
// }
}
/**
@ -292,6 +306,8 @@ export const createFormStore = (storeName, formType) => {
*/
function submitForm() {
if (!_isFormTypeAllowed(["advanced", "easy", "raw"])) return;
console.log("submitForm");
const formattedData = {};
}
/**