Compare commits

..

13 Commits

Author SHA1 Message Date
393a5361f0 Apply correct business logic in AirQualityDataLoadingStrategy. 2025-06-01 15:40:12 +03:00
a56e93d0d7 removed the interface method onSelectChildSpace, because all the clients dont use it and instead pass the onSpaceSelected, which isn't a good design. 2025-06-01 15:38:14 +03:00
94847fa936 SP-1664-Fe-Sider-bar-tree-behavior-issues-on-Analytics-page. 2025-06-01 15:36:52 +03:00
fdabfe5d95 Merge pull request #217 from SyncrowIOT/SP-1584-FE-Block-Energy-Device-from-Being-Added-to-Then-Section-with-Validation-Message
Refactor energy clamp dialog to handle empty functions list gracefully
2025-06-01 14:13:53 +03:00
8916000696 Refactor visibility logic in Energy Clamp Dialog to handle empty functions list more elegantly 2025-06-01 14:11:21 +03:00
305d695358 Refactor energy clamp dialog to handle empty functions list gracefully 2025-06-01 13:12:58 +03:00
cde79fc168 Merge pull request #212 from SyncrowIOT/SP-1594-FE-Implement-Real-Time-AQI-Data-Panel-for-Selected-Sensor
Sp 1594 fe implement real time aqi data panel for selected sensor
2025-05-29 15:27:08 +03:00
d9448d9709 Merge pull request #209 from SyncrowIOT/SP-1546-FE-Garage-door-opener-Countdown-counter-is-throwing-Device-not-found-error
Refactor event handling in GarageDoorBloc to use local variable for d…
2025-05-29 14:39:40 +03:00
7bfd08238e Refactor event handling in GarageDoorBloc to use local variable for deviceId 2025-05-29 12:19:04 +03:00
010960c89b Merge pull request #208 from SyncrowIOT/SP-1603-FE-Freeze-First-Row-in-All-Table-Views-Across-the-Platform
Refactor table layout to accommodate dynamic table size
2025-05-28 16:57:56 +03:00
fccf395c38 Update function names to follow consistent naming convention in name_filter.dart and users_page.dart 2025-05-28 16:56:51 +03:00
7c65b874eb Refactor table layout to accommodate dynamic table size 2025-05-28 16:40:44 +03:00
25db6ec687 Created pull_request_template.md . 2025-05-28 14:24:03 +03:00
14 changed files with 591 additions and 448 deletions

30
.github/pull_request_template.md vendored Normal file
View File

@ -0,0 +1,30 @@
<!--
Thanks for contributing!
Provide a description of your changes below and a general summary in the title
Please look at the following checklist to ensure that your PR can be accepted quickly:
-->
## Jira Ticket
<!-- Add your Jira ticket number as a link (e.g., [PROJ-123](https://jira.company.com/browse/PROJ-123)) -->
## Status
**READY/IN DEVELOPMENT/HOLD**
## Description
<!--- Describe your changes in detail -->
## Type of Change
<!--- Put an `x` in all the boxes that apply: -->
- [ ] ✨ New feature (non-breaking change which adds functionality)
- [ ] 🛠️ Bug fix (non-breaking change which fixes an issue)
- [ ] ❌ Breaking change (fix or feature that would cause existing functionality to change)
- [ ] 🧹 Code refactor
- [ ] ✅ Build configuration change
- [ ] 📝 Documentation
- [ ] 🗑️ Chore

View File

@ -26,10 +26,10 @@ final class AirQualityDataLoadingStrategy implements AnalyticsDataLoadingStrateg
final spaceTreeBloc = context.read<SpaceTreeBloc>(); final spaceTreeBloc = context.read<SpaceTreeBloc>();
final isSpaceSelected = spaceTreeBloc.state.selectedSpaces.contains(space.uuid); final isSpaceSelected = spaceTreeBloc.state.selectedSpaces.contains(space.uuid);
if (isSpaceSelected) { final hasSelectedSpaces = spaceTreeBloc.state.selectedSpaces.isNotEmpty;
clearData(context); if (hasSelectedSpaces) clearData(context);
return;
} if (isSpaceSelected) return;
spaceTreeBloc spaceTreeBloc
..add(const SpaceTreeClearSelectionEvent()) ..add(const SpaceTreeClearSelectionEvent())
@ -42,18 +42,11 @@ final class AirQualityDataLoadingStrategy implements AnalyticsDataLoadingStrateg
); );
} }
@override
void onChildSpaceSelected(
BuildContext context,
CommunityModel community,
SpaceModel child,
) {
return onSpaceSelected(context, community, child);
}
@override @override
void clearData(BuildContext context) { void clearData(BuildContext context) {
context.read<SpaceTreeBloc>().add(const SpaceTreeClearSelectionEvent()); context.read<SpaceTreeBloc>().add(
const AnalyticsClearAllSpaceTreeSelectionsEvent(),
);
FetchAirQualityDataHelper.clearAllData(context); FetchAirQualityDataHelper.clearAllData(context);
} }
} }

View File

@ -13,10 +13,5 @@ abstract class AnalyticsDataLoadingStrategy {
CommunityModel community, CommunityModel community,
SpaceModel space, SpaceModel space,
); );
void onChildSpaceSelected(
BuildContext context,
CommunityModel community,
SpaceModel child,
);
void clearData(BuildContext context); void clearData(BuildContext context);
} }

View File

@ -14,24 +14,14 @@ class EnergyManagementDataLoadingStrategy implements AnalyticsDataLoadingStrateg
CommunityModel community, CommunityModel community,
List<SpaceModel> spaces, List<SpaceModel> spaces,
) { ) {
context.read<SpaceTreeBloc>().add( final spaceTreeBloc = context.read<SpaceTreeBloc>();
OnCommunitySelected( final isCommunitySelected =
community.uuid, spaceTreeBloc.state.selectedCommunities.contains(community.uuid);
spaces,
),
);
final spaceTreeState = context.read<SpaceTreeBloc>().state; if (isCommunitySelected) {
if (spaceTreeState.selectedCommunities.contains(community.uuid)) {
clearData(context); clearData(context);
return; return;
} }
FetchEnergyManagementDataHelper.loadEnergyManagementData(
context,
communityId: community.uuid,
spaceId: spaces.isNotEmpty ? spaces.first.uuid ?? '' : '',
);
} }
@override @override
@ -40,21 +30,31 @@ class EnergyManagementDataLoadingStrategy implements AnalyticsDataLoadingStrateg
CommunityModel community, CommunityModel community,
SpaceModel space, SpaceModel space,
) { ) {
context.read<SpaceTreeBloc>().add( final spaceTreeBloc = context.read<SpaceTreeBloc>();
OnSpaceSelected( final isSpaceSelected = spaceTreeBloc.state.selectedSpaces.contains(space.uuid);
community, final hasSelectedSpaces = spaceTreeBloc.state.selectedSpaces.isNotEmpty;
space.uuid ?? '',
space.children,
),
);
final spaceTreeState = context.read<SpaceTreeBloc>().state; if (isSpaceSelected) {
if (spaceTreeState.selectedCommunities.contains(community.uuid) || final firstSelectedSpace = spaceTreeBloc.state.selectedSpaces.first;
spaceTreeState.selectedSpaces.contains(space.uuid)) { final isTheFirstSelectedSpace = firstSelectedSpace == space.uuid;
clearData(context); if (isTheFirstSelectedSpace) {
clearData(context);
}
return; return;
} }
if (hasSelectedSpaces) {
clearData(context);
}
spaceTreeBloc.add(
OnSpaceSelected(
community,
space.uuid ?? '',
space.children,
),
);
FetchEnergyManagementDataHelper.loadEnergyManagementData( FetchEnergyManagementDataHelper.loadEnergyManagementData(
context, context,
communityId: community.uuid, communityId: community.uuid,
@ -62,18 +62,11 @@ class EnergyManagementDataLoadingStrategy implements AnalyticsDataLoadingStrateg
); );
} }
@override
void onChildSpaceSelected(
BuildContext context,
CommunityModel community,
SpaceModel child,
) {
return onSpaceSelected(context, community, child);
}
@override @override
void clearData(BuildContext context) { void clearData(BuildContext context) {
context.read<SpaceTreeBloc>().add(const SpaceTreeClearSelectionEvent()); context.read<SpaceTreeBloc>().add(
const AnalyticsClearAllSpaceTreeSelectionsEvent(),
);
FetchEnergyManagementDataHelper.clearAllData(context); FetchEnergyManagementDataHelper.clearAllData(context);
} }
} }

View File

@ -26,10 +26,10 @@ class OccupancyDataLoadingStrategy implements AnalyticsDataLoadingStrategy {
final spaceTreeBloc = context.read<SpaceTreeBloc>(); final spaceTreeBloc = context.read<SpaceTreeBloc>();
final isSpaceSelected = spaceTreeBloc.state.selectedSpaces.contains(space.uuid); final isSpaceSelected = spaceTreeBloc.state.selectedSpaces.contains(space.uuid);
if (isSpaceSelected) { final hasSelectedSpaces = spaceTreeBloc.state.selectedSpaces.isNotEmpty;
clearData(context); if (hasSelectedSpaces) clearData(context);
return;
} if (isSpaceSelected) return;
spaceTreeBloc spaceTreeBloc
..add(const SpaceTreeClearSelectionEvent()) ..add(const SpaceTreeClearSelectionEvent())
@ -42,18 +42,11 @@ class OccupancyDataLoadingStrategy implements AnalyticsDataLoadingStrategy {
); );
} }
@override
void onChildSpaceSelected(
BuildContext context,
CommunityModel community,
SpaceModel child,
) {
return onSpaceSelected(context, community, child);
}
@override @override
void clearData(BuildContext context) { void clearData(BuildContext context) {
context.read<SpaceTreeBloc>().add(const SpaceTreeClearSelectionEvent()); context.read<SpaceTreeBloc>().add(
const AnalyticsClearAllSpaceTreeSelectionsEvent(),
);
FetchOccupancyDataHelper.clearAllData(context); FetchOccupancyDataHelper.clearAllData(context);
} }
} }

View File

@ -21,7 +21,7 @@ class AnalyticsCommunitiesSidebar extends StatelessWidget {
strategy.onSpaceSelected(context, community, space); strategy.onSpaceSelected(context, community, space);
}, },
onSelectChildSpace: (community, child) { onSelectChildSpace: (community, child) {
strategy.onChildSpaceSelected(context, community, child); strategy.onSpaceSelected(context, community, child);
}, },
), ),
); );

View File

@ -21,6 +21,7 @@ class DynamicTable extends StatefulWidget {
final List<String>? initialSelectedIds; final List<String>? initialSelectedIds;
final int uuidIndex; final int uuidIndex;
final Function(dynamic selectedRows)? onSelectionChanged; final Function(dynamic selectedRows)? onSelectionChanged;
final Function(int rowIndex)? onSettingsPressed;
const DynamicTable({ const DynamicTable({
super.key, super.key,
required this.headers, required this.headers,
@ -37,6 +38,7 @@ class DynamicTable extends StatefulWidget {
this.initialSelectedIds, this.initialSelectedIds,
required this.uuidIndex, required this.uuidIndex,
this.onSelectionChanged, this.onSelectionChanged,
this.onSettingsPressed,
}); });
@override @override
@ -48,11 +50,20 @@ class _DynamicTableState extends State<DynamicTable> {
bool _selectAll = false; bool _selectAll = false;
final ScrollController _verticalScrollController = ScrollController(); final ScrollController _verticalScrollController = ScrollController();
final ScrollController _horizontalScrollController = ScrollController(); final ScrollController _horizontalScrollController = ScrollController();
late ScrollController _horizontalHeaderScrollController;
late ScrollController _horizontalBodyScrollController;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_initializeSelection(); _initializeSelection();
_horizontalHeaderScrollController = ScrollController();
_horizontalBodyScrollController = ScrollController();
// Synchronize horizontal scrolling
_horizontalBodyScrollController.addListener(() {
_horizontalHeaderScrollController
.jumpTo(_horizontalBodyScrollController.offset);
});
} }
@override @override
@ -102,101 +113,87 @@ class _DynamicTableState extends State<DynamicTable> {
context.read<DeviceManagementBloc>().add(UpdateSelection(_selectedRows)); context.read<DeviceManagementBloc>().add(UpdateSelection(_selectedRows));
} }
@override
void dispose() {
_horizontalHeaderScrollController.dispose();
_horizontalBodyScrollController.dispose();
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
decoration: widget.cellDecoration, decoration: widget.cellDecoration,
child: Scrollbar( child: Column(
controller: _verticalScrollController, children: [
thumbVisibility: true, Container(
trackVisibility: true, decoration: widget.headerDecoration ??
child: Scrollbar( const BoxDecoration(color: ColorsManager.boxColor),
controller: _horizontalScrollController,
thumbVisibility: true,
trackVisibility: true,
notificationPredicate: (notif) => notif.depth == 1,
child: SingleChildScrollView(
controller: _verticalScrollController,
child: SingleChildScrollView( child: SingleChildScrollView(
controller: _horizontalScrollController,
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
physics: const NeverScrollableScrollPhysics(),
controller: _horizontalHeaderScrollController,
child: SizedBox( child: SizedBox(
width: widget.size.width, width: widget.size.width,
child: Column( child: Row(
children: [ children: [
Container( if (widget.withCheckBox) _buildSelectAllCheckbox(),
decoration: widget.headerDecoration ?? ...List.generate(widget.headers.length, (index) {
const BoxDecoration( return _buildTableHeaderCell(
color: ColorsManager.boxColor, widget.headers[index], index);
), }),
child: Row(
children: [
if (widget.withCheckBox) _buildSelectAllCheckbox(),
...List.generate(widget.headers.length, (index) {
return _buildTableHeaderCell(
widget.headers[index], index);
})
//...widget.headers.map((header) => _buildTableHeaderCell(header)),
],
),
),
widget.isEmpty
? SizedBox(
height: widget.size.height * 0.5,
width: widget.size.width,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Column(
children: [
SvgPicture.asset(Assets.emptyTable),
const SizedBox(
height: 15,
),
Text(
widget.tableName == 'AccessManagement'
? 'No Password '
: 'No Devices',
style: Theme.of(context)
.textTheme
.bodySmall!
.copyWith(
color:
ColorsManager.grayColor),
)
],
),
],
),
],
),
)
: Column(
children:
List.generate(widget.data.length, (index) {
final row = widget.data[index];
return Row(
children: [
if (widget.withCheckBox)
_buildRowCheckbox(
index, widget.size.height * 0.08),
...row.map((cell) => _buildTableCell(
cell.toString(),
widget.size.height * 0.08)),
],
);
}),
),
], ],
), ),
), ),
), ),
), ),
), Expanded(
child: Scrollbar(
controller: _verticalScrollController,
thumbVisibility: true,
trackVisibility: true,
child: SingleChildScrollView(
controller: _verticalScrollController,
child: Scrollbar(
controller: _horizontalBodyScrollController,
thumbVisibility: false,
trackVisibility: false,
notificationPredicate: (notif) => notif.depth == 1,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
controller: _horizontalBodyScrollController,
child: SizedBox(
width: widget.size.width,
child: widget.isEmpty
? _buildEmptyState()
: Column(
children:
List.generate(widget.data.length, (rowIndex) {
final row = widget.data[rowIndex];
return Row(
children: [
if (widget.withCheckBox)
_buildRowCheckbox(
rowIndex, widget.size.height * 0.08),
...row.asMap().entries.map((entry) {
return _buildTableCell(
entry.value.toString(),
widget.size.height * 0.08,
rowIndex: rowIndex,
columnIndex: entry.key,
);
}).toList(),
],
);
}),
),
),
),
),
),
),
),
],
), ),
); );
} }
@ -218,6 +215,32 @@ class _DynamicTableState extends State<DynamicTable> {
); );
} }
Widget _buildEmptyState() => Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Column(
children: [
SvgPicture.asset(Assets.emptyTable),
const SizedBox(height: 15),
Text(
widget.tableName == 'AccessManagement'
? 'No Password '
: 'No Devices',
style: Theme.of(context)
.textTheme
.bodySmall!
.copyWith(color: ColorsManager.grayColor),
)
],
),
],
),
],
);
Widget _buildRowCheckbox(int index, double size) { Widget _buildRowCheckbox(int index, double size) {
return Container( return Container(
width: 50, width: 50,
@ -272,13 +295,23 @@ class _DynamicTableState extends State<DynamicTable> {
); );
} }
Widget _buildTableCell(String content, double size) { Widget _buildTableCell(
String content,
double size, {
required int rowIndex,
required int columnIndex,
}) {
bool isBatteryLevel = content.endsWith('%'); bool isBatteryLevel = content.endsWith('%');
double? batteryLevel; double? batteryLevel;
if (isBatteryLevel) { if (isBatteryLevel) {
batteryLevel = double.tryParse(content.replaceAll('%', '').trim()); batteryLevel = double.tryParse(content.replaceAll('%', '').trim());
} }
bool isSettingsColumn = widget.headers[columnIndex] == 'Settings';
if (isSettingsColumn) {
return _buildSettingsIcon(rowIndex, size);
}
Color? statusColor; Color? statusColor;
switch (content) { switch (content) {
@ -330,4 +363,23 @@ class _DynamicTableState extends State<DynamicTable> {
), ),
); );
} }
Widget _buildSettingsIcon(int rowIndex, double size) {
return Container(
height: size,
width: 120,
padding: const EdgeInsets.all(5.0),
decoration: const BoxDecoration(
border: Border(
bottom: BorderSide(color: ColorsManager.boxDivider, width: 1.0),
),
color: Colors.white,
),
alignment: Alignment.center,
child: IconButton(
icon: SvgPicture.asset(Assets.settings),
onPressed: () => widget.onSettingsPressed?.call(rowIndex),
),
);
}
} }

View File

@ -360,7 +360,7 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorState> {
delay: deviceStatus.delay + Duration(minutes: 10)); delay: deviceStatus.delay + Duration(minutes: 10));
emit(GarageDoorLoadedState(status: deviceStatus)); emit(GarageDoorLoadedState(status: deviceStatus));
add(GarageDoorControlEvent( add(GarageDoorControlEvent(
deviceId: event.deviceId, deviceId: deviceId,
value: deviceStatus.delay.inSeconds, value: deviceStatus.delay.inSeconds,
code: 'countdown_1')); code: 'countdown_1'));
} catch (e) { } catch (e) {

View File

@ -5,7 +5,7 @@ import 'package:syncrow_web/utils/constants/assets.dart';
Future<void> showNameMenu({ Future<void> showNameMenu({
required BuildContext context, required BuildContext context,
Function()? aToZTap, Function()? aToZTap,
Function()? zToaTap, Function()? zToATap,
String? isSelected, String? isSelected,
}) async { }) async {
final RenderBox overlay = final RenderBox overlay =
@ -46,7 +46,7 @@ Future<void> showNameMenu({
), ),
), ),
PopupMenuItem( PopupMenuItem(
onTap: zToaTap, onTap: zToATap,
child: ListTile( child: ListTile(
leading: Image.asset( leading: Image.asset(
Assets.ZtoAIcon, Assets.ZtoAIcon,

View File

@ -95,7 +95,7 @@ class _TableRow extends StatelessWidget {
], ],
), ),
if (!isLast) if (!isLast)
Divider( const Divider(
height: 1, height: 1,
thickness: 1, thickness: 1,
color: ColorsManager.boxDivider, color: ColorsManager.boxDivider,
@ -110,12 +110,14 @@ class DynamicTableScreen extends StatefulWidget {
final List<String> titles; final List<String> titles;
final List<List<Widget>> rows; final List<List<Widget>> rows;
final void Function(int columnIndex)? onFilter; final void Function(int columnIndex)? onFilter;
final double tableSize;
const DynamicTableScreen({ const DynamicTableScreen({
required this.titles, required this.titles,
required this.rows, required this.rows,
required this.onFilter, required this.onFilter,
Key? key, Key? key,
required this.tableSize,
}) : super(key: key); }) : super(key: key);
@override @override
@ -205,7 +207,8 @@ class _DynamicTableScreenState extends State<DynamicTableScreen> {
bottomRight: Radius.circular(15), bottomRight: Radius.circular(15),
), ),
), ),
child: Column( child: ListView(
shrinkWrap: true,
children: [ children: [
for (int rowIndex = 0; rowIndex < widget.rows.length; rowIndex++) for (int rowIndex = 0; rowIndex < widget.rows.length; rowIndex++)
_TableRow( _TableRow(
@ -253,7 +256,7 @@ class _DynamicTableScreenState extends State<DynamicTableScreen> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
_buildHeader(), _buildHeader(),
_buildBody(), Container(height: widget.tableSize - 37, child: _buildBody()),
], ],
), ),
), ),

View File

@ -27,7 +27,8 @@ class UsersPage extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final TextEditingController searchController = TextEditingController(); final TextEditingController searchController = TextEditingController();
Widget actionButton({bool isActive = false, required String title, Function()? onTap}) { Widget actionButton(
{bool isActive = false, required String title, Function()? onTap}) {
return InkWell( return InkWell(
onTap: onTap, onTap: onTap,
child: Padding( child: Padding(
@ -60,7 +61,8 @@ class UsersPage extends StatelessWidget {
: ColorsManager.disabledPink.withOpacity(0.5), : ColorsManager.disabledPink.withOpacity(0.5),
), ),
child: Padding( child: Padding(
padding: const EdgeInsets.only(left: 10, right: 10, bottom: 5, top: 5), padding:
const EdgeInsets.only(left: 10, right: 10, bottom: 5, top: 5),
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
@ -84,12 +86,15 @@ class UsersPage extends StatelessWidget {
} }
Widget changeIconStatus( Widget changeIconStatus(
{required String userId, required String status, required Function()? onTap}) { {required String userId,
required String status,
required Function()? onTap}) {
return Center( return Center(
child: InkWell( child: InkWell(
onTap: onTap, onTap: onTap,
child: Padding( child: Padding(
padding: const EdgeInsets.only(left: 5, right: 5, bottom: 5, top: 5), padding:
const EdgeInsets.only(left: 5, right: 5, bottom: 5, top: 5),
child: SvgPicture.asset( child: SvgPicture.asset(
status == "invited" status == "invited"
? Assets.invitedIcon ? Assets.invitedIcon
@ -114,8 +119,7 @@ class UsersPage extends StatelessWidget {
padding: const EdgeInsets.all(20), padding: const EdgeInsets.all(20),
child: Align( child: Align(
alignment: Alignment.topCenter, alignment: Alignment.topCenter,
child: ListView( child: Column(
shrinkWrap: true,
children: [ children: [
Row( Row(
children: [ children: [
@ -188,292 +192,325 @@ class UsersPage extends StatelessWidget {
), ),
], ],
), ),
const SizedBox(height: 25), const SizedBox(height: 20),
DynamicTableScreen( Container(
onFilter: (columnIndex) { height: screenSize.height * 0.65,
if (columnIndex == 0) { child: DynamicTableScreen(
showNameMenu( tableSize: screenSize.height * 0.65,
context: context, onFilter: (columnIndex) {
isSelected: _blocRole.currentSortOrder, if (columnIndex == 0) {
aToZTap: () { showNameMenu(
context.read<UserTableBloc>().add(const SortUsersByNameAsc()); context: context,
}, isSelected: _blocRole.currentSortOrder,
zToaTap: () { aToZTap: () {
context.read<UserTableBloc>().add(const SortUsersByNameDesc()); context
}, .read<UserTableBloc>()
); .add(const SortUsersByNameAsc());
} },
if (columnIndex == 2) { zToATap: () {
final Map<String, bool> checkboxStates = { context
for (var item in _blocRole.jobTitle) .read<UserTableBloc>()
item: _blocRole.selectedJobTitles.contains(item), .add(const SortUsersByNameDesc());
}; },
final RenderBox overlay = );
Overlay.of(context).context.findRenderObject() as RenderBox; }
if (columnIndex == 2) {
final Map<String, bool> checkboxStates = {
for (var item in _blocRole.jobTitle)
item: _blocRole.selectedJobTitles.contains(item),
};
final RenderBox overlay = Overlay.of(context)
.context
.findRenderObject() as RenderBox;
showPopUpFilterMenu( showPopUpFilterMenu(
position: RelativeRect.fromLTRB( position: RelativeRect.fromLTRB(
overlay.size.width / 5.3, overlay.size.width / 5.3,
240, 240,
overlay.size.width / 4, overlay.size.width / 4,
0, 0,
), ),
list: _blocRole.jobTitle, list: _blocRole.jobTitle,
context: context, context: context,
checkboxStates: checkboxStates, checkboxStates: checkboxStates,
isSelected: _blocRole.currentSortJopTitle, isSelected: _blocRole.currentSortJopTitle,
onOkPressed: () { onOkPressed: () {
searchController.clear(); searchController.clear();
_blocRole.add(FilterClearEvent()); _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( _blocRole.add(FilterUsersByJobEvent(
selectedJob: selectedItems, selectedJob: selectedItems,
sortOrder: _blocRole.currentSortJopTitle, sortOrder: _blocRole.currentSortJopTitle,
)); ));
}, },
onSortAtoZ: (v) { onSortAtoZ: (v) {
_blocRole.currentSortJopTitle = v; _blocRole.currentSortJopTitle = v;
}, },
onSortZtoA: (v) { onSortZtoA: (v) {
_blocRole.currentSortJopTitle = v; _blocRole.currentSortJopTitle = v;
}, },
); );
} }
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)
item: _blocRole.selectedRoles.contains(item), item: _blocRole.selectedRoles.contains(item),
}; };
final RenderBox overlay = final RenderBox overlay = Overlay.of(context)
Overlay.of(context).context.findRenderObject() as RenderBox; .context
showPopUpFilterMenu( .findRenderObject() as RenderBox;
position: RelativeRect.fromLTRB( showPopUpFilterMenu(
overlay.size.width / 4, position: RelativeRect.fromLTRB(
240, overlay.size.width / 4,
overlay.size.width / 4, 240,
0, overlay.size.width / 4,
), 0,
list: _blocRole.roleTypes, ),
context: context, list: _blocRole.roleTypes,
checkboxStates: checkboxStates, context: context,
isSelected: _blocRole.currentSortRole, checkboxStates: checkboxStates,
onOkPressed: () { isSelected: _blocRole.currentSortRole,
searchController.clear(); onOkPressed: () {
_blocRole.add(FilterClearEvent()); searchController.clear();
final selectedItems = checkboxStates.entries _blocRole.add(FilterClearEvent());
.where((entry) => entry.value) final selectedItems = checkboxStates.entries
.map((entry) => entry.key) .where((entry) => entry.value)
.toList(); .map((entry) => entry.key)
Navigator.of(context).pop(); .toList();
context.read<UserTableBloc>().add(FilterUsersByRoleEvent( Navigator.of(context).pop();
selectedRoles: selectedItems, context.read<UserTableBloc>().add(
sortOrder: _blocRole.currentSortRole)); FilterUsersByRoleEvent(
}, selectedRoles: selectedItems,
onSortAtoZ: (v) { sortOrder: _blocRole.currentSortRole));
_blocRole.currentSortRole = v; },
}, onSortAtoZ: (v) {
onSortZtoA: (v) { _blocRole.currentSortRole = v;
_blocRole.currentSortRole = v; },
}, onSortZtoA: (v) {
); _blocRole.currentSortRole = v;
} },
if (columnIndex == 4) { );
showDateFilterMenu( }
context: context, if (columnIndex == 4) {
isSelected: _blocRole.currentSortOrder, showDateFilterMenu(
aToZTap: () { context: context,
context.read<UserTableBloc>().add(const DateNewestToOldestEvent()); isSelected: _blocRole.currentSortOrder,
}, aToZTap: () {
zToaTap: () { context
context.read<UserTableBloc>().add(const DateOldestToNewestEvent()); .read<UserTableBloc>()
}, .add(const DateNewestToOldestEvent());
); },
} zToaTap: () {
if (columnIndex == 6) { context
final Map<String, bool> checkboxStates = { .read<UserTableBloc>()
for (var item in _blocRole.createdBy) .add(const DateOldestToNewestEvent());
item: _blocRole.selectedCreatedBy.contains(item), },
}; );
final RenderBox overlay = }
Overlay.of(context).context.findRenderObject() as RenderBox; if (columnIndex == 6) {
showPopUpFilterMenu( final Map<String, bool> checkboxStates = {
position: RelativeRect.fromLTRB( for (var item in _blocRole.createdBy)
overlay.size.width / 1, item: _blocRole.selectedCreatedBy.contains(item),
240, };
overlay.size.width / 4, final RenderBox overlay = Overlay.of(context)
0, .context
), .findRenderObject() as RenderBox;
list: _blocRole.createdBy, showPopUpFilterMenu(
context: context, position: RelativeRect.fromLTRB(
checkboxStates: checkboxStates, overlay.size.width / 1,
isSelected: _blocRole.currentSortCreatedBy, 240,
onOkPressed: () { overlay.size.width / 4,
searchController.clear(); 0,
_blocRole.add(FilterClearEvent()); ),
final selectedItems = checkboxStates.entries list: _blocRole.createdBy,
.where((entry) => entry.value) context: context,
.map((entry) => entry.key) checkboxStates: checkboxStates,
.toList(); isSelected: _blocRole.currentSortCreatedBy,
Navigator.of(context).pop(); onOkPressed: () {
_blocRole.add(FilterUsersByCreatedEvent( searchController.clear();
selectedCreatedBy: selectedItems, _blocRole.add(FilterClearEvent());
sortOrder: _blocRole.currentSortCreatedBy)); final selectedItems = checkboxStates.entries
}, .where((entry) => entry.value)
onSortAtoZ: (v) { .map((entry) => entry.key)
_blocRole.currentSortCreatedBy = v; .toList();
}, Navigator.of(context).pop();
onSortZtoA: (v) { _blocRole.add(FilterUsersByCreatedEvent(
_blocRole.currentSortCreatedBy = v; selectedCreatedBy: selectedItems,
}, sortOrder: _blocRole.currentSortCreatedBy));
); },
} onSortAtoZ: (v) {
if (columnIndex == 7) { _blocRole.currentSortCreatedBy = v;
final Map<String, bool> checkboxStates = { },
for (var item in _blocRole.status) onSortZtoA: (v) {
item: _blocRole.selectedStatuses.contains(item), _blocRole.currentSortCreatedBy = v;
}; },
);
}
if (columnIndex == 7) {
final Map<String, bool> checkboxStates = {
for (var item in _blocRole.status)
item: _blocRole.selectedStatuses.contains(item),
};
final RenderBox overlay = final RenderBox overlay = Overlay.of(context)
Overlay.of(context).context.findRenderObject() as RenderBox; .context
showPopUpFilterMenu( .findRenderObject() as RenderBox;
position: RelativeRect.fromLTRB( showPopUpFilterMenu(
overlay.size.width / 0, position: RelativeRect.fromLTRB(
240, overlay.size.width / 0,
overlay.size.width / 5, 240,
0, overlay.size.width / 5,
0,
),
list: _blocRole.status,
context: context,
checkboxStates: checkboxStates,
isSelected: _blocRole.currentSortStatus,
onOkPressed: () {
searchController.clear();
_blocRole.add(FilterClearEvent());
final selectedItems = checkboxStates.entries
.where((entry) => entry.value)
.map((entry) => entry.key)
.toList();
Navigator.of(context).pop();
_blocRole.add(FilterUsersByDeActevateEvent(
selectedActivate: selectedItems,
sortOrder: _blocRole.currentSortStatus));
},
onSortAtoZ: (v) {
_blocRole.currentSortStatus = v;
},
onSortZtoA: (v) {
_blocRole.currentSortStatus = v;
},
);
}
if (columnIndex == 8) {
showDeActivateFilterMenu(
context: context,
isSelected: _blocRole.currentSortOrderDate,
aToZTap: () {
context
.read<UserTableBloc>()
.add(const DateNewestToOldestEvent());
},
zToaTap: () {
context
.read<UserTableBloc>()
.add(const DateOldestToNewestEvent());
},
);
}
},
titles: const [
"Full Name",
"Email Address",
"Job Title",
"Role",
"Creation Date",
"Creation Time",
"Created By",
"Status",
"De/Activate",
"Action"
],
rows: state.users.map((user) {
return [
Text('${user.firstName} ${user.lastName}'),
Text(user.email),
Text(user.jobTitle),
Text(user.roleType ?? ''),
Text(user.createdDate ?? ''),
Text(user.createdTime ?? ''),
Text(user.invitedBy),
status(
status: user.isEnabled == false
? 'disabled'
: user.status,
), ),
list: _blocRole.status, changeIconStatus(
context: context, status: user.isEnabled == false
checkboxStates: checkboxStates, ? 'disabled'
isSelected: _blocRole.currentSortStatus, : user.status,
onOkPressed: () { userId: user.uuid,
searchController.clear(); onTap: user.status != "invited"
_blocRole.add(FilterClearEvent()); ? () {
final selectedItems = checkboxStates.entries context.read<UserTableBloc>().add(
.where((entry) => entry.value) ChangeUserStatus(
.map((entry) => entry.key) userId: user.uuid,
.toList(); newStatus: user.isEnabled == false
Navigator.of(context).pop(); ? 'disabled'
_blocRole.add(FilterUsersByDeActevateEvent( : user.status));
selectedActivate: selectedItems, }
sortOrder: _blocRole.currentSortStatus)); : null,
}, ),
onSortAtoZ: (v) { Row(
_blocRole.currentSortStatus = v; children: [
}, user.isEnabled != false
onSortZtoA: (v) { ? actionButton(
_blocRole.currentSortStatus = v; isActive: true,
}, title: "Edit",
); onTap: () {
} context
if (columnIndex == 8) { .read<SpaceTreeBloc>()
showDeActivateFilterMenu( .add(ClearCachedData());
context: context, showDialog(
isSelected: _blocRole.currentSortOrderDate, context: context,
aToZTap: () { barrierDismissible: false,
context.read<UserTableBloc>().add(const DateNewestToOldestEvent()); builder: (BuildContext context) {
}, return EditUserDialog(
zToaTap: () { userId: user.uuid);
context.read<UserTableBloc>().add(const DateOldestToNewestEvent()); },
}, ).then((v) {
);
}
},
titles: const [
"Full Name",
"Email Address",
"Job Title",
"Role",
"Creation Date",
"Creation Time",
"Created By",
"Status",
"De/Activate",
"Action"
],
rows: state.users.map((user) {
return [
Text('${user.firstName} ${user.lastName}'),
Text(user.email),
Text(user.jobTitle),
Text(user.roleType ?? ''),
Text(user.createdDate ?? ''),
Text(user.createdTime ?? ''),
Text(user.invitedBy),
status(
status: user.isEnabled == false ? 'disabled' : user.status,
),
changeIconStatus(
status: user.isEnabled == false ? 'disabled' : user.status,
userId: user.uuid,
onTap: user.status != "invited"
? () {
context.read<UserTableBloc>().add(ChangeUserStatus(
userId: user.uuid,
newStatus:
user.isEnabled == false ? 'disabled' : user.status));
}
: null,
),
Row(
children: [
user.isEnabled != false
? actionButton(
isActive: true,
title: "Edit",
onTap: () {
context.read<SpaceTreeBloc>().add(ClearCachedData());
showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return EditUserDialog(userId: user.uuid);
},
).then((v) {
if (v != null) {
if (v != null) { if (v != null) {
_blocRole.add(const GetUsers()); if (v != null) {
_blocRole.add(const GetUsers());
}
} }
});
},
)
: actionButton(
title: "Edit",
),
actionButton(
title: "Delete",
onTap: () {
showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return DeleteUserDialog(
onTapDelete: () async {
try {
_blocRole.add(DeleteUserEvent(
user.uuid, context));
await Future.delayed(
const Duration(seconds: 2));
return true;
} catch (e) {
return false;
} }
}); });
}, },
) ).then((v) {
: actionButton( if (v != null) {
title: "Edit", _blocRole.add(const GetUsers());
), }
actionButton( });
title: "Delete", },
onTap: () { ),
showDialog( ],
context: context, ),
barrierDismissible: false, ];
builder: (BuildContext context) { }).toList(),
return DeleteUserDialog(onTapDelete: () async { ),
try {
_blocRole.add(DeleteUserEvent(user.uuid, context));
await Future.delayed(const Duration(seconds: 2));
return true;
} catch (e) {
return false;
}
});
},
).then((v) {
if (v != null) {
_blocRole.add(const GetUsers());
}
});
},
),
],
),
];
}).toList(),
), ),
Padding( Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
@ -486,14 +523,20 @@ class UsersPage extends StatelessWidget {
visiblePagesCount: 4, visiblePagesCount: 4,
buttonRadius: 10, buttonRadius: 10,
selectedButtonColor: ColorsManager.secondaryColor, selectedButtonColor: ColorsManager.secondaryColor,
buttonUnSelectedBorderColor: ColorsManager.grayBorder, buttonUnSelectedBorderColor:
lastPageIcon: const Icon(Icons.keyboard_double_arrow_right), ColorsManager.grayBorder,
firstPageIcon: const Icon(Icons.keyboard_double_arrow_left), lastPageIcon:
totalPages: const Icon(Icons.keyboard_double_arrow_right),
(_blocRole.totalUsersCount.length / _blocRole.itemsPerPage).ceil(), firstPageIcon:
const Icon(Icons.keyboard_double_arrow_left),
totalPages: (_blocRole.totalUsersCount.length /
_blocRole.itemsPerPage)
.ceil(),
currentPage: _blocRole.currentPage, currentPage: _blocRole.currentPage,
onPageChanged: (int pageNumber) { onPageChanged: (int pageNumber) {
context.read<UserTableBloc>().add(ChangePage(pageNumber)); context
.read<UserTableBloc>()
.add(ChangePage(pageNumber));
}, },
), ),
), ),

View File

@ -99,7 +99,27 @@ class _EnergyClampDialogState extends State<EnergyClampDialog> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
const DialogHeader('Energy Clamp Conditions'), const DialogHeader('Energy Clamp Conditions'),
Expanded(child: _buildMainContent(context, state)), Expanded(
child: Visibility(
visible: _functions.isNotEmpty,
replacement: SizedBox(
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Center(
child: Text(
'You Cant add\n the Power Clamp to Then Section',
textAlign: TextAlign.center,
style: context.textTheme.bodyMedium!.copyWith(
color: ColorsManager.red,
fontWeight: FontWeight.w400),
)),
],
),
),
child: _buildMainContent(context, state),
)),
_buildDialogFooter(context, state), _buildDialogFooter(context, state),
], ],
), ),

View File

@ -24,6 +24,9 @@ class SpaceTreeBloc extends Bloc<SpaceTreeEvent, SpaceTreeState> {
on<PaginationEvent>(_fetchPaginationSpaces); on<PaginationEvent>(_fetchPaginationSpaces);
on<DebouncedSearchEvent>(_onDebouncedSearch); on<DebouncedSearchEvent>(_onDebouncedSearch);
on<SpaceTreeClearSelectionEvent>(_onSpaceTreeClearSelectionEvent); on<SpaceTreeClearSelectionEvent>(_onSpaceTreeClearSelectionEvent);
on<AnalyticsClearAllSpaceTreeSelectionsEvent>(
_onAnalyticsClearAllSpaceTreeSelectionsEvent,
);
} }
Timer _timer = Timer(const Duration(microseconds: 0), () {}); Timer _timer = Timer(const Duration(microseconds: 0), () {});
@ -493,6 +496,20 @@ class SpaceTreeBloc extends Bloc<SpaceTreeEvent, SpaceTreeState> {
); );
} }
void _onAnalyticsClearAllSpaceTreeSelectionsEvent(
AnalyticsClearAllSpaceTreeSelectionsEvent event,
Emitter<SpaceTreeState> emit,
) async {
emit(
state.copyWith(
selectedCommunities: [],
selectedCommunityAndSpaces: {},
selectedSpaces: [],
soldCheck: [],
),
);
}
@override @override
Future<void> close() async { Future<void> close() async {
_timer.cancel(); _timer.cancel();

View File

@ -112,3 +112,7 @@ class ClearCachedData extends SpaceTreeEvent {}
class SpaceTreeClearSelectionEvent extends SpaceTreeEvent { class SpaceTreeClearSelectionEvent extends SpaceTreeEvent {
const SpaceTreeClearSelectionEvent(); const SpaceTreeClearSelectionEvent();
} }
final class AnalyticsClearAllSpaceTreeSelectionsEvent extends SpaceTreeEvent {
const AnalyticsClearAllSpaceTreeSelectionsEvent();
}