[iOS] Admin Dashboard - Allowed Tags Cleanup (#1489)
* Enable if AllowedTags exist instead of just blockedTags * Separation * cleanup --------- Co-authored-by: Ethan Pippin <ethanpippin2343@gmail.com>
This commit is contained in:
parent
8c4fde87f1
commit
a585bbda5f
|
@ -42,6 +42,11 @@ struct EditServerUserAccessTagsView: View {
|
|||
@State
|
||||
private var error: Error?
|
||||
|
||||
private var hasTags: Bool {
|
||||
viewModel.user.policy?.blockedTags?.isEmpty == true &&
|
||||
viewModel.user.policy?.allowedTags?.isEmpty == true
|
||||
}
|
||||
|
||||
private var allowedTags: [TagWithAccess] {
|
||||
viewModel.user.policy?.allowedTags?
|
||||
.sorted()
|
||||
|
@ -103,20 +108,16 @@ struct EditServerUserAccessTagsView: View {
|
|||
}
|
||||
.navigationBarMenuButton(
|
||||
isLoading: viewModel.backgroundStates.contains(.refreshing),
|
||||
isHidden: isEditing || (
|
||||
viewModel.user.policy?.blockedTags?.isEmpty == true
|
||||
)
|
||||
isHidden: isEditing || hasTags
|
||||
) {
|
||||
Button(L10n.add, systemImage: "plus") {
|
||||
router.route(to: \.userAddAccessTag, viewModel)
|
||||
}
|
||||
|
||||
if viewModel.user.policy?.blockedTags?.isNotEmpty == true {
|
||||
Button(L10n.edit, systemImage: "checkmark.circle") {
|
||||
isEditing = true
|
||||
}
|
||||
}
|
||||
}
|
||||
.onReceive(viewModel.events) { event in
|
||||
switch event {
|
||||
case let .error(eventError):
|
||||
|
@ -179,6 +180,7 @@ struct EditServerUserAccessTagsView: View {
|
|||
}
|
||||
} else {
|
||||
if allowedTags.isNotEmpty {
|
||||
Section {
|
||||
DisclosureGroup(L10n.allowed) {
|
||||
ForEach(
|
||||
allowedTags,
|
||||
|
@ -187,7 +189,9 @@ struct EditServerUserAccessTagsView: View {
|
|||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
if blockedTags.isNotEmpty {
|
||||
Section {
|
||||
DisclosureGroup(L10n.blocked) {
|
||||
ForEach(
|
||||
blockedTags,
|
||||
|
@ -199,15 +203,16 @@ struct EditServerUserAccessTagsView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Select/Remove All Button
|
||||
|
||||
@ViewBuilder
|
||||
private var navigationBarSelectView: some View {
|
||||
let isAllSelected = selectedTags.count == blockedTags.count
|
||||
let isAllSelected = selectedTags.count == blockedTags.count + allowedTags.count
|
||||
|
||||
Button(isAllSelected ? L10n.removeAll : L10n.selectAll) {
|
||||
selectedTags = isAllSelected ? [] : Set(blockedTags)
|
||||
selectedTags = isAllSelected ? [] : Set(blockedTags + allowedTags)
|
||||
}
|
||||
.buttonStyle(.toolbarPill)
|
||||
.disabled(!isEditing)
|
||||
|
|
Loading…
Reference in New Issue