feat: require groupId in EntryEditViewModel, add group picker to EntryEditView
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WYqycDFsynHH9VnnK7LNSf
This commit is contained in:
@@ -9,6 +9,7 @@ import MyPassCore
|
||||
|
||||
struct EntryDetailView: View {
|
||||
let entry: Entry
|
||||
let groupId: UUID
|
||||
let session: VaultSession
|
||||
|
||||
@State private var showPassword = false
|
||||
@@ -30,7 +31,7 @@ struct EntryDetailView: View {
|
||||
}
|
||||
}
|
||||
.sheet(isPresented: $showEditSheet) {
|
||||
EntryEditView(vm: EntryEditViewModel(session: session, existing: entry))
|
||||
EntryEditView(vm: EntryEditViewModel(session: session, groupId: groupId, existing: entry))
|
||||
}
|
||||
#if os(macOS)
|
||||
.keyboardShortcut("e", modifiers: .command)
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
//
|
||||
// EntryEditView.swift
|
||||
// MyPass
|
||||
//
|
||||
|
||||
// MyPass/Views/EntryEditView.swift
|
||||
import SwiftUI
|
||||
import MyPassCore
|
||||
|
||||
@@ -13,6 +9,16 @@ struct EntryEditView: View {
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
Form {
|
||||
if !vm.isEditing {
|
||||
Section("Group") {
|
||||
Picker("Group", selection: $vm.groupId) {
|
||||
ForEach(vm.flatGroups) { flatGroup in
|
||||
Text(groupLabel(for: flatGroup)).tag(flatGroup.group.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Section("Credentials") {
|
||||
TextField("Title", text: $vm.title)
|
||||
TextField("Username", text: $vm.username)
|
||||
@@ -69,4 +75,8 @@ struct EntryEditView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func groupLabel(for flatGroup: FlatGroup) -> String {
|
||||
(flatGroup.breadcrumb.map(\.name) + [flatGroup.group.name]).joined(separator: " > ")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user