mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-16 01:56:24 +00:00
Compare commits
20 Commits
feat/space
...
chore/remo
Author | SHA1 | Date | |
---|---|---|---|
c5871be990 | |||
97bdb1bbb7 | |||
7ce0a27af0 | |||
bc4af6a237 | |||
830725254f | |||
ba7db3a5fb | |||
513175ed1e | |||
f35b699d4c | |||
7ffdc67016 | |||
18afc4f563 | |||
44d95f5701 | |||
e47f3d6d59 | |||
788ea27de1 | |||
81e9e58627 | |||
25eae3dfaa | |||
59eafc99a5 | |||
db7eaa53af | |||
20a9f19480 | |||
eb7eeebf18 | |||
15023e5882 |
@ -10,6 +10,10 @@ class UserModel {
|
|||||||
final String? phoneNumber;
|
final String? phoneNumber;
|
||||||
final bool? isEmailVerified;
|
final bool? isEmailVerified;
|
||||||
final bool? isAgreementAccepted;
|
final bool? isAgreementAccepted;
|
||||||
|
final bool? hasAcceptedWebAgreement;
|
||||||
|
final DateTime? webAgreementAcceptedAt;
|
||||||
|
final UserRole? role;
|
||||||
|
|
||||||
UserModel({
|
UserModel({
|
||||||
required this.uuid,
|
required this.uuid,
|
||||||
required this.email,
|
required this.email,
|
||||||
@ -19,6 +23,9 @@ class UserModel {
|
|||||||
required this.phoneNumber,
|
required this.phoneNumber,
|
||||||
required this.isEmailVerified,
|
required this.isEmailVerified,
|
||||||
required this.isAgreementAccepted,
|
required this.isAgreementAccepted,
|
||||||
|
required this.hasAcceptedWebAgreement,
|
||||||
|
required this.webAgreementAcceptedAt,
|
||||||
|
required this.role,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory UserModel.fromJson(Map<String, dynamic> json) {
|
factory UserModel.fromJson(Map<String, dynamic> json) {
|
||||||
@ -31,6 +38,11 @@ class UserModel {
|
|||||||
phoneNumber: json['phoneNumber'],
|
phoneNumber: json['phoneNumber'],
|
||||||
isEmailVerified: json['isEmailVerified'],
|
isEmailVerified: json['isEmailVerified'],
|
||||||
isAgreementAccepted: json['isAgreementAccepted'],
|
isAgreementAccepted: json['isAgreementAccepted'],
|
||||||
|
hasAcceptedWebAgreement: json['hasAcceptedWebAgreement'],
|
||||||
|
webAgreementAcceptedAt: json['webAgreementAcceptedAt'] != null
|
||||||
|
? DateTime.parse(json['webAgreementAcceptedAt'])
|
||||||
|
: null,
|
||||||
|
role: json['role'] != null ? UserRole.fromJson(json['role']) : null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,6 +53,9 @@ class UserModel {
|
|||||||
Map<String, dynamic> tempJson = Token.decodeToken(token.accessToken);
|
Map<String, dynamic> tempJson = Token.decodeToken(token.accessToken);
|
||||||
|
|
||||||
return UserModel(
|
return UserModel(
|
||||||
|
hasAcceptedWebAgreement: null,
|
||||||
|
role: null,
|
||||||
|
webAgreementAcceptedAt: null,
|
||||||
uuid: tempJson['uuid'].toString(),
|
uuid: tempJson['uuid'].toString(),
|
||||||
email: tempJson['email'],
|
email: tempJson['email'],
|
||||||
firstName: null,
|
firstName: null,
|
||||||
@ -65,3 +80,26 @@ class UserModel {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class UserRole {
|
||||||
|
final String uuid;
|
||||||
|
final DateTime createdAt;
|
||||||
|
final DateTime updatedAt;
|
||||||
|
final String type;
|
||||||
|
|
||||||
|
UserRole({
|
||||||
|
required this.uuid,
|
||||||
|
required this.createdAt,
|
||||||
|
required this.updatedAt,
|
||||||
|
required this.type,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory UserRole.fromJson(Map<String, dynamic> json) {
|
||||||
|
return UserRole(
|
||||||
|
uuid: json['uuid'],
|
||||||
|
createdAt: DateTime.parse(json['createdAt']),
|
||||||
|
updatedAt: DateTime.parse(json['updatedAt']),
|
||||||
|
type: json['type'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -18,10 +18,15 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
|||||||
List<Node> sourcesList = [];
|
List<Node> sourcesList = [];
|
||||||
List<Node> destinationsList = [];
|
List<Node> destinationsList = [];
|
||||||
UserModel? user;
|
UserModel? user;
|
||||||
|
String terms = '';
|
||||||
|
String policy = '';
|
||||||
|
|
||||||
HomeBloc() : super((HomeInitial())) {
|
HomeBloc() : super((HomeInitial())) {
|
||||||
on<CreateNewNode>(_createNode);
|
on<CreateNewNode>(_createNode);
|
||||||
on<FetchUserInfo>(_fetchUserInfo);
|
on<FetchUserInfo>(_fetchUserInfo);
|
||||||
|
on<FetchTermEvent>(_fetchTerms);
|
||||||
|
on<FetchPolicyEvent>(_fetchPolicy);
|
||||||
|
on<ConfirmUserAgreementEvent>(_confirmUserAgreement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _createNode(CreateNewNode event, Emitter<HomeState> emit) async {
|
void _createNode(CreateNewNode event, Emitter<HomeState> emit) async {
|
||||||
@ -45,12 +50,45 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
|||||||
var uuid =
|
var uuid =
|
||||||
await const FlutterSecureStorage().read(key: UserModel.userUuidKey);
|
await const FlutterSecureStorage().read(key: UserModel.userUuidKey);
|
||||||
user = await HomeApi().fetchUserInfo(uuid);
|
user = await HomeApi().fetchUserInfo(uuid);
|
||||||
|
add(FetchTermEvent());
|
||||||
emit(HomeInitial());
|
emit(HomeInitial());
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future _fetchTerms(FetchTermEvent event, Emitter<HomeState> emit) async {
|
||||||
|
try {
|
||||||
|
emit(LoadingHome());
|
||||||
|
terms = await HomeApi().fetchTerms();
|
||||||
|
add(FetchPolicyEvent());
|
||||||
|
} catch (e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future _fetchPolicy(FetchPolicyEvent event, Emitter<HomeState> emit) async {
|
||||||
|
try {
|
||||||
|
emit(LoadingHome());
|
||||||
|
policy = await HomeApi().fetchPolicy();
|
||||||
|
} catch (e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future _confirmUserAgreement(
|
||||||
|
ConfirmUserAgreementEvent event, Emitter<HomeState> emit) async {
|
||||||
|
try {
|
||||||
|
emit(LoadingHome());
|
||||||
|
var uuid =
|
||||||
|
await const FlutterSecureStorage().read(key: UserModel.userUuidKey);
|
||||||
|
policy = await HomeApi().confirmUserAgreements(uuid);
|
||||||
|
emit(PolicyAgreement());
|
||||||
|
} catch (e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// static Future fetchUserInfo() async {
|
// static Future fetchUserInfo() async {
|
||||||
// try {
|
// try {
|
||||||
// var uuid =
|
// var uuid =
|
||||||
|
@ -20,4 +20,8 @@ class CreateNewNode extends HomeEvent {
|
|||||||
|
|
||||||
class FetchUserInfo extends HomeEvent {
|
class FetchUserInfo extends HomeEvent {
|
||||||
const FetchUserInfo();
|
const FetchUserInfo();
|
||||||
}
|
}class FetchTermEvent extends HomeEvent {}
|
||||||
|
|
||||||
|
class FetchPolicyEvent extends HomeEvent {}
|
||||||
|
|
||||||
|
class ConfirmUserAgreementEvent extends HomeEvent {}
|
@ -7,8 +7,12 @@ abstract class HomeState extends Equatable {
|
|||||||
@override
|
@override
|
||||||
List<Object> get props => [];
|
List<Object> get props => [];
|
||||||
}
|
}
|
||||||
|
class LoadingHome extends HomeState {}
|
||||||
|
|
||||||
class HomeInitial extends HomeState {}
|
class HomeInitial extends HomeState {}
|
||||||
|
class TermsAgreement extends HomeState {}
|
||||||
|
|
||||||
|
class PolicyAgreement extends HomeState {}
|
||||||
|
|
||||||
class HomeCounterState extends HomeState {
|
class HomeCounterState extends HomeState {
|
||||||
final int counter;
|
final int counter;
|
||||||
@ -24,3 +28,5 @@ class HomeUpdateTree extends HomeState {
|
|||||||
@override
|
@override
|
||||||
List<Object> get props => [graph, builder];
|
List<Object> get props => [graph, builder];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//FetchTermEvent
|
176
lib/pages/home/view/agreement_and_privacy_dialog.dart
Normal file
176
lib/pages/home/view/agreement_and_privacy_dialog.dart
Normal file
@ -0,0 +1,176 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_html/flutter_html.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:syncrow_web/pages/auth/bloc/auth_bloc.dart';
|
||||||
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
import 'package:syncrow_web/utils/constants/routes_const.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
|
class AgreementAndPrivacyDialog extends StatefulWidget {
|
||||||
|
final String terms;
|
||||||
|
final String policy;
|
||||||
|
|
||||||
|
const AgreementAndPrivacyDialog({
|
||||||
|
super.key,
|
||||||
|
required this.terms,
|
||||||
|
required this.policy,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_AgreementAndPrivacyDialogState createState() =>
|
||||||
|
_AgreementAndPrivacyDialogState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AgreementAndPrivacyDialogState extends State<AgreementAndPrivacyDialog> {
|
||||||
|
final ScrollController _scrollController = ScrollController();
|
||||||
|
bool _isAtEnd = false;
|
||||||
|
int _currentPage = 1;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_scrollController.addListener(_onScroll);
|
||||||
|
WidgetsBinding.instance
|
||||||
|
.addPostFrameCallback((_) => _checkScrollRequirement());
|
||||||
|
}
|
||||||
|
|
||||||
|
void _checkScrollRequirement() {
|
||||||
|
final scrollPosition = _scrollController.position;
|
||||||
|
if (scrollPosition.maxScrollExtent <= 0) {
|
||||||
|
setState(() {
|
||||||
|
_isAtEnd = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_scrollController.removeListener(_onScroll);
|
||||||
|
_scrollController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onScroll() {
|
||||||
|
if (_scrollController.position.atEdge) {
|
||||||
|
final isAtBottom = _scrollController.position.pixels ==
|
||||||
|
_scrollController.position.maxScrollExtent;
|
||||||
|
if (isAtBottom && !_isAtEnd) {
|
||||||
|
setState(() {
|
||||||
|
_isAtEnd = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String get _dialogTitle =>
|
||||||
|
_currentPage == 2 ? 'User Agreement' : 'Privacy Policy';
|
||||||
|
|
||||||
|
String get _dialogContent => _currentPage == 2 ? widget.terms : widget.policy;
|
||||||
|
|
||||||
|
Widget _buildScrollableContent() {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.all(40),
|
||||||
|
width: MediaQuery.of(context).size.width * 0.8,
|
||||||
|
height: MediaQuery.of(context).size.height * 0.75,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.grey[200],
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(20)),
|
||||||
|
),
|
||||||
|
child: Scrollbar(
|
||||||
|
thumbVisibility: true,
|
||||||
|
trackVisibility: true,
|
||||||
|
interactive: true,
|
||||||
|
controller: _scrollController,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
controller: _scrollController,
|
||||||
|
padding: const EdgeInsets.all(25),
|
||||||
|
child: Html(
|
||||||
|
data: _dialogContent,
|
||||||
|
onLinkTap: (url, attributes, element) async {
|
||||||
|
if (url != null) {
|
||||||
|
final uri = Uri.parse(url);
|
||||||
|
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
style: {
|
||||||
|
"body": Style(
|
||||||
|
fontSize: FontSize(14),
|
||||||
|
color: Colors.black87,
|
||||||
|
lineHeight: LineHeight(1.5),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildActionButton() {
|
||||||
|
final String buttonText = _currentPage == 2 ? "I Agree" : "Next";
|
||||||
|
|
||||||
|
return InkWell(
|
||||||
|
onTap: _isAtEnd
|
||||||
|
? () {
|
||||||
|
if (_currentPage == 1) {
|
||||||
|
setState(() {
|
||||||
|
_currentPage = 2;
|
||||||
|
_isAtEnd = false;
|
||||||
|
_scrollController.jumpTo(0);
|
||||||
|
WidgetsBinding.instance
|
||||||
|
.addPostFrameCallback((_) => _checkScrollRequirement());
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Navigator.of(context).pop(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
child: Text(
|
||||||
|
buttonText,
|
||||||
|
style: TextStyle(
|
||||||
|
color: _isAtEnd ? ColorsManager.secondaryColor : Colors.grey,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Dialog(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Text(
|
||||||
|
_dialogTitle,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
color: ColorsManager.secondaryColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Divider(),
|
||||||
|
_buildScrollableContent(),
|
||||||
|
const Divider(),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
|
children: [
|
||||||
|
InkWell(
|
||||||
|
onTap: () {
|
||||||
|
AuthBloc.logout();
|
||||||
|
context.go(RoutesConst.auth);
|
||||||
|
},
|
||||||
|
child: const Text("Cancel"),
|
||||||
|
),
|
||||||
|
_buildActionButton(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
|
import 'package:syncrow_web/pages/home/bloc/home_event.dart';
|
||||||
|
import 'package:syncrow_web/pages/home/view/agreement_and_privacy_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/home/bloc/home_bloc.dart';
|
import 'package:syncrow_web/pages/home/bloc/home_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/home/bloc/home_state.dart';
|
import 'package:syncrow_web/pages/home/bloc/home_state.dart';
|
||||||
import 'package:syncrow_web/pages/home/view/home_card.dart';
|
import 'package:syncrow_web/pages/home/view/home_card.dart';
|
||||||
@ -9,16 +11,40 @@ import 'package:syncrow_web/web_layout/web_scaffold.dart';
|
|||||||
|
|
||||||
class HomeWebPage extends StatelessWidget {
|
class HomeWebPage extends StatelessWidget {
|
||||||
const HomeWebPage({super.key});
|
const HomeWebPage({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
Size size = MediaQuery.of(context).size;
|
Size size = MediaQuery.of(context).size;
|
||||||
|
final homeBloc = BlocProvider.of<HomeBloc>(context);
|
||||||
|
|
||||||
return PopScope(
|
return PopScope(
|
||||||
canPop: false,
|
canPop: false,
|
||||||
onPopInvoked: (didPop) => false,
|
onPopInvoked: (didPop) => false,
|
||||||
child: BlocConsumer<HomeBloc, HomeState>(
|
child: BlocConsumer<HomeBloc, HomeState>(
|
||||||
listener: (BuildContext context, state) {},
|
listener: (BuildContext context, state) {
|
||||||
|
if (state is HomeInitial) {
|
||||||
|
if (homeBloc.user!.hasAcceptedWebAgreement == false) {
|
||||||
|
Future.delayed(const Duration(seconds: 1), () {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AgreementAndPrivacyDialog(
|
||||||
|
terms: homeBloc.terms,
|
||||||
|
policy: homeBloc.policy,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
).then((v) {
|
||||||
|
if (v != null) {
|
||||||
|
homeBloc.add(ConfirmUserAgreementEvent());
|
||||||
|
homeBloc.add(const FetchUserInfo());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final homeBloc = BlocProvider.of<HomeBloc>(context);
|
|
||||||
return WebScaffold(
|
return WebScaffold(
|
||||||
enableMenuSidebar: false,
|
enableMenuSidebar: false,
|
||||||
appBarTitle: Row(
|
appBarTitle: Row(
|
||||||
@ -52,7 +78,8 @@ class HomeWebPage extends StatelessWidget {
|
|||||||
width: size.width * 0.68,
|
width: size.width * 0.68,
|
||||||
child: GridView.builder(
|
child: GridView.builder(
|
||||||
itemCount: 3, //8
|
itemCount: 3, //8
|
||||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
gridDelegate:
|
||||||
|
const SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
crossAxisCount: 4,
|
crossAxisCount: 4,
|
||||||
crossAxisSpacing: 20.0,
|
crossAxisSpacing: 20.0,
|
||||||
mainAxisSpacing: 20.0,
|
mainAxisSpacing: 20.0,
|
||||||
@ -64,7 +91,8 @@ class HomeWebPage extends StatelessWidget {
|
|||||||
active: homeBloc.homeItems[index].active!,
|
active: homeBloc.homeItems[index].active!,
|
||||||
name: homeBloc.homeItems[index].title!,
|
name: homeBloc.homeItems[index].title!,
|
||||||
img: homeBloc.homeItems[index].icon!,
|
img: homeBloc.homeItems[index].icon!,
|
||||||
onTap: () => homeBloc.homeItems[index].onPress(context),
|
onTap: () =>
|
||||||
|
homeBloc.homeItems[index].onPress(context),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -42,7 +42,7 @@ class RolesUserModel {
|
|||||||
invitedBy:
|
invitedBy:
|
||||||
json['invitedBy'].toString().toLowerCase().replaceAll("_", " "),
|
json['invitedBy'].toString().toLowerCase().replaceAll("_", " "),
|
||||||
phoneNumber: json['phoneNumber'],
|
phoneNumber: json['phoneNumber'],
|
||||||
jobTitle: json['jobTitle'].toString(),
|
jobTitle: json['jobTitle'] ?? "-",
|
||||||
createdDate: json['createdDate'],
|
createdDate: json['createdDate'],
|
||||||
createdTime: json['createdTime'],
|
createdTime: json['createdTime'],
|
||||||
);
|
);
|
||||||
|
@ -114,7 +114,7 @@ class _AddNewUserDialogState extends State<AddNewUserDialog> {
|
|||||||
currentStep++;
|
currentStep++;
|
||||||
if (currentStep == 2) {
|
if (currentStep == 2) {
|
||||||
_blocRole.add(
|
_blocRole.add(
|
||||||
CheckStepStatus(isEditUser: false));
|
const CheckStepStatus(isEditUser: false));
|
||||||
} else if (currentStep == 3) {
|
} else if (currentStep == 3) {
|
||||||
_blocRole
|
_blocRole
|
||||||
.add(const CheckSpacesStepStatus());
|
.add(const CheckSpacesStepStatus());
|
||||||
@ -151,11 +151,11 @@ class _AddNewUserDialogState extends State<AddNewUserDialog> {
|
|||||||
Widget _getFormContent() {
|
Widget _getFormContent() {
|
||||||
switch (currentStep) {
|
switch (currentStep) {
|
||||||
case 1:
|
case 1:
|
||||||
return BasicsView(
|
return const BasicsView(
|
||||||
userId: '',
|
userId: '',
|
||||||
);
|
);
|
||||||
case 2:
|
case 2:
|
||||||
return SpacesAccessView();
|
return const SpacesAccessView();
|
||||||
case 3:
|
case 3:
|
||||||
return const RolesAndPermission();
|
return const RolesAndPermission();
|
||||||
default:
|
default:
|
||||||
@ -172,7 +172,7 @@ class _AddNewUserDialogState extends State<AddNewUserDialog> {
|
|||||||
bloc.add(const CheckSpacesStepStatus());
|
bloc.add(const CheckSpacesStepStatus());
|
||||||
currentStep = step;
|
currentStep = step;
|
||||||
Future.delayed(const Duration(milliseconds: 500), () {
|
Future.delayed(const Duration(milliseconds: 500), () {
|
||||||
bloc.add(ValidateBasicsStep());
|
bloc.add(const ValidateBasicsStep());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -237,10 +237,11 @@ class _AddNewUserDialogState extends State<AddNewUserDialog> {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
currentStep = step;
|
currentStep = step;
|
||||||
bloc.add(CheckStepStatus(isEditUser: false));
|
bloc.add(const CheckStepStatus(isEditUser: false));
|
||||||
if (step3 == 3) {
|
if (step3 == 3) {
|
||||||
bloc.add(const CheckRoleStepStatus());
|
bloc.add(const CheckRoleStepStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: Column(
|
child: Column(
|
||||||
|
@ -4,7 +4,6 @@ import 'package:intl_phone_field/countries.dart';
|
|||||||
import 'package:intl_phone_field/country_picker_dialog.dart';
|
import 'package:intl_phone_field/country_picker_dialog.dart';
|
||||||
import 'package:intl_phone_field/intl_phone_field.dart';
|
import 'package:intl_phone_field/intl_phone_field.dart';
|
||||||
import 'package:syncrow_web/pages/roles_and_permission/users_page/add_user_dialog/bloc/users_bloc.dart';
|
import 'package:syncrow_web/pages/roles_and_permission/users_page/add_user_dialog/bloc/users_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/roles_and_permission/users_page/add_user_dialog/bloc/users_event.dart';
|
|
||||||
import 'package:syncrow_web/pages/roles_and_permission/users_page/add_user_dialog/bloc/users_status.dart';
|
import 'package:syncrow_web/pages/roles_and_permission/users_page/add_user_dialog/bloc/users_status.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
@ -47,7 +46,9 @@ class BasicsView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
SizedBox(
|
||||||
|
width: MediaQuery.of(context).size.width * 0.18,
|
||||||
|
height: MediaQuery.of(context).size.width * 0.08,
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@ -76,12 +77,12 @@ class BasicsView extends StatelessWidget {
|
|||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
style:
|
style:
|
||||||
const TextStyle(color: ColorsManager.blackColor),
|
const TextStyle(color: ColorsManager.blackColor),
|
||||||
onChanged: (value) {
|
// onChanged: (value) {
|
||||||
Future.delayed(const Duration(milliseconds: 200),
|
// Future.delayed(const Duration(milliseconds: 200),
|
||||||
() {
|
// () {
|
||||||
_blocRole.add(ValidateBasicsStep());
|
// _blocRole.add(const ValidateBasicsStep());
|
||||||
});
|
// });
|
||||||
},
|
// },
|
||||||
controller: _blocRole.firstNameController,
|
controller: _blocRole.firstNameController,
|
||||||
decoration: inputTextFormDeco(
|
decoration: inputTextFormDeco(
|
||||||
hintText: "Enter first name",
|
hintText: "Enter first name",
|
||||||
@ -103,7 +104,9 @@ class BasicsView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
Expanded(
|
SizedBox(
|
||||||
|
width: MediaQuery.of(context).size.width * 0.18,
|
||||||
|
height: MediaQuery.of(context).size.width * 0.08,
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@ -128,12 +131,12 @@ class BasicsView extends StatelessWidget {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
onChanged: (value) {
|
// onChanged: (value) {
|
||||||
Future.delayed(const Duration(milliseconds: 200),
|
// Future.delayed(const Duration(milliseconds: 200),
|
||||||
() {
|
// () {
|
||||||
_blocRole.add(ValidateBasicsStep());
|
// _blocRole.add(ValidateBasicsStep());
|
||||||
});
|
// });
|
||||||
},
|
// },
|
||||||
controller: _blocRole.lastNameController,
|
controller: _blocRole.lastNameController,
|
||||||
style: const TextStyle(color: Colors.black),
|
style: const TextStyle(color: Colors.black),
|
||||||
decoration:
|
decoration:
|
||||||
@ -186,13 +189,13 @@ class BasicsView extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
enabled: userId != '' ? false : true,
|
enabled: userId != '' ? false : true,
|
||||||
onChanged: (value) {
|
// onChanged: (value) {
|
||||||
Future.delayed(const Duration(milliseconds: 200), () {
|
// Future.delayed(const Duration(milliseconds: 200), () {
|
||||||
_blocRole.add(CheckStepStatus(
|
// _blocRole.add(CheckStepStatus(
|
||||||
isEditUser: userId != '' ? false : true));
|
// isEditUser: userId != '' ? false : true));
|
||||||
_blocRole.add(ValidateBasicsStep());
|
// _blocRole.add(ValidateBasicsStep());
|
||||||
});
|
// });
|
||||||
},
|
// },
|
||||||
controller: _blocRole.emailController,
|
controller: _blocRole.emailController,
|
||||||
style: const TextStyle(color: ColorsManager.blackColor),
|
style: const TextStyle(color: ColorsManager.blackColor),
|
||||||
decoration: inputTextFormDeco(hintText: "name@example.com")
|
decoration: inputTextFormDeco(hintText: "name@example.com")
|
||||||
|
@ -11,7 +11,14 @@ class DeleteUserDialog extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _DeleteUserDialogState extends State<DeleteUserDialog> {
|
class _DeleteUserDialogState extends State<DeleteUserDialog> {
|
||||||
int currentStep = 1;
|
bool isLoading = false;
|
||||||
|
bool _isDisposed = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_isDisposed = true;
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -56,7 +63,7 @@ class _DeleteUserDialogState extends State<DeleteUserDialog> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.of(context).pop(true);
|
Navigator.of(context).pop(false); // Return false if canceled
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.all(10),
|
padding: const EdgeInsets.all(10),
|
||||||
@ -76,7 +83,26 @@ class _DeleteUserDialogState extends State<DeleteUserDialog> {
|
|||||||
)),
|
)),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: widget.onTapDelete,
|
onTap: isLoading
|
||||||
|
? null
|
||||||
|
: () async {
|
||||||
|
setState(() {
|
||||||
|
isLoading = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (widget.onTapDelete != null) {
|
||||||
|
await widget.onTapDelete!();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (!_isDisposed) {
|
||||||
|
setState(() {
|
||||||
|
isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Navigator.of(context).pop(true);
|
||||||
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.all(10),
|
padding: const EdgeInsets.all(10),
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
@ -91,13 +117,22 @@ class _DeleteUserDialogState extends State<DeleteUserDialog> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: const Center(
|
child: Center(
|
||||||
child: Text(
|
child: isLoading
|
||||||
'Delete',
|
? const SizedBox(
|
||||||
style: TextStyle(
|
height: 20,
|
||||||
color: ColorsManager.red,
|
width: 20,
|
||||||
),
|
child: CircularProgressIndicator(
|
||||||
))),
|
color: ColorsManager.red,
|
||||||
|
strokeWidth: 2.0,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: const Text(
|
||||||
|
'Delete',
|
||||||
|
style: TextStyle(
|
||||||
|
color: ColorsManager.red,
|
||||||
|
),
|
||||||
|
))),
|
||||||
)),
|
)),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -128,7 +128,7 @@ class _PermissionManagementState extends State<PermissionManagement> {
|
|||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Text(
|
Text(
|
||||||
option.title,
|
' ${option.title.isNotEmpty ? option.title[0].toUpperCase() : ''}${option.title.substring(1)}',
|
||||||
style: context.textTheme.bodyMedium?.copyWith(
|
style: context.textTheme.bodyMedium?.copyWith(
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
@ -184,7 +184,7 @@ class _PermissionManagementState extends State<PermissionManagement> {
|
|||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Text(
|
Text(
|
||||||
subOption.title,
|
' ${subOption.title.isNotEmpty ? subOption.title[0].toUpperCase() : ''}${subOption.title.substring(1)}',
|
||||||
style: context.textTheme.bodyMedium?.copyWith(
|
style: context.textTheme.bodyMedium?.copyWith(
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
@ -246,7 +246,7 @@ class _PermissionManagementState extends State<PermissionManagement> {
|
|||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Text(
|
Text(
|
||||||
child.title,
|
' ${child.title.isNotEmpty ? child.title[0].toUpperCase() : ''}${child.title.substring(1)}',
|
||||||
style: context.textTheme.bodyMedium?.copyWith(
|
style: context.textTheme.bodyMedium?.copyWith(
|
||||||
fontWeight: FontWeight.w400,
|
fontWeight: FontWeight.w400,
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
|
@ -5,141 +5,156 @@ import 'package:syncrow_web/utils/style.dart';
|
|||||||
|
|
||||||
Future<void> showPopUpFilterMenu({
|
Future<void> showPopUpFilterMenu({
|
||||||
required BuildContext context,
|
required BuildContext context,
|
||||||
Function()? onSortAtoZ,
|
required Function(String value) onSortAtoZ,
|
||||||
Function()? onSortZtoA,
|
required Function(String value) onSortZtoA,
|
||||||
Function()? cancelButton,
|
Function()? cancelButton,
|
||||||
required Map<String, bool> checkboxStates,
|
required Map<String, bool> checkboxStates,
|
||||||
required RelativeRect position,
|
required RelativeRect position,
|
||||||
Function()? onOkPressed,
|
Function()? onOkPressed,
|
||||||
List<String>? list,
|
List<String>? list,
|
||||||
|
String? isSelected,
|
||||||
}) async {
|
}) async {
|
||||||
|
|
||||||
|
|
||||||
await showMenu(
|
await showMenu(
|
||||||
context: context,
|
context: context,
|
||||||
position:position,
|
position: position,
|
||||||
|
|
||||||
|
|
||||||
color: ColorsManager.whiteColors,
|
color: ColorsManager.whiteColors,
|
||||||
shape: const RoundedRectangleBorder(
|
shape: const RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.all(Radius.circular(10)),
|
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||||
),
|
),
|
||||||
items: <PopupMenuEntry>[
|
items: <PopupMenuEntry>[
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
onTap: onSortAtoZ,
|
enabled: false,
|
||||||
child: ListTile(
|
child: StatefulBuilder(
|
||||||
leading: Image.asset(
|
builder: (context, setState) {
|
||||||
Assets.AtoZIcon,
|
return Column(
|
||||||
width: 25,
|
mainAxisSize: MainAxisSize.min,
|
||||||
),
|
children: [
|
||||||
title: const Text(
|
SizedBox(
|
||||||
"Sort A to Z",
|
child: ListTile(
|
||||||
style: TextStyle(color: Colors.blueGrey),
|
onTap: () {
|
||||||
),
|
setState(() {
|
||||||
),
|
if (isSelected == 'Asc') {
|
||||||
),
|
isSelected = null;
|
||||||
PopupMenuItem(
|
onSortAtoZ.call('');
|
||||||
onTap: onSortZtoA,
|
} else {
|
||||||
child: ListTile(
|
onSortAtoZ.call('Asc');
|
||||||
leading: Image.asset(
|
isSelected = 'Asc';
|
||||||
Assets.ZtoAIcon,
|
}
|
||||||
width: 25,
|
});
|
||||||
),
|
},
|
||||||
title: const Text(
|
leading: Image.asset(
|
||||||
"Sort Z to A",
|
Assets.AtoZIcon,
|
||||||
style: TextStyle(color: Colors.blueGrey),
|
width: 25,
|
||||||
),
|
),
|
||||||
),
|
title: Text(
|
||||||
),
|
"Sort A to Z",
|
||||||
const PopupMenuDivider(),
|
style: TextStyle(
|
||||||
const PopupMenuItem(
|
color: isSelected == "Asc"
|
||||||
child: Text(
|
? ColorsManager.blackColor
|
||||||
"Filter by Status",
|
: ColorsManager.grayColor),
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
),
|
||||||
)
|
),
|
||||||
// Container(
|
|
||||||
// decoration: containerDecoration.copyWith(
|
|
||||||
// boxShadow: [],
|
|
||||||
// borderRadius: const BorderRadius.only(
|
|
||||||
// topLeft: Radius.circular(10), topRight: Radius.circular(10))),
|
|
||||||
// child: Padding(
|
|
||||||
// padding: const EdgeInsets.all(8.0),
|
|
||||||
// child: TextFormField(
|
|
||||||
// onChanged: onTextFieldChanged,
|
|
||||||
// style: const TextStyle(color: Colors.black),
|
|
||||||
// decoration: textBoxDecoration(radios: 15)!.copyWith(
|
|
||||||
// fillColor: ColorsManager.whiteColors,
|
|
||||||
// errorStyle: const TextStyle(height: 0),
|
|
||||||
// hintStyle: context.textTheme.titleSmall?.copyWith(
|
|
||||||
// color: Colors.grey,
|
|
||||||
// fontSize: 12,
|
|
||||||
// ),
|
|
||||||
// hintText: 'Search',
|
|
||||||
// suffixIcon: SizedBox(
|
|
||||||
// child: SvgPicture.asset(
|
|
||||||
// Assets.searchIconUser,
|
|
||||||
// fit: BoxFit.none,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// // "Filter by Status",
|
|
||||||
// // style: TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
),
|
|
||||||
PopupMenuItem(
|
|
||||||
child: Container(
|
|
||||||
decoration: containerDecoration.copyWith(
|
|
||||||
boxShadow: [],
|
|
||||||
borderRadius: const BorderRadius.only(
|
|
||||||
bottomLeft: Radius.circular(10),
|
|
||||||
bottomRight: Radius.circular(10))),
|
|
||||||
padding: const EdgeInsets.all(10),
|
|
||||||
height: 200,
|
|
||||||
width: 400,
|
|
||||||
child: Container(
|
|
||||||
padding: const EdgeInsets.all(10),
|
|
||||||
color: Colors.white,
|
|
||||||
child: ListView.builder(
|
|
||||||
itemCount: list?.length ?? 0,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
final item = list![index];
|
|
||||||
return CheckboxListTile(
|
|
||||||
dense: true,
|
|
||||||
title: Text(item),
|
|
||||||
value: checkboxStates[item],
|
|
||||||
onChanged: (bool? newValue) {
|
|
||||||
checkboxStates[item] = newValue ?? false;
|
|
||||||
(context as Element).markNeedsBuild();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
PopupMenuItem(
|
|
||||||
child: Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
Navigator.of(context).pop(); // Close the menu
|
|
||||||
},
|
|
||||||
child: const Text("Cancel"),
|
|
||||||
),
|
|
||||||
GestureDetector(
|
|
||||||
onTap: onOkPressed,
|
|
||||||
child: const Text(
|
|
||||||
"OK",
|
|
||||||
style: TextStyle(
|
|
||||||
color: ColorsManager.spaceColor,
|
|
||||||
),
|
),
|
||||||
),
|
ListTile(
|
||||||
),
|
onTap: () {
|
||||||
],
|
setState(() {
|
||||||
|
if (isSelected == 'Desc') {
|
||||||
|
isSelected = null;
|
||||||
|
onSortZtoA.call('');
|
||||||
|
} else {
|
||||||
|
onSortZtoA.call('Desc');
|
||||||
|
isSelected = 'Desc';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
leading: Image.asset(
|
||||||
|
Assets.ZtoAIcon,
|
||||||
|
width: 25,
|
||||||
|
),
|
||||||
|
title: Text(
|
||||||
|
"Sort Z to A",
|
||||||
|
style: TextStyle(
|
||||||
|
color: isSelected == "Desc"
|
||||||
|
? ColorsManager.blackColor
|
||||||
|
: ColorsManager.grayColor),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Divider(),
|
||||||
|
const Text(
|
||||||
|
"Filter by Status",
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
decoration: containerDecoration.copyWith(
|
||||||
|
boxShadow: [],
|
||||||
|
borderRadius: const BorderRadius.only(
|
||||||
|
topLeft: Radius.circular(10),
|
||||||
|
topRight: Radius.circular(10),
|
||||||
|
bottomLeft: Radius.circular(10),
|
||||||
|
bottomRight: Radius.circular(10))),
|
||||||
|
padding: const EdgeInsets.all(10),
|
||||||
|
height: 200,
|
||||||
|
width: 400,
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(10),
|
||||||
|
color: Colors.white,
|
||||||
|
child: ListView.builder(
|
||||||
|
itemCount: list?.length ?? 0,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final item = list![index];
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
Checkbox(
|
||||||
|
value: checkboxStates[item],
|
||||||
|
onChanged: (bool? newValue) {
|
||||||
|
checkboxStates[item] = newValue ?? false;
|
||||||
|
(context as Element).markNeedsBuild();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
item,
|
||||||
|
style: TextStyle(color: ColorsManager.grayColor),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
const Divider(),
|
||||||
|
const SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).pop(); // Close the menu
|
||||||
|
},
|
||||||
|
child: const Text("Cancel"),
|
||||||
|
),
|
||||||
|
GestureDetector(
|
||||||
|
onTap: onOkPressed,
|
||||||
|
child: const Text(
|
||||||
|
"OK",
|
||||||
|
style: TextStyle(
|
||||||
|
color: ColorsManager.spaceColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -52,14 +52,16 @@ class _RoleDropdownState extends State<RoleDropdown> {
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
child: DropdownButtonFormField<String>(
|
child: DropdownButtonFormField<String>(
|
||||||
dropdownColor: ColorsManager.whiteColors,
|
dropdownColor: ColorsManager.whiteColors,
|
||||||
alignment: Alignment.center,
|
// alignment: Alignment.,
|
||||||
focusColor: Colors.white,
|
focusColor: Colors.white,
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
value: selectedRole.isNotEmpty ? selectedRole : null,
|
value: selectedRole.isNotEmpty ? selectedRole : null,
|
||||||
items: widget.bloc!.roles.map((role) {
|
items: widget.bloc!.roles.map((role) {
|
||||||
return DropdownMenuItem<String>(
|
return DropdownMenuItem<String>(
|
||||||
value: role.uuid,
|
value: role.uuid,
|
||||||
child: Text(role.type),
|
child: Text(
|
||||||
|
' ${role.type.isNotEmpty ? role.type[0].toUpperCase() : ''}${role.type.substring(1)}',
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
|
@ -93,7 +93,7 @@ class UserTableBloc extends Bloc<UserTableEvent, UserTableState> {
|
|||||||
try {
|
try {
|
||||||
emit(UsersLoadingState());
|
emit(UsersLoadingState());
|
||||||
bool res = await UserPermissionApi().changeUserStatusById(
|
bool res = await UserPermissionApi().changeUserStatusById(
|
||||||
event.userId, event.newStatus == "disabled" ? true : false);
|
event.userId, event.newStatus == "disabled" ? false : true);
|
||||||
if (res == true) {
|
if (res == true) {
|
||||||
add(const GetUsers());
|
add(const GetUsers());
|
||||||
// users = users.map((user) {
|
// users = users.map((user) {
|
||||||
@ -133,7 +133,10 @@ class UserTableBloc extends Bloc<UserTableEvent, UserTableState> {
|
|||||||
} else {
|
} else {
|
||||||
emit(UsersLoadingState());
|
emit(UsersLoadingState());
|
||||||
currentSortOrder = "Asc";
|
currentSortOrder = "Asc";
|
||||||
users.sort((a, b) => a.firstName!.compareTo(b.firstName!));
|
users.sort((a, b) => a.firstName
|
||||||
|
.toString()
|
||||||
|
.toLowerCase()
|
||||||
|
.compareTo(b.firstName.toString().toLowerCase()));
|
||||||
emit(UsersLoadedState(users: users));
|
emit(UsersLoadedState(users: users));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -164,6 +167,7 @@ class UserTableBloc extends Bloc<UserTableEvent, UserTableState> {
|
|||||||
emit(UsersLoadedState(users: users));
|
emit(UsersLoadedState(users: users));
|
||||||
} else {
|
} else {
|
||||||
emit(UsersLoadingState());
|
emit(UsersLoadingState());
|
||||||
|
currentSortOrder = "NewestToOldest";
|
||||||
users.sort((a, b) {
|
users.sort((a, b) {
|
||||||
final dateA = _parseDateTime(a.createdDate);
|
final dateA = _parseDateTime(a.createdDate);
|
||||||
final dateB = _parseDateTime(b.createdDate);
|
final dateB = _parseDateTime(b.createdDate);
|
||||||
@ -188,6 +192,7 @@ class UserTableBloc extends Bloc<UserTableEvent, UserTableState> {
|
|||||||
final dateB = _parseDateTime(b.createdDate);
|
final dateB = _parseDateTime(b.createdDate);
|
||||||
return dateA.compareTo(dateB);
|
return dateA.compareTo(dateB);
|
||||||
});
|
});
|
||||||
|
currentSortOrder = "OldestToNewest";
|
||||||
emit(UsersLoadedState(users: users));
|
emit(UsersLoadedState(users: users));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -210,7 +215,7 @@ class UserTableBloc extends Bloc<UserTableEvent, UserTableState> {
|
|||||||
final query = event.query.toLowerCase();
|
final query = event.query.toLowerCase();
|
||||||
final filteredUsers = initialUsers.where((user) {
|
final filteredUsers = initialUsers.where((user) {
|
||||||
final fullName = "${user.firstName} ${user.lastName}".toLowerCase();
|
final fullName = "${user.firstName} ${user.lastName}".toLowerCase();
|
||||||
final email = user.email.toLowerCase() ;
|
final email = user.email.toLowerCase();
|
||||||
return fullName.contains(query) || email.contains(query);
|
return fullName.contains(query) || email.contains(query);
|
||||||
}).toList();
|
}).toList();
|
||||||
emit(UsersLoadedState(users: filteredUsers));
|
emit(UsersLoadedState(users: filteredUsers));
|
||||||
@ -256,49 +261,96 @@ class UserTableBloc extends Bloc<UserTableEvent, UserTableState> {
|
|||||||
|
|
||||||
void _filterUsersByRole(
|
void _filterUsersByRole(
|
||||||
FilterUsersByRoleEvent event, Emitter<UserTableState> emit) {
|
FilterUsersByRoleEvent event, Emitter<UserTableState> emit) {
|
||||||
selectedRoles = event.selectedRoles.toSet();
|
selectedRoles = event.selectedRoles!.toSet();
|
||||||
|
|
||||||
final filteredUsers = initialUsers.where((user) {
|
final filteredUsers = initialUsers.where((user) {
|
||||||
if (selectedRoles.isEmpty) return true;
|
if (selectedRoles.isEmpty) return true;
|
||||||
return selectedRoles.contains(user.roleType);
|
return selectedRoles.contains(user.roleType);
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
|
if (event.sortOrder == "Asc") {
|
||||||
|
currentSortOrder = "Asc";
|
||||||
|
filteredUsers.sort((a, b) => a.firstName
|
||||||
|
.toString()
|
||||||
|
.toLowerCase()
|
||||||
|
.compareTo(b.firstName.toString().toLowerCase()));
|
||||||
|
} else if (event.sortOrder == "Desc") {
|
||||||
|
currentSortOrder = "Desc";
|
||||||
|
filteredUsers.sort((a, b) => b.firstName!.compareTo(a.firstName!));
|
||||||
|
} else {
|
||||||
|
currentSortOrder = "";
|
||||||
|
}
|
||||||
|
|
||||||
emit(UsersLoadedState(users: filteredUsers));
|
emit(UsersLoadedState(users: filteredUsers));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _filterUsersByJobTitle(
|
void _filterUsersByJobTitle(
|
||||||
FilterUsersByJobEvent event, Emitter<UserTableState> emit) {
|
FilterUsersByJobEvent event, Emitter<UserTableState> emit) {
|
||||||
selectedJobTitles = event.selectedJob.toSet();
|
selectedJobTitles = event.selectedJob!.toSet();
|
||||||
|
emit(UsersLoadingState());
|
||||||
final filteredUsers = initialUsers.where((user) {
|
final filteredUsers = initialUsers.where((user) {
|
||||||
if (selectedJobTitles.isEmpty) return true;
|
if (selectedJobTitles.isEmpty) return true;
|
||||||
return selectedJobTitles.contains(user.jobTitle);
|
return selectedJobTitles.contains(user.jobTitle);
|
||||||
}).toList();
|
}).toList();
|
||||||
|
if (event.sortOrder == "Asc") {
|
||||||
|
currentSortOrder = "Asc";
|
||||||
|
filteredUsers.sort((a, b) => a.firstName
|
||||||
|
.toString()
|
||||||
|
.toLowerCase()
|
||||||
|
.compareTo(b.firstName.toString().toLowerCase()));
|
||||||
|
} else if (event.sortOrder == "Desc") {
|
||||||
|
currentSortOrder = "Desc";
|
||||||
|
filteredUsers.sort((a, b) => b.firstName!.compareTo(a.firstName!));
|
||||||
|
} else {
|
||||||
|
currentSortOrder = "";
|
||||||
|
}
|
||||||
emit(UsersLoadedState(users: filteredUsers));
|
emit(UsersLoadedState(users: filteredUsers));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _filterUsersByCreated(
|
void _filterUsersByCreated(
|
||||||
FilterUsersByCreatedEvent event, Emitter<UserTableState> emit) {
|
FilterUsersByCreatedEvent event, Emitter<UserTableState> emit) {
|
||||||
selectedCreatedBy = event.selectedCreatedBy.toSet();
|
selectedCreatedBy = event.selectedCreatedBy!.toSet();
|
||||||
|
|
||||||
final filteredUsers = initialUsers.where((user) {
|
final filteredUsers = initialUsers.where((user) {
|
||||||
if (selectedCreatedBy.isEmpty) return true;
|
if (selectedCreatedBy.isEmpty) return true;
|
||||||
return selectedCreatedBy.contains(user.invitedBy);
|
return selectedCreatedBy.contains(user.invitedBy);
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
|
if (event.sortOrder == "Asc") {
|
||||||
|
currentSortOrder = "Asc";
|
||||||
|
filteredUsers.sort((a, b) => a.firstName
|
||||||
|
.toString()
|
||||||
|
.toLowerCase()
|
||||||
|
.compareTo(b.firstName.toString().toLowerCase()));
|
||||||
|
} else if (event.sortOrder == "Desc") {
|
||||||
|
currentSortOrder = "Desc";
|
||||||
|
filteredUsers.sort((a, b) => b.firstName!.compareTo(a.firstName!));
|
||||||
|
} else {
|
||||||
|
currentSortOrder = "";
|
||||||
|
}
|
||||||
emit(UsersLoadedState(users: filteredUsers));
|
emit(UsersLoadedState(users: filteredUsers));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _filterUserStatus(
|
void _filterUserStatus(
|
||||||
FilterUsersByDeActevateEvent event, Emitter<UserTableState> emit) {
|
FilterUsersByDeActevateEvent event, Emitter<UserTableState> emit) {
|
||||||
selectedStatuses = event.selectedActivate.toSet();
|
selectedStatuses = event.selectedActivate!.toSet();
|
||||||
|
|
||||||
final filteredUsers = initialUsers.where((user) {
|
final filteredUsers = initialUsers.where((user) {
|
||||||
if (selectedStatuses.isEmpty) return true;
|
if (selectedStatuses.isEmpty) return true;
|
||||||
return selectedStatuses.contains(user.status);
|
return selectedStatuses.contains(user.status);
|
||||||
}).toList();
|
}).toList();
|
||||||
|
if (event.sortOrder == "Asc") {
|
||||||
|
currentSortOrder = "Asc";
|
||||||
|
filteredUsers.sort((a, b) => a.firstName
|
||||||
|
.toString()
|
||||||
|
.toLowerCase()
|
||||||
|
.compareTo(b.firstName.toString().toLowerCase()));
|
||||||
|
} else if (event.sortOrder == "Desc") {
|
||||||
|
currentSortOrder = "Desc";
|
||||||
|
filteredUsers.sort((a, b) => b.firstName!.compareTo(a.firstName!));
|
||||||
|
} else {
|
||||||
|
currentSortOrder = "";
|
||||||
|
}
|
||||||
emit(UsersLoadedState(users: filteredUsers));
|
emit(UsersLoadedState(users: filteredUsers));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,35 +89,36 @@ class DeleteUserEvent extends UserTableEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class FilterUsersByRoleEvent extends UserTableEvent {
|
class FilterUsersByRoleEvent extends UserTableEvent {
|
||||||
final List<String> selectedRoles;
|
final List<String>? selectedRoles;
|
||||||
|
final String? sortOrder;
|
||||||
|
|
||||||
FilterUsersByRoleEvent(this.selectedRoles);
|
const FilterUsersByRoleEvent({this.selectedRoles, this.sortOrder});
|
||||||
@override
|
List<Object?> get props => [selectedRoles, sortOrder];
|
||||||
List<Object?> get props => [selectedRoles];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class FilterUsersByJobEvent extends UserTableEvent {
|
class FilterUsersByJobEvent extends UserTableEvent {
|
||||||
final List<String> selectedJob;
|
final List<String>? selectedJob;
|
||||||
|
final String? sortOrder;
|
||||||
|
|
||||||
FilterUsersByJobEvent(this.selectedJob);
|
const FilterUsersByJobEvent({this.selectedJob, this.sortOrder});
|
||||||
@override
|
List<Object?> get props => [selectedJob, sortOrder];
|
||||||
List<Object?> get props => [selectedJob];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class FilterUsersByCreatedEvent extends UserTableEvent {
|
class FilterUsersByCreatedEvent extends UserTableEvent {
|
||||||
final List<String> selectedCreatedBy;
|
final List<String>? selectedCreatedBy;
|
||||||
|
|
||||||
FilterUsersByCreatedEvent(this.selectedCreatedBy);
|
final String? sortOrder;
|
||||||
@override
|
|
||||||
List<Object?> get props => [selectedCreatedBy];
|
const FilterUsersByCreatedEvent({this.selectedCreatedBy, this.sortOrder});
|
||||||
|
List<Object?> get props => [selectedCreatedBy, sortOrder];
|
||||||
}
|
}
|
||||||
|
|
||||||
class FilterUsersByDeActevateEvent extends UserTableEvent {
|
class FilterUsersByDeActevateEvent extends UserTableEvent {
|
||||||
final List<String> selectedActivate;
|
final List<String>? selectedActivate;
|
||||||
|
final String? sortOrder;
|
||||||
|
|
||||||
FilterUsersByDeActevateEvent(this.selectedActivate);
|
const FilterUsersByDeActevateEvent({this.selectedActivate, this.sortOrder});
|
||||||
@override
|
List<Object?> get props => [selectedActivate, sortOrder];
|
||||||
List<Object?> get props => [selectedActivate];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class FilterOptionsEvent extends UserTableEvent {
|
class FilterOptionsEvent extends UserTableEvent {
|
||||||
|
@ -19,19 +19,13 @@ class DynamicTableScreen extends StatefulWidget {
|
|||||||
class _DynamicTableScreenState extends State<DynamicTableScreen>
|
class _DynamicTableScreenState extends State<DynamicTableScreen>
|
||||||
with WidgetsBindingObserver {
|
with WidgetsBindingObserver {
|
||||||
late List<double> columnWidths;
|
late List<double> columnWidths;
|
||||||
|
late double totalWidth;
|
||||||
|
|
||||||
// @override
|
|
||||||
// void initState() {
|
|
||||||
// super.initState();
|
|
||||||
// // Initialize column widths with default sizes proportional to the screen width
|
|
||||||
// // Assigning placeholder values here. The actual sizes will be updated in `build`.
|
|
||||||
// }
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
setState(() {
|
columnWidths = List<double>.filled(widget.titles.length, 150.0);
|
||||||
columnWidths = List<double>.filled(widget.titles.length, 150.0);
|
totalWidth = columnWidths.reduce((a, b) => a + b);
|
||||||
});
|
|
||||||
WidgetsBinding.instance.addObserver(this);
|
WidgetsBinding.instance.addObserver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +38,6 @@ class _DynamicTableScreenState extends State<DynamicTableScreen>
|
|||||||
@override
|
@override
|
||||||
void didChangeMetrics() {
|
void didChangeMetrics() {
|
||||||
super.didChangeMetrics();
|
super.didChangeMetrics();
|
||||||
// Screen size might have changed
|
|
||||||
final newScreenWidth = MediaQuery.of(context).size.width;
|
final newScreenWidth = MediaQuery.of(context).size.width;
|
||||||
setState(() {
|
setState(() {
|
||||||
columnWidths = List<double>.generate(widget.titles.length, (index) {
|
columnWidths = List<double>.generate(widget.titles.length, (index) {
|
||||||
@ -53,7 +46,7 @@ class _DynamicTableScreenState extends State<DynamicTableScreen>
|
|||||||
0.12; // 20% of screen width for the second column
|
0.12; // 20% of screen width for the second column
|
||||||
} else if (index == 9) {
|
} else if (index == 9) {
|
||||||
return newScreenWidth *
|
return newScreenWidth *
|
||||||
0.2; // 25% of screen width for the tenth column
|
0.1; // 25% of screen width for the tenth column
|
||||||
}
|
}
|
||||||
return newScreenWidth *
|
return newScreenWidth *
|
||||||
0.09; // Default to 10% of screen width for other columns
|
0.09; // Default to 10% of screen width for other columns
|
||||||
@ -64,293 +57,204 @@ class _DynamicTableScreenState extends State<DynamicTableScreen>
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final screenWidth = MediaQuery.of(context).size.width;
|
final screenWidth = MediaQuery.of(context).size.width;
|
||||||
|
if (columnWidths.every((width) => width == screenWidth * 7)) {
|
||||||
// Initialize column widths if they are still set to placeholder values
|
|
||||||
if (columnWidths.every((width) => width == 120.0)) {
|
|
||||||
columnWidths = List<double>.generate(widget.titles.length, (index) {
|
columnWidths = List<double>.generate(widget.titles.length, (index) {
|
||||||
if (index == 1) {
|
if (index == 1) {
|
||||||
return screenWidth * 0.11;
|
return screenWidth * 0.11;
|
||||||
} else if (index == 9) {
|
} else if (index == 9) {
|
||||||
return screenWidth * 0.2;
|
return screenWidth * 0.1;
|
||||||
}
|
}
|
||||||
return screenWidth * 0.11;
|
return screenWidth * 0.09;
|
||||||
});
|
});
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
return Container(
|
return SingleChildScrollView(
|
||||||
child: SingleChildScrollView(
|
clipBehavior: Clip.none,
|
||||||
clipBehavior: Clip.none,
|
scrollDirection: Axis.horizontal,
|
||||||
scrollDirection: Axis.horizontal,
|
child: Container(
|
||||||
child: Container(
|
decoration: containerDecoration.copyWith(
|
||||||
decoration: containerDecoration.copyWith(
|
color: ColorsManager.whiteColors,
|
||||||
color: ColorsManager.whiteColors,
|
borderRadius: const BorderRadius.all(Radius.circular(20))),
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(20))),
|
child: FittedBox(
|
||||||
child: FittedBox(
|
child: Column(
|
||||||
child: Column(
|
children: [
|
||||||
children: [
|
Container(
|
||||||
// Header Row with Resizable Columns
|
width: totalWidth,
|
||||||
Container(
|
decoration: containerDecoration.copyWith(
|
||||||
width: MediaQuery.of(context).size.width,
|
color: ColorsManager.circleRolesBackground,
|
||||||
decoration: containerDecoration.copyWith(
|
borderRadius: const BorderRadius.only(
|
||||||
color: ColorsManager.circleRolesBackground,
|
topLeft: Radius.circular(15),
|
||||||
borderRadius: const BorderRadius.only(
|
topRight: Radius.circular(15))),
|
||||||
topLeft: Radius.circular(15),
|
child: Row(
|
||||||
topRight: Radius.circular(15))),
|
children: List.generate(widget.titles.length, (index) {
|
||||||
child: Row(
|
return Row(
|
||||||
children: List.generate(widget.titles.length, (index) {
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
return Row(
|
children: [
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
FittedBox(
|
||||||
children: [
|
child: Container(
|
||||||
FittedBox(
|
padding: const EdgeInsets.only(left: 5, right: 5),
|
||||||
child: Container(
|
width: columnWidths[index],
|
||||||
padding: const EdgeInsets.only(left: 5, right: 5),
|
child: Row(
|
||||||
width: columnWidths[index],
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
child: Row(
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
mainAxisAlignment:
|
children: [
|
||||||
MainAxisAlignment.spaceBetween,
|
SizedBox(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
child: Text(
|
||||||
children: [
|
widget.titles[index],
|
||||||
SizedBox(
|
maxLines: 2,
|
||||||
child: Text(
|
style: const TextStyle(
|
||||||
widget.titles[index],
|
overflow: TextOverflow.ellipsis,
|
||||||
maxLines: 2,
|
fontWeight: FontWeight.w400,
|
||||||
style: const TextStyle(
|
fontSize: 13,
|
||||||
overflow: TextOverflow.ellipsis,
|
color: ColorsManager.grayColor,
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
fontSize: 13,
|
|
||||||
color: ColorsManager.grayColor,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (index != 1 &&
|
),
|
||||||
index != 9 &&
|
if (index != 1 &&
|
||||||
index != 8 &&
|
index != 9 &&
|
||||||
index != 5)
|
index != 8 &&
|
||||||
FittedBox(
|
index != 5)
|
||||||
child: IconButton(
|
FittedBox(
|
||||||
icon: SvgPicture.asset(
|
child: IconButton(
|
||||||
Assets.filterTableIcon,
|
icon: SvgPicture.asset(
|
||||||
fit: BoxFit.none,
|
Assets.filterTableIcon,
|
||||||
),
|
fit: BoxFit.none,
|
||||||
onPressed: () {
|
|
||||||
if (widget.onFilter != null) {
|
|
||||||
widget.onFilter!(index);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
)
|
onPressed: () {
|
||||||
],
|
if (widget.onFilter != null) {
|
||||||
),
|
widget.onFilter!(index);
|
||||||
),
|
}
|
||||||
),
|
},
|
||||||
GestureDetector(
|
|
||||||
onHorizontalDragUpdate: (details) {
|
|
||||||
setState(() {
|
|
||||||
columnWidths[index] = (columnWidths[index] +
|
|
||||||
details.delta.dx)
|
|
||||||
.clamp(
|
|
||||||
150.0, 300.0); // Minimum & Maximum size
|
|
||||||
});
|
|
||||||
},
|
|
||||||
child: MouseRegion(
|
|
||||||
cursor: SystemMouseCursors
|
|
||||||
.resizeColumn, // Set the cursor to resize
|
|
||||||
child: Container(
|
|
||||||
color: Colors.green,
|
|
||||||
child: Container(
|
|
||||||
color: ColorsManager.boxDivider,
|
|
||||||
width: 1,
|
|
||||||
height: 50, // Height of the header cell
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// Data Rows with Dividers
|
|
||||||
widget.rows.isEmpty
|
|
||||||
? Container(
|
|
||||||
child: SizedBox(
|
|
||||||
height: MediaQuery.of(context).size.height / 2,
|
|
||||||
child: Container(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Column(
|
|
||||||
children: [
|
|
||||||
SvgPicture.asset(Assets.emptyTable),
|
|
||||||
const SizedBox(
|
|
||||||
height: 15,
|
|
||||||
),
|
),
|
||||||
const Text(
|
)
|
||||||
'No Users',
|
|
||||||
style: TextStyle(
|
|
||||||
color: ColorsManager.lightGrayColor,
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.w700),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
GestureDetector(
|
||||||
: Center(
|
onHorizontalDragUpdate: (details) {
|
||||||
child: Container(
|
setState(() {
|
||||||
// height: MediaQuery.of(context).size.height * 0.59,
|
columnWidths[index] =
|
||||||
width: MediaQuery.of(context).size.width,
|
(columnWidths[index] + details.delta.dx)
|
||||||
decoration: containerDecoration.copyWith(
|
.clamp(150.0, 300.0);
|
||||||
color: ColorsManager.whiteColors,
|
totalWidth = columnWidths.reduce((a, b) => a + b);
|
||||||
borderRadius: const BorderRadius.only(
|
});
|
||||||
bottomLeft: Radius.circular(15),
|
},
|
||||||
bottomRight: Radius.circular(15))),
|
child: MouseRegion(
|
||||||
child: ListView.builder(
|
cursor: SystemMouseCursors.resizeColumn,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
child: Container(
|
||||||
shrinkWrap: true,
|
color: Colors.green,
|
||||||
itemCount: widget.rows.length,
|
child: Container(
|
||||||
itemBuilder: (context, rowIndex) {
|
color: ColorsManager.boxDivider,
|
||||||
if (columnWidths
|
width: 1,
|
||||||
.every((width) => width == 120.0)) {
|
height: 50,
|
||||||
columnWidths = List<double>.generate(
|
),
|
||||||
widget.titles.length, (index) {
|
),
|
||||||
if (index == 1) {
|
),
|
||||||
return screenWidth * 0.11;
|
),
|
||||||
} else if (index == 9) {
|
],
|
||||||
return screenWidth * 0.2;
|
);
|
||||||
}
|
}),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
widget.rows.isEmpty
|
||||||
|
? SizedBox(
|
||||||
|
height: MediaQuery.of(context).size.height / 2,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
SvgPicture.asset(Assets.emptyTable),
|
||||||
|
const SizedBox(
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
const Text(
|
||||||
|
'No Users',
|
||||||
|
style: TextStyle(
|
||||||
|
color: ColorsManager.lightGrayColor,
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w700),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Center(
|
||||||
|
child: Container(
|
||||||
|
width: totalWidth,
|
||||||
|
decoration: containerDecoration.copyWith(
|
||||||
|
color: ColorsManager.whiteColors,
|
||||||
|
borderRadius: const BorderRadius.only(
|
||||||
|
bottomLeft: Radius.circular(15),
|
||||||
|
bottomRight: Radius.circular(15))),
|
||||||
|
child: ListView.builder(
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
shrinkWrap: true,
|
||||||
|
itemCount: widget.rows.length,
|
||||||
|
itemBuilder: (context, rowIndex) {
|
||||||
|
if (columnWidths.every((width) => width == 120.0)) {
|
||||||
|
columnWidths = List<double>.generate(
|
||||||
|
widget.titles.length, (index) {
|
||||||
|
if (index == 1) {
|
||||||
return screenWidth * 0.11;
|
return screenWidth * 0.11;
|
||||||
});
|
} else if (index == 9) {
|
||||||
setState(() {});
|
return screenWidth * 0.2;
|
||||||
}
|
}
|
||||||
final row = widget.rows[rowIndex];
|
return screenWidth * 0.11;
|
||||||
return Column(
|
});
|
||||||
children: [
|
setState(() {});
|
||||||
Container(
|
}
|
||||||
child: Padding(
|
final row = widget.rows[rowIndex];
|
||||||
padding: const EdgeInsets.only(
|
return Column(
|
||||||
left: 5,
|
children: [
|
||||||
top: 10,
|
Container(
|
||||||
right: 5,
|
child: Padding(
|
||||||
bottom: 10),
|
padding: const EdgeInsets.only(
|
||||||
child: Row(
|
left: 5, top: 10, right: 5, bottom: 10),
|
||||||
children:
|
child: Row(
|
||||||
List.generate(row.length, (index) {
|
children:
|
||||||
return SizedBox(
|
List.generate(row.length, (index) {
|
||||||
width: columnWidths[index],
|
|
||||||
child: SizedBox(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.only(
|
|
||||||
left: 15, right: 10),
|
|
||||||
child: row[index],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (rowIndex < widget.rows.length - 1)
|
|
||||||
Row(
|
|
||||||
children: List.generate(
|
|
||||||
widget.titles.length, (index) {
|
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
width: columnWidths[index],
|
width: columnWidths[index],
|
||||||
child: const Divider(
|
child: SizedBox(
|
||||||
color: ColorsManager.boxDivider,
|
child: Padding(
|
||||||
thickness: 1,
|
padding: const EdgeInsets.only(
|
||||||
height: 1,
|
left: 15, right: 10),
|
||||||
|
child: row[index],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
);
|
),
|
||||||
},
|
if (rowIndex < widget.rows.length - 1)
|
||||||
),
|
Row(
|
||||||
|
children: List.generate(
|
||||||
|
widget.titles.length, (index) {
|
||||||
|
return SizedBox(
|
||||||
|
width: columnWidths[index],
|
||||||
|
child: const Divider(
|
||||||
|
color: ColorsManager.boxDivider,
|
||||||
|
thickness: 1,
|
||||||
|
height: 1,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Widget build(BuildContext context) {
|
|
||||||
// return Scaffold(
|
|
||||||
// body: SingleChildScrollView(
|
|
||||||
// scrollDirection: Axis.horizontal,
|
|
||||||
// child: SingleChildScrollView(
|
|
||||||
// scrollDirection: Axis.vertical,
|
|
||||||
// child: Column(
|
|
||||||
// children: [
|
|
||||||
// // Header Row with Resizable Columns
|
|
||||||
// Container(
|
|
||||||
// color: Colors.green,
|
|
||||||
// child: Row(
|
|
||||||
// children: List.generate(widget.titles.length, (index) {
|
|
||||||
// return Row(
|
|
||||||
// children: [
|
|
||||||
// Container(
|
|
||||||
// width: columnWidths[index],
|
|
||||||
// decoration: const BoxDecoration(
|
|
||||||
// color: Colors.green,
|
|
||||||
// ),
|
|
||||||
// child: Text(
|
|
||||||
// widget.titles[index],
|
|
||||||
// style: TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
// textAlign: TextAlign.center,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// GestureDetector(
|
|
||||||
// onHorizontalDragUpdate: (details) {
|
|
||||||
// setState(() {
|
|
||||||
// columnWidths[index] = (columnWidths[index] +
|
|
||||||
// details.delta.dx)
|
|
||||||
// .clamp(50.0, 300.0); // Minimum & Maximum size
|
|
||||||
// });
|
|
||||||
// },
|
|
||||||
// child: MouseRegion(
|
|
||||||
// cursor: SystemMouseCursors
|
|
||||||
// .resizeColumn, // Set the cursor to resize
|
|
||||||
// child: Container(
|
|
||||||
// color: Colors.green,
|
|
||||||
// child: Container(
|
|
||||||
// color: Colors.black,
|
|
||||||
// width: 1,
|
|
||||||
// height: 50, // Height of the header cell
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// );
|
|
||||||
// }),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// // Data Rows
|
|
||||||
// ...widget.rows.map((row) {
|
|
||||||
// return Row(
|
|
||||||
// children: List.generate(row.length, (index) {
|
|
||||||
// return Container(
|
|
||||||
// width: columnWidths[index],
|
|
||||||
// child: row[index],
|
|
||||||
// );
|
|
||||||
// }),
|
|
||||||
// );
|
|
||||||
// }).toList(),
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
// }
|
|
@ -107,7 +107,6 @@ class UsersPage extends StatelessWidget {
|
|||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final screenSize = MediaQuery.of(context).size;
|
final screenSize = MediaQuery.of(context).size;
|
||||||
final _blocRole = BlocProvider.of<UserTableBloc>(context);
|
final _blocRole = BlocProvider.of<UserTableBloc>(context);
|
||||||
|
|
||||||
if (state is UsersLoadingState) {
|
if (state is UsersLoadingState) {
|
||||||
_blocRole.add(ChangePage(_blocRole.currentPage));
|
_blocRole.add(ChangePage(_blocRole.currentPage));
|
||||||
return const Center(child: CircularProgressIndicator());
|
return const Center(child: CircularProgressIndicator());
|
||||||
@ -189,8 +188,6 @@ class UsersPage extends StatelessWidget {
|
|||||||
const SizedBox(height: 25),
|
const SizedBox(height: 25),
|
||||||
DynamicTableScreen(
|
DynamicTableScreen(
|
||||||
onFilter: (columnIndex) {
|
onFilter: (columnIndex) {
|
||||||
_blocRole.add(FilterClearEvent());
|
|
||||||
|
|
||||||
if (columnIndex == 0) {
|
if (columnIndex == 0) {
|
||||||
showNameMenu(
|
showNameMenu(
|
||||||
context: context,
|
context: context,
|
||||||
@ -210,11 +207,12 @@ class UsersPage extends StatelessWidget {
|
|||||||
if (columnIndex == 2) {
|
if (columnIndex == 2) {
|
||||||
final Map<String, bool> checkboxStates = {
|
final Map<String, bool> checkboxStates = {
|
||||||
for (var item in _blocRole.jobTitle)
|
for (var item in _blocRole.jobTitle)
|
||||||
item: false, // Initialize with false
|
item: _blocRole.selectedJobTitles.contains(item),
|
||||||
};
|
};
|
||||||
final RenderBox overlay = Overlay.of(context)
|
final RenderBox overlay = Overlay.of(context)
|
||||||
.context
|
.context
|
||||||
.findRenderObject() as RenderBox;
|
.findRenderObject() as RenderBox;
|
||||||
|
|
||||||
showPopUpFilterMenu(
|
showPopUpFilterMenu(
|
||||||
position: RelativeRect.fromLTRB(
|
position: RelativeRect.fromLTRB(
|
||||||
overlay.size.width / 4,
|
overlay.size.width / 4,
|
||||||
@ -225,26 +223,28 @@ class UsersPage extends StatelessWidget {
|
|||||||
list: _blocRole.jobTitle,
|
list: _blocRole.jobTitle,
|
||||||
context: context,
|
context: context,
|
||||||
checkboxStates: checkboxStates,
|
checkboxStates: checkboxStates,
|
||||||
|
isSelected: _blocRole.currentSortOrder,
|
||||||
onOkPressed: () {
|
onOkPressed: () {
|
||||||
|
_blocRole.add(FilterClearEvent());
|
||||||
final selectedItems = checkboxStates.entries
|
final selectedItems = checkboxStates.entries
|
||||||
.where((entry) => entry.value)
|
.where((entry) => entry.value)
|
||||||
.map((entry) => entry.key)
|
.map((entry) => entry.key)
|
||||||
.toList();
|
.toList();
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
_blocRole.add(FilterUsersByJobEvent(selectedItems));
|
_blocRole.add(FilterUsersByJobEvent(
|
||||||
|
selectedJob: selectedItems,
|
||||||
|
sortOrder: _blocRole.currentSortOrder,
|
||||||
|
));
|
||||||
},
|
},
|
||||||
onSortAtoZ: () {
|
onSortAtoZ: (v) {
|
||||||
context
|
_blocRole.currentSortOrder = v;
|
||||||
.read<UserTableBloc>()
|
|
||||||
.add(const SortUsersByNameAsc());
|
|
||||||
},
|
},
|
||||||
onSortZtoA: () {
|
onSortZtoA: (v) {
|
||||||
context
|
_blocRole.currentSortOrder = v;
|
||||||
.read<UserTableBloc>()
|
|
||||||
.add(const SortUsersByNameDesc());
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (columnIndex == 3) {
|
if (columnIndex == 3) {
|
||||||
final Map<String, bool> checkboxStates = {
|
final Map<String, bool> checkboxStates = {
|
||||||
for (var item in _blocRole.roleTypes)
|
for (var item in _blocRole.roleTypes)
|
||||||
@ -263,32 +263,31 @@ class UsersPage extends StatelessWidget {
|
|||||||
list: _blocRole.roleTypes,
|
list: _blocRole.roleTypes,
|
||||||
context: context,
|
context: context,
|
||||||
checkboxStates: checkboxStates,
|
checkboxStates: checkboxStates,
|
||||||
|
isSelected: _blocRole.currentSortOrder,
|
||||||
onOkPressed: () {
|
onOkPressed: () {
|
||||||
|
_blocRole.add(FilterClearEvent());
|
||||||
final selectedItems = checkboxStates.entries
|
final selectedItems = checkboxStates.entries
|
||||||
.where((entry) => entry.value)
|
.where((entry) => entry.value)
|
||||||
.map((entry) => entry.key)
|
.map((entry) => entry.key)
|
||||||
.toList();
|
.toList();
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
context
|
context.read<UserTableBloc>().add(
|
||||||
.read<UserTableBloc>()
|
FilterUsersByRoleEvent(
|
||||||
.add(FilterUsersByRoleEvent(selectedItems));
|
selectedRoles: selectedItems,
|
||||||
|
sortOrder: _blocRole.currentSortOrder));
|
||||||
},
|
},
|
||||||
onSortAtoZ: () {
|
onSortAtoZ: (v) {
|
||||||
context
|
_blocRole.currentSortOrder = v;
|
||||||
.read<UserTableBloc>()
|
|
||||||
.add(const SortUsersByNameAsc());
|
|
||||||
},
|
},
|
||||||
onSortZtoA: () {
|
onSortZtoA: (v) {
|
||||||
context
|
_blocRole.currentSortOrder = v;
|
||||||
.read<UserTableBloc>()
|
|
||||||
.add(const SortUsersByNameDesc());
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (columnIndex == 4) {
|
if (columnIndex == 4) {
|
||||||
showDateFilterMenu(
|
showDateFilterMenu(
|
||||||
context: context,
|
context: context,
|
||||||
isSelected: _blocRole.currentSortOrderDate,
|
isSelected: _blocRole.currentSortOrder,
|
||||||
aToZTap: () {
|
aToZTap: () {
|
||||||
context
|
context
|
||||||
.read<UserTableBloc>()
|
.read<UserTableBloc>()
|
||||||
@ -319,32 +318,30 @@ class UsersPage extends StatelessWidget {
|
|||||||
list: _blocRole.createdBy,
|
list: _blocRole.createdBy,
|
||||||
context: context,
|
context: context,
|
||||||
checkboxStates: checkboxStates,
|
checkboxStates: checkboxStates,
|
||||||
|
isSelected: _blocRole.currentSortOrder,
|
||||||
onOkPressed: () {
|
onOkPressed: () {
|
||||||
|
_blocRole.add(FilterClearEvent());
|
||||||
final selectedItems = checkboxStates.entries
|
final selectedItems = checkboxStates.entries
|
||||||
.where((entry) => entry.value)
|
.where((entry) => entry.value)
|
||||||
.map((entry) => entry.key)
|
.map((entry) => entry.key)
|
||||||
.toList();
|
.toList();
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
_blocRole
|
_blocRole.add(FilterUsersByCreatedEvent(
|
||||||
.add(FilterUsersByCreatedEvent(selectedItems));
|
selectedCreatedBy: selectedItems,
|
||||||
|
sortOrder: _blocRole.currentSortOrder));
|
||||||
},
|
},
|
||||||
onSortAtoZ: () {
|
onSortAtoZ: (v) {
|
||||||
context
|
_blocRole.currentSortOrder = v;
|
||||||
.read<UserTableBloc>()
|
|
||||||
.add(const SortUsersByNameAsc());
|
|
||||||
},
|
},
|
||||||
onSortZtoA: () {
|
onSortZtoA: (v) {
|
||||||
context
|
_blocRole.currentSortOrder = v;
|
||||||
.read<UserTableBloc>()
|
|
||||||
.add(const SortUsersByNameDesc());
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (columnIndex == 7) {
|
if (columnIndex == 7) {
|
||||||
final Map<String, bool> checkboxStates = {
|
final Map<String, bool> checkboxStates = {
|
||||||
for (var item in _blocRole.status)
|
for (var item in _blocRole.status)
|
||||||
item: _blocRole.selectedCreatedBy.contains(item),
|
item: _blocRole.selectedStatuses.contains(item),
|
||||||
};
|
};
|
||||||
final RenderBox overlay = Overlay.of(context)
|
final RenderBox overlay = Overlay.of(context)
|
||||||
.context
|
.context
|
||||||
@ -359,24 +356,24 @@ class UsersPage extends StatelessWidget {
|
|||||||
list: _blocRole.status,
|
list: _blocRole.status,
|
||||||
context: context,
|
context: context,
|
||||||
checkboxStates: checkboxStates,
|
checkboxStates: checkboxStates,
|
||||||
|
isSelected: _blocRole.currentSortOrder,
|
||||||
onOkPressed: () {
|
onOkPressed: () {
|
||||||
|
_blocRole.add(FilterClearEvent());
|
||||||
|
|
||||||
final selectedItems = checkboxStates.entries
|
final selectedItems = checkboxStates.entries
|
||||||
.where((entry) => entry.value)
|
.where((entry) => entry.value)
|
||||||
.map((entry) => entry.key)
|
.map((entry) => entry.key)
|
||||||
.toList();
|
.toList();
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
_blocRole
|
_blocRole.add(FilterUsersByDeActevateEvent(
|
||||||
.add(FilterUsersByCreatedEvent(selectedItems));
|
selectedActivate: selectedItems,
|
||||||
|
sortOrder: _blocRole.currentSortOrder));
|
||||||
},
|
},
|
||||||
onSortAtoZ: () {
|
onSortAtoZ: (v) {
|
||||||
context
|
_blocRole.currentSortOrder = v;
|
||||||
.read<UserTableBloc>()
|
|
||||||
.add(const SortUsersByNameAsc());
|
|
||||||
},
|
},
|
||||||
onSortZtoA: () {
|
onSortZtoA: (v) {
|
||||||
context
|
_blocRole.currentSortOrder = v;
|
||||||
.read<UserTableBloc>()
|
|
||||||
.add(const SortUsersByNameDesc());
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -412,8 +409,8 @@ class UsersPage extends StatelessWidget {
|
|||||||
rows: state.users.map((user) {
|
rows: state.users.map((user) {
|
||||||
return [
|
return [
|
||||||
Text('${user.firstName} ${user.lastName}'),
|
Text('${user.firstName} ${user.lastName}'),
|
||||||
Text(user.email ),
|
Text(user.email),
|
||||||
Text(user.jobTitle ?? ''),
|
Text(user.jobTitle ?? '-'),
|
||||||
Text(user.roleType ?? ''),
|
Text(user.roleType ?? ''),
|
||||||
Text(user.createdDate ?? ''),
|
Text(user.createdDate ?? ''),
|
||||||
Text(user.createdTime ?? ''),
|
Text(user.createdTime ?? ''),
|
||||||
@ -476,11 +473,17 @@ class UsersPage extends StatelessWidget {
|
|||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return DeleteUserDialog(
|
return DeleteUserDialog(
|
||||||
onTapDelete: () {
|
onTapDelete: () async {
|
||||||
|
try {
|
||||||
_blocRole.add(DeleteUserEvent(
|
_blocRole.add(DeleteUserEvent(
|
||||||
user.uuid, context));
|
user.uuid, context));
|
||||||
},
|
await Future.delayed(
|
||||||
);
|
const Duration(seconds: 2));
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
).then((v) {
|
).then((v) {
|
||||||
if (v != null) {
|
if (v != null) {
|
||||||
@ -504,6 +507,7 @@ class UsersPage extends StatelessWidget {
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
width: 500,
|
width: 500,
|
||||||
child: NumberPagination(
|
child: NumberPagination(
|
||||||
|
visiblePagesCount: 4,
|
||||||
buttonRadius: 10,
|
buttonRadius: 10,
|
||||||
selectedButtonColor: ColorsManager.secondaryColor,
|
selectedButtonColor: ColorsManager.secondaryColor,
|
||||||
buttonUnSelectedBorderColor:
|
buttonUnSelectedBorderColor:
|
||||||
|
@ -48,6 +48,7 @@ class DeviceTypeTileWidget extends StatelessWidget {
|
|||||||
DeviceNameWidget(name: product.name),
|
DeviceNameWidget(name: product.name),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
CounterWidget(
|
CounterWidget(
|
||||||
|
isCreate: false,
|
||||||
initialCount: selectedProduct.count,
|
initialCount: selectedProduct.count,
|
||||||
onCountChanged: (newCount) {
|
onCountChanged: (newCount) {
|
||||||
context.read<AddDeviceTypeBloc>().add(
|
context.read<AddDeviceTypeBloc>().add(
|
||||||
|
@ -420,9 +420,10 @@ class SpaceManagementBloc
|
|||||||
await _api.deleteSpace(communityUuid, parent.uuid!);
|
await _api.deleteSpace(communityUuid, parent.uuid!);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
rethrow; // Decide whether to stop execution or continue
|
rethrow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
orderedSpaces.removeWhere((space) => parentsToDelete.contains(space));
|
||||||
|
|
||||||
for (var space in orderedSpaces) {
|
for (var space in orderedSpaces) {
|
||||||
try {
|
try {
|
||||||
|
@ -27,8 +27,7 @@ class SpaceManagementLoaded extends SpaceManagementState {
|
|||||||
required this.products,
|
required this.products,
|
||||||
this.selectedCommunity,
|
this.selectedCommunity,
|
||||||
this.selectedSpace,
|
this.selectedSpace,
|
||||||
this.spaceModels
|
this.spaceModels});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class SpaceModelManagenetLoaded extends SpaceManagementState {
|
class SpaceModelManagenetLoaded extends SpaceManagementState {
|
||||||
@ -38,14 +37,10 @@ class SpaceModelManagenetLoaded extends SpaceManagementState {
|
|||||||
class BlankState extends SpaceManagementState {
|
class BlankState extends SpaceManagementState {
|
||||||
final List<CommunityModel> communities;
|
final List<CommunityModel> communities;
|
||||||
final List<ProductModel> products;
|
final List<ProductModel> products;
|
||||||
List<SpaceTemplateModel>? spaceModels;
|
List<SpaceTemplateModel>? spaceModels;
|
||||||
|
|
||||||
|
BlankState(
|
||||||
BlankState({
|
{required this.communities, required this.products, this.spaceModels});
|
||||||
required this.communities,
|
|
||||||
required this.products,
|
|
||||||
this.spaceModels
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class SpaceCreationSuccess extends SpaceManagementState {
|
class SpaceCreationSuccess extends SpaceManagementState {
|
||||||
@ -67,7 +62,7 @@ class SpaceManagementError extends SpaceManagementState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class SpaceModelLoaded extends SpaceManagementState {
|
class SpaceModelLoaded extends SpaceManagementState {
|
||||||
final List<SpaceTemplateModel> spaceModels;
|
List<SpaceTemplateModel> spaceModels;
|
||||||
final List<ProductModel> products;
|
final List<ProductModel> products;
|
||||||
final List<CommunityModel> communities;
|
final List<CommunityModel> communities;
|
||||||
|
|
||||||
|
@ -66,4 +66,25 @@ class ProductModel {
|
|||||||
String toString() {
|
String toString() {
|
||||||
return 'ProductModel(uuid: $uuid, catName: $catName, prodId: $prodId, prodType: $prodType, name: $name, icon: $icon)';
|
return 'ProductModel(uuid: $uuid, catName: $catName, prodId: $prodId, prodType: $prodType, name: $name, icon: $icon)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) =>
|
||||||
|
identical(this, other) ||
|
||||||
|
other is ProductModel &&
|
||||||
|
runtimeType == other.runtimeType &&
|
||||||
|
uuid == other.uuid &&
|
||||||
|
catName == other.catName &&
|
||||||
|
prodId == other.prodId &&
|
||||||
|
prodType == other.prodType &&
|
||||||
|
name == other.name &&
|
||||||
|
icon == other.icon;
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode =>
|
||||||
|
uuid.hashCode ^
|
||||||
|
catName.hashCode ^
|
||||||
|
prodId.hashCode ^
|
||||||
|
prodType.hashCode ^
|
||||||
|
name.hashCode ^
|
||||||
|
icon.hashCode;
|
||||||
}
|
}
|
||||||
|
@ -137,6 +137,7 @@ class _AddDeviceWidgetState extends State<AddDeviceWidget> {
|
|||||||
_buildDeviceName(product, size),
|
_buildDeviceName(product, size),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
CounterWidget(
|
CounterWidget(
|
||||||
|
isCreate: false,
|
||||||
initialCount: selectedProduct.count,
|
initialCount: selectedProduct.count,
|
||||||
onCountChanged: (newCount) {
|
onCountChanged: (newCount) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
@ -177,7 +177,7 @@ 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)
|
entry.value.status != SpaceStatus.parentDeleted)
|
||||||
Positioned(
|
Positioned(
|
||||||
left: entry.value.position.dx,
|
left: entry.value.position.dx,
|
||||||
@ -301,7 +301,6 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
List<Tag>? tags) {
|
List<Tag>? tags) {
|
||||||
setState(() {
|
setState(() {
|
||||||
// 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);
|
||||||
SpaceModel newSpace = SpaceModel(
|
SpaceModel newSpace = SpaceModel(
|
||||||
@ -385,10 +384,10 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
|
|
||||||
void flatten(SpaceModel space) {
|
void flatten(SpaceModel space) {
|
||||||
if (space.status == SpaceStatus.deleted ||
|
if (space.status == SpaceStatus.deleted ||
|
||||||
space.status == SpaceStatus.parentDeleted) return;
|
space.status == SpaceStatus.parentDeleted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
result.add(space);
|
result.add(space);
|
||||||
|
|
||||||
for (var child in space.children) {
|
for (var child in space.children) {
|
||||||
flatten(child);
|
flatten(child);
|
||||||
}
|
}
|
||||||
@ -456,21 +455,15 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _onDelete() {
|
void _onDelete() {
|
||||||
if (widget.selectedCommunity != null &&
|
|
||||||
widget.selectedCommunity?.uuid != null &&
|
|
||||||
widget.selectedSpace == null) {
|
|
||||||
context.read<SpaceManagementBloc>().add(DeleteCommunityEvent(
|
|
||||||
communityUuid: widget.selectedCommunity!.uuid,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
if (widget.selectedSpace != null) {
|
if (widget.selectedSpace != null) {
|
||||||
setState(() {
|
setState(() {
|
||||||
for (var space in spaces) {
|
for (var space in spaces) {
|
||||||
if (space.uuid == widget.selectedSpace?.uuid) {
|
if (space.internalId == widget.selectedSpace?.internalId) {
|
||||||
space.status = SpaceStatus.deleted;
|
space.status = SpaceStatus.deleted;
|
||||||
_markChildrenAsDeleted(space);
|
_markChildrenAsDeleted(space);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_removeConnectionsForDeletedSpaces();
|
_removeConnectionsForDeletedSpaces();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,14 @@ import 'package:syncrow_web/utils/color_manager.dart';
|
|||||||
class CounterWidget extends StatefulWidget {
|
class CounterWidget extends StatefulWidget {
|
||||||
final int initialCount;
|
final int initialCount;
|
||||||
final ValueChanged<int> onCountChanged;
|
final ValueChanged<int> onCountChanged;
|
||||||
|
final bool isCreate;
|
||||||
|
|
||||||
const CounterWidget({
|
const CounterWidget(
|
||||||
Key? key,
|
{Key? key,
|
||||||
this.initialCount = 0,
|
this.initialCount = 0,
|
||||||
required this.onCountChanged,
|
required this.onCountChanged,
|
||||||
}) : super(key: key);
|
required this.isCreate})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<CounterWidget> createState() => _CounterWidgetState();
|
State<CounterWidget> createState() => _CounterWidgetState();
|
||||||
@ -53,25 +55,26 @@ class _CounterWidgetState extends State<CounterWidget> {
|
|||||||
child: Row(
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
_buildCounterButton(Icons.remove, _decrementCounter),
|
_buildCounterButton(Icons.remove, _decrementCounter,!widget.isCreate ),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Text(
|
Text(
|
||||||
'$_counter',
|
'$_counter',
|
||||||
style: theme.textTheme.bodyLarge?.copyWith(color: ColorsManager.spaceColor),
|
style: theme.textTheme.bodyLarge
|
||||||
|
?.copyWith(color: ColorsManager.spaceColor),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
_buildCounterButton(Icons.add, _incrementCounter),
|
_buildCounterButton(Icons.add, _incrementCounter, false),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildCounterButton(IconData icon, VoidCallback onPressed) {
|
Widget _buildCounterButton(IconData icon, VoidCallback onPressed, bool isDisabled) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: onPressed,
|
onTap: isDisabled? null: onPressed,
|
||||||
child: Icon(
|
child: Icon(
|
||||||
icon,
|
icon,
|
||||||
color: ColorsManager.spaceColor,
|
color: isDisabled? ColorsManager.spaceColor.withOpacity(0.3): ColorsManager.spaceColor,
|
||||||
size: 18,
|
size: 18,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -47,14 +47,13 @@ class AssignTagModelBloc
|
|||||||
}
|
}
|
||||||
|
|
||||||
emit(AssignTagModelLoaded(
|
emit(AssignTagModelLoaded(
|
||||||
tags: allTags,
|
tags: allTags,
|
||||||
isSaveEnabled: _validateTags(allTags),
|
isSaveEnabled: _validateTags(allTags),
|
||||||
));
|
errorMessage: ''));
|
||||||
});
|
});
|
||||||
|
|
||||||
on<UpdateTag>((event, emit) {
|
on<UpdateTag>((event, emit) {
|
||||||
final currentState = state;
|
final currentState = state;
|
||||||
|
|
||||||
if (currentState is AssignTagModelLoaded &&
|
if (currentState is AssignTagModelLoaded &&
|
||||||
currentState.tags.isNotEmpty) {
|
currentState.tags.isNotEmpty) {
|
||||||
final tags = List<TagModel>.from(currentState.tags);
|
final tags = List<TagModel>.from(currentState.tags);
|
||||||
@ -122,9 +121,7 @@ class AssignTagModelBloc
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool _validateTags(List<TagModel> tags) {
|
bool _validateTags(List<TagModel> tags) {
|
||||||
if (tags.isEmpty) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final uniqueTags = tags.map((tag) => tag.tag?.trim() ?? '').toSet();
|
final uniqueTags = tags.map((tag) => tag.tag?.trim() ?? '').toSet();
|
||||||
final hasEmptyTag = tags.any((tag) => (tag.tag?.trim() ?? '').isEmpty);
|
final hasEmptyTag = tags.any((tag) => (tag.tag?.trim() ?? '').isEmpty);
|
||||||
final isValid = uniqueTags.length == tags.length && !hasEmptyTag;
|
final isValid = uniqueTags.length == tags.length && !hasEmptyTag;
|
||||||
@ -133,7 +130,11 @@ class AssignTagModelBloc
|
|||||||
|
|
||||||
String? _getValidationError(List<TagModel> tags) {
|
String? _getValidationError(List<TagModel> tags) {
|
||||||
final hasEmptyTag = tags.any((tag) => (tag.tag?.trim() ?? '').isEmpty);
|
final hasEmptyTag = tags.any((tag) => (tag.tag?.trim() ?? '').isEmpty);
|
||||||
if (hasEmptyTag) return 'Tags cannot be empty.';
|
if (hasEmptyTag) {
|
||||||
|
return 'Tags cannot be empty.';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for duplicate tags
|
||||||
final duplicateTags = tags
|
final duplicateTags = tags
|
||||||
.map((tag) => tag.tag?.trim() ?? '')
|
.map((tag) => tag.tag?.trim() ?? '')
|
||||||
.fold<Map<String, int>>({}, (map, tag) {
|
.fold<Map<String, int>>({}, (map, tag) {
|
||||||
|
@ -5,7 +5,7 @@ abstract class AssignTagModelState extends Equatable {
|
|||||||
const AssignTagModelState();
|
const AssignTagModelState();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [];
|
List<Object?> get props => [];
|
||||||
}
|
}
|
||||||
|
|
||||||
class AssignTagModelInitial extends AssignTagModelState {}
|
class AssignTagModelInitial extends AssignTagModelState {}
|
||||||
@ -15,7 +15,7 @@ class AssignTagModelLoading extends AssignTagModelState {}
|
|||||||
class AssignTagModelLoaded extends AssignTagModelState {
|
class AssignTagModelLoaded extends AssignTagModelState {
|
||||||
final List<TagModel> tags;
|
final List<TagModel> tags;
|
||||||
final bool isSaveEnabled;
|
final bool isSaveEnabled;
|
||||||
final String? errorMessage;
|
final String? errorMessage;
|
||||||
|
|
||||||
const AssignTagModelLoaded({
|
const AssignTagModelLoaded({
|
||||||
required this.tags,
|
required this.tags,
|
||||||
@ -24,7 +24,7 @@ class AssignTagModelLoaded extends AssignTagModelState {
|
|||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [tags, isSaveEnabled];
|
List<Object?> get props => [tags, isSaveEnabled, errorMessage];
|
||||||
}
|
}
|
||||||
|
|
||||||
class AssignTagModelError extends AssignTagModelState {
|
class AssignTagModelError extends AssignTagModelState {
|
||||||
@ -33,5 +33,5 @@ class AssignTagModelError extends AssignTagModelState {
|
|||||||
const AssignTagModelError(this.errorMessage);
|
const AssignTagModelError(this.errorMessage);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [errorMessage];
|
List<Object?> get props => [errorMessage];
|
||||||
}
|
}
|
||||||
|
@ -9,22 +9,26 @@ import 'package:syncrow_web/pages/spaces_management/all_spaces/model/selected_pr
|
|||||||
import 'package:syncrow_web/pages/spaces_management/assign_tag_models/bloc/assign_tag_model_bloc.dart';
|
import 'package:syncrow_web/pages/spaces_management/assign_tag_models/bloc/assign_tag_model_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/assign_tag_models/bloc/assign_tag_model_event.dart';
|
import 'package:syncrow_web/pages/spaces_management/assign_tag_models/bloc/assign_tag_model_event.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/assign_tag_models/bloc/assign_tag_model_state.dart';
|
import 'package:syncrow_web/pages/spaces_management/assign_tag_models/bloc/assign_tag_model_state.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_model.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/dialog/create_space_model_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/tag_model/views/add_device_type_model_widget.dart';
|
import 'package:syncrow_web/pages/spaces_management/tag_model/views/add_device_type_model_widget.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
class AssignTagModelsDialog extends StatelessWidget {
|
class AssignTagModelsDialog extends StatelessWidget {
|
||||||
final List<ProductModel>? products;
|
final List<ProductModel>? products;
|
||||||
final List<SubspaceTemplateModel>? subspaces;
|
final List<SubspaceTemplateModel>? subspaces;
|
||||||
|
final SpaceTemplateModel? spaceModel;
|
||||||
|
|
||||||
final List<TagModel> initialTags;
|
final List<TagModel> initialTags;
|
||||||
final ValueChanged<List<TagModel>>? onTagsAssigned;
|
final ValueChanged<List<TagModel>>? onTagsAssigned;
|
||||||
final List<SelectedProduct> addedProducts;
|
final List<SelectedProduct> addedProducts;
|
||||||
final List<String>? allTags;
|
final List<String>? allTags;
|
||||||
final String spaceName;
|
final String spaceName;
|
||||||
final String title;
|
final String title;
|
||||||
final void Function(
|
final BuildContext? pageContext;
|
||||||
List<TagModel>? tags, List<SubspaceTemplateModel>? subspaces)? onUpdate;
|
final List<String>? otherSpaceModels;
|
||||||
|
|
||||||
const AssignTagModelsDialog(
|
const AssignTagModelsDialog(
|
||||||
{Key? key,
|
{Key? key,
|
||||||
@ -36,7 +40,9 @@ class AssignTagModelsDialog extends StatelessWidget {
|
|||||||
this.allTags,
|
this.allTags,
|
||||||
required this.spaceName,
|
required this.spaceName,
|
||||||
required this.title,
|
required this.title,
|
||||||
this.onUpdate})
|
this.pageContext,
|
||||||
|
this.otherSpaceModels,
|
||||||
|
this.spaceModel})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -47,249 +53,201 @@ class AssignTagModelsDialog extends StatelessWidget {
|
|||||||
..add('Main Space');
|
..add('Main Space');
|
||||||
|
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (_) => AssignTagModelBloc()
|
create: (_) => AssignTagModelBloc()
|
||||||
..add(InitializeTagModels(
|
..add(InitializeTagModels(
|
||||||
initialTags: initialTags,
|
initialTags: initialTags,
|
||||||
addedProducts: addedProducts,
|
addedProducts: addedProducts,
|
||||||
)),
|
)),
|
||||||
child: BlocBuilder<AssignTagModelBloc, AssignTagModelState>(
|
child: BlocListener<AssignTagModelBloc, AssignTagModelState>(
|
||||||
builder: (context, state) {
|
listener: (context, state) {},
|
||||||
if (state is AssignTagModelLoaded) {
|
child: BlocBuilder<AssignTagModelBloc, AssignTagModelState>(
|
||||||
final controllers = List.generate(
|
builder: (context, state) {
|
||||||
state.tags.length,
|
if (state is AssignTagModelLoaded) {
|
||||||
(index) => TextEditingController(text: state.tags[index].tag),
|
final controllers = List.generate(
|
||||||
);
|
state.tags.length,
|
||||||
|
(index) => TextEditingController(text: state.tags[index].tag),
|
||||||
|
);
|
||||||
|
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: Text(title),
|
title: Text(title),
|
||||||
backgroundColor: ColorsManager.whiteColors,
|
backgroundColor: ColorsManager.whiteColors,
|
||||||
content: SingleChildScrollView(
|
content: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
ClipRRect(
|
ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(20),
|
|
||||||
child: DataTable(
|
|
||||||
headingRowColor: WidgetStateProperty.all(
|
|
||||||
ColorsManager.dataHeaderGrey),
|
|
||||||
border: TableBorder.all(
|
|
||||||
color: ColorsManager.dataHeaderGrey,
|
|
||||||
width: 1,
|
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
),
|
child: DataTable(
|
||||||
columns: [
|
headingRowColor: WidgetStateProperty.all(
|
||||||
DataColumn(
|
ColorsManager.dataHeaderGrey),
|
||||||
label: Text('#',
|
border: TableBorder.all(
|
||||||
style:
|
color: ColorsManager.dataHeaderGrey,
|
||||||
Theme.of(context).textTheme.bodyMedium)),
|
width: 1,
|
||||||
DataColumn(
|
borderRadius: BorderRadius.circular(20),
|
||||||
label: Text('Device',
|
),
|
||||||
style:
|
columns: [
|
||||||
Theme.of(context).textTheme.bodyMedium)),
|
DataColumn(
|
||||||
DataColumn(
|
label: Text('#',
|
||||||
numeric: false,
|
style: Theme.of(context)
|
||||||
headingRowAlignment: MainAxisAlignment.start,
|
.textTheme
|
||||||
label: Text('Tag',
|
.bodyMedium)),
|
||||||
style:
|
DataColumn(
|
||||||
Theme.of(context).textTheme.bodyMedium)),
|
label: Text('Device',
|
||||||
DataColumn(
|
style: Theme.of(context)
|
||||||
label: Text('Location',
|
.textTheme
|
||||||
style:
|
.bodyMedium)),
|
||||||
Theme.of(context).textTheme.bodyMedium)),
|
DataColumn(
|
||||||
],
|
numeric: false,
|
||||||
rows: state.tags.isEmpty
|
label: Text('Tag',
|
||||||
? [
|
style: Theme.of(context)
|
||||||
const DataRow(cells: [
|
.textTheme
|
||||||
DataCell(
|
.bodyMedium)),
|
||||||
Center(
|
DataColumn(
|
||||||
child: Text(
|
label: Text('Location',
|
||||||
'No Data Available',
|
style: Theme.of(context)
|
||||||
style: TextStyle(
|
.textTheme
|
||||||
fontSize: 14,
|
.bodyMedium)),
|
||||||
color: ColorsManager.lightGrayColor,
|
],
|
||||||
|
rows: state.tags.isEmpty
|
||||||
|
? [
|
||||||
|
const DataRow(cells: [
|
||||||
|
DataCell(
|
||||||
|
Center(
|
||||||
|
child: Text(
|
||||||
|
'No Data Available',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color:
|
||||||
|
ColorsManager.lightGrayColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
DataCell(SizedBox()),
|
||||||
),
|
DataCell(SizedBox()),
|
||||||
DataCell(SizedBox()),
|
DataCell(SizedBox()),
|
||||||
DataCell(SizedBox()),
|
])
|
||||||
DataCell(SizedBox()),
|
]
|
||||||
])
|
: List.generate(state.tags.length, (index) {
|
||||||
]
|
final tag = state.tags[index];
|
||||||
: List.generate(state.tags.length, (index) {
|
final controller = controllers[index];
|
||||||
final tag = state.tags[index];
|
final availableTags = getAvailableTags(
|
||||||
final controller = controllers[index];
|
allTags ?? [], state.tags, tag);
|
||||||
final availableTags = getAvailableTags(
|
|
||||||
allTags ?? [], state.tags, tag);
|
|
||||||
|
|
||||||
return DataRow(
|
return DataRow(
|
||||||
cells: [
|
cells: [
|
||||||
DataCell(Text(index.toString())),
|
DataCell(Text((index + 1).toString())),
|
||||||
DataCell(
|
DataCell(
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment:
|
mainAxisAlignment:
|
||||||
MainAxisAlignment.spaceBetween,
|
MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
tag.product?.name ?? 'Unknown',
|
tag.product?.name ?? 'Unknown',
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
)),
|
)),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
|
Container(
|
||||||
|
width: 20.0,
|
||||||
|
height: 20.0,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
border: Border.all(
|
||||||
|
color: ColorsManager
|
||||||
|
.lightGrayColor,
|
||||||
|
width: 1.0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: IconButton(
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.close,
|
||||||
|
color: ColorsManager
|
||||||
|
.lightGreyColor,
|
||||||
|
size: 16,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
context
|
||||||
|
.read<
|
||||||
|
AssignTagModelBloc>()
|
||||||
|
.add(DeleteTagModel(
|
||||||
|
tagToDelete: tag,
|
||||||
|
tags: state.tags));
|
||||||
|
},
|
||||||
|
tooltip: 'Delete Tag',
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
constraints:
|
||||||
|
const BoxConstraints(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
DataCell(
|
||||||
Container(
|
Container(
|
||||||
width: 20.0,
|
alignment: Alignment
|
||||||
height: 20.0,
|
.centerLeft, // Align cell content to the left
|
||||||
decoration: BoxDecoration(
|
child: SizedBox(
|
||||||
shape: BoxShape.circle,
|
width: double
|
||||||
border: Border.all(
|
.infinity, // Ensure full width for dropdown
|
||||||
color: ColorsManager
|
child: DialogTextfieldDropdown(
|
||||||
.lightGrayColor,
|
items: availableTags,
|
||||||
width: 1.0,
|
initialValue: tag.tag,
|
||||||
|
onSelected: (value) {
|
||||||
|
controller.text = value;
|
||||||
|
context
|
||||||
|
.read<
|
||||||
|
AssignTagModelBloc>()
|
||||||
|
.add(UpdateTag(
|
||||||
|
index: index,
|
||||||
|
tag: value,
|
||||||
|
));
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: IconButton(
|
|
||||||
icon: const Icon(
|
|
||||||
Icons.close,
|
|
||||||
color: ColorsManager
|
|
||||||
.lightGreyColor,
|
|
||||||
size: 16,
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
context
|
|
||||||
.read<AssignTagModelBloc>()
|
|
||||||
.add(DeleteTagModel(
|
|
||||||
tagToDelete: tag,
|
|
||||||
tags: state.tags));
|
|
||||||
},
|
|
||||||
tooltip: 'Delete Tag',
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
constraints:
|
|
||||||
const BoxConstraints(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
DataCell(
|
|
||||||
Container(
|
|
||||||
alignment: Alignment
|
|
||||||
.centerLeft, // Align cell content to the left
|
|
||||||
child: SizedBox(
|
|
||||||
width: double
|
|
||||||
.infinity, // Ensure full width for dropdown
|
|
||||||
child: DialogTextfieldDropdown(
|
|
||||||
items: availableTags,
|
|
||||||
initialValue: tag.tag,
|
|
||||||
onSelected: (value) {
|
|
||||||
controller.text = value;
|
|
||||||
context
|
|
||||||
.read<AssignTagModelBloc>()
|
|
||||||
.add(UpdateTag(
|
|
||||||
index: index,
|
|
||||||
tag: value,
|
|
||||||
));
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
DataCell(
|
||||||
),
|
SizedBox(
|
||||||
DataCell(
|
width: double.infinity,
|
||||||
SizedBox(
|
child: DialogDropdown(
|
||||||
width: double.infinity,
|
items: locations,
|
||||||
child: DialogDropdown(
|
selectedValue:
|
||||||
items: locations,
|
tag.location ?? 'Main Space',
|
||||||
selectedValue:
|
onSelected: (value) {
|
||||||
tag.location ?? 'None',
|
context
|
||||||
onSelected: (value) {
|
.read<
|
||||||
context
|
AssignTagModelBloc>()
|
||||||
.read<AssignTagModelBloc>()
|
.add(UpdateLocation(
|
||||||
.add(UpdateLocation(
|
index: index,
|
||||||
index: index,
|
location: value,
|
||||||
location: value,
|
));
|
||||||
));
|
},
|
||||||
},
|
)),
|
||||||
)),
|
),
|
||||||
),
|
],
|
||||||
],
|
);
|
||||||
);
|
}),
|
||||||
}),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
if (state.errorMessage != null)
|
|
||||||
Text(
|
|
||||||
state.errorMessage!,
|
|
||||||
style: const TextStyle(color: ColorsManager.warningRed),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
actions: [
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
||||||
children: [
|
|
||||||
const SizedBox(width: 10),
|
|
||||||
Expanded(
|
|
||||||
child: Builder(
|
|
||||||
builder: (buttonContext) => CancelButton(
|
|
||||||
label: 'Add New Device',
|
|
||||||
onPressed: () async {
|
|
||||||
for (var tag in state.tags) {
|
|
||||||
if (tag.location == null || subspaces == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
final previousTagSubspace =
|
|
||||||
checkTagExistInSubspace(tag, subspaces ?? []);
|
|
||||||
|
|
||||||
if (tag.location == 'Main Space') {
|
|
||||||
removeTagFromSubspace(tag, previousTagSubspace);
|
|
||||||
} else if (tag.location !=
|
|
||||||
previousTagSubspace?.subspaceName) {
|
|
||||||
removeTagFromSubspace(tag, previousTagSubspace);
|
|
||||||
moveToNewSubspace(tag, subspaces ?? []);
|
|
||||||
state.tags.removeWhere(
|
|
||||||
(t) => t.internalId == tag.internalId);
|
|
||||||
} else {
|
|
||||||
updateTagInSubspace(tag, previousTagSubspace);
|
|
||||||
state.tags.removeWhere(
|
|
||||||
(t) => t.internalId == tag.internalId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (context.mounted) {
|
|
||||||
await showDialog<bool>(
|
|
||||||
barrierDismissible: false,
|
|
||||||
context: context,
|
|
||||||
builder: (dialogContext) =>
|
|
||||||
AddDeviceTypeModelWidget(
|
|
||||||
products: products,
|
|
||||||
subspaces: subspaces,
|
|
||||||
isCreate: false,
|
|
||||||
initialSelectedProducts: addedProducts,
|
|
||||||
allTags: allTags,
|
|
||||||
spaceName: spaceName,
|
|
||||||
spaceTagModels: state.tags,
|
|
||||||
onUpdate: (tags, subspaces) {
|
|
||||||
onUpdate?.call(state.tags, subspaces);
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
if (state.errorMessage != null)
|
||||||
|
Text(
|
||||||
|
state.errorMessage!,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: ColorsManager.warningRed),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(width: 10),
|
),
|
||||||
Expanded(
|
actions: [
|
||||||
child: DefaultButton(
|
Row(
|
||||||
borderRadius: 10,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
backgroundColor: state.isSaveEnabled
|
children: [
|
||||||
? ColorsManager.secondaryColor
|
const SizedBox(width: 10),
|
||||||
: ColorsManager.grayColor,
|
Expanded(
|
||||||
foregroundColor: ColorsManager.whiteColors,
|
child: Builder(
|
||||||
onPressed: state.isSaveEnabled
|
builder: (buttonContext) => CancelButton(
|
||||||
? () async {
|
label: 'Add New Device',
|
||||||
Navigator.of(context).pop();
|
onPressed: () async {
|
||||||
|
|
||||||
for (var tag in state.tags) {
|
for (var tag in state.tags) {
|
||||||
if (tag.location == null ||
|
if (tag.location == null ||
|
||||||
subspaces == null) {
|
subspaces == null) {
|
||||||
@ -317,26 +275,113 @@ class AssignTagModelsDialog extends StatelessWidget {
|
|||||||
(t) => t.internalId == tag.internalId);
|
(t) => t.internalId == tag.internalId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (context.mounted) {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
|
||||||
onUpdate?.call(state.tags, subspaces);
|
await showDialog<bool>(
|
||||||
}
|
barrierDismissible: false,
|
||||||
: null,
|
context: context,
|
||||||
child: const Text('Save'),
|
builder: (dialogContext) =>
|
||||||
),
|
AddDeviceTypeModelWidget(
|
||||||
|
products: products,
|
||||||
|
subspaces: subspaces,
|
||||||
|
isCreate: false,
|
||||||
|
initialSelectedProducts:
|
||||||
|
addedProducts,
|
||||||
|
allTags: allTags,
|
||||||
|
spaceName: spaceName,
|
||||||
|
otherSpaceModels: otherSpaceModels,
|
||||||
|
spaceTagModels: state.tags,
|
||||||
|
pageContext: pageContext,
|
||||||
|
spaceModel: SpaceTemplateModel(
|
||||||
|
modelName: spaceName,
|
||||||
|
tags: state.tags,
|
||||||
|
uuid: spaceModel?.uuid,
|
||||||
|
internalId:
|
||||||
|
spaceModel?.internalId,
|
||||||
|
subspaceModels: subspaces)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Expanded(
|
||||||
|
child: DefaultButton(
|
||||||
|
borderRadius: 10,
|
||||||
|
backgroundColor: state.isSaveEnabled
|
||||||
|
? ColorsManager.secondaryColor
|
||||||
|
: ColorsManager.grayColor,
|
||||||
|
foregroundColor: ColorsManager.whiteColors,
|
||||||
|
onPressed: state.isSaveEnabled
|
||||||
|
? () async {
|
||||||
|
for (var tag in state.tags) {
|
||||||
|
if (tag.location == null ||
|
||||||
|
subspaces == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
final previousTagSubspace =
|
||||||
|
checkTagExistInSubspace(
|
||||||
|
tag, subspaces ?? []);
|
||||||
|
|
||||||
|
if (tag.location == 'Main Space') {
|
||||||
|
removeTagFromSubspace(
|
||||||
|
tag, previousTagSubspace);
|
||||||
|
} else if (tag.location !=
|
||||||
|
previousTagSubspace?.subspaceName) {
|
||||||
|
removeTagFromSubspace(
|
||||||
|
tag, previousTagSubspace);
|
||||||
|
moveToNewSubspace(tag, subspaces ?? []);
|
||||||
|
state.tags.removeWhere((t) =>
|
||||||
|
t.internalId == tag.internalId);
|
||||||
|
} else {
|
||||||
|
updateTagInSubspace(
|
||||||
|
tag, previousTagSubspace);
|
||||||
|
state.tags.removeWhere((t) =>
|
||||||
|
t.internalId == tag.internalId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Navigator.of(context)
|
||||||
|
.popUntil((route) => route.isFirst);
|
||||||
|
|
||||||
|
await showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext dialogContext) {
|
||||||
|
return CreateSpaceModelDialog(
|
||||||
|
products: products,
|
||||||
|
allTags: allTags,
|
||||||
|
pageContext: pageContext,
|
||||||
|
otherSpaceModels: otherSpaceModels,
|
||||||
|
spaceModel: SpaceTemplateModel(
|
||||||
|
modelName: spaceName,
|
||||||
|
tags: state.tags,
|
||||||
|
uuid: spaceModel?.uuid,
|
||||||
|
internalId:
|
||||||
|
spaceModel?.internalId,
|
||||||
|
subspaceModels: subspaces),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
child: const Text('Save'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(width: 10),
|
|
||||||
],
|
],
|
||||||
),
|
);
|
||||||
],
|
} else if (state is AssignTagModelLoading) {
|
||||||
);
|
return const Center(child: CircularProgressIndicator());
|
||||||
} else if (state is AssignTagModelLoading) {
|
} else {
|
||||||
return const Center(child: CircularProgressIndicator());
|
return const Center(child: Text('Something went wrong.'));
|
||||||
} else {
|
}
|
||||||
return const Center(child: Text('Something went wrong.'));
|
},
|
||||||
}
|
),
|
||||||
},
|
));
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> getAvailableTags(
|
List<String> getAvailableTags(
|
||||||
|
@ -186,8 +186,7 @@ class CreateSubSpaceModelDialog extends StatelessWidget {
|
|||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
onPressed: (state.subSpaces.isEmpty ||
|
onPressed: (state.errorMessage.isNotEmpty)
|
||||||
state.errorMessage.isNotEmpty)
|
|
||||||
? null
|
? null
|
||||||
: () async {
|
: () async {
|
||||||
final subSpaces = context
|
final subSpaces = context
|
||||||
@ -201,8 +200,7 @@ class CreateSubSpaceModelDialog extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
backgroundColor: ColorsManager.secondaryColor,
|
backgroundColor: ColorsManager.secondaryColor,
|
||||||
borderRadius: 10,
|
borderRadius: 10,
|
||||||
foregroundColor: state.subSpaces.isEmpty ||
|
foregroundColor: state.errorMessage.isNotEmpty
|
||||||
state.errorMessage.isNotEmpty
|
|
||||||
? ColorsManager.whiteColorsWithOpacity
|
? ColorsManager.whiteColorsWithOpacity
|
||||||
: ColorsManager.whiteColors,
|
: ColorsManager.whiteColors,
|
||||||
child: const Text('OK'),
|
child: const Text('OK'),
|
||||||
|
@ -37,7 +37,8 @@ class TagHelper {
|
|||||||
final Map<ProductModel, int> groupedTags = {};
|
final Map<ProductModel, int> groupedTags = {};
|
||||||
for (var tag in tags) {
|
for (var tag in tags) {
|
||||||
if (tag.product != null) {
|
if (tag.product != null) {
|
||||||
groupedTags[tag.product!] = (groupedTags[tag.product!] ?? 0) + 1;
|
final product = tag.product!;
|
||||||
|
groupedTags[product] = (groupedTags[product] ?? 0) + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return groupedTags;
|
return groupedTags;
|
||||||
|
@ -5,7 +5,9 @@ import 'package:syncrow_web/pages/spaces_management/space_model/models/create_sp
|
|||||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_model.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_update_model.dart';
|
||||||
import 'package:syncrow_web/services/space_model_mang_api.dart';
|
import 'package:syncrow_web/services/space_model_mang_api.dart';
|
||||||
|
import 'package:syncrow_web/utils/constants/action_enum.dart';
|
||||||
|
|
||||||
class CreateSpaceModelBloc
|
class CreateSpaceModelBloc
|
||||||
extends Bloc<CreateSpaceModelEvent, CreateSpaceModelState> {
|
extends Bloc<CreateSpaceModelEvent, CreateSpaceModelState> {
|
||||||
@ -172,7 +174,12 @@ class CreateSpaceModelBloc
|
|||||||
on<UpdateSpaceTemplateName>((event, emit) {
|
on<UpdateSpaceTemplateName>((event, emit) {
|
||||||
final currentState = state;
|
final currentState = state;
|
||||||
if (currentState is CreateSpaceModelLoaded) {
|
if (currentState is CreateSpaceModelLoaded) {
|
||||||
if (event.name.trim().isEmpty) {
|
if (event.allModels.contains(event.name) == true) {
|
||||||
|
emit(CreateSpaceModelLoaded(
|
||||||
|
currentState.space,
|
||||||
|
errorMessage: "Duplicate Model name",
|
||||||
|
));
|
||||||
|
} else if (event.name.trim().isEmpty) {
|
||||||
emit(CreateSpaceModelLoaded(
|
emit(CreateSpaceModelLoaded(
|
||||||
currentState.space,
|
currentState.space,
|
||||||
errorMessage: "Model name cannot be empty",
|
errorMessage: "Model name cannot be empty",
|
||||||
@ -187,5 +194,160 @@ class CreateSpaceModelBloc
|
|||||||
emit(CreateSpaceModelError("Space template not initialized"));
|
emit(CreateSpaceModelError("Space template not initialized"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
on<ModifySpaceTemplate>((event, emit) async {
|
||||||
|
try {
|
||||||
|
final prevSpaceModel = event.spaceTemplate;
|
||||||
|
final newSpaceModel = event.updatedSpaceTemplate;
|
||||||
|
String? spaceModelName;
|
||||||
|
if (prevSpaceModel.modelName != newSpaceModel.modelName) {
|
||||||
|
spaceModelName = newSpaceModel.modelName;
|
||||||
|
}
|
||||||
|
List<TagModelUpdate> tagUpdates = [];
|
||||||
|
final List<UpdateSubspaceTemplateModel> subspaceUpdates = [];
|
||||||
|
final List<SubspaceTemplateModel>? prevSubspaces =
|
||||||
|
prevSpaceModel.subspaceModels;
|
||||||
|
final List<SubspaceTemplateModel>? newSubspaces =
|
||||||
|
newSpaceModel.subspaceModels;
|
||||||
|
|
||||||
|
tagUpdates = processTagUpdates(prevSpaceModel.tags, newSpaceModel.tags);
|
||||||
|
|
||||||
|
if (prevSubspaces != null || newSubspaces != null) {
|
||||||
|
if (prevSubspaces != null && newSubspaces != null) {
|
||||||
|
for (var prevSubspace in prevSubspaces!) {
|
||||||
|
final existsInNew = newSubspaces!
|
||||||
|
.any((newTag) => newTag.uuid == prevSubspace.uuid);
|
||||||
|
if (!existsInNew) {
|
||||||
|
subspaceUpdates.add(UpdateSubspaceTemplateModel(
|
||||||
|
action: Action.delete, uuid: prevSubspace.uuid));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (prevSubspaces != null && newSubspaces == null) {
|
||||||
|
for (var prevSubspace in prevSubspaces) {
|
||||||
|
subspaceUpdates.add(UpdateSubspaceTemplateModel(
|
||||||
|
action: Action.delete, uuid: prevSubspace.uuid));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newSubspaces != null) {
|
||||||
|
for (var newSubspace in newSubspaces!) {
|
||||||
|
// Tag without UUID
|
||||||
|
if ((newSubspace.uuid == null || newSubspace.uuid!.isEmpty)) {
|
||||||
|
final List<TagModelUpdate> tagUpdates = [];
|
||||||
|
|
||||||
|
if (newSubspace.tags != null) {
|
||||||
|
for (var tag in newSubspace.tags!) {
|
||||||
|
tagUpdates.add(TagModelUpdate(
|
||||||
|
action: Action.add,
|
||||||
|
tag: tag.tag,
|
||||||
|
productUuid: tag.product?.uuid));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
subspaceUpdates.add(UpdateSubspaceTemplateModel(
|
||||||
|
action: Action.add,
|
||||||
|
subspaceName: newSubspace.subspaceName,
|
||||||
|
tags: tagUpdates));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prevSubspaces != null && newSubspaces != null) {
|
||||||
|
final newSubspaceMap = {
|
||||||
|
for (var subspace in newSubspaces!) subspace.uuid: subspace
|
||||||
|
};
|
||||||
|
|
||||||
|
for (var prevSubspace in prevSubspaces!) {
|
||||||
|
final newSubspace = newSubspaceMap[prevSubspace.uuid];
|
||||||
|
if (newSubspace != null) {
|
||||||
|
final List<TagModelUpdate> tagSubspaceUpdates =
|
||||||
|
processTagUpdates(prevSubspace.tags, newSubspace.tags);
|
||||||
|
subspaceUpdates.add(UpdateSubspaceTemplateModel(
|
||||||
|
action: Action.update,
|
||||||
|
uuid: newSubspace.uuid,
|
||||||
|
subspaceName: newSubspace.subspaceName,
|
||||||
|
tags: tagSubspaceUpdates));
|
||||||
|
} else {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final spaceModelBody = CreateSpaceTemplateBodyModel(
|
||||||
|
modelName: spaceModelName,
|
||||||
|
tags: tagUpdates,
|
||||||
|
subspaceModels: subspaceUpdates);
|
||||||
|
|
||||||
|
final res = await _api.updateSpaceModel(
|
||||||
|
spaceModelBody, prevSpaceModel.uuid ?? '');
|
||||||
|
|
||||||
|
if (res != null) {
|
||||||
|
emit(CreateSpaceModelLoaded(newSpaceModel));
|
||||||
|
if (event.onUpdate != null) {
|
||||||
|
event.onUpdate!(event.updatedSpaceTemplate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
emit(CreateSpaceModelError('Error creating space model'));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
List<TagModelUpdate> processTagUpdates(
|
||||||
|
List<TagModel>? prevTags,
|
||||||
|
List<TagModel>? newTags,
|
||||||
|
) {
|
||||||
|
final List<TagModelUpdate> tagUpdates = [];
|
||||||
|
final processedTags = <String?>{};
|
||||||
|
|
||||||
|
if (newTags != null || prevTags != null) {
|
||||||
|
// Case 1: Tags deleted
|
||||||
|
if (prevTags != null && newTags != null) {
|
||||||
|
for (var prevTag in prevTags!) {
|
||||||
|
final existsInNew =
|
||||||
|
newTags!.any((newTag) => newTag.uuid == prevTag.uuid);
|
||||||
|
if (!existsInNew) {
|
||||||
|
tagUpdates
|
||||||
|
.add(TagModelUpdate(action: Action.delete, uuid: prevTag.uuid));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (prevTags != null && newTags == null) {
|
||||||
|
for (var prevTag in prevTags) {
|
||||||
|
tagUpdates
|
||||||
|
.add(TagModelUpdate(action: Action.delete, uuid: prevTag.uuid));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Case 2: Tags added
|
||||||
|
if (newTags != null) {
|
||||||
|
for (var newTag in newTags!) {
|
||||||
|
// Tag without UUID
|
||||||
|
if ((newTag.uuid == null || newTag.uuid!.isEmpty) &&
|
||||||
|
!processedTags.contains(newTag.tag)) {
|
||||||
|
tagUpdates.add(TagModelUpdate(
|
||||||
|
action: Action.add,
|
||||||
|
tag: newTag.tag,
|
||||||
|
productUuid: newTag.product?.uuid));
|
||||||
|
processedTags.add(newTag.tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Case 3: Tags updated
|
||||||
|
if (prevTags != null && newTags != null) {
|
||||||
|
final newTagMap = {for (var tag in newTags!) tag.uuid: tag};
|
||||||
|
|
||||||
|
for (var prevTag in prevTags!) {
|
||||||
|
final newTag = newTagMap[prevTag.uuid];
|
||||||
|
if (newTag != null) {
|
||||||
|
tagUpdates.add(TagModelUpdate(
|
||||||
|
action: Action.update,
|
||||||
|
uuid: newTag.uuid,
|
||||||
|
tag: newTag.tag,
|
||||||
|
));
|
||||||
|
} else {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tagUpdates;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ class CreateSpaceTemplate extends CreateSpaceModelEvent {
|
|||||||
final SpaceTemplateModel spaceTemplate;
|
final SpaceTemplateModel spaceTemplate;
|
||||||
final Function(SpaceTemplateModel)? onCreate;
|
final Function(SpaceTemplateModel)? onCreate;
|
||||||
|
|
||||||
|
|
||||||
const CreateSpaceTemplate({
|
const CreateSpaceTemplate({
|
||||||
required this.spaceTemplate,
|
required this.spaceTemplate,
|
||||||
this.onCreate,
|
this.onCreate,
|
||||||
@ -34,11 +33,12 @@ class CreateSpaceTemplate extends CreateSpaceModelEvent {
|
|||||||
|
|
||||||
class UpdateSpaceTemplateName extends CreateSpaceModelEvent {
|
class UpdateSpaceTemplateName extends CreateSpaceModelEvent {
|
||||||
final String name;
|
final String name;
|
||||||
|
final List<String> allModels;
|
||||||
|
|
||||||
UpdateSpaceTemplateName({required this.name});
|
UpdateSpaceTemplateName({required this.name, required this.allModels});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [name];
|
List<Object> get props => [name, allModels];
|
||||||
}
|
}
|
||||||
|
|
||||||
class AddSubspacesToSpaceTemplate extends CreateSpaceModelEvent {
|
class AddSubspacesToSpaceTemplate extends CreateSpaceModelEvent {
|
||||||
@ -53,9 +53,19 @@ class AddTagsToSpaceTemplate extends CreateSpaceModelEvent {
|
|||||||
AddTagsToSpaceTemplate(this.tags);
|
AddTagsToSpaceTemplate(this.tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class ValidateSpaceTemplateName extends CreateSpaceModelEvent {
|
class ValidateSpaceTemplateName extends CreateSpaceModelEvent {
|
||||||
final String name;
|
final String name;
|
||||||
|
|
||||||
ValidateSpaceTemplateName({required this.name});
|
ValidateSpaceTemplateName({required this.name});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ModifySpaceTemplate extends CreateSpaceModelEvent {
|
||||||
|
final SpaceTemplateModel spaceTemplate;
|
||||||
|
final SpaceTemplateModel updatedSpaceTemplate;
|
||||||
|
final Function(SpaceTemplateModel)? onUpdate;
|
||||||
|
|
||||||
|
ModifySpaceTemplate(
|
||||||
|
{required this.spaceTemplate,
|
||||||
|
required this.updatedSpaceTemplate,
|
||||||
|
this.onUpdate});
|
||||||
|
}
|
||||||
|
@ -12,6 +12,7 @@ class SpaceModelBloc extends Bloc<SpaceModelEvent, SpaceModelState> {
|
|||||||
required List<SpaceTemplateModel> initialSpaceModels,
|
required List<SpaceTemplateModel> initialSpaceModels,
|
||||||
}) : super(SpaceModelLoaded(spaceModels: initialSpaceModels)) {
|
}) : super(SpaceModelLoaded(spaceModels: initialSpaceModels)) {
|
||||||
on<CreateSpaceModel>(_onCreateSpaceModel);
|
on<CreateSpaceModel>(_onCreateSpaceModel);
|
||||||
|
on<UpdateSpaceModel>(_onUpdateSpaceModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onCreateSpaceModel(
|
Future<void> _onCreateSpaceModel(
|
||||||
@ -33,4 +34,23 @@ class SpaceModelBloc extends Bloc<SpaceModelEvent, SpaceModelState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _onUpdateSpaceModel(
|
||||||
|
UpdateSpaceModel event, Emitter<SpaceModelState> emit) async {
|
||||||
|
final currentState = state;
|
||||||
|
if (currentState is SpaceModelLoaded) {
|
||||||
|
try {
|
||||||
|
final newSpaceModel =
|
||||||
|
await api.getSpaceModel(event.spaceModelUuid ?? '');
|
||||||
|
if (newSpaceModel != null) {
|
||||||
|
final updatedSpaceModels = currentState.spaceModels.map((model) {
|
||||||
|
return model.uuid == event.spaceModelUuid ? newSpaceModel : model;
|
||||||
|
}).toList();
|
||||||
|
emit(SpaceModelLoaded(spaceModels: updatedSpaceModels));
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
emit(SpaceModelError(message: e.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,3 +16,21 @@ class CreateSpaceModel extends SpaceModelEvent {
|
|||||||
@override
|
@override
|
||||||
List<Object?> get props => [newSpaceModel];
|
List<Object?> get props => [newSpaceModel];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class GetSpaceModel extends SpaceModelEvent {
|
||||||
|
final String spaceModelUuid;
|
||||||
|
|
||||||
|
GetSpaceModel({required this.spaceModelUuid});
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [spaceModelUuid];
|
||||||
|
}
|
||||||
|
|
||||||
|
class UpdateSpaceModel extends SpaceModelEvent {
|
||||||
|
final String spaceModelUuid;
|
||||||
|
|
||||||
|
UpdateSpaceModel({required this.spaceModelUuid});
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [spaceModelUuid];
|
||||||
|
}
|
||||||
|
@ -30,12 +30,12 @@ class CreateSubspaceTemplateModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class CreateSpaceTemplateBodyModel {
|
class CreateSpaceTemplateBodyModel {
|
||||||
final String modelName;
|
final String? modelName;
|
||||||
final List<dynamic>? tags;
|
final List<dynamic>? tags;
|
||||||
final List<dynamic>? subspaceModels;
|
final List<dynamic>? subspaceModels;
|
||||||
|
|
||||||
CreateSpaceTemplateBodyModel({
|
CreateSpaceTemplateBodyModel({
|
||||||
required this.modelName,
|
this.modelName,
|
||||||
this.tags,
|
this.tags,
|
||||||
this.subspaceModels,
|
this.subspaceModels,
|
||||||
});
|
});
|
||||||
@ -47,4 +47,9 @@ class CreateSpaceTemplateBodyModel {
|
|||||||
'subspaceModels': subspaceModels,
|
'subspaceModels': subspaceModels,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return toJson().toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import 'package:equatable/equatable.dart';
|
|||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_model.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_update_model.dart';
|
||||||
import 'package:syncrow_web/utils/constants/action_enum.dart';
|
import 'package:syncrow_web/utils/constants/action_enum.dart';
|
||||||
import 'package:uuid/uuid.dart';
|
import 'package:uuid/uuid.dart';
|
||||||
|
|
||||||
@ -70,14 +71,14 @@ class SpaceTemplateModel extends Equatable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class UpdateSubspaceTemplateModel {
|
class UpdateSubspaceTemplateModel {
|
||||||
final String uuid;
|
final String? uuid;
|
||||||
final Action action;
|
final Action action;
|
||||||
final String? subspaceName;
|
final String? subspaceName;
|
||||||
final List<UpdateTagModel>? tags;
|
final List<TagModelUpdate>? tags;
|
||||||
|
|
||||||
UpdateSubspaceTemplateModel({
|
UpdateSubspaceTemplateModel({
|
||||||
required this.action,
|
required this.action,
|
||||||
required this.uuid,
|
this.uuid,
|
||||||
this.subspaceName,
|
this.subspaceName,
|
||||||
this.tags,
|
this.tags,
|
||||||
});
|
});
|
||||||
@ -88,7 +89,7 @@ class UpdateSubspaceTemplateModel {
|
|||||||
uuid: json['uuid'] ?? '',
|
uuid: json['uuid'] ?? '',
|
||||||
subspaceName: json['subspaceName'] ?? '',
|
subspaceName: json['subspaceName'] ?? '',
|
||||||
tags: (json['tags'] as List)
|
tags: (json['tags'] as List)
|
||||||
.map((item) => UpdateTagModel.fromJson(item))
|
.map((item) => TagModelUpdate.fromJson(item))
|
||||||
.toList(),
|
.toList(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -103,44 +104,6 @@ class UpdateSubspaceTemplateModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class UpdateTagModel {
|
|
||||||
final Action action;
|
|
||||||
final String? uuid;
|
|
||||||
final String tag;
|
|
||||||
final bool disabled;
|
|
||||||
final ProductModel? product;
|
|
||||||
|
|
||||||
UpdateTagModel({
|
|
||||||
required this.action,
|
|
||||||
this.uuid,
|
|
||||||
required this.tag,
|
|
||||||
required this.disabled,
|
|
||||||
this.product,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory UpdateTagModel.fromJson(Map<String, dynamic> json) {
|
|
||||||
return UpdateTagModel(
|
|
||||||
action: ActionExtension.fromValue(json['action']),
|
|
||||||
uuid: json['uuid'] ?? '',
|
|
||||||
tag: json['tag'] ?? '',
|
|
||||||
disabled: json['disabled'] ?? false,
|
|
||||||
product: json['product'] != null
|
|
||||||
? ProductModel.fromMap(json['product'])
|
|
||||||
: null,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
return {
|
|
||||||
'action': action.value,
|
|
||||||
'uuid': uuid,
|
|
||||||
'tag': tag,
|
|
||||||
'disabled': disabled,
|
|
||||||
'product': product?.toMap(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extension SpaceTemplateExtensions on SpaceTemplateModel {
|
extension SpaceTemplateExtensions on SpaceTemplateModel {
|
||||||
List<String> listAllTagValues() {
|
List<String> listAllTagValues() {
|
||||||
final List<String> tagValues = [];
|
final List<String> tagValues = [];
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
import 'package:syncrow_web/utils/constants/action_enum.dart';
|
||||||
|
|
||||||
|
class TagModelUpdate {
|
||||||
|
final Action action;
|
||||||
|
final String? uuid;
|
||||||
|
final String? tag;
|
||||||
|
final String? productUuid;
|
||||||
|
|
||||||
|
TagModelUpdate({
|
||||||
|
required this.action,
|
||||||
|
this.uuid,
|
||||||
|
this.tag,
|
||||||
|
this.productUuid,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory TagModelUpdate.fromJson(Map<String, dynamic> json) {
|
||||||
|
return TagModelUpdate(
|
||||||
|
action: json['action'],
|
||||||
|
uuid: json['uuid'],
|
||||||
|
tag: json['tag'],
|
||||||
|
productUuid: json['productUuid'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to convert an instance to JSON
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'action': action.value,
|
||||||
|
'uuid': uuid, // Nullable field
|
||||||
|
'tag': tag,
|
||||||
|
'productUuid': productUuid,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/space_model_bloc.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/space_model_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/space_model_event.dart';
|
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/space_model_state.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/space_model_state.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/add_space_model_widget.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/add_space_model_widget.dart';
|
||||||
@ -24,6 +23,7 @@ class SpaceModelPage extends StatelessWidget {
|
|||||||
} else if (state is SpaceModelLoaded) {
|
} else if (state is SpaceModelLoaded) {
|
||||||
final spaceModels = state.spaceModels;
|
final spaceModels = state.spaceModels;
|
||||||
final allTagValues = _getAllTagValues(spaceModels);
|
final allTagValues = _getAllTagValues(spaceModels);
|
||||||
|
final allSpaceModelNames = _getAllSpaceModelName(spaceModels);
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: ColorsManager.whiteColors,
|
backgroundColor: ColorsManager.whiteColors,
|
||||||
@ -52,12 +52,8 @@ class SpaceModelPage extends StatelessWidget {
|
|||||||
return CreateSpaceModelDialog(
|
return CreateSpaceModelDialog(
|
||||||
products: products,
|
products: products,
|
||||||
allTags: allTagValues,
|
allTags: allTagValues,
|
||||||
onLoad: (newModel) {
|
pageContext: context,
|
||||||
context.read<SpaceModelBloc>().add(
|
otherSpaceModels: allSpaceModelNames,
|
||||||
CreateSpaceModel(
|
|
||||||
newSpaceModel: newModel),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -67,6 +63,8 @@ class SpaceModelPage extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
// Render existing space model
|
// Render existing space model
|
||||||
final model = spaceModels[index];
|
final model = spaceModels[index];
|
||||||
|
final otherModel = List<String>.from(allSpaceModelNames);
|
||||||
|
otherModel.remove(model.modelName);
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
showDialog(
|
showDialog(
|
||||||
@ -76,7 +74,8 @@ class SpaceModelPage extends StatelessWidget {
|
|||||||
products: products,
|
products: products,
|
||||||
allTags: allTagValues,
|
allTags: allTagValues,
|
||||||
spaceModel: model,
|
spaceModel: model,
|
||||||
onLoad: (newModel) {},
|
otherSpaceModels: otherModel,
|
||||||
|
pageContext: context,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -128,4 +127,12 @@ class SpaceModelPage extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
return allTags;
|
return allTags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<String> _getAllSpaceModelName(List<SpaceTemplateModel> spaceModels) {
|
||||||
|
final List<String> names = [];
|
||||||
|
for (final spaceModel in spaceModels) {
|
||||||
|
names.add(spaceModel.modelName);
|
||||||
|
}
|
||||||
|
return names;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,11 @@ import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_mod
|
|||||||
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/create_space_model_bloc.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/create_space_model_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/create_space_model_event.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/create_space_model_event.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/create_space_model_state.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/create_space_model_state.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/space_model_state.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/tag_chips_display_widget.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/tag_chips_display_widget.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/space_model_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/space_model_event.dart';
|
||||||
|
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/subspace_model_create_widget.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/subspace_model_create_widget.dart';
|
||||||
import 'package:syncrow_web/services/space_model_mang_api.dart';
|
import 'package:syncrow_web/services/space_model_mang_api.dart';
|
||||||
@ -17,15 +20,17 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
|||||||
final List<ProductModel>? products;
|
final List<ProductModel>? products;
|
||||||
final List<String>? allTags;
|
final List<String>? allTags;
|
||||||
final SpaceTemplateModel? spaceModel;
|
final SpaceTemplateModel? spaceModel;
|
||||||
final void Function(SpaceTemplateModel newModel)? onLoad;
|
final BuildContext? pageContext;
|
||||||
|
final List<String>? otherSpaceModels;
|
||||||
|
|
||||||
const CreateSpaceModelDialog({
|
const CreateSpaceModelDialog(
|
||||||
Key? key,
|
{Key? key,
|
||||||
this.products,
|
this.products,
|
||||||
this.allTags,
|
this.allTags,
|
||||||
this.spaceModel,
|
this.spaceModel,
|
||||||
this.onLoad,
|
this.pageContext,
|
||||||
}) : super(key: key);
|
this.otherSpaceModels})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -44,17 +49,19 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
|||||||
child: BlocProvider(
|
child: BlocProvider(
|
||||||
create: (_) {
|
create: (_) {
|
||||||
final bloc = CreateSpaceModelBloc(_spaceModelApi);
|
final bloc = CreateSpaceModelBloc(_spaceModelApi);
|
||||||
if (spaceModel != null) {
|
if (spaceModel != null) {
|
||||||
bloc.add(UpdateSpaceTemplate(spaceModel!));
|
bloc.add(UpdateSpaceTemplate(spaceModel!));
|
||||||
} else {
|
} else {
|
||||||
bloc.add(UpdateSpaceTemplate(SpaceTemplateModel(
|
bloc.add(UpdateSpaceTemplate(SpaceTemplateModel(
|
||||||
modelName: '',
|
modelName: '',
|
||||||
subspaceModels: const [],
|
subspaceModels: const [],
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
spaceNameController.addListener(() {
|
spaceNameController.addListener(() {
|
||||||
bloc.add(UpdateSpaceTemplateName(name: spaceNameController.text));
|
bloc.add(UpdateSpaceTemplateName(
|
||||||
|
name: spaceNameController.text,
|
||||||
|
allModels: otherSpaceModels ?? []));
|
||||||
});
|
});
|
||||||
|
|
||||||
return bloc;
|
return bloc;
|
||||||
@ -86,9 +93,10 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
|||||||
child: TextField(
|
child: TextField(
|
||||||
controller: spaceNameController,
|
controller: spaceNameController,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
context
|
context.read<CreateSpaceModelBloc>().add(
|
||||||
.read<CreateSpaceModelBloc>()
|
UpdateSpaceTemplateName(
|
||||||
.add(UpdateSpaceTemplateName(name: value));
|
name: value,
|
||||||
|
allModels: otherSpaceModels ?? []));
|
||||||
},
|
},
|
||||||
style: const TextStyle(color: ColorsManager.blackColor),
|
style: const TextStyle(color: ColorsManager.blackColor),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
@ -128,21 +136,8 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
|||||||
subspaces: subspaces,
|
subspaces: subspaces,
|
||||||
allTags: allTags,
|
allTags: allTags,
|
||||||
spaceNameController: spaceNameController,
|
spaceNameController: spaceNameController,
|
||||||
onLoad: (tags, subspaces) {
|
pageContext: pageContext,
|
||||||
if (context.read<CreateSpaceModelBloc>().state
|
otherSpaceModels: otherSpaceModels,
|
||||||
is CreateSpaceModelLoaded) {
|
|
||||||
if (subspaces != null) {
|
|
||||||
context
|
|
||||||
.read<CreateSpaceModelBloc>()
|
|
||||||
.add(AddSubspacesToSpaceTemplate(subspaces));
|
|
||||||
}
|
|
||||||
if (tags != null) {
|
|
||||||
context
|
|
||||||
.read<CreateSpaceModelBloc>()
|
|
||||||
.add(AddTagsToSpaceTemplate(tags));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
@ -166,17 +161,73 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
|||||||
modelName:
|
modelName:
|
||||||
spaceNameController.text.trim(),
|
spaceNameController.text.trim(),
|
||||||
);
|
);
|
||||||
context.read<CreateSpaceModelBloc>().add(
|
if (updatedSpaceModel.uuid == null) {
|
||||||
CreateSpaceTemplate(
|
context
|
||||||
spaceTemplate:
|
.read<CreateSpaceModelBloc>()
|
||||||
updatedSpaceTemplate,
|
.add(
|
||||||
onCreate: (newModel) {
|
CreateSpaceTemplate(
|
||||||
onLoad!(newModel);
|
spaceTemplate:
|
||||||
Navigator.of(context)
|
updatedSpaceTemplate,
|
||||||
.pop(); // Close the dialog
|
onCreate: (newModel) {
|
||||||
},
|
if (pageContext != null) {
|
||||||
),
|
pageContext!
|
||||||
);
|
.read<SpaceModelBloc>()
|
||||||
|
.add(CreateSpaceModel(
|
||||||
|
newSpaceModel:
|
||||||
|
newModel));
|
||||||
|
}
|
||||||
|
Navigator.of(context)
|
||||||
|
.pop(); // Close the dialog
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
if (pageContext != null) {
|
||||||
|
final currentState = pageContext!
|
||||||
|
.read<SpaceModelBloc>()
|
||||||
|
.state;
|
||||||
|
if (currentState
|
||||||
|
is SpaceModelLoaded) {
|
||||||
|
final spaceModels =
|
||||||
|
List<SpaceTemplateModel>.from(
|
||||||
|
currentState.spaceModels);
|
||||||
|
|
||||||
|
final SpaceTemplateModel?
|
||||||
|
currentSpaceModel = spaceModels
|
||||||
|
.cast<SpaceTemplateModel?>()
|
||||||
|
.firstWhere(
|
||||||
|
(sm) =>
|
||||||
|
sm?.uuid ==
|
||||||
|
updatedSpaceModel
|
||||||
|
.uuid,
|
||||||
|
orElse: () => null,
|
||||||
|
);
|
||||||
|
if (currentSpaceModel != null) {
|
||||||
|
context
|
||||||
|
.read<CreateSpaceModelBloc>()
|
||||||
|
.add(ModifySpaceTemplate(
|
||||||
|
spaceTemplate:
|
||||||
|
currentSpaceModel,
|
||||||
|
updatedSpaceTemplate:
|
||||||
|
updatedSpaceTemplate,
|
||||||
|
onUpdate: (newModel) {
|
||||||
|
if (pageContext !=
|
||||||
|
null) {
|
||||||
|
pageContext!
|
||||||
|
.read<
|
||||||
|
SpaceModelBloc>()
|
||||||
|
.add(UpdateSpaceModel(
|
||||||
|
spaceModelUuid:
|
||||||
|
newModel.uuid ??
|
||||||
|
''));
|
||||||
|
}
|
||||||
|
Navigator.of(context)
|
||||||
|
.pop();
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
backgroundColor: ColorsManager.secondaryColor,
|
backgroundColor: ColorsManager.secondaryColor,
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
|
||||||
|
|
||||||
class SubspaceChipWidget extends StatelessWidget {
|
class SubspaceChipWidget extends StatelessWidget {
|
||||||
final String subspace;
|
final String subspace;
|
||||||
|
|
||||||
|
@ -46,23 +46,23 @@ class SubspaceModelCreate extends StatelessWidget {
|
|||||||
spacing: 8.0,
|
spacing: 8.0,
|
||||||
runSpacing: 8.0,
|
runSpacing: 8.0,
|
||||||
children: [
|
children: [
|
||||||
...subspaces.map(
|
...subspaces.map((subspace) => Container(
|
||||||
(subspace) => Chip(
|
padding: const EdgeInsets.symmetric(
|
||||||
label: Text(
|
horizontal: 8.0, vertical: 4.0),
|
||||||
subspace.subspaceName,
|
decoration: BoxDecoration(
|
||||||
style: const TextStyle(
|
color: ColorsManager.whiteColors,
|
||||||
color: ColorsManager.spaceColor), // Text color
|
borderRadius: BorderRadius.circular(10),
|
||||||
),
|
border: Border.all(
|
||||||
backgroundColor:
|
color: ColorsManager.transparentColor),
|
||||||
ColorsManager.whiteColors, // Chip background color
|
),
|
||||||
shape: RoundedRectangleBorder(
|
child: Text(
|
||||||
borderRadius:
|
subspace.subspaceName,
|
||||||
BorderRadius.circular(16), // Rounded chip
|
style: Theme.of(context)
|
||||||
side: const BorderSide(
|
.textTheme
|
||||||
color: ColorsManager.spaceColor), // Border color
|
.bodySmall
|
||||||
),
|
?.copyWith(color: ColorsManager.spaceColor),
|
||||||
),
|
),
|
||||||
),
|
)),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
await _openDialog(context, 'Edit Sub-space');
|
await _openDialog(context, 'Edit Sub-space');
|
||||||
|
@ -5,7 +5,6 @@ import 'package:syncrow_web/pages/spaces_management/assign_tag_models/views/assi
|
|||||||
import 'package:syncrow_web/pages/spaces_management/helper/tag_helper.dart';
|
import 'package:syncrow_web/pages/spaces_management/helper/tag_helper.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_model.dart';
|
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/button_content_widget.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/button_content_widget.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/tag_model/views/add_device_type_model_widget.dart';
|
import 'package:syncrow_web/pages/spaces_management/tag_model/views/add_device_type_model_widget.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
@ -17,8 +16,8 @@ class TagChipDisplay extends StatelessWidget {
|
|||||||
final List<SubspaceTemplateModel>? subspaces;
|
final List<SubspaceTemplateModel>? subspaces;
|
||||||
final List<String>? allTags;
|
final List<String>? allTags;
|
||||||
final TextEditingController spaceNameController;
|
final TextEditingController spaceNameController;
|
||||||
final void Function(
|
final BuildContext? pageContext;
|
||||||
List<TagModel>? tags, List<SubspaceTemplateModel>? subspaces)? onLoad;
|
final List<String>? otherSpaceModels;
|
||||||
|
|
||||||
const TagChipDisplay(BuildContext context,
|
const TagChipDisplay(BuildContext context,
|
||||||
{Key? key,
|
{Key? key,
|
||||||
@ -28,7 +27,8 @@ class TagChipDisplay extends StatelessWidget {
|
|||||||
required this.subspaces,
|
required this.subspaces,
|
||||||
required this.allTags,
|
required this.allTags,
|
||||||
required this.spaceNameController,
|
required this.spaceNameController,
|
||||||
this.onLoad})
|
this.pageContext,
|
||||||
|
this.otherSpaceModels})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -91,24 +91,23 @@ class TagChipDisplay extends StatelessWidget {
|
|||||||
|
|
||||||
if (navigatorContext != null) {
|
if (navigatorContext != null) {
|
||||||
await showDialog<bool>(
|
await showDialog<bool>(
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
context: navigatorContext,
|
context: navigatorContext,
|
||||||
builder: (context) => AssignTagModelsDialog(
|
builder: (context) => AssignTagModelsDialog(
|
||||||
products: products,
|
products: products,
|
||||||
subspaces: subspaces,
|
|
||||||
allTags: allTags,
|
|
||||||
initialTags: TagHelper.generateInitialTags(
|
|
||||||
subspaces: subspaces,
|
subspaces: subspaces,
|
||||||
spaceTagModels: spaceModel?.tags ?? []),
|
pageContext: pageContext,
|
||||||
title: 'Edit Device',
|
allTags: allTags,
|
||||||
addedProducts:
|
spaceModel: spaceModel,
|
||||||
TagHelper.createInitialSelectedProducts(
|
initialTags: TagHelper.generateInitialTags(
|
||||||
spaceModel?.tags ?? [], subspaces),
|
subspaces: subspaces,
|
||||||
spaceName: spaceModel?.modelName ?? '',
|
spaceTagModels: spaceModel?.tags ?? []),
|
||||||
onUpdate: (tags, subspaces) {
|
title: 'Edit Device',
|
||||||
onLoad?.call(tags, subspaces);
|
addedProducts:
|
||||||
}),
|
TagHelper.createInitialSelectedProducts(
|
||||||
);
|
spaceModel?.tags ?? [], subspaces),
|
||||||
|
spaceName: spaceModel?.modelName ?? '',
|
||||||
|
));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Chip(
|
child: Chip(
|
||||||
@ -129,6 +128,8 @@ class TagChipDisplay extends StatelessWidget {
|
|||||||
)
|
)
|
||||||
: TextButton(
|
: TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
|
||||||
await showDialog<bool>(
|
await showDialog<bool>(
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
context: context,
|
context: context,
|
||||||
@ -137,13 +138,9 @@ class TagChipDisplay extends StatelessWidget {
|
|||||||
subspaces: subspaces,
|
subspaces: subspaces,
|
||||||
allTags: allTags,
|
allTags: allTags,
|
||||||
spaceName: spaceNameController.text,
|
spaceName: spaceNameController.text,
|
||||||
|
pageContext: pageContext,
|
||||||
isCreate: true,
|
isCreate: true,
|
||||||
onUpdate: (tags, subspaces) {
|
spaceModel: spaceModel,
|
||||||
onLoad?.call(tags, subspaces);
|
|
||||||
},
|
|
||||||
onLoad: (tags, subspaces) {
|
|
||||||
onLoad?.call(tags, subspaces);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -5,8 +5,10 @@ import 'package:syncrow_web/pages/common/buttons/default_button.dart';
|
|||||||
import 'package:syncrow_web/pages/spaces_management/assign_tag_models/views/assign_tag_models_dialog.dart';
|
import 'package:syncrow_web/pages/spaces_management/assign_tag_models/views/assign_tag_models_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/selected_product_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/selected_product_model.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_model.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/dialog/create_space_model_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/tag_model/bloc/add_device_model_bloc.dart';
|
import 'package:syncrow_web/pages/spaces_management/tag_model/bloc/add_device_model_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/tag_model/bloc/add_device_model_state.dart';
|
import 'package:syncrow_web/pages/spaces_management/tag_model/bloc/add_device_model_state.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/tag_model/bloc/add_device_type_model_event.dart';
|
import 'package:syncrow_web/pages/spaces_management/tag_model/bloc/add_device_type_model_event.dart';
|
||||||
@ -21,28 +23,25 @@ class AddDeviceTypeModelWidget extends StatelessWidget {
|
|||||||
final List<String>? allTags;
|
final List<String>? allTags;
|
||||||
final String spaceName;
|
final String spaceName;
|
||||||
final bool isCreate;
|
final bool isCreate;
|
||||||
final void Function(
|
final List<String>? otherSpaceModels;
|
||||||
List<TagModel>? tags, List<SubspaceTemplateModel>? subspaces)? onLoad;
|
final BuildContext? pageContext;
|
||||||
final void Function(
|
final SpaceTemplateModel? spaceModel;
|
||||||
List<TagModel>? tags, List<SubspaceTemplateModel>? subspaces)? onUpdate;
|
|
||||||
|
|
||||||
const AddDeviceTypeModelWidget({
|
const AddDeviceTypeModelWidget(
|
||||||
super.key,
|
{super.key,
|
||||||
this.products,
|
this.products,
|
||||||
this.initialSelectedProducts,
|
this.initialSelectedProducts,
|
||||||
this.subspaces,
|
this.subspaces,
|
||||||
this.allTags,
|
this.allTags,
|
||||||
this.spaceTagModels,
|
this.spaceTagModels,
|
||||||
required this.spaceName,
|
required this.spaceName,
|
||||||
required this.isCreate,
|
required this.isCreate,
|
||||||
this.onLoad,
|
this.pageContext,
|
||||||
this.onUpdate,
|
this.otherSpaceModels,
|
||||||
});
|
this.spaceModel});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
|
|
||||||
final size = MediaQuery.of(context).size;
|
final size = MediaQuery.of(context).size;
|
||||||
final crossAxisCount = size.width > 1200
|
final crossAxisCount = size.width > 1200
|
||||||
? 8
|
? 8
|
||||||
@ -79,6 +78,7 @@ class AddDeviceTypeModelWidget extends StatelessWidget {
|
|||||||
padding:
|
padding:
|
||||||
const EdgeInsets.symmetric(horizontal: 20.0),
|
const EdgeInsets.symmetric(horizontal: 20.0),
|
||||||
child: ScrollableGridViewWidget(
|
child: ScrollableGridViewWidget(
|
||||||
|
isCreate: isCreate,
|
||||||
products: products,
|
products: products,
|
||||||
crossAxisCount: crossAxisCount,
|
crossAxisCount: crossAxisCount,
|
||||||
initialProductCounts: state.selectedProducts,
|
initialProductCounts: state.selectedProducts,
|
||||||
@ -102,6 +102,44 @@ class AddDeviceTypeModelWidget extends StatelessWidget {
|
|||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (isCreate) {
|
if (isCreate) {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
await showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext dialogContext) {
|
||||||
|
return CreateSpaceModelDialog(
|
||||||
|
products: products,
|
||||||
|
allTags: allTags,
|
||||||
|
pageContext: pageContext,
|
||||||
|
otherSpaceModels: otherSpaceModels,
|
||||||
|
spaceModel: SpaceTemplateModel(
|
||||||
|
modelName: spaceName,
|
||||||
|
tags: spaceModel?.tags ?? [],
|
||||||
|
uuid: spaceModel?.uuid,
|
||||||
|
internalId: spaceModel?.internalId,
|
||||||
|
subspaceModels: subspaces),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
final initialTags = generateInitialTags(
|
||||||
|
spaceTagModels: spaceTagModels,
|
||||||
|
subspaces: subspaces,
|
||||||
|
);
|
||||||
|
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
await showDialog<bool>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => AssignTagModelsDialog(
|
||||||
|
products: products,
|
||||||
|
subspaces: subspaces,
|
||||||
|
addedProducts: initialSelectedProducts ?? [],
|
||||||
|
allTags: allTags,
|
||||||
|
spaceName: spaceName,
|
||||||
|
initialTags: initialTags,
|
||||||
|
otherSpaceModels: otherSpaceModels,
|
||||||
|
title: 'Edit Device',
|
||||||
|
spaceModel: spaceModel,
|
||||||
|
pageContext: pageContext,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -142,10 +180,10 @@ class AddDeviceTypeModelWidget extends StatelessWidget {
|
|||||||
allTags: allTags,
|
allTags: allTags,
|
||||||
spaceName: spaceName,
|
spaceName: spaceName,
|
||||||
initialTags: state.initialTag,
|
initialTags: state.initialTag,
|
||||||
|
otherSpaceModels: otherSpaceModels,
|
||||||
title: dialogTitle,
|
title: dialogTitle,
|
||||||
onUpdate: (tags, subspaces) {
|
spaceModel: spaceModel,
|
||||||
onUpdate?.call(tags, subspaces);
|
pageContext: pageContext,
|
||||||
},
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -13,12 +13,13 @@ import 'package:syncrow_web/utils/constants/assets.dart';
|
|||||||
class DeviceTypeTileWidget extends StatelessWidget {
|
class DeviceTypeTileWidget extends StatelessWidget {
|
||||||
final ProductModel product;
|
final ProductModel product;
|
||||||
final List<SelectedProduct> productCounts;
|
final List<SelectedProduct> productCounts;
|
||||||
|
final bool isCreate;
|
||||||
|
|
||||||
const DeviceTypeTileWidget({
|
const DeviceTypeTileWidget(
|
||||||
super.key,
|
{super.key,
|
||||||
required this.product,
|
required this.product,
|
||||||
required this.productCounts,
|
required this.productCounts,
|
||||||
});
|
required this.isCreate});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -48,6 +49,7 @@ class DeviceTypeTileWidget extends StatelessWidget {
|
|||||||
DeviceNameWidget(name: product.name),
|
DeviceNameWidget(name: product.name),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
CounterWidget(
|
CounterWidget(
|
||||||
|
isCreate: isCreate,
|
||||||
initialCount: selectedProduct.count,
|
initialCount: selectedProduct.count,
|
||||||
onCountChanged: (newCount) {
|
onCountChanged: (newCount) {
|
||||||
context.read<AddDeviceTypeModelBloc>().add(
|
context.read<AddDeviceTypeModelBloc>().add(
|
||||||
|
@ -10,12 +10,14 @@ class ScrollableGridViewWidget extends StatelessWidget {
|
|||||||
final List<ProductModel>? products;
|
final List<ProductModel>? products;
|
||||||
final int crossAxisCount;
|
final int crossAxisCount;
|
||||||
final List<SelectedProduct>? initialProductCounts;
|
final List<SelectedProduct>? initialProductCounts;
|
||||||
|
final bool isCreate;
|
||||||
|
|
||||||
const ScrollableGridViewWidget({
|
const ScrollableGridViewWidget({
|
||||||
super.key,
|
super.key,
|
||||||
required this.products,
|
required this.products,
|
||||||
required this.crossAxisCount,
|
required this.crossAxisCount,
|
||||||
this.initialProductCounts,
|
this.initialProductCounts,
|
||||||
|
required this.isCreate
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -30,7 +32,7 @@ class ScrollableGridViewWidget extends StatelessWidget {
|
|||||||
final productCounts = state is AddDeviceModelLoaded
|
final productCounts = state is AddDeviceModelLoaded
|
||||||
? state.selectedProducts
|
? state.selectedProducts
|
||||||
: <SelectedProduct>[];
|
: <SelectedProduct>[];
|
||||||
|
|
||||||
return GridView.builder(
|
return GridView.builder(
|
||||||
controller: scrollController,
|
controller: scrollController,
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
@ -47,6 +49,7 @@ class ScrollableGridViewWidget extends StatelessWidget {
|
|||||||
|
|
||||||
return DeviceTypeTileWidget(
|
return DeviceTypeTileWidget(
|
||||||
product: product,
|
product: product,
|
||||||
|
isCreate: isCreate,
|
||||||
productCounts: initialProductCount != null
|
productCounts: initialProductCount != null
|
||||||
? [...productCounts, initialProductCount]
|
? [...productCounts, initialProductCount]
|
||||||
: productCounts,
|
: productCounts,
|
||||||
|
@ -12,4 +12,33 @@ class HomeApi {
|
|||||||
});
|
});
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future fetchTerms() async {
|
||||||
|
final response = await HTTPService().get(
|
||||||
|
path: ApiEndpoints.terms,
|
||||||
|
showServerMessage: true,
|
||||||
|
expectedResponseModel: (json) {
|
||||||
|
return json['data'];
|
||||||
|
});
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future fetchPolicy() async {
|
||||||
|
final response = await HTTPService().get(
|
||||||
|
path: ApiEndpoints.policy,
|
||||||
|
showServerMessage: true,
|
||||||
|
expectedResponseModel: (json) {
|
||||||
|
return json['data'];
|
||||||
|
});
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future confirmUserAgreements(uuid) async {
|
||||||
|
final response = await HTTPService().patch(
|
||||||
|
path: ApiEndpoints.userAgreements.replaceAll('{userUuid}', uuid!),
|
||||||
|
expectedResponseModel: (json) {
|
||||||
|
return json['data'];
|
||||||
|
});
|
||||||
|
return response;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,20 @@ class SpaceModelManagementApi {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Future<String?> updateSpaceModel(
|
||||||
|
CreateSpaceTemplateBodyModel spaceModel, String spaceModelUuid) async {
|
||||||
|
final response = await HTTPService().put(
|
||||||
|
path: ApiEndpoints.updateSpaceModel
|
||||||
|
.replaceAll('{projectId}', TempConst.projectId).replaceAll('{spaceModelUuid}', spaceModelUuid),
|
||||||
|
body: spaceModel.toJson(),
|
||||||
|
expectedResponseModel: (json) {
|
||||||
|
return json['message'];
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
Future<SpaceTemplateModel?> getSpaceModel(String spaceModelUuid) async {
|
Future<SpaceTemplateModel?> getSpaceModel(String spaceModelUuid) async {
|
||||||
final response = await HTTPService().get(
|
final response = await HTTPService().get(
|
||||||
path: ApiEndpoints.getSpaceModel
|
path: ApiEndpoints.getSpaceModel
|
||||||
|
@ -71,8 +71,8 @@ class UserPermissionApi {
|
|||||||
"firstName": firstName,
|
"firstName": firstName,
|
||||||
"lastName": lastName,
|
"lastName": lastName,
|
||||||
"email": email,
|
"email": email,
|
||||||
"jobTitle": jobTitle != '' ? jobTitle : " ",
|
"jobTitle": jobTitle != '' ? jobTitle : null,
|
||||||
"phoneNumber": phoneNumber != '' ? phoneNumber : " ",
|
"phoneNumber": phoneNumber != '' ? phoneNumber : null,
|
||||||
"roleUuid": roleUuid,
|
"roleUuid": roleUuid,
|
||||||
"projectUuid": "0e62577c-06fa-41b9-8a92-99a21fbaf51c",
|
"projectUuid": "0e62577c-06fa-41b9-8a92-99a21fbaf51c",
|
||||||
"spaceUuids": spaceUuids,
|
"spaceUuids": spaceUuids,
|
||||||
@ -119,13 +119,8 @@ class UserPermissionApi {
|
|||||||
);
|
);
|
||||||
return response ?? 'Unknown error occurred';
|
return response ?? 'Unknown error occurred';
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
if (e.response != null) {
|
final errorMessage = e.response?.data['error'];
|
||||||
final errorMessage = e.response?.data['error'];
|
return errorMessage;
|
||||||
return errorMessage is String
|
|
||||||
? errorMessage
|
|
||||||
: 'Error occurred while checking email';
|
|
||||||
}
|
|
||||||
return 'Error occurred while checking email';
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return e.toString();
|
return e.toString();
|
||||||
}
|
}
|
||||||
|
@ -101,8 +101,11 @@ abstract class ApiEndpoints {
|
|||||||
//space model
|
//space model
|
||||||
static const String listSpaceModels = '/projects/{projectId}/space-models';
|
static const String listSpaceModels = '/projects/{projectId}/space-models';
|
||||||
static const String createSpaceModel = '/projects/{projectId}/space-models';
|
static const String createSpaceModel = '/projects/{projectId}/space-models';
|
||||||
static const String getSpaceModel = '/projects/{projectId}/space-models/{spaceModelUuid}';
|
static const String getSpaceModel =
|
||||||
|
'/projects/{projectId}/space-models/{spaceModelUuid}';
|
||||||
|
static const String updateSpaceModel =
|
||||||
|
'/projects/{projectId}/space-models/{spaceModelUuid}';
|
||||||
|
|
||||||
static const String roleTypes = '/role/types';
|
static const String roleTypes = '/role/types';
|
||||||
static const String permission = '/permission/{roleUuid}';
|
static const String permission = '/permission/{roleUuid}';
|
||||||
static const String inviteUser = '/invite-user';
|
static const String inviteUser = '/invite-user';
|
||||||
@ -114,6 +117,7 @@ abstract class ApiEndpoints {
|
|||||||
static const String deleteUser = '/invite-user/{inviteUserUuid}';
|
static const String deleteUser = '/invite-user/{inviteUserUuid}';
|
||||||
static const String changeUserStatus =
|
static const String changeUserStatus =
|
||||||
'/invite-user/{invitedUserUuid}/disable';
|
'/invite-user/{invitedUserUuid}/disable';
|
||||||
|
static const String terms = '/terms';
|
||||||
// static const String updateAutomation = '/automation/{automationId}';
|
static const String policy = '/policy';
|
||||||
|
static const String userAgreements = '/user/agreements/web/{userUuid}';
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,13 @@
|
|||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
#include <flutter_secure_storage_linux/flutter_secure_storage_linux_plugin.h>
|
#include <flutter_secure_storage_linux/flutter_secure_storage_linux_plugin.h>
|
||||||
|
#include <url_launcher_linux/url_launcher_plugin.h>
|
||||||
|
|
||||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||||
g_autoptr(FlPluginRegistrar) flutter_secure_storage_linux_registrar =
|
g_autoptr(FlPluginRegistrar) flutter_secure_storage_linux_registrar =
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStorageLinuxPlugin");
|
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStorageLinuxPlugin");
|
||||||
flutter_secure_storage_linux_plugin_register_with_registrar(flutter_secure_storage_linux_registrar);
|
flutter_secure_storage_linux_plugin_register_with_registrar(flutter_secure_storage_linux_registrar);
|
||||||
|
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
|
||||||
|
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
|
||||||
|
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
list(APPEND FLUTTER_PLUGIN_LIST
|
list(APPEND FLUTTER_PLUGIN_LIST
|
||||||
flutter_secure_storage_linux
|
flutter_secure_storage_linux
|
||||||
|
url_launcher_linux
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||||
|
@ -8,9 +8,11 @@ import Foundation
|
|||||||
import flutter_secure_storage_macos
|
import flutter_secure_storage_macos
|
||||||
import path_provider_foundation
|
import path_provider_foundation
|
||||||
import shared_preferences_foundation
|
import shared_preferences_foundation
|
||||||
|
import url_launcher_macos
|
||||||
|
|
||||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
|
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
|
||||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||||
|
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,8 @@ dependencies:
|
|||||||
time_picker_spinner: ^1.0.0
|
time_picker_spinner: ^1.0.0
|
||||||
intl_phone_field: ^3.2.0
|
intl_phone_field: ^3.2.0
|
||||||
number_pagination: ^1.1.6
|
number_pagination: ^1.1.6
|
||||||
|
url_launcher: ^6.2.5
|
||||||
|
flutter_html: ^3.0.0-beta.2
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
@ -7,8 +7,11 @@
|
|||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
|
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
|
||||||
|
#include <url_launcher_windows/url_launcher_windows.h>
|
||||||
|
|
||||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||||
FlutterSecureStorageWindowsPluginRegisterWithRegistrar(
|
FlutterSecureStorageWindowsPluginRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin"));
|
registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin"));
|
||||||
|
UrlLauncherWindowsRegisterWithRegistrar(
|
||||||
|
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
list(APPEND FLUTTER_PLUGIN_LIST
|
list(APPEND FLUTTER_PLUGIN_LIST
|
||||||
flutter_secure_storage_windows
|
flutter_secure_storage_windows
|
||||||
|
url_launcher_windows
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||||
|
Reference in New Issue
Block a user