Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,17 @@ extension FeatureFormView {
let source: UtilityAssociationFeatureSource

/// The filtered asset types that can be used to query for association candidates.
///
/// Types are sorted first by their name and then by their group name.
private var filteredTypes: [UtilityAssetType] {
let result: [UtilityAssetType]
if filterPhrase.isEmpty {
source.assetTypes
result = source.assetTypes
} else {
source.assetTypes.filter({ $0.name.localizedStandardContains(filterPhrase) })
result = source.assetTypes.filter({ $0.name.localizedStandardContains(filterPhrase) })
}
return result.sorted {
($0.name, $0.group?.name ?? "") < ($1.name, $1.group?.name ?? "")
}
}

Expand All @@ -50,20 +56,29 @@ extension FeatureFormView {
comment: """
A label for a search field to filter utility
asset types by name.
""",
"""
),
prompt: nil
)
}
Section {
ForEach(filteredTypes, id: \.compositeID) { assetType in
NavigationLink(
assetType.name,
value: FeatureFormView.NavigationPathItem.utilityAssociationFeatureCandidatesView(
form, element, filter, source, assetType
form, element,
filter,
source, assetType
)
)
.accessibilityIdentifier("Asset Type \(assetType.name) \(assetType.code)")
) {
VStack(alignment: .leading) {
Text(assetType.name)
if let group = assetType.group {
Text(group.name)
.font(.caption)
.foregroundStyle(.secondary)
}
}
}
}
} header: {
HStack {
Expand Down
12 changes: 6 additions & 6 deletions Test Runner/UI Tests/FeatureFormViewTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,7 @@ final class FeatureFormViewTests: XCTestCase {
let app = XCUIApplication()
let addButton = app.buttons["Add"]
let associationTypeLabel = app.staticTexts["Association Type"]
let cabinetFuseButton = app.buttons["Cabinet Fuse"]
let cabinetFuseButton = app.buttons["Cabinet Fuse, Fuse"]
let connectedFilterTitle = app.staticTexts["Connected"]
let connectivityLabel = app.staticTexts["Connectivity"]
let discardButton = app.buttons["Discard"]
Expand Down Expand Up @@ -1549,7 +1549,7 @@ final class FeatureFormViewTests: XCTestCase {
let terminalLabel = app.staticTexts["Terminal"]
let terminalPicker = app.buttons["Terminal, High"]
let toElementLabel = app.staticTexts["To Element"]
let undergroundMediumVoltageThreePhaseDisconnectButton = app.buttons["Asset Type Underground Medium Voltage Three Phase Disconnect 493"]
let undergroundMediumVoltageThreePhaseDisconnectButton = app.buttons["Underground Medium Voltage Three Phase Disconnect, Switch"]

#if targetEnvironment(macCatalyst)
let addAssociationButton = app.buttons["Add Association"]
Expand Down Expand Up @@ -1648,7 +1648,7 @@ final class FeatureFormViewTests: XCTestCase {
let structureJunctionDataSourceButton = app.buttons["Structure Junction"]
let toElementValueLabel = app.staticTexts["Vault"]
let toElementLabel = app.staticTexts["To Element"]
let vaultAssetTypeButton = app.buttons["Vault"]
let vaultAssetTypeButton = app.buttons["Vault, Vault"]
let vaultCandidateButton = app.staticTexts.matching(identifier: "Vault").element(boundBy: 1)

#if targetEnvironment(macCatalyst)
Expand Down Expand Up @@ -1722,7 +1722,7 @@ final class FeatureFormViewTests: XCTestCase {
let filterButton = app.buttons["Filter Candidates"]
let formTitle = app.staticTexts["Electric Distribution Device"]
let lineEndCandidates = app.buttons.matching(identifier: "Line End")
let lowVoltageSinglePhaseLineEnd = app.buttons["Low Voltage Single Phase Line End"]
let lowVoltageSinglePhaseLineEnd = app.buttons["Low Voltage Single Phase Line End, Line End"]
let valueButton = app.buttons["Value"]

#if os(visionOS) || targetEnvironment(macCatalyst)
Expand Down Expand Up @@ -1857,7 +1857,7 @@ final class FeatureFormViewTests: XCTestCase {
let greaterThanLabels = app.staticTexts.matching(identifier: ">")
let jan2014Label = app.staticTexts["January 2014"]
let lessThanButton = app.buttons["<"]
let municipalButton = app.buttons["Municipal"]
let municipalButton = app.buttons["Municipal, Street Light"]
let streetLightCandidates = app.buttons.matching(identifier: "Street Light")

#if os(visionOS) || targetEnvironment(macCatalyst)
Expand Down Expand Up @@ -1972,7 +1972,7 @@ final class FeatureFormViewTests: XCTestCase {
let textField = app.textFields["Enter a value"]
let filterButton = app.buttons["Filter Candidates"]
let formTitle = app.staticTexts["Structure Junction"]
let municipalButton = app.buttons["Municipal"]
let municipalButton = app.buttons["Municipal, Street Light"]
let streetLightButton = app.buttons["Street Light"]
let streetLightCandidates = app.buttons.matching(identifier: "Street Light")

Expand Down