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