mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
comment (SpaceModelLinking && Or)Widgets cuz no need for spaceModel for now&& fix the delete devices from subSpaces to keep in main space not to get deleted
This commit is contained in:
@ -155,63 +155,76 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
SpaceModelLinkingWidget(
|
||||
isSpaceModelDisabled: isSpaceModelDisabled,
|
||||
onPressed: () {
|
||||
isSpaceModelDisabled
|
||||
? null
|
||||
: _showLinkSpaceModelDialog(context);
|
||||
},
|
||||
onDeleted: () => setState(() {
|
||||
selectedSpaceModel = null;
|
||||
subspaces = widget.subspaces ?? [];
|
||||
tags = widget.tags ?? [];
|
||||
}),
|
||||
screenWidth: screenWidth,
|
||||
selectedSpaceModel: selectedSpaceModel,
|
||||
),
|
||||
// SpaceModelLinkingWidget(
|
||||
// isSpaceModelDisabled: true,
|
||||
// // isSpaceModelDisabled,
|
||||
// onPressed: () {
|
||||
// isSpaceModelDisabled
|
||||
// ? null
|
||||
// : _showLinkSpaceModelDialog(context);
|
||||
// },
|
||||
// onDeleted: () => setState(() {
|
||||
// selectedSpaceModel = null;
|
||||
// subspaces = widget.subspaces ?? [];
|
||||
// tags = widget.tags ?? [];
|
||||
// }),
|
||||
// screenWidth: screenWidth,
|
||||
// selectedSpaceModel: selectedSpaceModel,
|
||||
// ),
|
||||
const SizedBox(height: 25),
|
||||
Row(
|
||||
children: [
|
||||
const Expanded(
|
||||
child: Divider(
|
||||
color: ColorsManager.neutralGray,
|
||||
thickness: 1.0,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6.0),
|
||||
child: Text(
|
||||
'OR',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium
|
||||
?.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
const Expanded(
|
||||
child: Divider(
|
||||
color: ColorsManager.neutralGray,
|
||||
thickness: 1.0,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
// Row(
|
||||
// children: [
|
||||
// const Expanded(
|
||||
// child: Divider(
|
||||
// color: ColorsManager.neutralGray,
|
||||
// thickness: 1.0,
|
||||
// ),
|
||||
// ),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 6.0),
|
||||
// child: Text(
|
||||
// 'OR',
|
||||
// style: Theme.of(context)
|
||||
// .textTheme
|
||||
// .bodyMedium
|
||||
// ?.copyWith(fontWeight: FontWeight.bold),
|
||||
// ),
|
||||
// ),
|
||||
// const Expanded(
|
||||
// child: Divider(
|
||||
// color: ColorsManager.neutralGray,
|
||||
// thickness: 1.0,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
const SizedBox(height: 25),
|
||||
SubSpacePartWidget(
|
||||
subspaces: subspaces,
|
||||
onPressed: () {
|
||||
isTagsAndSubspaceModelDisabled
|
||||
? null
|
||||
: _showSubSpaceDialog(context, enteredName, [],
|
||||
false, widget.products, subspaces);
|
||||
: _showSubSpaceDialog(
|
||||
context,
|
||||
enteredName,
|
||||
[],
|
||||
false,
|
||||
widget.products,
|
||||
subspaces,
|
||||
);
|
||||
},
|
||||
isTagsAndSubspaceModelDisabled:
|
||||
isTagsAndSubspaceModelDisabled,
|
||||
screenWidth: screenWidth,
|
||||
editChipOnTap: () async {
|
||||
_showSubSpaceDialog(context, enteredName, [], true,
|
||||
widget.products, subspaces);
|
||||
_showSubSpaceDialog(
|
||||
context,
|
||||
enteredName,
|
||||
[],
|
||||
true,
|
||||
widget.products,
|
||||
subspaces,
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
@ -289,6 +302,13 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
? enteredName
|
||||
: (widget.name ?? '');
|
||||
if (newName.isNotEmpty) {
|
||||
if (tags != null && tags!.isNotEmpty) {
|
||||
if (tags!.any(
|
||||
(tag) => tag.uuid == null || tag.uuid!.isEmpty,
|
||||
)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
widget.onCreateSpace(
|
||||
newName,
|
||||
selectedIcon,
|
||||
@ -352,12 +372,13 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
}
|
||||
|
||||
void _showSubSpaceDialog(
|
||||
BuildContext context,
|
||||
String name,
|
||||
final List<Tag>? spaceTags,
|
||||
bool isEdit,
|
||||
List<ProductModel>? products,
|
||||
final List<SubspaceModel>? existingSubSpaces) {
|
||||
BuildContext context,
|
||||
String name,
|
||||
final List<Tag>? spaceTags,
|
||||
bool isEdit,
|
||||
List<ProductModel>? products,
|
||||
final List<SubspaceModel>? existingSubSpaces,
|
||||
) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
@ -366,7 +387,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
dialogTitle: isEdit ? 'Edit Sub-spaces' : 'Create Sub-spaces',
|
||||
products: products,
|
||||
existingSubSpaces: existingSubSpaces,
|
||||
onSave: (slectedSubspaces) {
|
||||
onSave: (slectedSubspaces, updatedSubSpaces) {
|
||||
final List<Tag> tagsToAppendToSpace = [];
|
||||
|
||||
if (slectedSubspaces != null && slectedSubspaces.isNotEmpty) {
|
||||
@ -378,6 +399,22 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
.toList();
|
||||
for (var s in deletedSubspaces) {
|
||||
if (s.tags != null) {
|
||||
s.tags!.forEach(
|
||||
(tag) => tag.location = null,
|
||||
);
|
||||
tagsToAppendToSpace.addAll(s.tags!);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (existingSubSpaces != null) {
|
||||
final deletedSubspaces = existingSubSpaces;
|
||||
|
||||
for (var s in deletedSubspaces) {
|
||||
if (s.tags != null) {
|
||||
s.tags!.forEach(
|
||||
(tag) => tag.location = null,
|
||||
);
|
||||
tagsToAppendToSpace.addAll(s.tags!);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user