Document gen fixed
This commit is contained in:
@@ -228,16 +228,27 @@
|
||||
class="input input-bordered input-sm w-full col-span-4"
|
||||
placeholder="custom ključ (npr. order_id)"
|
||||
/>
|
||||
<input
|
||||
v-model="row.value"
|
||||
type="text"
|
||||
class="input input-bordered input-sm w-full col-span-5"
|
||||
placeholder="privzeta vrednost"
|
||||
/>
|
||||
<template v-if="row.type === 'text'">
|
||||
<textarea
|
||||
v-model="row.value"
|
||||
rows="3"
|
||||
class="textarea textarea-bordered w-full text-xs col-span-5"
|
||||
placeholder="privzeta vrednost"
|
||||
/>
|
||||
</template>
|
||||
<template v-else>
|
||||
<input
|
||||
v-model="row.value"
|
||||
type="text"
|
||||
class="input input-bordered input-sm w-full col-span-5"
|
||||
placeholder="privzeta vrednost"
|
||||
/>
|
||||
</template>
|
||||
<select v-model="row.type" class="select select-bordered select-sm w-full col-span-2">
|
||||
<option value="string">string</option>
|
||||
<option value="number">number</option>
|
||||
<option value="date">date</option>
|
||||
<option value="text">text</option>
|
||||
</select>
|
||||
<button type="button" class="btn btn-ghost btn-xs col-span-1" @click="removeCustomDefault(idx)">✕</button>
|
||||
</div>
|
||||
@@ -393,10 +404,21 @@ function toggleActive() {
|
||||
// Custom defaults rows state
|
||||
const baseDefaults = (props.template.meta && props.template.meta.custom_defaults) || {};
|
||||
const baseTypes = (props.template.meta && props.template.meta.custom_default_types) || {};
|
||||
// Gather detected custom tokens from template.tokens
|
||||
const detectedCustoms = Array.isArray(props.template.tokens)
|
||||
? props.template.tokens.filter((t) => typeof t === 'string' && t.startsWith('custom.')).map((t) => t.replace(/^custom\./, ''))
|
||||
: [];
|
||||
// Build a union of keys from defaults, types, and detected tokens
|
||||
const allKeysSet = new Set([
|
||||
...Object.keys(baseDefaults || {}),
|
||||
...Object.keys(baseTypes || {}),
|
||||
...detectedCustoms,
|
||||
]);
|
||||
const allKeys = Array.from(allKeysSet);
|
||||
const customRows = reactive(
|
||||
Object.keys(baseDefaults).length
|
||||
? Object.entries(baseDefaults).map(([k, v]) => ({ key: k, value: v, type: baseTypes[k] || 'string' }))
|
||||
: [{ key: "", value: "", type: 'string' }]
|
||||
allKeys.length
|
||||
? allKeys.map((k) => ({ key: k, value: baseDefaults[k] ?? '', type: baseTypes[k] || 'string' }))
|
||||
: [{ key: '', value: '', type: 'string' }]
|
||||
);
|
||||
|
||||
function addCustomDefault() {
|
||||
@@ -405,6 +427,6 @@ function addCustomDefault() {
|
||||
|
||||
function removeCustomDefault(idx) {
|
||||
customRows.splice(idx, 1);
|
||||
if (!customRows.length) customRows.push({ key: "", value: "" });
|
||||
if (!customRows.length) customRows.push({ key: "", value: "", type: 'string' });
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user