feat(pay): mirror reference resource row with copy, icon and reorder
The post editor's download row only exposed address / button text / remark, leaving copy_key, copy_val and class as hidden inputs with no UI, so the reference copy area, custom button icon, text and color were unreachable. The submission popup already emitted those keys, which made the two write paths diverge from anything the editor could produce. Expose the full reference field set (地址/备注/复制名称/复制内容/图标/文案/ 颜色) as an accordion card with drag reordering, add the one genuinely new `icon` key through aksrt_sanitize_icon_value(), and teach both frontend download renderers to consume the fields they previously ignored. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -105,6 +105,51 @@ test('front submit paid resources use the reference modal editor and compact lis
|
||||
assert.doesNotMatch(downloads, /shop|forum|bbs_/i);
|
||||
});
|
||||
|
||||
test('the post editor resource row mirrors the reference seven fields with icon support', () => {
|
||||
const meta = read('src/Core/ResourceMetaBox.php');
|
||||
const model = read('src/Core/DomainModel.php');
|
||||
const setup = read('src/Core/Setup.php');
|
||||
|
||||
['下载地址', '资源备注', '复制的名称', '复制的内容', '自定义按钮图标', '自定义按钮文案', '自定义按钮颜色'].forEach((label) => {
|
||||
assert.ok(meta.includes(label), `missing label: ${label}`);
|
||||
});
|
||||
|
||||
// copy_key / copy_val / class must be real inputs, not hidden-only leftovers.
|
||||
['url', 'extract_code', 'copy_key', 'copy_val', 'icon', 'label', 'class'].forEach((field) => {
|
||||
assert.match(meta, new RegExp(`\\[${field}\\]`));
|
||||
assert.match(model, new RegExp(`'${field}'`));
|
||||
});
|
||||
// copy_key / copy_val must be real visible inputs, not hidden-only leftovers.
|
||||
// The color field legitimately keeps a hidden store behind the swatch buttons.
|
||||
assert.doesNotMatch(meta, /type="hidden"[^>]*name="[^"]*\[(?:copy_key|copy_val)\]"/);
|
||||
|
||||
// Accordion + drag reorder affordances.
|
||||
assert.match(meta, /data-group-toggle/);
|
||||
assert.match(meta, /data-group-drag/);
|
||||
assert.match(meta, /aksrt-icon-picker_assets\(|aksrt_icon_picker_field\(/);
|
||||
// The swatch palette and the sanitizer share one class whitelist.
|
||||
assert.match(meta, /DomainModel::DOWNLOAD_BUTTON_CLASSES/);
|
||||
assert.match(model, /const DOWNLOAD_BUTTON_CLASSES/);
|
||||
|
||||
const js = read('assets/js/admin-pay-meta-box.js');
|
||||
assert.match(js, /dragstart/);
|
||||
assert.match(js, /dragover/);
|
||||
assert.match(js, /reindexRows/);
|
||||
|
||||
// Reindexing rewrites the row index for every field and is scoped to its own
|
||||
// group, so dragging a download row can never renumber attributes/episodes.
|
||||
const reindex = (group, name, index) =>
|
||||
name.replace(new RegExp(`aksrt_pay\\[${group}\\]\\[\\d+\\]`), `aksrt_pay[${group}][${index}]`);
|
||||
['url', 'label', 'extract_code', 'copy_key', 'copy_val', 'icon', 'class'].forEach((field) => {
|
||||
assert.equal(reindex('downloads', `aksrt_pay[downloads][0][${field}]`, 3), `aksrt_pay[downloads][3][${field}]`);
|
||||
});
|
||||
assert.equal(reindex('downloads', 'aksrt_pay[downloads][5][url]', 1), 'aksrt_pay[downloads][1][url]');
|
||||
assert.equal(reindex('downloads', 'aksrt_pay[attributes][0][key]', 9), 'aksrt_pay[attributes][0][key]');
|
||||
assert.equal(reindex('downloads', 'aksrt_pay[video_episode][1][title]', 9), 'aksrt_pay[video_episode][1][title]');
|
||||
|
||||
assert.match(setup, /'icon' => \['type' => 'string'\]/);
|
||||
});
|
||||
|
||||
test('front submit paid-content prices and switch use the reference alignment rules', () => {
|
||||
const pay = read('templates/parts/submit/sidebar-pay.php');
|
||||
const submitCss = read('assets/css/frontend/pages/submit.css');
|
||||
|
||||
Reference in New Issue
Block a user