manager: Fix groups and caps selection, close #592

This commit is contained in:
weishu
2023-06-05 08:29:24 +08:00
parent 6ba2bd3af9
commit e8755f8ae0

View File

@@ -181,7 +181,7 @@ fun RootProfileConfig(
@OptIn(ExperimentalLayoutApi::class) @OptIn(ExperimentalLayoutApi::class)
@Composable @Composable
fun GroupsPanel(selected: List<Groups>, closeSelection: (selection: List<Groups>) -> Unit) { fun GroupsPanel(selected: List<Groups>, closeSelection: (selection: Set<Groups>) -> Unit) {
var showDialog by remember { mutableStateOf(false) } var showDialog by remember { mutableStateOf(false) }
@@ -194,7 +194,7 @@ fun GroupsPanel(selected: List<Groups>, closeSelection: (selection: List<Groups>
) )
} }
val selection = ArrayList(selected) val selection = HashSet(selected)
ListDialog( ListDialog(
state = rememberUseCaseState(visible = true, onFinishedRequest = { state = rememberUseCaseState(visible = true, onFinishedRequest = {
closeSelection(selection) closeSelection(selection)
@@ -206,6 +206,7 @@ fun GroupsPanel(selected: List<Groups>, closeSelection: (selection: List<Groups>
options = options, options = options,
) { indecies, _ -> ) { indecies, _ ->
// Handle selection // Handle selection
selection.clear()
indecies.forEach { index -> indecies.forEach { index ->
val group = groups[index] val group = groups[index]
selection.add(group) selection.add(group)
@@ -240,7 +241,7 @@ fun GroupsPanel(selected: List<Groups>, closeSelection: (selection: List<Groups>
@Composable @Composable
fun CapsPanel( fun CapsPanel(
selected: Collection<Capabilities>, selected: Collection<Capabilities>,
closeSelection: (selection: List<Capabilities>) -> Unit closeSelection: (selection: Set<Capabilities>) -> Unit
) { ) {
var showDialog by remember { mutableStateOf(false) } var showDialog by remember { mutableStateOf(false) }
@@ -254,7 +255,7 @@ fun CapsPanel(
) )
} }
val selection = ArrayList(selected) val selection = HashSet(selected)
ListDialog( ListDialog(
state = rememberUseCaseState(visible = true, onFinishedRequest = { state = rememberUseCaseState(visible = true, onFinishedRequest = {
closeSelection(selection) closeSelection(selection)
@@ -266,6 +267,7 @@ fun CapsPanel(
options = options options = options
) { indecies, _ -> ) { indecies, _ ->
// Handle selection // Handle selection
selection.clear()
indecies.forEach { index -> indecies.forEach { index ->
val group = caps[index] val group = caps[index]
selection.add(group) selection.add(group)