This commit is contained in:
hannathkadher
2025-01-21 11:41:53 +04:00
parent eb53671e3a
commit 0e912207e5
4 changed files with 29 additions and 34 deletions

View File

@ -123,7 +123,6 @@ class AssignTagModelBloc
bool _validateTags(List<TagModel> tags) {
if (tags.isEmpty) {
print("tags empty");
return false;
}
final uniqueTags = tags.map((tag) => tag.tag?.trim() ?? '').toSet();

View File

@ -232,8 +232,6 @@ class AssignTagModelsDialog extends StatelessWidget {
builder: (buttonContext) => CancelButton(
label: 'Add New Device',
onPressed: () async {
Navigator.of(context).pop();
for (var tag in state.tags) {
if (tag.location == null || subspaces == null) {
continue;
@ -255,13 +253,13 @@ class AssignTagModelsDialog extends StatelessWidget {
state.tags.removeWhere(
(t) => t.internalId == tag.internalId);
}
}
if (context.mounted) {
await showDialog<bool>(
barrierDismissible: false,
context:
Navigator.of(context, rootNavigator: true)
.context,
builder: (context) => AddDeviceTypeModelWidget(
context: context,
builder: (dialogContext) =>
AddDeviceTypeModelWidget(
products: products,
subspaces: subspaces,
isCreate: false,
@ -271,6 +269,7 @@ class AssignTagModelsDialog extends StatelessWidget {
spaceTagModels: state.tags,
onUpdate: (tags, subspaces) {
onUpdate?.call(state.tags, subspaces);
Navigator.of(context).pop();
},
),
);
@ -318,10 +317,8 @@ class AssignTagModelsDialog extends StatelessWidget {
(t) => t.internalId == tag.internalId);
}
}
print("tryinh yo save");
onUpdate?.call(state.tags, subspaces);
}
: null,
child: const Text('Save'),

View File

@ -94,21 +94,20 @@ class TagChipDisplay extends StatelessWidget {
barrierDismissible: false,
context: navigatorContext,
builder: (context) => AssignTagModelsDialog(
products: products,
subspaces: subspaces,
allTags: allTags,
initialTags: TagHelper.generateInitialTags(
subspaces: subspaces,
spaceTagModels: spaceModel?.tags ?? []),
title: 'Edit Device',
addedProducts:
TagHelper.createInitialSelectedProducts(
spaceModel?.tags ?? [], subspaces),
spaceName: spaceModel?.modelName ?? '',
onUpdate: (tags, subspaces){
print("here");
onLoad?.call(tags, subspaces);}
),
products: products,
subspaces: subspaces,
allTags: allTags,
initialTags: TagHelper.generateInitialTags(
subspaces: subspaces,
spaceTagModels: spaceModel?.tags ?? []),
title: 'Edit Device',
addedProducts:
TagHelper.createInitialSelectedProducts(
spaceModel?.tags ?? [], subspaces),
spaceName: spaceModel?.modelName ?? '',
onUpdate: (tags, subspaces) {
onLoad?.call(tags, subspaces);
}),
);
}
},
@ -139,7 +138,12 @@ class TagChipDisplay extends StatelessWidget {
allTags: allTags,
spaceName: spaceNameController.text,
isCreate: true,
onLoad: (tags, subspaces) => onLoad?.call(tags, subspaces),
onUpdate: (tags, subspaces) {
onLoad?.call(tags, subspaces);
},
onLoad: (tags, subspaces) {
onLoad?.call(tags, subspaces);
},
),
);
},

View File

@ -41,12 +41,7 @@ class AddDeviceTypeModelWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
if (spaceTagModels != null) {
for (var tag in spaceTagModels!) {
print(tag.tag);
}
}
final size = MediaQuery.of(context).size;
final crossAxisCount = size.width > 1200
@ -149,7 +144,7 @@ class AddDeviceTypeModelWidget extends StatelessWidget {
initialTags: state.initialTag,
title: dialogTitle,
onUpdate: (tags, subspaces) {
onLoad?.call(tags, subspaces);
onUpdate?.call(tags, subspaces);
},
),
);