Skip to content

Commit

Permalink
fix circular JSON dep
Browse files Browse the repository at this point in the history
  • Loading branch information
syrk4web committed Jul 23, 2024
1 parent ceb9369 commit 6f9e7fe
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/ui/client/dashboard/components/Form/Raw.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}),
Expand Down Expand Up @@ -116,7 +117,6 @@ function json2raw(json) {
}
const editorData = {
value: data.str,
name: `raw-editor-${uuidv4()}`,
label: `raw-editor-${uuidv4()}`,
hideLabel: true,
Expand Down Expand Up @@ -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" />

Expand Down
20 changes: 18 additions & 2 deletions src/ui/client/dashboard/store/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
// }
}

/**
Expand Down Expand Up @@ -292,6 +306,8 @@ export const createFormStore = (storeName, formType) => {
*/
function submitForm() {
if (!_isFormTypeAllowed(["advanced", "easy", "raw"])) return;
console.log("submitForm");
const formattedData = {};
}

/**
Expand Down

0 comments on commit 6f9e7fe

Please sign in to comment.