-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BDOG-3332 Add team and digital filter to shutter overview
- Loading branch information
1 parent
dfbd4c9
commit 489051f
Showing
6 changed files
with
144 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,18 +16,26 @@ | |
|
||
@import uk.gov.hmrc.cataloguefrontend.shuttering.{routes, ShutterCause, ShutterStateChangeEvent, ShutterState, ShutterStatusValue, ShutterType} | ||
@import uk.gov.hmrc.cataloguefrontend.util.DateHelper._ | ||
@import views.html.helper.{FieldConstructor, select} | ||
|
||
@this() | ||
|
||
@(shutterStates : Map[Environment, Seq[(ShutterState, Option[ShutterStateChangeEvent])]] | ||
, shutterType : ShutterType | ||
, selectedEnv : Environment | ||
, killSwitchLink: Option[String] | ||
@(form : Form[?] | ||
, shutterStates : Map[Environment, Seq[(ShutterState, Option[ShutterStateChangeEvent])]] | ||
, shutterType : ShutterType | ||
, selectedEnv : Environment | ||
, selectedTeamName : Option[TeamName] | ||
, selectedDigitalService: Option[DigitalService] | ||
, killSwitchLink : Option[String] | ||
, teams : Seq[TeamName] | ||
, digitalServices : Seq[DigitalService] | ||
)(implicit | ||
request : RequestHeader | ||
, messages : Messages | ||
) | ||
|
||
@implicitField: FieldConstructor = @{ FieldConstructor(catalogueFieldConstructor.f) } | ||
|
||
@standard_layout(s"Shutter Overview - ${shutterType.asString.capitalize}", active = "shuttering") { | ||
|
||
<h1 class="page-heading mt-4">Shutter Overview - @{shutterType.asString.capitalize}</h1> | ||
|
@@ -41,6 +49,33 @@ <h1 class="page-heading mt-4">Shutter Overview - @{shutterType.asString.capitali | |
|
||
<section id="shutter-overview"> | ||
|
||
<div class="row"> | ||
<form id="form" method="get"> | ||
<div class="row"> | ||
<div class="col-md-3"> | ||
@select( | ||
field = form("teamName"), | ||
options = teams.map(t => t.asString -> t.asString), | ||
Symbol("_default") -> "All", | ||
Symbol("_label") -> "Team", | ||
Symbol("_labelClass") -> "form-label", | ||
Symbol("id") -> "teamName-dropdown", | ||
Symbol("class") -> "form-select" | ||
) | ||
</div> | ||
<div class="col-md-3"> | ||
@select( | ||
field = form("digitalService"), | ||
options = digitalServices.map(ds => ds.asString -> ds.asString), | ||
Symbol("_default") -> "All", | ||
Symbol("_label") -> "Digital Service", | ||
Symbol("_labelClass") -> "form-label", | ||
Symbol("id") -> "digitalService-dropdown", | ||
Symbol("class") -> "form-select" | ||
) | ||
</div> | ||
</form> | ||
|
||
<div class="row mb-3"> | ||
<div class="col-12 position-relative"> | ||
<ul id="environment" class="nav nav-tabs mb2"> | ||
|
@@ -75,53 +110,62 @@ <h1 class="page-heading mt-4">Shutter Overview - @{shutterType.asString.capitali | |
</tr> | ||
</thead> | ||
<tbody class="list"> | ||
@shutterRows(shutterStates.get(selectedEnv).getOrElse(Seq.empty)) | ||
@shutterRows(shutterStates.getOrElse(selectedEnv, Seq.empty)) | ||
</tbody> | ||
</table> | ||
</div> | ||
</section> | ||
|
||
<script @CSPNonce.attr> | ||
function filterUnshuttered() { | ||
let checkBox = document.getElementById("shuttered-only"); | ||
let unshutteredServices = document.querySelectorAll("tr.unshuttered"); | ||
|
||
if (checkBox.checked === true) { | ||
unshutteredServices.forEach(function(element) { | ||
element.classList.add("d-none"); | ||
}); | ||
} else { | ||
unshutteredServices.forEach(function(element) { | ||
element.classList.remove("d-none"); | ||
}); | ||
} | ||
let checkBox = document.getElementById("shuttered-only"); | ||
let unshutteredServices = document.querySelectorAll("tr.unshuttered"); | ||
|
||
if (checkBox.checked === true) { | ||
unshutteredServices.forEach(function(element) { | ||
element.classList.add("d-none"); | ||
}); | ||
} else { | ||
unshutteredServices.forEach(function(element) { | ||
element.classList.remove("d-none"); | ||
}); | ||
} | ||
} | ||
|
||
document.getElementById("shuttered-only").addEventListener("change", function() { | ||
filterUnshuttered(); | ||
filterUnshuttered(); | ||
}); | ||
|
||
let options = { valueNames: [ 'shutter-service', @if(shutterType != ShutterType.Frontend) { 'shutter-context' }, 'shutter-state', 'shutter-user', 'shutter-date' ] }; | ||
let serviceList = new List('service-list', options); | ||
["teamName-dropdown", "digitalService-dropdown"] | ||
.forEach(function(id) { | ||
document.getElementById(id).addEventListener("change", function() { | ||
document.getElementById("form").submit(); | ||
}); | ||
}); | ||
|
||
@if(shutterStates.getOrElse(selectedEnv, Seq.empty).nonEmpty) { | ||
let options = { valueNames: [ 'shutter-service', @if(shutterType != ShutterType.Frontend) { 'shutter-context', } 'shutter-state', 'shutter-user', 'shutter-date' ] }; | ||
let serviceList = new List('service-list', options); | ||
} | ||
</script> | ||
} | ||
|
||
@envOption(env: Environment) = { | ||
@defining(env == selectedEnv) { active => | ||
<li id="[email protected]" class="nav-item"> | ||
<a class="nav-link @if(active) {active}" href="@uk.gov.hmrc.cataloguefrontend.shuttering.routes.ShutterOverviewController.allStatesForEnv(shutterType, env)"> | ||
<a class="nav-link @if(active) {active}" href="@uk.gov.hmrc.cataloguefrontend.shuttering.routes.ShutterOverviewController.allStatesForEnv(shutterType, env, selectedTeamName, selectedDigitalService)"> | ||
@env.displayString (@shutteredCount(env) / @serviceCount(env)) | ||
</a> | ||
</li> | ||
} | ||
} | ||
|
||
@serviceCount(env: Environment) = { | ||
@shutterStates.get(env).getOrElse(Seq.empty).size | ||
@shutterStates.getOrElse(env, Seq.empty).size | ||
} | ||
|
||
@shutteredCount(env: Environment) = { | ||
@shutterStates.get(env).getOrElse(Seq.empty).filter(_._1.status.value == ShutterStatusValue.Shuttered).size | ||
@shutterStates.getOrElse(env, Seq.empty).filter(_._1.status.value == ShutterStatusValue.Shuttered).size | ||
} | ||
|
||
@shutterRows(states: Seq[(ShutterState, Option[ShutterStateChangeEvent])]) = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters