portfolio-edit: edit-mode toggle scaffold
This commit is contained in:
parent
9ed78f2758
commit
f1b242720d
1 changed files with 43 additions and 0 deletions
43
app/static/js/portfolio_edit.js
Normal file
43
app/static/js/portfolio_edit.js
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/* Dashboard-native portfolio editing.
|
||||
*
|
||||
* Owns: the EDIT button toggle, the add-position form behaviour
|
||||
* (ticker validation on blur, qty/cost inputs, date-mode historical
|
||||
* lookup, Add click), and per-row delete via event delegation.
|
||||
*
|
||||
* Reads/writes the portfolio via window.CassandraPortfolio.loadPie /
|
||||
* savePie / mountAndRender — the same surface portfolio.js exposes
|
||||
* for the CSV-import preview.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
const panel = document.getElementById('portfolio-panel');
|
||||
const editBtn = document.getElementById('pf-edit-btn');
|
||||
const doneBtn = document.getElementById('pf-done-btn');
|
||||
const form = document.getElementById('pf-add-form');
|
||||
if (!panel || !editBtn || !doneBtn || !form) return;
|
||||
|
||||
function enterEditMode() {
|
||||
panel.classList.add('pf-editing');
|
||||
form.hidden = false;
|
||||
editBtn.hidden = true;
|
||||
doneBtn.hidden = false;
|
||||
editBtn.setAttribute('aria-pressed', 'true');
|
||||
document.getElementById('pf-add-ticker').focus();
|
||||
}
|
||||
|
||||
function exitEditMode() {
|
||||
panel.classList.remove('pf-editing');
|
||||
// Form stays visible when the pie is empty (empty-state UX handled
|
||||
// by portfolio.js setting the pf-empty class on the panel).
|
||||
if (!panel.classList.contains('pf-empty')) {
|
||||
form.hidden = true;
|
||||
}
|
||||
editBtn.hidden = false;
|
||||
doneBtn.hidden = true;
|
||||
editBtn.setAttribute('aria-pressed', 'false');
|
||||
}
|
||||
|
||||
editBtn.addEventListener('click', enterEditMode);
|
||||
doneBtn.addEventListener('click', exitEditMode);
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue