mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-16 01:56:24 +00:00
fixed the edit flow of space
This commit is contained in:
@ -195,6 +195,7 @@ 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,
|
||||||
);
|
);
|
||||||
@ -305,6 +306,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
// Set the first space in the center or use passed position
|
// Set the first space in the center or use passed position
|
||||||
Offset centerPosition =
|
Offset centerPosition =
|
||||||
position ?? _getCenterPosition(screenSize);
|
position ?? _getCenterPosition(screenSize);
|
||||||
|
print(tags);
|
||||||
SpaceModel newSpace = SpaceModel(
|
SpaceModel newSpace = SpaceModel(
|
||||||
name: name,
|
name: name,
|
||||||
icon: icon,
|
icon: icon,
|
||||||
@ -350,6 +352,8 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
name: widget.selectedSpace!.name,
|
name: widget.selectedSpace!.name,
|
||||||
icon: widget.selectedSpace!.icon,
|
icon: widget.selectedSpace!.icon,
|
||||||
editSpace: widget.selectedSpace,
|
editSpace: widget.selectedSpace,
|
||||||
|
tags: widget.selectedSpace?.tags,
|
||||||
|
subspaces: widget.selectedSpace?.subspaces,
|
||||||
isEdit: true,
|
isEdit: true,
|
||||||
onCreateSpace: (String name,
|
onCreateSpace: (String name,
|
||||||
String icon,
|
String icon,
|
||||||
|
@ -12,6 +12,7 @@ import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
|||||||
import 'package:syncrow_web/pages/spaces_management/assign_tag/bloc/assign_tag_bloc.dart';
|
import 'package:syncrow_web/pages/spaces_management/assign_tag/bloc/assign_tag_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/assign_tag/bloc/assign_tag_event.dart';
|
import 'package:syncrow_web/pages/spaces_management/assign_tag/bloc/assign_tag_event.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/assign_tag/bloc/assign_tag_state.dart';
|
import 'package:syncrow_web/pages/spaces_management/assign_tag/bloc/assign_tag_state.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/helper/tag_helper.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
class AssignTagDialog extends StatelessWidget {
|
class AssignTagDialog extends StatelessWidget {
|
||||||
@ -40,8 +41,11 @@ class AssignTagDialog extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final List<String> locations =
|
final List<String> locations = (subspaces ?? [])
|
||||||
(subspaces ?? []).map((subspace) => subspace.subspaceName).toList();
|
.map((subspace) => subspace.subspaceName)
|
||||||
|
.toList()
|
||||||
|
..add('Main Space');
|
||||||
|
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (_) => AssignTagBloc()
|
create: (_) => AssignTagBloc()
|
||||||
..add(InitializeTags(
|
..add(InitializeTags(
|
||||||
@ -235,16 +239,18 @@ class AssignTagDialog extends StatelessWidget {
|
|||||||
|
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
|
||||||
await showDialog<bool>(
|
await showDialog(
|
||||||
barrierDismissible: false,
|
|
||||||
context: context,
|
context: context,
|
||||||
builder: (dialogContext) => AddDeviceTypeWidget(
|
builder: (context) => AddDeviceTypeWidget(
|
||||||
products: products,
|
products: products,
|
||||||
subspaces: processedSubspaces,
|
subspaces: processedSubspaces,
|
||||||
initialSelectedProducts: addedProducts,
|
initialSelectedProducts: TagHelper
|
||||||
allTags: allTags,
|
.createInitialSelectedProductsForTags(
|
||||||
|
processedTags, processedSubspaces),
|
||||||
spaceName: spaceName,
|
spaceName: spaceName,
|
||||||
spaceTags: processedTags,
|
spaceTags: processedTags,
|
||||||
|
isCreate: false,
|
||||||
|
onSave: onSave,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -261,7 +267,6 @@ class AssignTagDialog extends StatelessWidget {
|
|||||||
foregroundColor: ColorsManager.whiteColors,
|
foregroundColor: ColorsManager.whiteColors,
|
||||||
onPressed: state.isSaveEnabled
|
onPressed: state.isSaveEnabled
|
||||||
? () async {
|
? () async {
|
||||||
Navigator.of(context).pop();
|
|
||||||
final updatedTags = List<Tag>.from(state.tags);
|
final updatedTags = List<Tag>.from(state.tags);
|
||||||
final result =
|
final result =
|
||||||
processTags(updatedTags, subspaces);
|
processTags(updatedTags, subspaces);
|
||||||
@ -270,8 +275,8 @@ class AssignTagDialog extends StatelessWidget {
|
|||||||
result['updatedTags'] as List<Tag>;
|
result['updatedTags'] as List<Tag>;
|
||||||
final processedSubspaces =
|
final processedSubspaces =
|
||||||
result['subspaces'] as List<SubspaceModel>;
|
result['subspaces'] as List<SubspaceModel>;
|
||||||
|
onSave?.call(processedTags, processedSubspaces);
|
||||||
onSave!(processedTags, processedSubspaces);
|
Navigator.of(context).pop();
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
child: const Text('Save'),
|
child: const Text('Save'),
|
||||||
@ -307,7 +312,15 @@ class AssignTagDialog extends StatelessWidget {
|
|||||||
final modifiedTags = List<Tag>.from(updatedTags);
|
final modifiedTags = List<Tag>.from(updatedTags);
|
||||||
final modifiedSubspaces = List<SubspaceModel>.from(subspaces ?? []);
|
final modifiedSubspaces = List<SubspaceModel>.from(subspaces ?? []);
|
||||||
|
|
||||||
for (var tag in modifiedTags.toList()) {
|
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;
|
if (modifiedSubspaces.isEmpty) continue;
|
||||||
|
|
||||||
final prevIndice = checkTagExistInSubspace(tag, modifiedSubspaces);
|
final prevIndice = checkTagExistInSubspace(tag, modifiedSubspaces);
|
||||||
|
@ -268,7 +268,7 @@ class AssignTagModelsDialog extends StatelessWidget {
|
|||||||
builder: (dialogContext) =>
|
builder: (dialogContext) =>
|
||||||
AddDeviceTypeModelWidget(
|
AddDeviceTypeModelWidget(
|
||||||
products: products,
|
products: products,
|
||||||
subspaces: subspaces,
|
subspaces: processedSubspaces,
|
||||||
isCreate: false,
|
isCreate: false,
|
||||||
initialSelectedProducts: TagHelper
|
initialSelectedProducts: TagHelper
|
||||||
.createInitialSelectedProducts(
|
.createInitialSelectedProducts(
|
||||||
|
@ -193,17 +193,21 @@ class CreateSubSpaceDialog extends StatelessWidget {
|
|||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
onPressed: () async {
|
onPressed: (state.errorMessage.isNotEmpty)
|
||||||
final subSpaces = context
|
? null
|
||||||
.read<SubSpaceBloc>()
|
: () async {
|
||||||
.state
|
final subSpaces = context
|
||||||
.subSpaces;
|
.read<SubSpaceBloc>()
|
||||||
onSave!(subSpaces);
|
.state
|
||||||
Navigator.of(context).pop();
|
.subSpaces;
|
||||||
},
|
onSave!(subSpaces);
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
backgroundColor: ColorsManager.secondaryColor,
|
backgroundColor: ColorsManager.secondaryColor,
|
||||||
borderRadius: 10,
|
borderRadius: 10,
|
||||||
foregroundColor: ColorsManager.whiteColors,
|
foregroundColor: state.errorMessage.isNotEmpty
|
||||||
|
? ColorsManager.whiteColorsWithOpacity
|
||||||
|
: ColorsManager.whiteColors,
|
||||||
child: const Text('OK'),
|
child: const Text('OK'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -105,6 +105,7 @@ class _SubspaceModelCreateState extends State<SubspaceModelCreate> {
|
|||||||
isEdit: true,
|
isEdit: true,
|
||||||
dialogTitle: dialogTitle,
|
dialogTitle: dialogTitle,
|
||||||
existingSubSpaces: _subspaces,
|
existingSubSpaces: _subspaces,
|
||||||
|
|
||||||
onUpdate: (subspaceModels) {
|
onUpdate: (subspaceModels) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_subspaces = subspaceModels;
|
_subspaces = subspaceModels;
|
||||||
|
Reference in New Issue
Block a user