mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
add subspace validation
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
||||||
import 'package:syncrow_web/utils/constants/action_enum.dart';
|
import 'package:syncrow_web/utils/constants/action_enum.dart';
|
||||||
|
import 'package:uuid/uuid.dart';
|
||||||
|
|
||||||
import 'tag.dart';
|
import 'tag.dart';
|
||||||
|
|
||||||
@ -8,19 +9,24 @@ class SubspaceModel {
|
|||||||
String subspaceName;
|
String subspaceName;
|
||||||
final bool disabled;
|
final bool disabled;
|
||||||
List<Tag>? tags;
|
List<Tag>? tags;
|
||||||
|
String internalId;
|
||||||
|
|
||||||
SubspaceModel({
|
SubspaceModel({
|
||||||
this.uuid,
|
this.uuid,
|
||||||
required this.subspaceName,
|
required this.subspaceName,
|
||||||
required this.disabled,
|
required this.disabled,
|
||||||
this.tags,
|
this.tags,
|
||||||
});
|
String? internalId,
|
||||||
|
}) : internalId = internalId ?? const Uuid().v4();
|
||||||
|
|
||||||
factory SubspaceModel.fromJson(Map<String, dynamic> json) {
|
factory SubspaceModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
final String internalId = json['internalId'] ?? const Uuid().v4();
|
||||||
|
|
||||||
return SubspaceModel(
|
return SubspaceModel(
|
||||||
uuid: json['uuid'] ?? '',
|
uuid: json['uuid'] ?? '',
|
||||||
subspaceName: json['subspaceName'] ?? '',
|
subspaceName: json['subspaceName'] ?? '',
|
||||||
disabled: json['disabled'] ?? false,
|
disabled: json['disabled'] ?? false,
|
||||||
|
internalId: internalId,
|
||||||
tags: (json['tags'] as List<dynamic>?)
|
tags: (json['tags'] as List<dynamic>?)
|
||||||
?.map((item) => Tag.fromJson(item))
|
?.map((item) => Tag.fromJson(item))
|
||||||
.toList() ??
|
.toList() ??
|
||||||
|
@ -358,10 +358,21 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
|||||||
SubspaceNameDisplayWidget(
|
SubspaceNameDisplayWidget(
|
||||||
text: subspace.subspaceName,
|
text: subspace.subspaceName,
|
||||||
validateName: (updatedName) {
|
validateName: (updatedName) {
|
||||||
return subspaces!.any((s) =>
|
bool nameExists =
|
||||||
s != subspace &&
|
subspaces!.any((s) {
|
||||||
s.subspaceName ==
|
bool isSameId = s.internalId ==
|
||||||
updatedName);
|
subspace.internalId;
|
||||||
|
bool isSameName = s.subspaceName
|
||||||
|
.trim()
|
||||||
|
.toLowerCase() ==
|
||||||
|
updatedName
|
||||||
|
.trim()
|
||||||
|
.toLowerCase();
|
||||||
|
|
||||||
|
return !isSameId && isSameName;
|
||||||
|
});
|
||||||
|
|
||||||
|
return !nameExists;
|
||||||
},
|
},
|
||||||
onNameChanged: (updatedName) {
|
onNameChanged: (updatedName) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
Reference in New Issue
Block a user