1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-06 21:48:12 -05:00

amend: i changed all var keywords to let, i removed asp-for duplicates and i introduced i0,i1,12 variables to store the current value of the loop counter variable i at different points within the loop (#3100)

Co-authored-by: Chukwuma Akunyili <56761791+ChukwumaA@users.noreply.github.com>
Co-authored-by: Daniel James Smith <2670567+djsmith85@users.noreply.github.com>
This commit is contained in:
Chukwuma Akunyili 2023-12-27 16:39:33 +01:00 committed by GitHub
parent 1f8e2385db
commit fbc25f3317
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,12 +6,12 @@
@section Scripts { @section Scripts {
<script> <script>
function onRowSelect(selectingPage = false) { function onRowSelect(selectingPage = false) {
var checkboxes = document.getElementsByClassName('row-check'); let checkboxes = document.getElementsByClassName('row-check');
var checkedCheckboxCount = 0; let checkedCheckboxCount = 0;
var bulkActions = document.getElementById('bulkActions'); let bulkActions = document.getElementById('bulkActions');
var selectPage = document.getElementById('selectPage'); let selectPage = document.getElementById('selectPage');
for(var i = 0; i < checkboxes.length; i++){ for(let i = 0; i < checkboxes.length; i++){
if((checkboxes[i].checked && !selectingPage) || selectingPage && selectPage.checked) { if((checkboxes[i].checked && !selectingPage) || selectingPage && selectPage.checked) {
checkboxes[i].checked = true; checkboxes[i].checked = true;
checkedCheckboxCount += 1; checkedCheckboxCount += 1;
@ -26,40 +26,39 @@
bulkActions.classList.add("d-none"); bulkActions.classList.add("d-none");
} }
var selectPage = document.getElementById('selectPage'); let selectAll = document.getElementById('selectAll');
var selectAll = document.getElementById('selectAll'); if (checkedCheckboxCount === checkboxes.length) {
if (checkedCheckboxCount == checkboxes.length) {
selectPage.checked = true; selectPage.checked = true;
selectAll.classList.remove("d-none"); selectAll.classList.remove("d-none");
var selectAllElement = document.getElementById('selectAllElement'); let selectAllElement = document.getElementById('selectAllElement');
selectAllElement.classList.remove('d-none'); selectAllElement.classList.remove('d-none');
var selectedAllConfirmation = document.getElementById('selectedAllConfirmation'); let selectedAllConfirmation = document.getElementById('selectedAllConfirmation');
selectedAllConfirmation.classList.add('d-none'); selectedAllConfirmation.classList.add('d-none');
} else { } else {
selectPage.checked = false; selectPage.checked = false;
selectAll.classList.add("d-none"); selectAll.classList.add("d-none");
var selectAllInput = document.getElementById('selectAllInput'); let selectAllInput = document.getElementById('selectAllInput');
selectAllInput.checked = false; selectAllInput.checked = false;
} }
} }
function onSelectAll() { function onSelectAll() {
var selectAllInput = document.getElementById('selectAllInput'); let selectAllInput = document.getElementById('selectAllInput');
selectAllInput.checked = true; selectAllInput.checked = true;
var selectAllElement = document.getElementById('selectAllElement'); let selectAllElement = document.getElementById('selectAllElement');
selectAllElement.classList.add('d-none'); selectAllElement.classList.add('d-none');
var selectedAllConfirmation = document.getElementById('selectedAllConfirmation'); let selectedAllConfirmation = document.getElementById('selectedAllConfirmation');
selectedAllConfirmation.classList.remove('d-none'); selectedAllConfirmation.classList.remove('d-none');
} }
function exportSelectedSubscriptions() { function exportSelectedSubscriptions() {
var selectAll = document.getElementById('selectAll'); let selectAll = document.getElementById('selectAll');
var httpRequest = new XMLHttpRequest(); let httpRequest = new XMLHttpRequest();
httpRequest.open('POST'); httpRequest.open("POST");
httpRequest.send(); httpRequest.send();
} }
@ -74,9 +73,9 @@
{ {
<div class="alert alert-success"></div> <div class="alert alert-success"></div>
} }
<form method="post"> <form method="post">
<div asp-validation-summary="All" class="alert alert-danger"></div> <div asp-validation-summary="All" class="alert alert-danger"></div>
<div class="row"> <div class="row">
<div class="col-6"> <div class="col-6">
<label asp-for="Filter.Status">Status</label> <label asp-for="Filter.Status">Status</label>
<select asp-for="Filter.Status" name="filter.Status" class="form-control mr-2"> <select asp-for="Filter.Status" name="filter.Status" class="form-control mr-2">
@ -102,14 +101,16 @@
} }
</div> </div>
</div> </div>
</div> </div>
<div class="row mt-2"> <div class="row mt-2">
<div class="col-6"> <div class="col-6">
<label asp-for="Filter.Price">Price ID</label> <label asp-for="Filter.Price">Price ID</label>
<select asp-for="Filter.Price" name="filter.Price" class="form-control mr-2"> <select asp-for="Filter.Price" name="filter.Price" class="form-control mr-2">
<option asp-selected="Model.Filter.Price == null" value="@null">All</option> <option asp-selected="Model.Filter.Price == null" value="@null">All</option>
@foreach (var price in Model.Prices) @foreach (var price in Model.Prices)
{<option asp-selected='@Model.Filter.Price == @price.Id' value="@price.Id">@price.Id</option>} {
<option asp-selected='@Model.Filter.Price == @price.Id' value="@price.Id">@price.Id</option>
}
</select> </select>
</div> </div>
<div class="col-6"> <div class="col-6">
@ -117,24 +118,26 @@
<select asp-for="Filter.TestClock" name="filter.TestClock" class="form-control mr-2"> <select asp-for="Filter.TestClock" name="filter.TestClock" class="form-control mr-2">
<option asp-selected="Model.Filter.TestClock == null" value="@null">All</option> <option asp-selected="Model.Filter.TestClock == null" value="@null">All</option>
@foreach (var clock in Model.TestClocks) @foreach (var clock in Model.TestClocks)
{<option asp-selected='@Model.Filter.TestClock == @clock.Id' value="@clock.Id">@clock.Name</option>} {
<option asp-selected='@Model.Filter.TestClock == @clock.Id' value="@clock.Id">@clock.Name</option>
}
</select> </select>
</div> </div>
</div> </div>
<div class="row col-12 d-flex justify-content-end my-3"> <div class="row col-12 d-flex justify-content-end my-3">
<button type="submit" class="btn btn-primary" title="Search" name="action" asp-for="Action" value="@StripeSubscriptionsAction.Search"><i class="fa fa-search"></i> Search</button> <button type="submit" class="btn btn-primary" title="Search" name="action" asp-for="Action" value="@StripeSubscriptionsAction.Search"><i class="fa fa-search"></i> Search</button>
</div> </div>
<hr/> <hr/>
<input type="checkbox" class="d-none" asp-for="Filter.SelectAll" name="filter.SelectAll" id="selectAllInput" asp-for="Model.Filter.SelectAll"> <input type="checkbox" class="d-none" name="filter.SelectAll" id="selectAllInput" asp-for="@Model.Filter.SelectAll">
<div class="text-center row d-flex justify-content-center"> <div class="text-center row d-flex justify-content-center">
<div id="selectAll" class="d-none col-8"> <div id="selectAll" class="d-none col-8">
All @Model.Items.Count subscriptions on this page are selected.<br/> All @Model.Items.Count subscriptions on this page are selected.<br/>
<button type="button" id="selectAllElement" class="btn btn-link p-0 pb-1" onclick="onSelectAll()">Click here to select all subscriptions for this search.</button> <button type="button" id="selectAllElement" class="btn btn-link p-0 pb-1" onclick="onSelectAll()">Click here to select all subscriptions for this search.</button>
<span id="selectedAllConfirmation" class="d-none text-muted">✔ All subscriptions for this search are selected.</span><br/> <span id="selectedAllConfirmation" class="d-none text-muted">✔ All subscriptions for this search are selected.</span><br/>
<div class="alert alert-warning" role="alert">Please be aware that bulk operations may take several minutes to complete.</div> <div class="alert alert-warning" role="alert">Please be aware that bulk operations may take several minutes to complete.</div>
</div> </div>
</div> </div>
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-striped table-hover"> <table class="table table-striped table-hover">
<thead> <thead>
<tr> <tr>
@ -151,7 +154,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@if(!Model.Items.Any()) @if (!Model.Items.Any())
{ {
<tr> <tr>
<td colspan="6">No results to list.</td> <td colspan="6">No results to list.</td>
@ -159,27 +162,36 @@
} }
else else
{ {
@for(var i = 0; i < Model.Items.Count; i++) @for (var i = 0; i < Model.Items.Count; i++)
{ {
<tr> <tr>
<td> <td>
<input type="hidden" asp-for="@Model.Items[i].Subscription.Id" value="@Model.Items[i].Subscription.Id">
<input type="hidden" asp-for="@Model.Items[i].Subscription.Status" value="@Model.Items[i].Subscription.Status">
<input type="hidden" asp-for="@Model.Items[i].Subscription.CurrentPeriodEnd" value="@Model.Items[i].Subscription.CurrentPeriodEnd">
<input type="hidden" asp-for="@Model.Items[i].Subscription.Customer.Email" value="@Model.Items[i].Subscription.Customer.Email">
<input type="hidden" asp-for="@Model.Items[i].Subscription.LatestInvoice.Status" value="@Model.Items[i].Subscription.LatestInvoice.Status">
<input type="hidden" asp-for="@Model.Items[i].Subscription.LatestInvoice.Id" value="@Model.Items[i].Subscription.LatestInvoice.Id">
@for(var j = 0; j < Model.Items[i].Subscription.Items.Data.Count; j++) @{
var i0 = i;
}
<input type="hidden" asp-for="@Model.Items[i0].Subscription.Id" value="@Model.Items[i].Subscription.Id">
<input type="hidden" asp-for="@Model.Items[i0].Subscription.Status" value="@Model.Items[i].Subscription.Status">
<input type="hidden" asp-for="@Model.Items[i0].Subscription.CurrentPeriodEnd" value="@Model.Items[i].Subscription.CurrentPeriodEnd">
<input type="hidden" asp-for="@Model.Items[i0].Subscription.Customer.Email" value="@Model.Items[i].Subscription.Customer.Email">
<input type="hidden" asp-for="@Model.Items[i0].Subscription.LatestInvoice.Status" value="@Model.Items[i].Subscription.LatestInvoice.Status">
<input type="hidden" asp-for="@Model.Items[i0].Subscription.LatestInvoice.Id" value="@Model.Items[i].Subscription.LatestInvoice.Id">
@for (var j = 0; j < Model.Items[i].Subscription.Items.Data.Count; j++)
{ {
var i1 = i;
var j1 = j;
<input <input
type="hidden" type="hidden"
asp-for="@Model.Items[i].Subscription.Items.Data[j].Plan.Id" asp-for="@Model.Items[i1].Subscription.Items.Data[j1].Plan.Id"
value="@Model.Items[i].Subscription.Items.Data[j].Plan.Id" value="@Model.Items[i].Subscription.Items.Data[j].Plan.Id">
>
} }
<div class="form-check"> <div class="form-check">
<input class="form-check-input row-check" onchange="onRowSelect()" asp-for="@Model.Items[i].Selected">
@{
var i2 = i;
}
<input class="form-check-input row-check" onchange="onRowSelect()" asp-for="@Model.Items[i2].Selected">
</div> </div>
</td> </td>
<td> <td>
@ -202,10 +214,10 @@
} }
</tbody> </tbody>
</table> </table>
</div> </div>
<nav class="d-inline-flex"> <nav class="d-inline-flex">
<ul class="pagination"> <ul class="pagination">
@if(!string.IsNullOrWhiteSpace(Model.Filter.EndingBefore)) @if (!string.IsNullOrWhiteSpace(Model.Filter.EndingBefore))
{ {
<input type="hidden" asp-for="@Model.Filter.EndingBefore" value="@Model.Filter.EndingBefore"> <input type="hidden" asp-for="@Model.Filter.EndingBefore" value="@Model.Filter.EndingBefore">
<li class="page-item"> <li class="page-item">
@ -214,8 +226,7 @@
class="page-link" class="page-link"
name="action" name="action"
asp-for="Action" asp-for="Action"
value="@StripeSubscriptionsAction.PreviousPage" value="@StripeSubscriptionsAction.PreviousPage">
>
Previous Previous
</button> </button>
</li> </li>
@ -226,7 +237,7 @@
<a class="page-link" href="#" tabindex="-1">Previous</a> <a class="page-link" href="#" tabindex="-1">Previous</a>
</li> </li>
} }
@if(!string.IsNullOrWhiteSpace(Model.Filter.StartingAfter)) @if (!string.IsNullOrWhiteSpace(Model.Filter.StartingAfter))
{ {
<input type="hidden" asp-for="@Model.Filter.StartingAfter" value="@Model.Filter.StartingAfter"> <input type="hidden" asp-for="@Model.Filter.StartingAfter" value="@Model.Filter.StartingAfter">
<li class="page-item"> <li class="page-item">
@ -234,8 +245,7 @@
type="submit" type="submit"
name="action" name="action"
asp-for="Action" asp-for="Action"
value="@StripeSubscriptionsAction.NextPage" value="@StripeSubscriptionsAction.NextPage">
>
Next Next
</button> </button>
</li> </li>
@ -254,8 +264,7 @@
class="btn btn-primary mr-1" class="btn btn-primary mr-1"
name="action" name="action"
asp-for="Action" asp-for="Action"
value="@StripeSubscriptionsAction.Export" value="@StripeSubscriptionsAction.Export">
>
Export Export
</button> </button>
<button <button
@ -263,11 +272,10 @@
class="btn btn-danger" class="btn btn-danger"
name="action" name="action"
asp-for="Action" asp-for="Action"
value="@StripeSubscriptionsAction.BulkCancel" value="@StripeSubscriptionsAction.BulkCancel">
>
Bulk Cancel Bulk Cancel
</button> </button>
</span> </span>
</span> </span>
</nav> </nav>
</form> </form>