Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding refresh functionality to input page #9

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions etfcalc/static/css/bootstrap/bootstrap.min.css

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions etfcalc/static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
padding: 0.5rem;
}

.btn_header_cell {
padding: 0.5rem !important;
}

.dt-bootstrap4 {
width: 100% !important;
}
Expand All @@ -14,6 +18,15 @@
font-weight: 700;
}

.btn-refresh-row {
font-weight: 700;
}

.btn-refresh-table {
font-weight: 900;
width: 100%;
}

.progress-bar {
width: 100%;
}
Expand Down
3 changes: 1 addition & 2 deletions etfcalc/static/js/bootstrap/bootstrap.bundle.min.js

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions etfcalc/static/js/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,22 @@ function remove_row(el) {
validate_inputs();
}

function refresh_row(el) {
let tr = el.parentElement.parentElement;
let ticker_input = tr.querySelector('[name="tickers"]');
ticker_value(ticker_input, ticker_input.value);
}

function refresh_table(el) {
let table = el.parentElement.parentElement.parentElement.parentElement;
let rows = table.querySelectorAll('tr');
// start at i = 1 to skit the header
for (let i = 1; i < rows.length; ++i) {
let ticker_input = rows[i].querySelector('[name="tickers"]');
ticker_value(ticker_input, ticker_input.value);
}
}

function ticker_value(el, ticker) {
if (!ticker) {
return;
Expand Down
11 changes: 10 additions & 1 deletion etfcalc/templates/input/input.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
<span>&times;</span>
</button>
</td>
<td>
<button type="button" class="btn btn-success btn-refresh-row" onclick="refresh_row(this)">
<span>&olarr;</span>
</button>
</td>
</tr>
</template>

Expand All @@ -55,7 +60,11 @@
<th>Ticker</th>
<th>Shares</th>
<th class="w-25">Price</th>
<th></th>
<th colspan="2" class="btn_header_cell">
<button type="button" class="btn btn-success btn-refresh-table" onclick="refresh_table(this)">
<span>&olarr;</span>
</button>
</th>
</tr>
</thead>
<tbody id="holding-table"></tbody>
Expand Down