mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-11-27 20:04:56 +00:00
@ -16,7 +16,7 @@ abstract class BaseTag {
|
||||
this.location,
|
||||
}) : internalId = internalId ?? const Uuid().v4();
|
||||
|
||||
Map<String, dynamic> toJson();
|
||||
Map<String, dynamic> toJson();
|
||||
BaseTag copyWith({
|
||||
String? tag,
|
||||
ProductModel? product,
|
||||
|
||||
@ -27,12 +27,9 @@ class CommunityModel {
|
||||
updatedAt: DateTime.parse(json['updatedAt'] ?? ''),
|
||||
name: json['name'] ?? '',
|
||||
description: json['description'] ?? '',
|
||||
region:
|
||||
json['region'] != null ? RegionModel.fromJson(json['region']) : null,
|
||||
region: json['region'] != null ? RegionModel.fromJson(json['region']) : null,
|
||||
spaces: json['spaces'] != null
|
||||
? (json['spaces'] as List)
|
||||
.map((space) => SpaceModel.fromJson(space))
|
||||
.toList()
|
||||
? (json['spaces'] as List).map((space) => SpaceModel.fromJson(space)).toList()
|
||||
: [],
|
||||
);
|
||||
}
|
||||
@ -45,9 +42,7 @@ class CommunityModel {
|
||||
'name': name,
|
||||
'description': description,
|
||||
'region': region?.toJson(),
|
||||
'spaces': spaces
|
||||
.map((space) => space.toMap())
|
||||
.toList(), // Convert spaces to Map
|
||||
'spaces': spaces.map((space) => space.toMap()).toList(), // Convert spaces to Map
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/selected_product_model.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
|
||||
import 'selected_product_model.dart';
|
||||
|
||||
class ProductModel {
|
||||
final String uuid;
|
||||
final String catName;
|
||||
|
||||
@ -6,11 +6,7 @@ class SelectedProduct {
|
||||
final String productName;
|
||||
final ProductModel? product;
|
||||
|
||||
SelectedProduct(
|
||||
{required this.productId,
|
||||
required this.count,
|
||||
required this.productName,
|
||||
this.product});
|
||||
SelectedProduct({required this.productId, required this.count, required this.productName, this.product});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
@ -20,7 +16,7 @@ class SelectedProduct {
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
@override
|
||||
String toString() {
|
||||
return 'SelectedProduct(productId: $productId, count: $count)';
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ class SpaceModel {
|
||||
{String? parentInternalId}) {
|
||||
final String internalId = json['internalId'] ?? const Uuid().v4();
|
||||
|
||||
final children = json['children'] != null
|
||||
final List<SpaceModel> children = json['children'] != null
|
||||
? (json['children'] as List).map((childJson) {
|
||||
return SpaceModel.fromJson(
|
||||
childJson,
|
||||
@ -73,8 +73,8 @@ class SpaceModel {
|
||||
isPrivate: json['isPrivate'] ?? false,
|
||||
invitationCode: json['invitationCode'],
|
||||
subspaces: (json['subspaces'] as List<dynamic>?)
|
||||
?.whereType<Map<String, dynamic>>() // Validate type
|
||||
.map(SubspaceModel.fromJson)
|
||||
?.where((e) => e is Map<String, dynamic>) // Validate type
|
||||
.map((e) => SubspaceModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
[],
|
||||
parent: parentInternalId != null
|
||||
@ -102,8 +102,8 @@ class SpaceModel {
|
||||
? SpaceTemplateModel.fromJson(json['spaceModel'])
|
||||
: null,
|
||||
tags: (json['productAllocations'] as List<dynamic>?)
|
||||
?.whereType<Map<String, dynamic>>() // Validate type
|
||||
.map(Tag.fromJson)
|
||||
?.where((item) => item is Map<String, dynamic>) // Validate type
|
||||
.map((item) => Tag.fromJson(item as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
[],
|
||||
);
|
||||
@ -150,7 +150,7 @@ class SpaceModel {
|
||||
|
||||
extension SpaceExtensions on SpaceModel {
|
||||
List<String> listAllTagValues() {
|
||||
final tagValues = <String>[];
|
||||
final List<String> tagValues = [];
|
||||
|
||||
if (tags != null) {
|
||||
tagValues.addAll(
|
||||
@ -174,10 +174,10 @@ extension SpaceExtensions on SpaceModel {
|
||||
|
||||
bool isNoChangesSubmited(String name, icon, SpaceTemplateModel? spaceModel,
|
||||
List<SubspaceModel>? subspaces, List<Tag>? tags) {
|
||||
return name == this.name &&
|
||||
return (name == this.name &&
|
||||
icon == this.icon &&
|
||||
spaceModel == this.spaceModel &&
|
||||
subspaces == this.subspaces &&
|
||||
tags == this.tags;
|
||||
tags == this.tags);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
||||
|
||||
import 'space_model.dart';
|
||||
|
||||
class SpacesResponse {
|
||||
final List<SpaceModel> data;
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
||||
import 'package:syncrow_web/utils/constants/action_enum.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
import 'tag.dart';
|
||||
|
||||
class SubspaceModel {
|
||||
final String? uuid;
|
||||
String subspaceName;
|
||||
|
||||
@ -6,12 +6,18 @@ import 'package:uuid/uuid.dart';
|
||||
|
||||
class Tag extends BaseTag {
|
||||
Tag({
|
||||
super.uuid,
|
||||
required super.tag,
|
||||
super.product,
|
||||
super.internalId,
|
||||
super.location,
|
||||
});
|
||||
String? uuid,
|
||||
required String? tag,
|
||||
ProductModel? product,
|
||||
String? internalId,
|
||||
String? location,
|
||||
}) : super(
|
||||
uuid: uuid,
|
||||
tag: tag,
|
||||
product: product,
|
||||
internalId: internalId,
|
||||
location: location,
|
||||
);
|
||||
|
||||
factory Tag.fromJson(Map<String, dynamic> json) {
|
||||
final String internalId = json['internalId'] ?? const Uuid().v4();
|
||||
@ -44,7 +50,6 @@ class Tag extends BaseTag {
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
if (uuid != null) 'uuid': uuid,
|
||||
|
||||
Reference in New Issue
Block a user