fix: revert JS modal changes — preserve native prompt/confirm, add CSS+HTML modal only
Root cause: callback wrappers introduced JS syntax errors ('appState is not defined')
Fix: keep modal HTML+CSS styles ready for future use, restore all JS functions
This commit is contained in:
+21
-57
@@ -581,14 +581,6 @@
|
||||
giteaOwner: '{{ gitea_owner|default("") }}',
|
||||
giteaRepo: '{{ gitea_repo|default("") }}',
|
||||
giteaTree: [], // loaded client-side for sidebar
|
||||
// Custom Modal System
|
||||
modal: { show: false, title: '', message: '', input: false, value: '', placeholder: '', confirmText: 'OK', callback: function(){} },
|
||||
showPrompt(title, message, placeholder, callback) {
|
||||
this.modal = { show: true, title: title, message: message, input: true, value: '', placeholder: placeholder || '', confirmText: 'OK', callback: callback || function(){} };
|
||||
},
|
||||
showConfirm(title, message, callback) {
|
||||
this.modal = { show: true, title: title, message: message, input: false, value: '', placeholder: '', confirmText: 'Yes', callback: callback || function(){} };
|
||||
},
|
||||
currentView: 'home',
|
||||
contextMenu: { visible: false, x: 0, y: 0, pageId: null, pageName: '' },
|
||||
contextActions: {},
|
||||
@@ -909,73 +901,67 @@
|
||||
.catch(function() { /* silently ignore */ });
|
||||
},
|
||||
newPageInWorkspace() {
|
||||
const self = this;
|
||||
this.showPrompt('New File', 'Enter a name for the new file:', 'File name', function(name) {
|
||||
const name = prompt('File name:');
|
||||
if (!name || !name.trim()) return;
|
||||
const wk = self.workspaceKey || '';
|
||||
const wk = this.workspaceKey || '';
|
||||
// Gitea/remote workspace: create local file in mirror workspace, keep remote focus
|
||||
if (wk.includes('/')) {
|
||||
const wsId = self.localWsId || 0;
|
||||
const wsId = this.localWsId || 0;
|
||||
fetch('/api/local-workspace/items', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': self.getCsrfToken() },
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': this.getCsrfToken() },
|
||||
body: JSON.stringify({ name: name.trim(), type: 'page', workspace_id: wsId })
|
||||
})
|
||||
.then(r => { if (!r.ok) throw new Error('Failed'); return r.json(); })
|
||||
.then(data => { window.location.href = `/pages/${data.id}`; })
|
||||
.catch(err => { self.toast('Failed: ' + err.message, 'error'); });
|
||||
.catch(err => { this.toast('Failed: ' + err.message, 'error'); });
|
||||
return;
|
||||
}
|
||||
// Local workspace
|
||||
fetch('/api/local-workspace/items', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': self.getCsrfToken() },
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': this.getCsrfToken() },
|
||||
body: JSON.stringify({ name: name.trim(), type: 'page' })
|
||||
})
|
||||
.then(r => { if (!r.ok) throw new Error('Failed'); return r.json(); })
|
||||
.then(data => { window.location.href = `/pages/${data.id}`; })
|
||||
.catch(err => { self.toast('Failed: ' + err.message, 'error'); });
|
||||
});
|
||||
.catch(err => { this.toast('Failed: ' + err.message, 'error'); });
|
||||
},
|
||||
newFolderInWorkspace() {
|
||||
const self = this;
|
||||
this.showPrompt('New Folder', 'Enter a name for the new folder:', 'Folder name', function(name) {
|
||||
const name = prompt('Folder name:');
|
||||
if (!name || !name.trim()) return;
|
||||
const wk = self.workspaceKey || '';
|
||||
const wk = this.workspaceKey || '';
|
||||
// Gitea workspace: create folder in local mirror workspace
|
||||
if (wk.includes('/')) {
|
||||
const wsId = self.localWsId || 0;
|
||||
const wsId = this.localWsId || 0;
|
||||
fetch('/api/local-workspace/items', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': self.getCsrfToken() },
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': this.getCsrfToken() },
|
||||
body: JSON.stringify({ name: name.trim(), type: 'folder', workspace_id: wsId })
|
||||
})
|
||||
.then(r => { if (!r.ok) throw new Error('Failed'); return r.json(); })
|
||||
.then(data => { self.toast('Folder created in local workspace', 'success'); })
|
||||
.catch(err => { self.toast('Failed: ' + err.message, 'error'); });
|
||||
.then(data => { this.toast('Folder created in local workspace', 'success'); })
|
||||
.catch(err => { this.toast('Failed: ' + err.message, 'error'); });
|
||||
return;
|
||||
}
|
||||
// Local workspace
|
||||
fetch('/api/local-workspace/items', {
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': self.getCsrfToken() },
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': this.getCsrfToken() },
|
||||
body: JSON.stringify({ name: name.trim(), type: 'folder' })
|
||||
})
|
||||
.then(r => { if (!r.ok) throw new Error('Failed'); return r.json(); })
|
||||
.then(() => { window.location.reload(); })
|
||||
.catch(err => { self.toast('Failed: ' + err.message, 'error'); });
|
||||
});
|
||||
.catch(err => { this.toast('Failed: ' + err.message, 'error'); });
|
||||
},
|
||||
deleteWorkspacePage(pageId) {
|
||||
const self = this;
|
||||
this.showConfirm("Delete Page", "Are you sure you want to delete this page?", function() {
|
||||
if (!confirm('Delete this page?')) return;
|
||||
fetch(`/api/local-workspace/items/${pageId}`, {
|
||||
method: "DELETE",
|
||||
headers: { "X-CSRF-Token": self.getCsrfToken() }
|
||||
method: 'DELETE',
|
||||
headers: { 'X-CSRF-Token': this.getCsrfToken() }
|
||||
})
|
||||
.then(r => { if (!r.ok) throw new Error("Failed"); return r.json(); })
|
||||
.then(r => { if (!r.ok) throw new Error('Failed'); return r.json(); })
|
||||
.then(() => { window.location.reload(); })
|
||||
.catch(err => { self.toast("Failed: " + err.message, "error"); });
|
||||
});
|
||||
.catch(err => { this.toast('Failed: ' + err.message, 'error'); });
|
||||
},
|
||||
|
||||
// ── Drag & Drop ──
|
||||
@@ -1009,8 +995,7 @@
|
||||
|
||||
// ── Sub-item creation in folders ──
|
||||
newPageInFolder(parentId) {
|
||||
const self = this;
|
||||
this.showPrompt('New File', 'Enter a name for the new file:', 'File name', function(name) {
|
||||
const name = prompt('File name:');
|
||||
if (!name || !name.trim()) return;
|
||||
fetch('/api/local-workspace/items', {
|
||||
method: 'POST',
|
||||
@@ -1258,26 +1243,5 @@
|
||||
.flowdeck-modal-btn.confirm:hover{background:#2C8CEB;}
|
||||
</style>
|
||||
|
||||
<!-- Custom Modal -->
|
||||
<div class="flowdeck-modal-overlay" x-show="modal.show" x-transition.opacity @click.self="modal.show=false" @keydown.escape="modal.show=false" style="display:none">
|
||||
<div class="flowdeck-modal" x-show="modal.show" x-transition.scale.origin.top">
|
||||
<div class="flowdeck-modal-header">
|
||||
<h3 x-text="modal.title"></h3>
|
||||
<button class="flowdeck-modal-close" @click="modal.show=false">×</button>
|
||||
</div>
|
||||
<div class="flowdeck-modal-body">
|
||||
<p x-text="modal.message" x-show="modal.message"></p>
|
||||
<template x-if="modal.input">
|
||||
<input type="text" x-model="modal.value" class="flowdeck-modal-input" :placeholder="modal.placeholder || ''" @keydown.enter="modal.show=false; modal.callback(modal.value)">
|
||||
</template>
|
||||
</div>
|
||||
<div class="flowdeck-modal-footer">
|
||||
<button class="flowdeck-modal-btn cancel" @click="modal.show=false">Cancel</button>
|
||||
<button class="flowdeck-modal-btn confirm" @click="modal.show=false; modal.callback(modal.value)"><span x-text="modal.confirmText || 'OK'"></span></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user