mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-11 15:47:44 +00:00
Compare commits
9 Commits
bugfix/edi
...
bugfix/fix
Author | SHA1 | Date | |
---|---|---|---|
64e3fb7f34 | |||
e6e46be9b4 | |||
91dfd53477 | |||
916b606cb1 | |||
29c444eede | |||
9dd6c9e1e7 | |||
bf5b39e742 | |||
a294988558 | |||
09c1a785e5 |
@ -0,0 +1,47 @@
|
|||||||
|
class DeviceSubspace {
|
||||||
|
final String uuid;
|
||||||
|
final DateTime? createdAt;
|
||||||
|
final DateTime? updatedAt;
|
||||||
|
final String subspaceName;
|
||||||
|
final bool disabled;
|
||||||
|
|
||||||
|
DeviceSubspace({
|
||||||
|
required this.uuid,
|
||||||
|
this.createdAt,
|
||||||
|
this.updatedAt,
|
||||||
|
required this.subspaceName,
|
||||||
|
required this.disabled,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory DeviceSubspace.fromJson(Map<String, dynamic> json) {
|
||||||
|
return DeviceSubspace(
|
||||||
|
uuid: json['uuid'] as String,
|
||||||
|
createdAt: json['createdAt'] != null
|
||||||
|
? DateTime.tryParse(json['createdAt'].toString())
|
||||||
|
: null,
|
||||||
|
updatedAt: json['updatedAt'] != null
|
||||||
|
? DateTime.tryParse(json['updatedAt'].toString())
|
||||||
|
: null,
|
||||||
|
subspaceName: json['subspaceName'] as String,
|
||||||
|
disabled: json['disabled'] as bool,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'uuid': uuid,
|
||||||
|
'createdAt': createdAt?.toIso8601String(),
|
||||||
|
'updatedAt': updatedAt?.toIso8601String(),
|
||||||
|
'subspaceName': subspaceName,
|
||||||
|
'disabled': disabled,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static List<DeviceSubspace> listFromJson(List<dynamic> jsonList) {
|
||||||
|
return jsonList.map((json) => DeviceSubspace.fromJson(json)).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
static List<Map<String, dynamic>> listToJson(List<DeviceSubspace> subspaces) {
|
||||||
|
return subspaces.map((subspace) => subspace.toJson()).toList();
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_community.model.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_community.model.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_space_model.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_space_model.dart';
|
||||||
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_subspace.model.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/room.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/room.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/unit.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/unit.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/models/ac/ac_function.dart';
|
import 'package:syncrow_web/pages/routiens/models/ac/ac_function.dart';
|
||||||
@ -47,6 +48,7 @@ class AllDevicesModel {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
DevicesModelRoom? room;
|
DevicesModelRoom? room;
|
||||||
|
DeviceSubspace? subspace;
|
||||||
DevicesModelUnit? unit;
|
DevicesModelUnit? unit;
|
||||||
DeviceCommunityModel? community;
|
DeviceCommunityModel? community;
|
||||||
String? productUuid;
|
String? productUuid;
|
||||||
@ -77,6 +79,7 @@ class AllDevicesModel {
|
|||||||
|
|
||||||
AllDevicesModel({
|
AllDevicesModel({
|
||||||
this.room,
|
this.room,
|
||||||
|
this.subspace,
|
||||||
this.unit,
|
this.unit,
|
||||||
this.community,
|
this.community,
|
||||||
this.productUuid,
|
this.productUuid,
|
||||||
@ -110,6 +113,9 @@ class AllDevicesModel {
|
|||||||
room = (json['room'] != null && (json['room'] is Map))
|
room = (json['room'] != null && (json['room'] is Map))
|
||||||
? DevicesModelRoom.fromJson(json['room'])
|
? DevicesModelRoom.fromJson(json['room'])
|
||||||
: null;
|
: null;
|
||||||
|
subspace = (json['subspace'] != null && (json['subspace'] is Map))
|
||||||
|
? DeviceSubspace.fromJson(json['subspace'])
|
||||||
|
: null;
|
||||||
unit = (json['unit'] != null && (json['unit'] is Map))
|
unit = (json['unit'] != null && (json['unit'] is Map))
|
||||||
? DevicesModelUnit.fromJson(json['unit'])
|
? DevicesModelUnit.fromJson(json['unit'])
|
||||||
: null;
|
: null;
|
||||||
@ -288,6 +294,9 @@ SOS
|
|||||||
if (room != null) {
|
if (room != null) {
|
||||||
data['room'] = room!.toJson();
|
data['room'] = room!.toJson();
|
||||||
}
|
}
|
||||||
|
if (subspace != null) {
|
||||||
|
data['subspace'] = subspace!.toJson();
|
||||||
|
}
|
||||||
if (unit != null) {
|
if (unit != null) {
|
||||||
data['unit'] = unit!.toJson();
|
data['unit'] = unit!.toJson();
|
||||||
}
|
}
|
||||||
@ -330,6 +339,7 @@ SOS
|
|||||||
|
|
||||||
return other is AllDevicesModel &&
|
return other is AllDevicesModel &&
|
||||||
other.room == room &&
|
other.room == room &&
|
||||||
|
other.subspace == subspace &&
|
||||||
other.unit == unit &&
|
other.unit == unit &&
|
||||||
other.productUuid == productUuid &&
|
other.productUuid == productUuid &&
|
||||||
other.productType == productType &&
|
other.productType == productType &&
|
||||||
@ -360,6 +370,7 @@ SOS
|
|||||||
@override
|
@override
|
||||||
int get hashCode {
|
int get hashCode {
|
||||||
return room.hashCode ^
|
return room.hashCode ^
|
||||||
|
subspace.hashCode ^
|
||||||
unit.hashCode ^
|
unit.hashCode ^
|
||||||
productUuid.hashCode ^
|
productUuid.hashCode ^
|
||||||
productType.hashCode ^
|
productType.hashCode ^
|
||||||
|
@ -95,8 +95,9 @@ class DeviceControlDialog extends StatelessWidget with RouteControlsBasedCode {
|
|||||||
]),
|
]),
|
||||||
TableRow(
|
TableRow(
|
||||||
children: [
|
children: [
|
||||||
_buildInfoRow('Space Name:', device.unit?.name ?? 'N/A'),
|
_buildInfoRow('Space Name:',
|
||||||
_buildInfoRow('Room:', device.room?.name ?? 'N/A'),
|
device.spaces?.firstOrNull?.spaceName ?? 'N/A'),
|
||||||
|
_buildInfoRow('Room:', device.subspace?.subspaceName ?? 'N/A'),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
TableRow(
|
TableRow(
|
||||||
@ -111,9 +112,13 @@ class DeviceControlDialog extends StatelessWidget with RouteControlsBasedCode {
|
|||||||
),
|
),
|
||||||
_buildInfoRow(
|
_buildInfoRow(
|
||||||
'Battery Level:',
|
'Battery Level:',
|
||||||
device.batteryLevel != null ? '${device.batteryLevel ?? 0}%' : "-",
|
device.batteryLevel != null
|
||||||
|
? '${device.batteryLevel ?? 0}%'
|
||||||
|
: "-",
|
||||||
statusColor: device.batteryLevel != null
|
statusColor: device.batteryLevel != null
|
||||||
? (device.batteryLevel! < 20 ? ColorsManager.red : ColorsManager.green)
|
? (device.batteryLevel! < 20
|
||||||
|
? ColorsManager.red
|
||||||
|
: ColorsManager.green)
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -179,6 +179,7 @@ class SpaceManagementBloc
|
|||||||
final updatedCommunities =
|
final updatedCommunities =
|
||||||
await Future.wait(communities.map((community) async {
|
await Future.wait(communities.map((community) async {
|
||||||
final spaces = await _fetchSpacesForCommunity(community.uuid);
|
final spaces = await _fetchSpacesForCommunity(community.uuid);
|
||||||
|
|
||||||
return CommunityModel(
|
return CommunityModel(
|
||||||
uuid: community.uuid,
|
uuid: community.uuid,
|
||||||
createdAt: community.createdAt,
|
createdAt: community.createdAt,
|
||||||
@ -313,6 +314,7 @@ class SpaceManagementBloc
|
|||||||
SelectSpaceEvent event,
|
SelectSpaceEvent event,
|
||||||
Emitter<SpaceManagementState> emit,
|
Emitter<SpaceManagementState> emit,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
_handleCommunitySpaceStateUpdate(
|
_handleCommunitySpaceStateUpdate(
|
||||||
emit: emit,
|
emit: emit,
|
||||||
selectedCommunity: event.selectedCommunity,
|
selectedCommunity: event.selectedCommunity,
|
||||||
|
@ -95,6 +95,9 @@ class SpaceModel {
|
|||||||
icon: json['icon'] ?? Assets.location,
|
icon: json['icon'] ?? Assets.location,
|
||||||
position: Offset(json['x'] ?? 0, json['y'] ?? 0),
|
position: Offset(json['x'] ?? 0, json['y'] ?? 0),
|
||||||
isHovered: false,
|
isHovered: false,
|
||||||
|
spaceModel: json['spaceModel'] != null
|
||||||
|
? SpaceTemplateModel.fromJson(json['spaceModel'])
|
||||||
|
: null,
|
||||||
tags: (json['tags'] as List<dynamic>?)
|
tags: (json['tags'] as List<dynamic>?)
|
||||||
?.where((item) => item is Map<String, dynamic>) // Validate type
|
?.where((item) => item is Map<String, dynamic>) // Validate type
|
||||||
.map((item) => Tag.fromJson(item as Map<String, dynamic>))
|
.map((item) => Tag.fromJson(item as Map<String, dynamic>))
|
||||||
|
@ -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() ??
|
||||||
@ -43,7 +49,7 @@ class UpdateSubspaceModel {
|
|||||||
final Action action;
|
final Action action;
|
||||||
final String? subspaceName;
|
final String? subspaceName;
|
||||||
final List<UpdateTag>? tags;
|
final List<UpdateTag>? tags;
|
||||||
UpdateSubspaceModel({
|
UpdateSubspaceModel({
|
||||||
required this.action,
|
required this.action,
|
||||||
required this.uuid,
|
required this.uuid,
|
||||||
this.subspaceName,
|
this.subspaceName,
|
||||||
@ -107,4 +113,4 @@ class UpdateTag {
|
|||||||
'product': product?.toMap(),
|
'product': product?.toMap(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/curved_li
|
|||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/dialogs/duplicate_process_dialog.dart';
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/dialogs/duplicate_process_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/space_card_widget.dart';
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/space_card_widget.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/space_container_widget.dart';
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/space_container_widget.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/helper/space_helper.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';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
@ -195,7 +196,6 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
screenSize,
|
screenSize,
|
||||||
position:
|
position:
|
||||||
spaces[index].position + newPosition,
|
spaces[index].position + newPosition,
|
||||||
|
|
||||||
parentIndex: index,
|
parentIndex: index,
|
||||||
direction: direction,
|
direction: direction,
|
||||||
);
|
);
|
||||||
@ -351,11 +351,14 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
spaceModels: widget.spaceModels,
|
spaceModels: widget.spaceModels,
|
||||||
name: widget.selectedSpace!.name,
|
name: widget.selectedSpace!.name,
|
||||||
icon: widget.selectedSpace!.icon,
|
icon: widget.selectedSpace!.icon,
|
||||||
|
parentSpace: SpaceHelper.findSpaceByInternalId(
|
||||||
|
widget.selectedSpace?.parent?.internalId, spaces),
|
||||||
editSpace: widget.selectedSpace,
|
editSpace: widget.selectedSpace,
|
||||||
|
currentSpaceModel: widget.selectedSpace?.spaceModel,
|
||||||
tags: widget.selectedSpace?.tags,
|
tags: widget.selectedSpace?.tags,
|
||||||
subspaces: widget.selectedSpace?.subspaces,
|
subspaces: widget.selectedSpace?.subspaces,
|
||||||
isEdit: true,
|
isEdit: true,
|
||||||
allTags: _getAllTagValues(spaces),
|
allTags: _getAllTagValues(spaces),
|
||||||
onCreateSpace: (String name,
|
onCreateSpace: (String name,
|
||||||
String icon,
|
String icon,
|
||||||
List<SelectedProduct> selectedProducts,
|
List<SelectedProduct> selectedProducts,
|
||||||
@ -374,6 +377,15 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
widget.selectedSpace!.status =
|
widget.selectedSpace!.status =
|
||||||
SpaceStatus.modified; // Mark as modified
|
SpaceStatus.modified; // Mark as modified
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (var space in spaces) {
|
||||||
|
if (space.internalId == widget.selectedSpace?.internalId) {
|
||||||
|
space.status = SpaceStatus.modified;
|
||||||
|
space.subspaces = subspaces;
|
||||||
|
space.tags = tags;
|
||||||
|
space.name = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
key: Key(widget.selectedSpace!.name),
|
key: Key(widget.selectedSpace!.name),
|
||||||
@ -452,7 +464,6 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
if (spacesToSave.isEmpty) {
|
if (spacesToSave.isEmpty) {
|
||||||
debugPrint("No new or modified spaces to save.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -643,12 +654,6 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
|
|
||||||
final Map<String, int> nameCounters = {};
|
final Map<String, int> nameCounters = {};
|
||||||
|
|
||||||
String _generateCopyName(String originalName) {
|
|
||||||
final baseName = originalName.replaceAll(RegExp(r'\(\d+\)$'), '').trim();
|
|
||||||
nameCounters[baseName] = (nameCounters[baseName] ?? 0) + 1;
|
|
||||||
return "$baseName(${nameCounters[baseName]})";
|
|
||||||
}
|
|
||||||
|
|
||||||
SpaceModel duplicateRecursive(SpaceModel original, Offset parentPosition,
|
SpaceModel duplicateRecursive(SpaceModel original, Offset parentPosition,
|
||||||
SpaceModel? duplicatedParent) {
|
SpaceModel? duplicatedParent) {
|
||||||
Offset newPosition = parentPosition + Offset(horizontalGap, 0);
|
Offset newPosition = parentPosition + Offset(horizontalGap, 0);
|
||||||
@ -659,7 +664,8 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
newPosition += Offset(horizontalGap, 0);
|
newPosition += Offset(horizontalGap, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
final duplicatedName = _generateCopyName(original.name);
|
final duplicatedName =
|
||||||
|
SpaceHelper.generateUniqueSpaceName(original.name, spaces);
|
||||||
|
|
||||||
final duplicated = SpaceModel(
|
final duplicated = SpaceModel(
|
||||||
name: duplicatedName,
|
name: duplicatedName,
|
||||||
@ -748,7 +754,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> _getAllTagValues(List<SpaceModel> spaces) {
|
List<String> _getAllTagValues(List<SpaceModel> spaces) {
|
||||||
final List<String> allTags = [];
|
final List<String> allTags = [];
|
||||||
for (final space in spaces) {
|
for (final space in spaces) {
|
||||||
if (space.tags != null) {
|
if (space.tags != null) {
|
||||||
|
@ -40,6 +40,7 @@ class CreateSpaceDialog extends StatefulWidget {
|
|||||||
final List<SubspaceModel>? subspaces;
|
final List<SubspaceModel>? subspaces;
|
||||||
final List<Tag>? tags;
|
final List<Tag>? tags;
|
||||||
final List<String>? allTags;
|
final List<String>? allTags;
|
||||||
|
final SpaceTemplateModel? currentSpaceModel;
|
||||||
|
|
||||||
const CreateSpaceDialog(
|
const CreateSpaceDialog(
|
||||||
{super.key,
|
{super.key,
|
||||||
@ -54,7 +55,8 @@ class CreateSpaceDialog extends StatefulWidget {
|
|||||||
this.selectedProducts = const [],
|
this.selectedProducts = const [],
|
||||||
this.spaceModels,
|
this.spaceModels,
|
||||||
this.subspaces,
|
this.subspaces,
|
||||||
this.tags});
|
this.tags,
|
||||||
|
this.currentSpaceModel});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
CreateSpaceDialogState createState() => CreateSpaceDialogState();
|
CreateSpaceDialogState createState() => CreateSpaceDialogState();
|
||||||
@ -83,6 +85,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
|||||||
enteredName.isNotEmpty || nameController.text.isNotEmpty;
|
enteredName.isNotEmpty || nameController.text.isNotEmpty;
|
||||||
tags = widget.tags ?? [];
|
tags = widget.tags ?? [];
|
||||||
subspaces = widget.subspaces ?? [];
|
subspaces = widget.subspaces ?? [];
|
||||||
|
selectedSpaceModel = widget.currentSpaceModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -358,10 +361,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(() {
|
||||||
@ -446,7 +460,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
|||||||
context: context,
|
context: context,
|
||||||
builder: (context) => AssignTagDialog(
|
builder: (context) => AssignTagDialog(
|
||||||
products: widget.products,
|
products: widget.products,
|
||||||
subspaces: widget.subspaces,
|
subspaces: subspaces,
|
||||||
addedProducts: TagHelper
|
addedProducts: TagHelper
|
||||||
.createInitialSelectedProductsForTags(
|
.createInitialSelectedProductsForTags(
|
||||||
tags ?? [], subspaces),
|
tags ?? [], subspaces),
|
||||||
@ -477,7 +491,6 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
|||||||
enteredName,
|
enteredName,
|
||||||
widget.isEdit,
|
widget.isEdit,
|
||||||
widget.products,
|
widget.products,
|
||||||
subspaces,
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
style: TextButton.styleFrom(
|
style: TextButton.styleFrom(
|
||||||
@ -560,12 +573,23 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool _isNameConflict(String value) {
|
bool _isNameConflict(String value) {
|
||||||
return (widget.parentSpace?.children.any((child) => child.name == value) ??
|
final parentSpace = widget.parentSpace;
|
||||||
false) ||
|
final editSpace = widget.editSpace;
|
||||||
(widget.parentSpace?.name == value) ||
|
final siblings = parentSpace?.children
|
||||||
(widget.editSpace?.parent?.name == value) ||
|
.where((child) => child.uuid != editSpace?.uuid)
|
||||||
(widget.editSpace?.children.any((child) => child.name == value) ??
|
.toList() ??
|
||||||
false);
|
[];
|
||||||
|
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) {
|
||||||
@ -606,9 +630,26 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
|||||||
products: products,
|
products: products,
|
||||||
existingSubSpaces: existingSubSpaces,
|
existingSubSpaces: existingSubSpaces,
|
||||||
onSave: (slectedSubspaces) {
|
onSave: (slectedSubspaces) {
|
||||||
|
final List<Tag> tagsToAppendToSpace = [];
|
||||||
|
|
||||||
|
if (slectedSubspaces != null) {
|
||||||
|
final updatedIds =
|
||||||
|
slectedSubspaces.map((s) => s.internalId).toSet();
|
||||||
|
if (existingSubSpaces != null) {
|
||||||
|
final deletedSubspaces = existingSubSpaces
|
||||||
|
.where((s) => !updatedIds.contains(s.internalId))
|
||||||
|
.toList();
|
||||||
|
for (var s in deletedSubspaces) {
|
||||||
|
if (s.tags != null) {
|
||||||
|
tagsToAppendToSpace.addAll(s.tags!);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (slectedSubspaces != null) {
|
if (slectedSubspaces != null) {
|
||||||
setState(() {
|
setState(() {
|
||||||
subspaces = slectedSubspaces;
|
subspaces = slectedSubspaces;
|
||||||
|
tags?.addAll(tagsToAppendToSpace);
|
||||||
selectedSpaceModel = null;
|
selectedSpaceModel = null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -618,7 +659,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _showTagCreateDialog(BuildContext context, String name, bool isEdit,
|
void _showTagCreateDialog(BuildContext context, String name, bool isEdit,
|
||||||
List<ProductModel>? products, List<SubspaceModel>? subspaces) {
|
List<ProductModel>? products) {
|
||||||
isEdit
|
isEdit
|
||||||
? showDialog(
|
? showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
|
@ -11,7 +11,7 @@ import 'package:syncrow_web/pages/spaces_management/space_model/models/space_tem
|
|||||||
import 'package:syncrow_web/pages/spaces_management/space_model/view/space_model_page.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/view/space_model_page.dart';
|
||||||
import 'package:syncrow_web/services/space_model_mang_api.dart';
|
import 'package:syncrow_web/services/space_model_mang_api.dart';
|
||||||
|
|
||||||
class LoadedSpaceView extends StatelessWidget {
|
class LoadedSpaceView extends StatefulWidget {
|
||||||
final List<CommunityModel> communities;
|
final List<CommunityModel> communities;
|
||||||
final CommunityModel? selectedCommunity;
|
final CommunityModel? selectedCommunity;
|
||||||
final SpaceModel? selectedSpace;
|
final SpaceModel? selectedSpace;
|
||||||
@ -26,41 +26,73 @@ class LoadedSpaceView extends StatelessWidget {
|
|||||||
this.selectedSpace,
|
this.selectedSpace,
|
||||||
this.products,
|
this.products,
|
||||||
this.spaceModels,
|
this.spaceModels,
|
||||||
required this.shouldNavigateToSpaceModelPage
|
required this.shouldNavigateToSpaceModelPage,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
_LoadedSpaceViewState createState() => _LoadedSpaceViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LoadedSpaceViewState extends State<LoadedSpaceView> {
|
||||||
|
late List<SpaceTemplateModel> _spaceModels;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_spaceModels = List.from(widget.spaceModels ?? []);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didUpdateWidget(covariant LoadedSpaceView oldWidget) {
|
||||||
|
super.didUpdateWidget(oldWidget);
|
||||||
|
if (widget.spaceModels != oldWidget.spaceModels) {
|
||||||
|
setState(() {
|
||||||
|
_spaceModels = List.from(widget.spaceModels ?? []);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onSpaceModelsUpdated(List<SpaceTemplateModel> updatedModels) {
|
||||||
|
if (mounted && updatedModels != _spaceModels) {
|
||||||
|
setState(() {
|
||||||
|
_spaceModels = updatedModels;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
return Stack(
|
return Stack(
|
||||||
clipBehavior: Clip.none,
|
clipBehavior: Clip.none,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
SidebarWidget(
|
SidebarWidget(
|
||||||
communities: communities,
|
communities: widget.communities,
|
||||||
selectedSpaceUuid:
|
selectedSpaceUuid: widget.selectedSpace?.uuid ??
|
||||||
selectedSpace?.uuid ?? selectedCommunity?.uuid ?? '',
|
widget.selectedCommunity?.uuid ??
|
||||||
|
'',
|
||||||
),
|
),
|
||||||
shouldNavigateToSpaceModelPage
|
widget.shouldNavigateToSpaceModelPage
|
||||||
? Expanded(
|
? Expanded(
|
||||||
child: BlocProvider(
|
child: BlocProvider(
|
||||||
create: (context) => SpaceModelBloc(
|
create: (context) => SpaceModelBloc(
|
||||||
api: SpaceModelManagementApi(),
|
api: SpaceModelManagementApi(),
|
||||||
initialSpaceModels: spaceModels ?? [],
|
initialSpaceModels: _spaceModels,
|
||||||
),
|
),
|
||||||
child: SpaceModelPage(
|
child: SpaceModelPage(
|
||||||
products: products,
|
products: widget.products,
|
||||||
|
onSpaceModelsUpdated: _onSpaceModelsUpdated,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: CommunityStructureArea(
|
: CommunityStructureArea(
|
||||||
selectedCommunity: selectedCommunity,
|
selectedCommunity: widget.selectedCommunity,
|
||||||
selectedSpace: selectedSpace,
|
selectedSpace: widget.selectedSpace,
|
||||||
spaces: selectedCommunity?.spaces ?? [],
|
spaces: widget.selectedCommunity?.spaces ?? [],
|
||||||
products: products,
|
products: widget.products,
|
||||||
communities: communities,
|
communities: widget.communities,
|
||||||
spaceModels: spaceModels,
|
spaceModels: _spaceModels,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -68,13 +100,4 @@ class LoadedSpaceView extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpaceModel? findSpaceByUuid(String? uuid, List<CommunityModel> communities) {
|
|
||||||
for (var community in communities) {
|
|
||||||
for (var space in community.spaces) {
|
|
||||||
if (space.uuid == uuid) return space;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -233,11 +233,13 @@ class AssignTagDialog extends StatelessWidget {
|
|||||||
label: 'Add New Device',
|
label: 'Add New Device',
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final updatedTags = List<Tag>.from(state.tags);
|
final updatedTags = List<Tag>.from(state.tags);
|
||||||
final result = processTags(updatedTags, subspaces);
|
final result =
|
||||||
|
TagHelper.processTags(updatedTags, subspaces);
|
||||||
|
|
||||||
final processedTags =
|
final processedTags =
|
||||||
result['updatedTags'] as List<Tag>;
|
result['updatedTags'] as List<Tag>;
|
||||||
final processedSubspaces = result['subspaces'];
|
final processedSubspaces = List<SubspaceModel>.from(
|
||||||
|
result['subspaces'] as List<dynamic>);
|
||||||
|
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
|
||||||
@ -270,13 +272,14 @@ class AssignTagDialog extends StatelessWidget {
|
|||||||
onPressed: state.isSaveEnabled
|
onPressed: state.isSaveEnabled
|
||||||
? () async {
|
? () async {
|
||||||
final updatedTags = List<Tag>.from(state.tags);
|
final updatedTags = List<Tag>.from(state.tags);
|
||||||
final result =
|
final result = TagHelper.processTags(
|
||||||
processTags(updatedTags, subspaces);
|
updatedTags, subspaces);
|
||||||
|
|
||||||
final processedTags =
|
final processedTags =
|
||||||
result['updatedTags'] as List<Tag>;
|
result['updatedTags'] as List<Tag>;
|
||||||
final processedSubspaces =
|
final processedSubspaces =
|
||||||
result['subspaces'] as List<SubspaceModel>;
|
List<SubspaceModel>.from(
|
||||||
|
result['subspaces'] as List<dynamic>);
|
||||||
onSave?.call(processedTags, processedSubspaces);
|
onSave?.call(processedTags, processedSubspaces);
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
}
|
}
|
||||||
@ -301,115 +304,12 @@ class AssignTagDialog extends StatelessWidget {
|
|||||||
|
|
||||||
List<String> getAvailableTags(
|
List<String> getAvailableTags(
|
||||||
List<String> allTags, List<Tag> currentTags, Tag currentTag) {
|
List<String> allTags, List<Tag> currentTags, Tag currentTag) {
|
||||||
return allTags
|
List<String> availableTagsForTagModel = TagHelper.getAvailableTags<Tag>(
|
||||||
.where((tagValue) => !currentTags
|
allTags: allTags,
|
||||||
.where((e) => e != currentTag) // Exclude the current row
|
currentTags: currentTags,
|
||||||
.map((e) => e.tag)
|
currentTag: currentTag,
|
||||||
.contains(tagValue))
|
getTag: (tag) => tag.tag ?? '',
|
||||||
.toList();
|
);
|
||||||
}
|
return availableTagsForTagModel;
|
||||||
|
|
||||||
Map<String, dynamic> processTags(
|
|
||||||
List<Tag> updatedTags, List<SubspaceModel>? subspaces) {
|
|
||||||
final modifiedTags = List<Tag>.from(updatedTags);
|
|
||||||
final modifiedSubspaces = List<SubspaceModel>.from(subspaces ?? []);
|
|
||||||
|
|
||||||
if (subspaces != null) {
|
|
||||||
for (var subspace in subspaces) {
|
|
||||||
subspace.tags?.removeWhere(
|
|
||||||
(tag) => !modifiedTags
|
|
||||||
.any((updatedTag) => updatedTag.internalId == tag.internalId),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (var tag in modifiedTags.toList()) {
|
|
||||||
if (modifiedSubspaces.isEmpty) continue;
|
|
||||||
|
|
||||||
final prevIndice = checkTagExistInSubspace(tag, modifiedSubspaces);
|
|
||||||
|
|
||||||
if ((tag.location == 'Main Space' || tag.location == null) &&
|
|
||||||
(prevIndice == null ||
|
|
||||||
modifiedSubspaces[prevIndice].subspaceName == 'Main Space')) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((tag.location == 'Main Space' || tag.location == null) &&
|
|
||||||
prevIndice != null) {
|
|
||||||
modifiedSubspaces[prevIndice]
|
|
||||||
.tags
|
|
||||||
?.removeWhere((t) => t.internalId == tag.internalId);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((tag.location != 'Main Space' && tag.location != null) &&
|
|
||||||
prevIndice == null) {
|
|
||||||
final newIndex = modifiedSubspaces
|
|
||||||
.indexWhere((subspace) => subspace.subspaceName == tag.location);
|
|
||||||
if (newIndex != -1) {
|
|
||||||
if (modifiedSubspaces[newIndex]
|
|
||||||
.tags
|
|
||||||
?.any((t) => t.internalId == tag.internalId) !=
|
|
||||||
true) {
|
|
||||||
tag.location = modifiedSubspaces[newIndex].subspaceName;
|
|
||||||
modifiedSubspaces[newIndex].tags?.add(tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
modifiedTags.removeWhere((t) => t.internalId == tag.internalId);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((tag.location != 'Main Space' && tag.location != null) &&
|
|
||||||
tag.location != modifiedSubspaces[prevIndice!].subspaceName) {
|
|
||||||
modifiedSubspaces[prevIndice]
|
|
||||||
.tags
|
|
||||||
?.removeWhere((t) => t.internalId == tag.internalId);
|
|
||||||
final newIndex = modifiedSubspaces
|
|
||||||
.indexWhere((subspace) => subspace.subspaceName == tag.location);
|
|
||||||
if (newIndex != -1) {
|
|
||||||
if (modifiedSubspaces[newIndex]
|
|
||||||
.tags
|
|
||||||
?.any((t) => t.internalId == tag.internalId) !=
|
|
||||||
true) {
|
|
||||||
tag.location = modifiedSubspaces[newIndex].subspaceName;
|
|
||||||
modifiedSubspaces[newIndex].tags?.add(tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
modifiedTags.removeWhere((t) => t.internalId == tag.internalId);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((tag.location != 'Main Space' && tag.location != null) &&
|
|
||||||
tag.location == modifiedSubspaces[prevIndice!].subspaceName) {
|
|
||||||
modifiedTags.removeWhere((t) => t.internalId == tag.internalId);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((tag.location == 'Main Space' || tag.location == null) &&
|
|
||||||
prevIndice != null) {
|
|
||||||
modifiedSubspaces[prevIndice]
|
|
||||||
.tags
|
|
||||||
?.removeWhere((t) => t.internalId == tag.internalId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
'updatedTags': modifiedTags,
|
|
||||||
'subspaces': modifiedSubspaces,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
int? checkTagExistInSubspace(Tag tag, List<SubspaceModel>? subspaces) {
|
|
||||||
if (subspaces == null) return null;
|
|
||||||
for (int i = 0; i < subspaces.length; i++) {
|
|
||||||
final subspace = subspaces[i];
|
|
||||||
if (subspace.tags == null) continue;
|
|
||||||
for (var t in subspace.tags!) {
|
|
||||||
if (tag.internalId == t.internalId) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,8 +133,9 @@ class AssignTagModelsDialog extends StatelessWidget {
|
|||||||
: List.generate(state.tags.length, (index) {
|
: List.generate(state.tags.length, (index) {
|
||||||
final tag = state.tags[index];
|
final tag = state.tags[index];
|
||||||
final controller = controllers[index];
|
final controller = controllers[index];
|
||||||
final availableTags = getAvailableTags(
|
final availableTags =
|
||||||
allTags ?? [], state.tags, tag);
|
TagHelper.getAvailableTagModels(
|
||||||
|
allTags ?? [], state.tags, tag);
|
||||||
|
|
||||||
return DataRow(
|
return DataRow(
|
||||||
cells: [
|
cells: [
|
||||||
@ -254,11 +255,15 @@ class AssignTagModelsDialog extends StatelessWidget {
|
|||||||
final updatedTags =
|
final updatedTags =
|
||||||
List<TagModel>.from(state.tags);
|
List<TagModel>.from(state.tags);
|
||||||
final result =
|
final result =
|
||||||
processTags(updatedTags, subspaces);
|
TagHelper.updateSubspaceTagModels(
|
||||||
|
updatedTags, subspaces);
|
||||||
|
|
||||||
final processedTags =
|
final processedTags =
|
||||||
result['updatedTags'] as List<TagModel>;
|
result['updatedTags'] as List<TagModel>;
|
||||||
final processedSubspaces = result['subspaces'];
|
final processedSubspaces =
|
||||||
|
List<SubspaceTemplateModel>.from(
|
||||||
|
result['subspaces'] as List<dynamic>);
|
||||||
|
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
|
||||||
@ -305,14 +310,17 @@ class AssignTagModelsDialog extends StatelessWidget {
|
|||||||
? () async {
|
? () async {
|
||||||
final updatedTags =
|
final updatedTags =
|
||||||
List<TagModel>.from(state.tags);
|
List<TagModel>.from(state.tags);
|
||||||
|
|
||||||
final result =
|
final result =
|
||||||
processTags(updatedTags, subspaces);
|
TagHelper.updateSubspaceTagModels(
|
||||||
|
updatedTags, subspaces);
|
||||||
|
|
||||||
final processedTags =
|
final processedTags =
|
||||||
result['updatedTags'] as List<TagModel>;
|
result['updatedTags'] as List<TagModel>;
|
||||||
final processedSubspaces =
|
final processedSubspaces =
|
||||||
result['subspaces']
|
List<SubspaceTemplateModel>.from(
|
||||||
as List<SubspaceTemplateModel>;
|
result['subspaces']
|
||||||
|
as List<dynamic>);
|
||||||
|
|
||||||
Navigator.of(context)
|
Navigator.of(context)
|
||||||
.popUntil((route) => route.isFirst);
|
.popUntil((route) => route.isFirst);
|
||||||
@ -356,120 +364,4 @@ class AssignTagModelsDialog extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> getAvailableTags(
|
|
||||||
List<String> allTags, List<TagModel> currentTags, TagModel currentTag) {
|
|
||||||
return allTags
|
|
||||||
.where((tagValue) => !currentTags
|
|
||||||
.where((e) => e != currentTag) // Exclude the current row
|
|
||||||
.map((e) => e.tag)
|
|
||||||
.contains(tagValue))
|
|
||||||
.toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
int? checkTagExistInSubspace(
|
|
||||||
TagModel tag, List<SubspaceTemplateModel>? subspaces) {
|
|
||||||
if (subspaces == null) return null;
|
|
||||||
for (int i = 0; i < subspaces.length; i++) {
|
|
||||||
final subspace = subspaces[i];
|
|
||||||
if (subspace.tags == null) continue;
|
|
||||||
for (var t in subspace.tags!) {
|
|
||||||
if (tag.internalId == t.internalId) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> processTags(
|
|
||||||
List<TagModel> updatedTags, List<SubspaceTemplateModel>? subspaces) {
|
|
||||||
final modifiedTags = List<TagModel>.from(updatedTags);
|
|
||||||
final modifiedSubspaces = List<SubspaceTemplateModel>.from(subspaces ?? []);
|
|
||||||
|
|
||||||
if (subspaces != null) {
|
|
||||||
for (var subspace in subspaces) {
|
|
||||||
subspace.tags?.removeWhere(
|
|
||||||
(tag) => !modifiedTags
|
|
||||||
.any((updatedTag) => updatedTag.internalId == tag.internalId),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var tag in modifiedTags.toList()) {
|
|
||||||
if (modifiedSubspaces.isEmpty) continue;
|
|
||||||
|
|
||||||
final prevIndice = checkTagExistInSubspace(tag, modifiedSubspaces);
|
|
||||||
|
|
||||||
if ((tag.location == 'Main Space' || tag.location == null) &&
|
|
||||||
(prevIndice == null ||
|
|
||||||
modifiedSubspaces[prevIndice].subspaceName == 'Main Space')) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((tag.location == 'Main Space' || tag.location == null) &&
|
|
||||||
prevIndice != null) {
|
|
||||||
modifiedSubspaces[prevIndice]
|
|
||||||
.tags
|
|
||||||
?.removeWhere((t) => t.internalId == tag.internalId);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((tag.location != 'Main Space' && tag.location != null) &&
|
|
||||||
prevIndice == null) {
|
|
||||||
final newIndex = modifiedSubspaces
|
|
||||||
.indexWhere((subspace) => subspace.subspaceName == tag.location);
|
|
||||||
if (newIndex != -1) {
|
|
||||||
if (modifiedSubspaces[newIndex]
|
|
||||||
.tags
|
|
||||||
?.any((t) => t.internalId == tag.internalId) !=
|
|
||||||
true) {
|
|
||||||
tag.location = modifiedSubspaces[newIndex].subspaceName;
|
|
||||||
modifiedSubspaces[newIndex].tags?.add(tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
modifiedTags.removeWhere((t) => t.internalId == tag.internalId);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((tag.location != 'Main Space' && tag.location != null) &&
|
|
||||||
tag.location != modifiedSubspaces[prevIndice!].subspaceName) {
|
|
||||||
modifiedSubspaces[prevIndice]
|
|
||||||
.tags
|
|
||||||
?.removeWhere((t) => t.internalId == tag.internalId);
|
|
||||||
final newIndex = modifiedSubspaces
|
|
||||||
.indexWhere((subspace) => subspace.subspaceName == tag.location);
|
|
||||||
if (newIndex != -1) {
|
|
||||||
if (modifiedSubspaces[newIndex]
|
|
||||||
.tags
|
|
||||||
?.any((t) => t.internalId == tag.internalId) !=
|
|
||||||
true) {
|
|
||||||
tag.location = modifiedSubspaces[newIndex].subspaceName;
|
|
||||||
modifiedSubspaces[newIndex].tags?.add(tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
modifiedTags.removeWhere((t) => t.internalId == tag.internalId);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((tag.location != 'Main Space' && tag.location != null) &&
|
|
||||||
tag.location == modifiedSubspaces[prevIndice!].subspaceName) {
|
|
||||||
modifiedTags.removeWhere((t) => t.internalId == tag.internalId);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((tag.location == 'Main Space' || tag.location == null) &&
|
|
||||||
prevIndice != null) {
|
|
||||||
modifiedSubspaces[prevIndice]
|
|
||||||
.tags
|
|
||||||
?.removeWhere((t) => t.internalId == tag.internalId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
'updatedTags': modifiedTags,
|
|
||||||
'subspaces': modifiedSubspaces,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
43
lib/pages/spaces_management/helper/space_helper.dart
Normal file
43
lib/pages/spaces_management/helper/space_helper.dart
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
||||||
|
|
||||||
|
class SpaceHelper {
|
||||||
|
static SpaceModel? findSpaceByUuid(
|
||||||
|
String? uuid, List<CommunityModel> communities) {
|
||||||
|
for (var community in communities) {
|
||||||
|
for (var space in community.spaces) {
|
||||||
|
if (space.uuid == uuid) return space;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SpaceModel? findSpaceByInternalId(
|
||||||
|
String? internalId, List<SpaceModel> spaces) {
|
||||||
|
if (internalId != null) {
|
||||||
|
for (var space in spaces) {
|
||||||
|
if (space.internalId == internalId) return space;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
static String generateUniqueSpaceName(
|
||||||
|
String originalName, List<SpaceModel> spaces) {
|
||||||
|
final baseName = originalName.replaceAll(RegExp(r'\(\d+\)$'), '').trim();
|
||||||
|
int maxNumber = 0;
|
||||||
|
|
||||||
|
for (var space in spaces) {
|
||||||
|
final match = RegExp(r'^(.*?)\((\d+)\)$').firstMatch(space.name);
|
||||||
|
if (match != null && match.group(1)?.trim() == baseName) {
|
||||||
|
int existingNumber = int.parse(match.group(2)!);
|
||||||
|
if (existingNumber > maxNumber) {
|
||||||
|
maxNumber = existingNumber;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "$baseName(${maxNumber + 1})";
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,138 @@ import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_
|
|||||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_model.dart';
|
||||||
|
|
||||||
class TagHelper {
|
class TagHelper {
|
||||||
|
static Map<String, dynamic> updateTags<T>({
|
||||||
|
required List<T> updatedTags,
|
||||||
|
required List<dynamic>? subspaces,
|
||||||
|
required String Function(T) getInternalId,
|
||||||
|
required String? Function(T) getLocation,
|
||||||
|
required void Function(T, String) setLocation,
|
||||||
|
required String Function(dynamic) getSubspaceName,
|
||||||
|
required List<T>? Function(dynamic) getSubspaceTags,
|
||||||
|
required void Function(dynamic, List<T>?) setSubspaceTags,
|
||||||
|
required int? Function(T, List<dynamic>) checkTagExistInSubspace,
|
||||||
|
}) {
|
||||||
|
final modifiedTags = List<T>.from(updatedTags);
|
||||||
|
final modifiedSubspaces = List<dynamic>.from(subspaces ?? []);
|
||||||
|
|
||||||
|
if (subspaces != null) {
|
||||||
|
for (var subspace in subspaces) {
|
||||||
|
getSubspaceTags(subspace)?.removeWhere(
|
||||||
|
(tag) => !modifiedTags.any(
|
||||||
|
(updatedTag) => getInternalId(updatedTag) == getInternalId(tag)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var tag in modifiedTags.toList()) {
|
||||||
|
if (modifiedSubspaces.isEmpty) continue;
|
||||||
|
|
||||||
|
final prevIndice = checkTagExistInSubspace(tag, modifiedSubspaces);
|
||||||
|
final tagLocation = getLocation(tag);
|
||||||
|
|
||||||
|
if ((tagLocation == 'Main Space' || tagLocation == null) &&
|
||||||
|
(prevIndice == null ||
|
||||||
|
getSubspaceName(modifiedSubspaces[prevIndice]) == 'Main Space')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((tagLocation == 'Main Space' || tagLocation == null) &&
|
||||||
|
prevIndice != null) {
|
||||||
|
getSubspaceTags(modifiedSubspaces[prevIndice])
|
||||||
|
?.removeWhere((t) => getInternalId(t) == getInternalId(tag));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((tagLocation != 'Main Space' && tagLocation != null) &&
|
||||||
|
prevIndice == null) {
|
||||||
|
final newIndex = modifiedSubspaces
|
||||||
|
.indexWhere((subspace) => getSubspaceName(subspace) == tagLocation);
|
||||||
|
|
||||||
|
if (newIndex != -1) {
|
||||||
|
if (getSubspaceTags(modifiedSubspaces[newIndex])
|
||||||
|
?.any((t) => getInternalId(t) == getInternalId(tag)) !=
|
||||||
|
true) {
|
||||||
|
setLocation(tag, getSubspaceName(modifiedSubspaces[newIndex]));
|
||||||
|
final subspaceTags =
|
||||||
|
getSubspaceTags(modifiedSubspaces[newIndex]) ?? [];
|
||||||
|
subspaceTags.add(tag);
|
||||||
|
setSubspaceTags(modifiedSubspaces[newIndex], subspaceTags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
modifiedTags.removeWhere((t) => getInternalId(t) == getInternalId(tag));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((tagLocation != 'Main Space' && tagLocation != null) &&
|
||||||
|
tagLocation != getSubspaceName(modifiedSubspaces[prevIndice!])) {
|
||||||
|
getSubspaceTags(modifiedSubspaces[prevIndice])
|
||||||
|
?.removeWhere((t) => getInternalId(t) == getInternalId(tag));
|
||||||
|
|
||||||
|
final newIndex = modifiedSubspaces
|
||||||
|
.indexWhere((subspace) => getSubspaceName(subspace) == tagLocation);
|
||||||
|
|
||||||
|
if (newIndex != -1) {
|
||||||
|
if (getSubspaceTags(modifiedSubspaces[newIndex])
|
||||||
|
?.any((t) => getInternalId(t) == getInternalId(tag)) !=
|
||||||
|
true) {
|
||||||
|
setLocation(tag, getSubspaceName(modifiedSubspaces[newIndex]));
|
||||||
|
final subspaceTags =
|
||||||
|
getSubspaceTags(modifiedSubspaces[newIndex]) ?? [];
|
||||||
|
subspaceTags.add(tag);
|
||||||
|
setSubspaceTags(modifiedSubspaces[newIndex], subspaceTags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
modifiedTags.removeWhere((t) => getInternalId(t) == getInternalId(tag));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((tagLocation != 'Main Space' && tagLocation != null) &&
|
||||||
|
tagLocation == getSubspaceName(modifiedSubspaces[prevIndice!])) {
|
||||||
|
modifiedTags.removeWhere((t) => getInternalId(t) == getInternalId(tag));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((tagLocation == 'Main Space' || tagLocation == null) &&
|
||||||
|
prevIndice != null) {
|
||||||
|
getSubspaceTags(modifiedSubspaces[prevIndice])
|
||||||
|
?.removeWhere((t) => getInternalId(t) == getInternalId(tag));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
'updatedTags': modifiedTags,
|
||||||
|
'subspaces': modifiedSubspaces,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static List<String> getAvailableTags<T>({
|
||||||
|
required List<String> allTags,
|
||||||
|
required List<T> currentTags,
|
||||||
|
required T currentTag,
|
||||||
|
required String? Function(T) getTag, // Allow nullable return type
|
||||||
|
}) {
|
||||||
|
return allTags
|
||||||
|
.where((tagValue) => !currentTags
|
||||||
|
.where((e) => e != currentTag) // Exclude the current row
|
||||||
|
.map((e) => getTag(e) ?? '') // Handle null values gracefully
|
||||||
|
.contains(tagValue))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
static List<String> getAvailableTagModels(
|
||||||
|
List<String> allTags, List<TagModel> currentTags, TagModel currentTag) {
|
||||||
|
List<String> availableTagsForTagModel =
|
||||||
|
TagHelper.getAvailableTags<TagModel>(
|
||||||
|
allTags: allTags,
|
||||||
|
currentTags: currentTags,
|
||||||
|
currentTag: currentTag,
|
||||||
|
getTag: (tag) => tag.tag ?? '',
|
||||||
|
);
|
||||||
|
return availableTagsForTagModel;
|
||||||
|
}
|
||||||
|
|
||||||
static List<TagModel> generateInitialTags({
|
static List<TagModel> generateInitialTags({
|
||||||
List<TagModel>? spaceTagModels,
|
List<TagModel>? spaceTagModels,
|
||||||
List<SubspaceTemplateModel>? subspaces,
|
List<SubspaceTemplateModel>? subspaces,
|
||||||
@ -36,7 +168,7 @@ class TagHelper {
|
|||||||
return initialTags;
|
return initialTags;
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<Tag> generateInitialForTags({
|
static List<Tag> generateInitialForTags({
|
||||||
List<Tag>? spaceTags,
|
List<Tag>? spaceTags,
|
||||||
List<SubspaceModel>? subspaces,
|
List<SubspaceModel>? subspaces,
|
||||||
}) {
|
}) {
|
||||||
@ -145,4 +277,64 @@ class TagHelper {
|
|||||||
))
|
))
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int? checkTagExistInSubspaceModels(
|
||||||
|
TagModel tag, List<dynamic>? subspaces) {
|
||||||
|
if (subspaces == null) return null;
|
||||||
|
|
||||||
|
for (int i = 0; i < subspaces.length; i++) {
|
||||||
|
final subspace = subspaces[i] as SubspaceTemplateModel; // Explicit cast
|
||||||
|
if (subspace.tags == null) continue;
|
||||||
|
for (var t in subspace.tags!) {
|
||||||
|
if (tag.internalId == t.internalId) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Map<String, dynamic> updateSubspaceTagModels(
|
||||||
|
List<TagModel> updatedTags, List<SubspaceTemplateModel>? subspaces) {
|
||||||
|
return TagHelper.updateTags<TagModel>(
|
||||||
|
updatedTags: updatedTags,
|
||||||
|
subspaces: subspaces,
|
||||||
|
getInternalId: (tag) => tag.internalId,
|
||||||
|
getLocation: (tag) => tag.location,
|
||||||
|
setLocation: (tag, location) => tag.location = location,
|
||||||
|
getSubspaceName: (subspace) => subspace.subspaceName,
|
||||||
|
getSubspaceTags: (subspace) => subspace.tags,
|
||||||
|
setSubspaceTags: (subspace, tags) => subspace.tags = tags,
|
||||||
|
checkTagExistInSubspace: checkTagExistInSubspaceModels,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int? checkTagExistInSubspace(Tag tag, List<dynamic>? subspaces) {
|
||||||
|
if (subspaces == null) return null;
|
||||||
|
for (int i = 0; i < subspaces.length; i++) {
|
||||||
|
final subspace = subspaces[i];
|
||||||
|
if (subspace.tags == null) continue;
|
||||||
|
for (var t in subspace.tags!) {
|
||||||
|
if (tag.internalId == t.internalId) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Map<String, dynamic> processTags(
|
||||||
|
List<Tag> updatedTags, List<SubspaceModel>? subspaces) {
|
||||||
|
return TagHelper.updateTags<Tag>(
|
||||||
|
updatedTags: updatedTags,
|
||||||
|
subspaces: subspaces,
|
||||||
|
getInternalId: (tag) => tag.internalId,
|
||||||
|
getLocation: (tag) => tag.location,
|
||||||
|
setLocation: (tag, location) => tag.location = location,
|
||||||
|
getSubspaceName: (subspace) => subspace.subspaceName,
|
||||||
|
getSubspaceTags: (subspace) => subspace.tags,
|
||||||
|
setSubspaceTags: (subspace, tags) => subspace.tags = tags,
|
||||||
|
checkTagExistInSubspace: checkTagExistInSubspace,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_model.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_update_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_update_model.dart';
|
||||||
|
@ -11,8 +11,10 @@ import 'package:syncrow_web/utils/color_manager.dart';
|
|||||||
|
|
||||||
class SpaceModelPage extends StatelessWidget {
|
class SpaceModelPage extends StatelessWidget {
|
||||||
final List<ProductModel>? products;
|
final List<ProductModel>? products;
|
||||||
|
final Function(List<SpaceTemplateModel>)? onSpaceModelsUpdated;
|
||||||
|
|
||||||
const SpaceModelPage({Key? key, this.products}) : super(key: key);
|
const SpaceModelPage({Key? key, this.products, this.onSpaceModelsUpdated})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -25,6 +27,10 @@ class SpaceModelPage extends StatelessWidget {
|
|||||||
final allTagValues = _getAllTagValues(spaceModels);
|
final allTagValues = _getAllTagValues(spaceModels);
|
||||||
final allSpaceModelNames = _getAllSpaceModelName(spaceModels);
|
final allSpaceModelNames = _getAllSpaceModelName(spaceModels);
|
||||||
|
|
||||||
|
if (onSpaceModelsUpdated != null) {
|
||||||
|
onSpaceModelsUpdated!(spaceModels);
|
||||||
|
}
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: ColorsManager.whiteColors,
|
backgroundColor: ColorsManager.whiteColors,
|
||||||
body: Padding(
|
body: Padding(
|
||||||
|
@ -129,10 +129,16 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
|||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
SubspaceModelCreate(
|
SubspaceModelCreate(
|
||||||
subspaces: state.space.subspaceModels ?? [],
|
subspaces: state.space.subspaceModels ?? [],
|
||||||
onSpaceModelUpdate: (updatedSubspaces) {
|
tags: state.space.tags ?? [],
|
||||||
|
onSpaceModelUpdate: (updatedSubspaces,updatedTags) {
|
||||||
context
|
context
|
||||||
.read<CreateSpaceModelBloc>()
|
.read<CreateSpaceModelBloc>()
|
||||||
.add(AddSubspacesToSpaceTemplate(updatedSubspaces));
|
.add(AddSubspacesToSpaceTemplate(updatedSubspaces));
|
||||||
|
if(updatedTags!=null){
|
||||||
|
context
|
||||||
|
.read<CreateSpaceModelBloc>()
|
||||||
|
.add(AddTagsToSpaceTemplate(updatedTags));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:syncrow_web/common/edit_chip.dart';
|
import 'package:syncrow_web/common/edit_chip.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_model.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/button_content_widget.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/button_content_widget.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/create_subspace_model/views/create_subspace_model_dialog.dart';
|
import 'package:syncrow_web/pages/spaces_management/create_subspace_model/views/create_subspace_model_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/subspace_name_label_widget.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/subspace_name_label_widget.dart';
|
||||||
@ -8,13 +9,16 @@ import 'package:syncrow_web/utils/color_manager.dart';
|
|||||||
|
|
||||||
class SubspaceModelCreate extends StatefulWidget {
|
class SubspaceModelCreate extends StatefulWidget {
|
||||||
final List<SubspaceTemplateModel> subspaces;
|
final List<SubspaceTemplateModel> subspaces;
|
||||||
final void Function(List<SubspaceTemplateModel> newSubspaces)?
|
final void Function(
|
||||||
|
List<SubspaceTemplateModel> newSubspaces, List<TagModel>? tags)?
|
||||||
onSpaceModelUpdate;
|
onSpaceModelUpdate;
|
||||||
|
final List<TagModel> tags;
|
||||||
|
|
||||||
const SubspaceModelCreate({
|
const SubspaceModelCreate({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.subspaces,
|
required this.subspaces,
|
||||||
this.onSpaceModelUpdate,
|
this.onSpaceModelUpdate,
|
||||||
|
required this.tags,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -24,11 +28,13 @@ class SubspaceModelCreate extends StatefulWidget {
|
|||||||
class _SubspaceModelCreateState extends State<SubspaceModelCreate> {
|
class _SubspaceModelCreateState extends State<SubspaceModelCreate> {
|
||||||
late List<SubspaceTemplateModel> _subspaces;
|
late List<SubspaceTemplateModel> _subspaces;
|
||||||
String? errorSubspaceId;
|
String? errorSubspaceId;
|
||||||
|
late List<TagModel> _tags;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_subspaces = List.from(widget.subspaces);
|
_subspaces = List.from(widget.subspaces);
|
||||||
|
_tags = List.from(widget.tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -105,14 +111,26 @@ class _SubspaceModelCreateState extends State<SubspaceModelCreate> {
|
|||||||
isEdit: true,
|
isEdit: true,
|
||||||
dialogTitle: dialogTitle,
|
dialogTitle: dialogTitle,
|
||||||
existingSubSpaces: _subspaces,
|
existingSubSpaces: _subspaces,
|
||||||
|
|
||||||
onUpdate: (subspaceModels) {
|
onUpdate: (subspaceModels) {
|
||||||
|
final updatedIds = subspaceModels.map((s) => s.internalId).toSet();
|
||||||
|
final deletedSubspaces = _subspaces
|
||||||
|
.where((s) => !updatedIds.contains(s.internalId))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
final List<TagModel> tagsToAppendToSpace = [];
|
||||||
|
|
||||||
|
for (var s in deletedSubspaces) {
|
||||||
|
if (s.tags != null) {
|
||||||
|
tagsToAppendToSpace.addAll(s.tags!);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_subspaces = subspaceModels;
|
_subspaces = subspaceModels;
|
||||||
errorSubspaceId = null;
|
_tags.addAll(tagsToAppendToSpace);
|
||||||
});
|
});
|
||||||
if (widget.onSpaceModelUpdate != null) {
|
if (widget.onSpaceModelUpdate != null) {
|
||||||
widget.onSpaceModelUpdate!(subspaceModels);
|
widget.onSpaceModelUpdate!(subspaceModels, _tags);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -52,6 +52,13 @@ class _SubspaceNameDisplayWidgetState extends State<SubspaceNameDisplayWidget> {
|
|||||||
|
|
||||||
void _handleValidationAndSave() {
|
void _handleValidationAndSave() {
|
||||||
final updatedName = _controller.text;
|
final updatedName = _controller.text;
|
||||||
|
|
||||||
|
if (updatedName.isEmpty) {
|
||||||
|
setState(() {
|
||||||
|
errorText = 'Subspace name cannot be empty.';
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (widget.validateName(updatedName)) {
|
if (widget.validateName(updatedName)) {
|
||||||
setState(() {
|
setState(() {
|
||||||
errorText = null;
|
errorText = null;
|
||||||
|
Reference in New Issue
Block a user