mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
added edit space sibling conflict
This commit is contained in:
@ -12,6 +12,7 @@ import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
|||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/dialogs/icon_selection_dialog.dart';
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/dialogs/icon_selection_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/assign_tag/views/assign_tag_dialog.dart';
|
import 'package:syncrow_web/pages/spaces_management/assign_tag/views/assign_tag_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/create_subspace/views/create_subspace_model_dialog.dart';
|
import 'package:syncrow_web/pages/spaces_management/create_subspace/views/create_subspace_model_dialog.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/helper/space_helper.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/helper/tag_helper.dart';
|
import 'package:syncrow_web/pages/spaces_management/helper/tag_helper.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/link_space_model/view/link_space_model_dialog.dart';
|
import 'package:syncrow_web/pages/spaces_management/link_space_model/view/link_space_model_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
||||||
@ -177,7 +178,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
|||||||
isNameFieldInvalid = value.isEmpty;
|
isNameFieldInvalid = value.isEmpty;
|
||||||
|
|
||||||
if (!isNameFieldInvalid) {
|
if (!isNameFieldInvalid) {
|
||||||
if (_isNameConflict(value)) {
|
if (SpaceHelper.isNameConflict(value, widget.parentSpace, widget.editSpace)) {
|
||||||
isNameFieldExist = true;
|
isNameFieldExist = true;
|
||||||
isOkButtonEnabled = false;
|
isOkButtonEnabled = false;
|
||||||
} else {
|
} else {
|
||||||
@ -591,26 +592,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _isNameConflict(String value) {
|
|
||||||
final parentSpace = widget.parentSpace;
|
|
||||||
final editSpace = widget.editSpace;
|
|
||||||
final siblings = parentSpace?.children
|
|
||||||
.where((child) => child.uuid != editSpace?.uuid)
|
|
||||||
.toList() ??
|
|
||||||
[];
|
|
||||||
final siblingConflict = siblings.any((child) => child.name == value);
|
|
||||||
final parentConflict =
|
|
||||||
parentSpace?.name == value && parentSpace?.uuid != editSpace?.uuid;
|
|
||||||
final parentOfEditSpaceConflict = editSpace?.parent?.name == value &&
|
|
||||||
editSpace?.parent?.uuid != editSpace?.uuid;
|
|
||||||
final childConflict =
|
|
||||||
editSpace?.children.any((child) => child.name == value) ?? false;
|
|
||||||
return siblingConflict ||
|
|
||||||
parentConflict ||
|
|
||||||
parentOfEditSpaceConflict ||
|
|
||||||
childConflict;
|
|
||||||
}
|
|
||||||
|
|
||||||
void _showLinkSpaceModelDialog(BuildContext context) {
|
void _showLinkSpaceModelDialog(BuildContext context) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
|
@ -58,4 +58,37 @@ class SpaceHelper {
|
|||||||
?.any((child) => child.internalId == space.internalId) ==
|
?.any((child) => child.internalId == space.internalId) ==
|
||||||
true;
|
true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool isNameConflict(
|
||||||
|
String value, SpaceModel? parentSpace, SpaceModel? editSpace) {
|
||||||
|
final siblings = parentSpace?.children
|
||||||
|
.where((child) => child.internalId != editSpace?.internalId)
|
||||||
|
.toList() ??
|
||||||
|
[];
|
||||||
|
|
||||||
|
final editSiblings = editSpace?.parent?.children
|
||||||
|
.where((child) => child.internalId != editSpace.internalId)
|
||||||
|
.toList() ??
|
||||||
|
[];
|
||||||
|
|
||||||
|
final editSiblingConflict =
|
||||||
|
editSiblings.any((child) => child.name == value);
|
||||||
|
|
||||||
|
final siblingConflict = siblings.any((child) => child.name == value);
|
||||||
|
|
||||||
|
final parentConflict = parentSpace?.name == value &&
|
||||||
|
parentSpace?.internalId != editSpace?.internalId;
|
||||||
|
|
||||||
|
final parentOfEditSpaceConflict = editSpace?.parent?.name == value &&
|
||||||
|
editSpace?.parent?.internalId != editSpace?.internalId;
|
||||||
|
|
||||||
|
final childConflict =
|
||||||
|
editSpace?.children.any((child) => child.name == value) ?? false;
|
||||||
|
|
||||||
|
return siblingConflict ||
|
||||||
|
parentConflict ||
|
||||||
|
editSiblingConflict ||
|
||||||
|
parentOfEditSpaceConflict ||
|
||||||
|
childConflict;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user