@@ -34,6 +34,9 @@ struct ManageFeaturesView: View {
3434 /// The current viewpoint of the map view.
3535 @State private var currentViewpoint : Viewpoint ?
3636
37+ /// A Boolean value indicating whether the update attribute dialog is displayed.
38+ @State private var isShowingUpdateAttributeDialog = false
39+
3740 var body : some View {
3841 Group {
3942 switch data {
@@ -127,15 +130,10 @@ struct ManageFeaturesView: View {
127130 . foregroundStyle ( . secondary)
128131 }
129132 Menu {
130- Button {
131- Task {
132- clearSelection ( )
133- await updateAttribute ( for: feature)
134- }
135- } label: {
136- Text ( " Update Attribute " )
133+ Button ( " Update Attribute " ) {
134+ isShowingUpdateAttributeDialog = true
137135 }
138- Button {
136+ Button ( " Update Geometry " ) {
139137 // Hide callout, leave feature selected.
140138 calloutPlacement = nil
141139 Task {
@@ -146,23 +144,33 @@ struct ManageFeaturesView: View {
146144 // Update callout location after moving feature.
147145 calloutPlacement = . geoElement( feature)
148146 }
149- } label: {
150- Text ( " Update Geometry " )
151147 }
152- Button {
148+ Button ( " Delete Feature " ) {
153149 Task {
154150 clearSelection ( )
155151 await delete ( feature: feature)
156152 }
157- } label: {
158- Text ( " Delete Feature " )
159153 }
160154 } label: {
161155 Label ( " Edit Feature " , systemImage: " ellipsis " )
162156 . padding ( )
163157 . contentShape ( . rect)
164158 . labelStyle ( . iconOnly)
165159 }
160+ . confirmationDialog ( " Update Attribute " , isPresented: $isShowingUpdateAttributeDialog) {
161+ ForEach ( DamageKind . allCases, id: \. self) { damageKind in
162+ Button ( damageKind. rawValue) {
163+ isShowingUpdateAttributeDialog = false
164+ clearSelection ( )
165+
166+ Task {
167+ await updateAttribute ( for: feature, damageKind: damageKind)
168+ }
169+ }
170+ }
171+ } message: {
172+ Text ( " Choose a damage kind for the feature. " )
173+ }
166174 }
167175 . padding ( [ . leading, . vertical] )
168176 }
@@ -250,13 +258,15 @@ extension ManageFeaturesView {
250258 }
251259
252260 /// Updates the attributes of a feature and applies edits to the service.
253- /// - Parameter feature: The feature to update.
254- func updateAttribute( for feature: Feature ) async {
261+ /// - Parameters:
262+ /// - feature: The feature to update.
263+ /// - damageKind: The kind used to set the feature's damage assessment attribute.
264+ func updateAttribute( for feature: Feature , damageKind: DamageKind ) async {
255265 guard case . success( let data) = data else { return }
256266 let table = data. featureTable
257267
258268 do {
259- feature. damageKind = feature . damageKind? . next ?? . inaccessible
269+ feature. damageKind = damageKind
260270 try await table. update ( feature)
261271 _ = try await table. serviceGeodatabase? . applyEdits ( )
262272 status = " Update attribute succeeded. "
@@ -322,14 +332,6 @@ extension ManageFeaturesView {
322332 case minor = " Minor "
323333 case major = " Major "
324334 case destroyed = " Destroyed "
325-
326- /// The next damage kind to set on a feature.
327- var next : Self {
328- let allCases = Self . allCases
329- let index = allCases. firstIndex ( of: self ) !
330- let nextIndex = allCases. index ( after: index)
331- return allCases [ nextIndex == allCases. count ? 0 : nextIndex]
332- }
333335 }
334336}
335337
0 commit comments