mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-15 01:35:25 +00:00
fixed space creation api
This commit is contained in:
@ -11,6 +11,8 @@ import 'package:syncrow_web/pages/spaces_management/all_spaces/model/selected_pr
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/connection_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/subspace_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/blank_community_widget.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/community_structure_header_widget.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/dialogs/create_space_dialog.dart';
|
||||
@ -55,7 +57,6 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
print("sxdsf ${widget.spaceModels}");
|
||||
spaces = widget.spaces.isNotEmpty ? flattenSpaces(widget.spaces) : [];
|
||||
connections =
|
||||
widget.spaces.isNotEmpty ? createConnections(widget.spaces) : [];
|
||||
@ -293,21 +294,24 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
onCreateSpace: (String name,
|
||||
String icon,
|
||||
List<SelectedProduct> selectedProducts,
|
||||
SpaceTemplateModel? spaceModel) {
|
||||
SpaceTemplateModel? spaceModel,
|
||||
List<SubspaceModel>? subspaces,
|
||||
List<Tag>? tags) {
|
||||
setState(() {
|
||||
// Set the first space in the center or use passed position
|
||||
|
||||
Offset centerPosition =
|
||||
position ?? _getCenterPosition(screenSize);
|
||||
SpaceModel newSpace = SpaceModel(
|
||||
name: name,
|
||||
icon: icon,
|
||||
position: centerPosition,
|
||||
isPrivate: false,
|
||||
children: [],
|
||||
status: SpaceStatus.newSpace,
|
||||
spaceModel: spaceModel,
|
||||
);
|
||||
name: name,
|
||||
icon: icon,
|
||||
position: centerPosition,
|
||||
isPrivate: false,
|
||||
children: [],
|
||||
status: SpaceStatus.newSpace,
|
||||
spaceModel: spaceModel,
|
||||
subspaces: subspaces,
|
||||
tags: tags);
|
||||
|
||||
if (parentIndex != null && direction != null) {
|
||||
SpaceModel parentSpace = spaces[parentIndex];
|
||||
@ -346,12 +350,16 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
onCreateSpace: (String name,
|
||||
String icon,
|
||||
List<SelectedProduct> selectedProducts,
|
||||
SpaceTemplateModel? spaceModel) {
|
||||
SpaceTemplateModel? spaceModel,
|
||||
List<SubspaceModel>? subspaces,
|
||||
List<Tag>? tags) {
|
||||
setState(() {
|
||||
// Update the space's properties
|
||||
space.name = name;
|
||||
space.icon = icon;
|
||||
space.spaceModel = spaceModel;
|
||||
space.subspaces= subspaces;
|
||||
space.tags = tags;
|
||||
|
||||
if (space.status != SpaceStatus.newSpace) {
|
||||
space.status = SpaceStatus.modified; // Mark as modified
|
||||
|
@ -18,7 +18,7 @@ import 'package:syncrow_web/utils/constants/space_icon_const.dart';
|
||||
|
||||
class CreateSpaceDialog extends StatefulWidget {
|
||||
final Function(String, String, List<SelectedProduct> selectedProducts,
|
||||
SpaceTemplateModel? spaceModel) onCreateSpace;
|
||||
SpaceTemplateModel? spaceModel, List<SubspaceModel>? subspaces, List<Tag>? tags) onCreateSpace;
|
||||
final List<ProductModel>? products;
|
||||
final String? name;
|
||||
final String? icon;
|
||||
@ -487,7 +487,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
_showTagCreateDialog(context, enteredName,
|
||||
tags, subspaces, widget.products);
|
||||
widget.products);
|
||||
// Edit action
|
||||
},
|
||||
child: Chip(
|
||||
@ -511,8 +511,8 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
)
|
||||
: DefaultButton(
|
||||
onPressed: () {
|
||||
_showTagCreateDialog(context, enteredName, tags,
|
||||
subspaces, widget.products);
|
||||
_showTagCreateDialog(
|
||||
context, enteredName, widget.products);
|
||||
},
|
||||
backgroundColor: ColorsManager.textFieldGreyColor,
|
||||
foregroundColor: Colors.black,
|
||||
@ -580,7 +580,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
: (widget.name ?? '');
|
||||
if (newName.isNotEmpty) {
|
||||
widget.onCreateSpace(newName, selectedIcon,
|
||||
selectedProducts, selectedSpaceModel);
|
||||
selectedProducts, selectedSpaceModel,subspaces,tags);
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
@ -673,11 +673,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
}
|
||||
|
||||
void _showTagCreateDialog(
|
||||
BuildContext context,
|
||||
String name,
|
||||
final List<Tag>? spaceTags,
|
||||
List<SubspaceModel>? subspaces,
|
||||
List<ProductModel>? products) {
|
||||
BuildContext context, String name, List<ProductModel>? products) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
@ -685,16 +681,18 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
spaceName: name,
|
||||
products: products,
|
||||
subspaces: subspaces,
|
||||
spaceTags: spaceTags,
|
||||
spaceTags: tags,
|
||||
allTags: [],
|
||||
initialSelectedProducts:
|
||||
createInitialSelectedProducts(tags, subspaces),
|
||||
onSave: (selectedSpaceTags, selectedSubspaces) {
|
||||
setState(() {
|
||||
if (spaceTags != null) selectedSpaceTags = spaceTags;
|
||||
tags = selectedSpaceTags;
|
||||
selectedSpaceModel = null;
|
||||
|
||||
if (selectedSubspaces != null) {
|
||||
if (subspaces != null) {
|
||||
for (final subspace in subspaces) {
|
||||
for (final subspace in subspaces!) {
|
||||
for (final selectedSubspace in selectedSubspaces) {
|
||||
if (subspace.subspaceName ==
|
||||
selectedSubspace.subspaceName) {
|
||||
|
Reference in New Issue
Block a user