fix: paginated region/city pages, no routes before first save, safer structure save
- Add /{slug}/page/N/ rules and keep the page number through 301s
- Route only regions synced to a term, so unsaved presets never claim /europe/ etc.
- Flush rewrites on the request after activation so structure routes survive
- Suggest the existing term slug for new cities (keeps live /tour-destination/ URLs)
- Refuse saves without the editor sentinel; confirm before saving an empty structure
- Show term-sync failures to the admin instead of reporting success
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -43,7 +43,7 @@
|
||||
var row = fromTemplate('vc-tpl-city');
|
||||
row.querySelector('[data-f="id"]').value = item.id;
|
||||
row.querySelector('[data-f="name"]').value = item.name;
|
||||
row.querySelector('[data-f="slug"]').value = slugify(item.name);
|
||||
row.querySelector('[data-f="slug"]').value = item.slug || slugify(item.name);
|
||||
row.querySelector('.vc-city__name').textContent = item.name;
|
||||
row.querySelector('.vc-city__id').textContent = item.id;
|
||||
region.querySelector('.vc-cities tbody').appendChild(row);
|
||||
@@ -147,8 +147,27 @@
|
||||
region.querySelector('[data-f="name"]').focus();
|
||||
});
|
||||
|
||||
form.addEventListener('submit', function () {
|
||||
list.querySelectorAll('.vc-region').forEach(function (region, i) {
|
||||
function hidden(name) {
|
||||
var input = document.createElement('input');
|
||||
input.type = 'hidden';
|
||||
input.name = name;
|
||||
input.value = '1';
|
||||
form.appendChild(input);
|
||||
}
|
||||
|
||||
form.addEventListener('submit', function (e) {
|
||||
var regions = list.querySelectorAll('.vc-region');
|
||||
if (!regions.length) {
|
||||
if (!window.confirm(i18n.confirmEmpty)) {
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
hidden('vc_confirm_empty');
|
||||
}
|
||||
// Proves the editor ran: the server refuses a save without it, so a
|
||||
// failed script can never submit an empty structure by accident.
|
||||
hidden('vc_structure_present');
|
||||
regions.forEach(function (region, i) {
|
||||
region.querySelectorAll('.vc-region__head [data-f]').forEach(function (input) {
|
||||
input.name = 'vc_structure[' + i + '][' + input.dataset.f + ']';
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user