feat(metablogizer): Add "Set as index" checkbox to upload modal
- Upload modal now defaults to replacing index.html - "Set as index" checkbox checked by default - Uncheck to use original filename (shows destination field) - Fixes issue where uploads weren't updating main page Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
ed0c95f8da
commit
af1564821f
@ -308,10 +308,18 @@ return view.extend({
|
|||||||
])
|
])
|
||||||
]),
|
]),
|
||||||
E('div', { 'class': 'cbi-value' }, [
|
E('div', { 'class': 'cbi-value' }, [
|
||||||
|
E('label', { 'class': 'cbi-value-title' }, _('Set as index')),
|
||||||
|
E('div', { 'class': 'cbi-value-field' }, [
|
||||||
|
E('input', { 'type': 'checkbox', 'id': 'upload-as-index', 'checked': true }),
|
||||||
|
E('span', { 'style': 'margin-left:0.5em' }, _('Replace index.html (main page)')),
|
||||||
|
E('div', { 'class': 'cbi-value-description' }, _('Uncheck to keep original filename'))
|
||||||
|
])
|
||||||
|
]),
|
||||||
|
E('div', { 'class': 'cbi-value', 'id': 'upload-dest-row', 'style': 'display:none' }, [
|
||||||
E('label', { 'class': 'cbi-value-title' }, _('Destination')),
|
E('label', { 'class': 'cbi-value-title' }, _('Destination')),
|
||||||
E('div', { 'class': 'cbi-value-field' }, [
|
E('div', { 'class': 'cbi-value-field' }, [
|
||||||
E('input', { 'type': 'text', 'id': 'upload-dest', 'class': 'cbi-input-text',
|
E('input', { 'type': 'text', 'id': 'upload-dest', 'class': 'cbi-input-text',
|
||||||
'placeholder': 'index.html' }),
|
'placeholder': 'filename.html' }),
|
||||||
E('div', { 'class': 'cbi-value-description' }, _('Leave empty to use original filename'))
|
E('div', { 'class': 'cbi-value-description' }, _('Leave empty to use original filename'))
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
@ -324,6 +332,7 @@ return view.extend({
|
|||||||
'click': function() {
|
'click': function() {
|
||||||
var fileInput = document.getElementById('upload-file-input');
|
var fileInput = document.getElementById('upload-file-input');
|
||||||
var destInput = document.getElementById('upload-dest');
|
var destInput = document.getElementById('upload-dest');
|
||||||
|
var asIndexCheckbox = document.getElementById('upload-as-index');
|
||||||
var file = fileInput.files[0];
|
var file = fileInput.files[0];
|
||||||
|
|
||||||
if (!file) {
|
if (!file) {
|
||||||
@ -331,7 +340,7 @@ return view.extend({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var dest = destInput.value.trim() || file.name;
|
var dest = asIndexCheckbox.checked ? 'index.html' : (destInput.value.trim() || file.name);
|
||||||
|
|
||||||
ui.hideModal();
|
ui.hideModal();
|
||||||
ui.showModal(_('Uploading'), [E('p', { 'class': 'spinning' }, _('Uploading file...'))]);
|
ui.showModal(_('Uploading'), [E('p', { 'class': 'spinning' }, _('Uploading file...'))]);
|
||||||
@ -370,6 +379,13 @@ return view.extend({
|
|||||||
}, _('Upload'))
|
}, _('Upload'))
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// Toggle destination field based on checkbox
|
||||||
|
var checkbox = document.getElementById('upload-as-index');
|
||||||
|
var destRow = document.getElementById('upload-dest-row');
|
||||||
|
checkbox.onchange = function() {
|
||||||
|
destRow.style.display = this.checked ? 'none' : '';
|
||||||
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
handleEmancipate: function(site) {
|
handleEmancipate: function(site) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user