mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
Reset Selected space
This commit is contained in:
@ -25,9 +25,6 @@ class DeviceManagementPage extends StatelessWidget with HelperResponsiveLayout {
|
||||
create: (context) =>
|
||||
DeviceManagementBloc()..add(FetchDevices(context)),
|
||||
),
|
||||
BlocProvider<CreateRoutineBloc>(
|
||||
create: (context) => CreateRoutineBloc(),
|
||||
),
|
||||
],
|
||||
child: WebScaffold(
|
||||
appBarTitle: Text(
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:bloc/bloc.dart';
|
||||
@ -16,14 +15,9 @@ import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/routine_details_model.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/routine_model.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
||||
import 'package:syncrow_web/services/devices_mang_api.dart';
|
||||
import 'package:syncrow_web/services/routines_api.dart';
|
||||
import 'package:syncrow_web/services/space_mana_api.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
import 'package:syncrow_web/utils/constants/strings_manager.dart';
|
||||
import 'package:syncrow_web/utils/constants/temp_const.dart';
|
||||
import 'package:syncrow_web/utils/helpers/shared_preferences_helper.dart';
|
||||
import 'package:syncrow_web/utils/navigation_service.dart';
|
||||
import 'package:syncrow_web/utils/snack_bar.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
@ -227,6 +221,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
BuildContext context = NavigationService.navigatorKey.currentContext!;
|
||||
var createRoutineBloc = context.read<CreateRoutineBloc>();
|
||||
try {
|
||||
|
||||
if (createRoutineBloc.selectedSpaceId == '' &&
|
||||
createRoutineBloc.selectedCommunityId == '') {
|
||||
var spaceBloc = context.read<SpaceTreeBloc>();
|
||||
@ -342,10 +337,10 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
}).toList();
|
||||
|
||||
BuildContext context = NavigationService.navigatorKey.currentContext!;
|
||||
var spaceBloc = context.read<CreateRoutineBloc>();
|
||||
var createRoutineBloc = context.read<CreateRoutineBloc>();
|
||||
|
||||
final createSceneModel = CreateSceneModel(
|
||||
spaceUuid: spaceBloc.selectedSpaceId,
|
||||
spaceUuid: createRoutineBloc.selectedSpaceId,
|
||||
iconId: state.selectedIcon ?? '',
|
||||
showInDevice: true,
|
||||
sceneName: state.routineName ?? '',
|
||||
@ -472,10 +467,10 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
});
|
||||
}).toList();
|
||||
BuildContext context = NavigationService.navigatorKey.currentContext!;
|
||||
var spaceBloc = context.read<CreateRoutineBloc>();
|
||||
var createRoutineBloc = context.read<CreateRoutineBloc>();
|
||||
|
||||
final createAutomationModel = CreateAutomationModel(
|
||||
spaceUuid: spaceBloc.selectedSpaceId,
|
||||
spaceUuid: createRoutineBloc.selectedSpaceId,
|
||||
automationName: state.routineName ?? '',
|
||||
decisionExpr: state.selectedAutomationOperator,
|
||||
effectiveTime: EffectiveTime(
|
||||
@ -866,24 +861,33 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
isUpdate: false,
|
||||
createRoutineView: false));
|
||||
}
|
||||
|
||||
FutureOr<void> _deleteScene(
|
||||
DeleteScene event, Emitter<RoutineState> emit) async {
|
||||
FutureOr<void> _deleteScene(DeleteScene event, Emitter<RoutineState> emit) async {
|
||||
try {
|
||||
emit(state.copyWith(isLoading: true));
|
||||
final projectId = await ProjectManager.getProjectUUID() ?? '';
|
||||
|
||||
emit(state.copyWith(isLoading: true));
|
||||
BuildContext context = NavigationService.navigatorKey.currentContext!;
|
||||
var createRoutineBloc = context.read<CreateRoutineBloc>();
|
||||
var spaceBloc = context.read<SpaceTreeBloc>();
|
||||
if (state.isTabToRun) {
|
||||
await SceneApi.deleteScene(
|
||||
unitUuid: createRoutineBloc.selectedSpaceId,
|
||||
sceneId: state.sceneId ?? '');
|
||||
unitUuid: spaceBloc.state.selectedSpaces[0], sceneId: state.sceneId ?? '');
|
||||
} else {
|
||||
await SceneApi.deleteAutomation(
|
||||
projectId: projectId,
|
||||
unitUuid: createRoutineBloc.selectedSpaceId,
|
||||
automationId: state.automationId ?? '');
|
||||
unitUuid: spaceBloc.state.selectedSpaces[0],
|
||||
automationId: state.automationId ?? '',
|
||||
projectId: projectId);
|
||||
}
|
||||
// var createRoutineBloc = context.read<CreateRoutineBloc>();
|
||||
// if (state.isTabToRun) {
|
||||
// await SceneApi.deleteScene(
|
||||
// unitUuid: createRoutineBloc.selectedSpaceId,
|
||||
// sceneId: state.sceneId ?? '');
|
||||
// } else {
|
||||
// await SceneApi.deleteAutomation(
|
||||
// projectId: projectId,
|
||||
// unitUuid: createRoutineBloc.selectedSpaceId,
|
||||
// automationId: state.automationId ?? '');
|
||||
// }
|
||||
|
||||
add(const LoadScenes());
|
||||
add(const LoadAutomation());
|
||||
@ -896,7 +900,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// FutureOr<void> _deleteAutomation(DeleteAutomation event, Emitter<RoutineState> emit) {
|
||||
// try {
|
||||
// emit(state.copyWith(isLoading: true));
|
||||
|
@ -31,10 +31,10 @@ class _RoutinesViewState extends State<RoutinesView> {
|
||||
final routineBloc = context.read<RoutineBloc>();
|
||||
_bloc.add(SaveCommunityIdAndSpaceIdEvent(
|
||||
communityID: communityId, spaceID: spaceId));
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
routineBloc.add(const CreateNewRoutineViewEvent(createRoutineView: true));
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
BlocProvider.of<CreateRoutineBloc>(context).add(const ResetSelectedEvent());
|
||||
await Future.delayed(const Duration(milliseconds:500));
|
||||
_bloc.add(const ResetSelectedEvent());
|
||||
}
|
||||
|
||||
@override
|
||||
|
Reference in New Issue
Block a user