mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
added space delete
This commit is contained in:
@ -7,7 +7,7 @@ import 'package:syncrow_web/pages/spaces_management/space_model/models/space_tem
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
enum SpaceStatus { newSpace, modified, unchanged, deleted }
|
||||
enum SpaceStatus { newSpace, modified, unchanged, deleted, parentDeleted }
|
||||
|
||||
class SpaceModel {
|
||||
String? uuid;
|
||||
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
|
||||
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';
|
||||
import 'package:syncrow_web/pages/spaces_management/create_community/view/create_community_dialog.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
@ -17,6 +18,7 @@ class CommunityStructureHeader extends StatefulWidget {
|
||||
final ValueChanged<String> onNameSubmitted;
|
||||
final List<CommunityModel> communities;
|
||||
final CommunityModel? community;
|
||||
final SpaceModel? selectedSpace;
|
||||
|
||||
const CommunityStructureHeader(
|
||||
{super.key,
|
||||
@ -29,7 +31,8 @@ class CommunityStructureHeader extends StatefulWidget {
|
||||
required this.onEditName,
|
||||
required this.onNameSubmitted,
|
||||
this.community,
|
||||
required this.communities});
|
||||
required this.communities,
|
||||
this.selectedSpace});
|
||||
|
||||
@override
|
||||
State<CommunityStructureHeader> createState() =>
|
||||
@ -137,11 +140,9 @@ class _CommunityStructureHeaderState extends State<CommunityStructureHeader> {
|
||||
],
|
||||
),
|
||||
),
|
||||
if (widget.isSave) ...[
|
||||
const SizedBox(width: 8),
|
||||
_buildActionButtons(theme),
|
||||
],
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
@ -152,12 +153,20 @@ class _CommunityStructureHeaderState extends State<CommunityStructureHeader> {
|
||||
alignment: WrapAlignment.end,
|
||||
spacing: 10,
|
||||
children: [
|
||||
if (widget.isSave)
|
||||
_buildButton(
|
||||
label: "Save",
|
||||
icon: const Icon(Icons.save,
|
||||
size: 18, color: ColorsManager.spaceColor),
|
||||
onPressed: widget.onSave,
|
||||
theme: theme),
|
||||
if(widget.selectedSpace!= null)
|
||||
_buildButton(
|
||||
label: "Delete",
|
||||
icon: const Icon(Icons.delete,
|
||||
size: 18, color: ColorsManager.warningRed),
|
||||
onPressed: widget.onDelete,
|
||||
theme: theme),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
@ -131,6 +131,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
isEditingName: isEditingName,
|
||||
nameController: _nameController,
|
||||
onSave: _saveSpaces,
|
||||
selectedSpace: widget.selectedSpace,
|
||||
onDelete: _onDelete,
|
||||
onEditName: () {
|
||||
setState(() {
|
||||
@ -176,7 +177,8 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
painter: CurvedLinePainter([connection])),
|
||||
),
|
||||
for (var entry in spaces.asMap().entries)
|
||||
if (entry.value.status != SpaceStatus.deleted)
|
||||
if (entry.value.status != SpaceStatus.deleted ||
|
||||
entry.value.status != SpaceStatus.parentDeleted)
|
||||
Positioned(
|
||||
left: entry.value.position.dx,
|
||||
top: entry.value.position.dy,
|
||||
@ -358,7 +360,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
space.name = name;
|
||||
space.icon = icon;
|
||||
space.spaceModel = spaceModel;
|
||||
space.subspaces= subspaces;
|
||||
space.subspaces = subspaces;
|
||||
space.tags = tags;
|
||||
|
||||
if (space.status != SpaceStatus.newSpace) {
|
||||
@ -382,7 +384,8 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
List<SpaceModel> result = [];
|
||||
|
||||
void flatten(SpaceModel space) {
|
||||
if (space.status == SpaceStatus.deleted) return;
|
||||
if (space.status == SpaceStatus.deleted ||
|
||||
space.status == SpaceStatus.parentDeleted) return;
|
||||
|
||||
result.add(space);
|
||||
|
||||
@ -475,7 +478,8 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
|
||||
void _markChildrenAsDeleted(SpaceModel parent) {
|
||||
for (var child in parent.children) {
|
||||
child.status = SpaceStatus.deleted;
|
||||
child.status = SpaceStatus.parentDeleted;
|
||||
|
||||
_markChildrenAsDeleted(child);
|
||||
}
|
||||
}
|
||||
@ -483,7 +487,9 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
void _removeConnectionsForDeletedSpaces() {
|
||||
connections.removeWhere((connection) {
|
||||
return connection.startSpace.status == SpaceStatus.deleted ||
|
||||
connection.endSpace.status == SpaceStatus.deleted;
|
||||
connection.endSpace.status == SpaceStatus.deleted ||
|
||||
connection.startSpace.status == SpaceStatus.parentDeleted ||
|
||||
connection.endSpace.status == SpaceStatus.parentDeleted;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:syncrow_web/services/api/http_interceptor.dart';
|
||||
import 'package:syncrow_web/services/locator.dart';
|
||||
@ -121,13 +123,22 @@ class HTTPService {
|
||||
required T Function(dynamic) expectedResponseModel,
|
||||
bool showServerMessage = true,
|
||||
}) async {
|
||||
log('DELETE Request Initiated', name: 'API DELETE');
|
||||
log('Path: $path', name: 'API DELETE');
|
||||
if (queryParameters != null) {
|
||||
log('Query Parameters: $queryParameters', name: 'API DELETE');
|
||||
}
|
||||
|
||||
try {
|
||||
final response = await client.delete(
|
||||
path,
|
||||
queryParameters: queryParameters,
|
||||
);
|
||||
log('Response: ${response.data}', name: 'API DELETE');
|
||||
return expectedResponseModel(response.data);
|
||||
} catch (error) {
|
||||
} catch (error, stackTrace) {
|
||||
log('Error during DELETE Request: $error',
|
||||
name: 'API DELETE', error: error, stackTrace: stackTrace);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
class TempConst {
|
||||
static const projectId = '0e62577c-06fa-41b9-8a92-99a21fbaf51c';
|
||||
static const projectId = '0685c781-df33-4cbf-bf65-9f4e835eb468';
|
||||
}
|
||||
|
Reference in New Issue
Block a user