mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
updating tags inside subspace
This commit is contained in:
@ -299,7 +299,7 @@ class TagHelper {
|
||||
|
||||
static Map<String, dynamic> updateSubspaceTagModels(
|
||||
List<TagModel> updatedTags, List<SubspaceTemplateModel>? subspaces) {
|
||||
return TagHelper.updateTags<TagModel>(
|
||||
final result = TagHelper.updateTags<TagModel>(
|
||||
updatedTags: updatedTags,
|
||||
subspaces: subspaces,
|
||||
getInternalId: (tag) => tag.internalId,
|
||||
@ -310,6 +310,34 @@ class TagHelper {
|
||||
setSubspaceTags: (subspace, tags) => subspace.tags = tags,
|
||||
checkTagExistInSubspace: checkTagExistInSubspaceModels,
|
||||
);
|
||||
|
||||
final processedTags = result['updatedTags'] as List<TagModel>;
|
||||
final processedSubspaces =
|
||||
List<SubspaceTemplateModel>.from(result['subspaces'] as List<dynamic>);
|
||||
|
||||
for (var subspace in processedSubspaces) {
|
||||
final subspaceTags = subspace.tags;
|
||||
|
||||
if (subspaceTags != null) {
|
||||
for (int i = 0; i < subspaceTags.length; i++) {
|
||||
final tag = subspaceTags[i];
|
||||
|
||||
// Find the updated tag inside processedTags
|
||||
final changedTag = updatedTags.firstWhere(
|
||||
(t) => t.internalId == tag.internalId,
|
||||
orElse: () => tag,
|
||||
);
|
||||
|
||||
if (changedTag.tag != tag.tag) {
|
||||
subspaceTags[i] = changedTag.copyWith(tag: changedTag.tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
subspace.tags = subspaceTags;
|
||||
}
|
||||
|
||||
return {'updatedTags': processedTags, 'subspaces': processedSubspaces};
|
||||
}
|
||||
|
||||
static int? checkTagExistInSubspace(Tag tag, List<dynamic>? subspaces) {
|
||||
@ -328,7 +356,7 @@ class TagHelper {
|
||||
|
||||
static Map<String, dynamic> processTags(
|
||||
List<Tag> updatedTags, List<SubspaceModel>? subspaces) {
|
||||
return TagHelper.updateTags<Tag>(
|
||||
final result = TagHelper.updateTags<Tag>(
|
||||
updatedTags: updatedTags,
|
||||
subspaces: subspaces,
|
||||
getInternalId: (tag) => tag.internalId,
|
||||
@ -339,6 +367,33 @@ class TagHelper {
|
||||
setSubspaceTags: (subspace, tags) => subspace.tags = tags,
|
||||
checkTagExistInSubspace: checkTagExistInSubspace,
|
||||
);
|
||||
|
||||
final processedTags = result['updatedTags'] as List<Tag>;
|
||||
final processedSubspaces =
|
||||
List<SubspaceModel>.from(result['subspaces'] as List<dynamic>);
|
||||
|
||||
for (var subspace in processedSubspaces) {
|
||||
final subspaceTags = subspace.tags;
|
||||
|
||||
if (subspaceTags != null) {
|
||||
for (int i = 0; i < subspaceTags.length; i++) {
|
||||
final tag = subspaceTags[i];
|
||||
|
||||
final changedTag = updatedTags.firstWhere(
|
||||
(t) => t.internalId == tag.internalId,
|
||||
orElse: () => tag,
|
||||
);
|
||||
|
||||
if (changedTag.tag != tag.tag) {
|
||||
subspaceTags[i] = changedTag.copyWith(tag: changedTag.tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
subspace.tags = subspaceTags;
|
||||
}
|
||||
|
||||
return {'updatedTags': processedTags, 'subspaces': processedSubspaces};
|
||||
}
|
||||
|
||||
static List<String> getAllTagValues(
|
||||
|
Reference in New Issue
Block a user