mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-08-26 09:49:41 +00:00
Refactor Space and Tag Models: Removed unused JSON serialization methods from SpaceDetailsModel, ProductAllocation, and Subspace. Updated Tag model to eliminate unnecessary fields. Enhanced UpdateSpaceParam to streamline JSON conversion for subspaces and product allocations, improving data handling during updates.
This commit is contained in:
@ -13,33 +13,29 @@ class UpdateSpaceParam {
|
||||
return {
|
||||
'spaceName': space.spaceName,
|
||||
'icon': space.icon,
|
||||
'subspaces': space.subspaces
|
||||
.map(
|
||||
(e) => {
|
||||
'subspaceName': e.name,
|
||||
'productAllocations': e.productAllocations
|
||||
.map(
|
||||
(e) => {
|
||||
'name': e.tag.name,
|
||||
'productUuid': e.product.uuid,
|
||||
'uuid': e.uuid,
|
||||
},
|
||||
)
|
||||
.toList(),
|
||||
'uuid': e.uuid,
|
||||
},
|
||||
)
|
||||
.toList(),
|
||||
'productAllocations': space.productAllocations
|
||||
.map(
|
||||
(e) => {
|
||||
'tagName': e.tag.name,
|
||||
'tagUuid': e.tag.uuid,
|
||||
'productUuid': e.product.uuid,
|
||||
},
|
||||
)
|
||||
.toList(),
|
||||
'spaceModelUuid': space.uuid,
|
||||
'subspaces': space.subspaces.map((e) => e._toJson()).toList(),
|
||||
'productAllocations':
|
||||
space.productAllocations.map((e) => e._toJson()).toList(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
extension _ProductAllocationToJson on ProductAllocation {
|
||||
Map<String, dynamic> _toJson() {
|
||||
final isNewTag = tag.uuid.isEmpty;
|
||||
return <String, dynamic>{
|
||||
if (isNewTag) 'tagName': tag.name else 'tagUuid': tag.uuid,
|
||||
'productUuid': product.uuid,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
extension _SubspaceToJson on Subspace {
|
||||
Map<String, dynamic> _toJson() {
|
||||
final isNewSubspace = uuid.endsWith('-NewTag');
|
||||
return <String, dynamic>{
|
||||
if (isNewSubspace) 'subspaceName': name else 'uuid': uuid,
|
||||
'productAllocations': productAllocations.map((e) => e._toJson()).toList(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user