fix(admin): replicate reference advanced-filter settings page 1:1
- Rewrite post_list/filter schema (PHP + JS) with the reference theme's
field set, order, defaults and dependencies; topics fields excluded
(no topics taxonomy), AKSRT private filter_* toggles dropped
- Support dynamic checkbox options in AksField (options as formData key)
so cat_custom_filter.custom_filters lists the custom_filter dimensions
- Map PostDisplay filter settings to the new keys without legacy fallback;
cat_custom_filter now carries lists/dropdown fieldsets and array filters
- Wire the archive chain to reference semantics: cat_custom_filter
overrides per-category filter projects, custom_filter_show gates the
default display, dimension chip groups render on category/tag archives
- Filter archive queries (main query + AJAX endpoint) by _aksrt_cf_{key}
meta with exact-quoted LIKE matching
- Add advanced-filter settings reference contract test
This commit is contained in:
1 parent
4d6b2c6045
commit
a8060fa71d
16 files changed
+635
-154
No files matched your search
@@ -481,6 +481,7 @@
|
||||
:key="field.key"
|
||||
:schema="field"
|
||||
:model-value="fieldsetValue(field)"
|
||||
:form-data="formData"
|
||||
@update:model-value="updateFieldsetValue(field.key, $event)"
|
||||
/>
|
||||
</div>
|
||||
@@ -501,7 +502,7 @@
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="item.fields && item.fields.length" class="aksrt-field__sortable-body">
|
||||
<AksField v-for="field in item.fields" :key="field.key" :schema="field" :model-value="modelValue?.[item.key]?.[field.key] ?? field.default" @update:model-value="updateSortable(item.key, field.key, $event)" />
|
||||
<AksField v-for="field in item.fields" :key="field.key" :schema="field" :model-value="modelValue?.[item.key]?.[field.key] ?? field.default" :form-data="formData" @update:model-value="updateSortable(item.key, field.key, $event)" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -531,6 +532,7 @@
|
||||
v-if="matchDependency(field.dependsOn, item)"
|
||||
:schema="field"
|
||||
:model-value="item[field.key]"
|
||||
:form-data="formData"
|
||||
:disabled="schema.disabled"
|
||||
@update:model-value="updateRepeaterItem(index, field.key, $event)"
|
||||
/>
|
||||
@@ -646,6 +648,7 @@
|
||||
:key="field.key"
|
||||
:schema="field"
|
||||
:model-value="repeaterDraft[field.key]"
|
||||
:form-data="formData"
|
||||
@update:model-value="updateRepeaterDraft(field.key, $event)"
|
||||
/>
|
||||
</div>
|
||||
@@ -696,6 +699,8 @@ const props = defineProps({
|
||||
},
|
||||
/** Current field value */
|
||||
modelValue: { default: null },
|
||||
/** Whole-form data — used to resolve dynamic options (schema.options as string = formData key). */
|
||||
formData: { type: Object, default: () => ({}) },
|
||||
/** Error message to display */
|
||||
errorMessage: { type: String, default: '' },
|
||||
})
|
||||
@@ -729,10 +734,22 @@ function updateFieldsetValue(key, value) {
|
||||
emit('update:modelValue', { ...current, [key]: value })
|
||||
}
|
||||
|
||||
/** Normalize options: support both string[] and {label, value}[] */
|
||||
/** Normalize options: support string[], {label, value}[], and dynamic formData-key references */
|
||||
const normalizedOptions = computed(() => {
|
||||
const opts = props.schema.options || []
|
||||
return opts.map(opt => {
|
||||
const opts = props.schema.options
|
||||
if (typeof opts === 'string') {
|
||||
// 动态选项:引用 formData 中同名字段(如 custom_filter 维度定义 [{key,name,vals}])。
|
||||
const source = props.formData?.[opts]
|
||||
if (!Array.isArray(source)) return []
|
||||
return source
|
||||
.map(item => {
|
||||
const value = String(item?.key ?? '')
|
||||
if (value === '') return null
|
||||
return { label: String(item?.name ?? item?.key ?? value), value }
|
||||
})
|
||||
.filter(Boolean)
|
||||
}
|
||||
return (Array.isArray(opts) ? opts : []).map(opt => {
|
||||
if (typeof opt === 'string') return { label: opt, value: opt }
|
||||
if (typeof opt === 'object' && opt !== null) {
|
||||
return { ...opt, label: opt.label ?? opt.name ?? opt.value, value: opt.value ?? opt.label ?? opt.name }
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
v-if="isFieldVisible(sub)"
|
||||
:schema="sub"
|
||||
:model-value="getFieldValue(sub.key)"
|
||||
:form-data="formData"
|
||||
:error-message="errors?.[sub.key]"
|
||||
@update:model-value="setFieldValue(sub.key, $event)"
|
||||
@action="emit('field-action', $event)"
|
||||
@@ -89,6 +90,7 @@
|
||||
<AksField
|
||||
:schema="field"
|
||||
:model-value="getFieldValue(field.key)"
|
||||
:form-data="formData"
|
||||
:error-message="errors?.[field.key]"
|
||||
@update:model-value="setFieldValue(field.key, $event)"
|
||||
@action="emit('field-action', $event)"
|
||||
@@ -98,6 +100,7 @@
|
||||
v-else
|
||||
:schema="field"
|
||||
:model-value="getFieldValue(field.key)"
|
||||
:form-data="formData"
|
||||
:error-message="errors?.[field.key]"
|
||||
@update:model-value="setFieldValue(field.key, $event)"
|
||||
@action="emit('field-action', $event)"
|
||||
|
||||
Reference in new issue
Block a user