mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-08-26 07:29:41 +00:00
updated tag issue for subspace
This commit is contained in:
26
lib/pages/spaces_management/all_spaces/model/base_tag.dart
Normal file
26
lib/pages/spaces_management/all_spaces/model/base_tag.dart
Normal file
@ -0,0 +1,26 @@
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
abstract class BaseTag {
|
||||
String? uuid;
|
||||
String? tag;
|
||||
final ProductModel? product;
|
||||
String internalId;
|
||||
String? location;
|
||||
|
||||
BaseTag({
|
||||
this.uuid,
|
||||
required this.tag,
|
||||
this.product,
|
||||
String? internalId,
|
||||
this.location,
|
||||
}) : internalId = internalId ?? const Uuid().v4();
|
||||
|
||||
Map<String, dynamic> toJson();
|
||||
BaseTag copyWith({
|
||||
String? tag,
|
||||
ProductModel? product,
|
||||
String? location,
|
||||
String? internalId,
|
||||
});
|
||||
}
|
@ -1,22 +1,23 @@
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/base_tag.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/create_space_template_body_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_body_model.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
class Tag {
|
||||
String? uuid;
|
||||
String? tag;
|
||||
final ProductModel? product;
|
||||
String internalId;
|
||||
String? location;
|
||||
|
||||
Tag(
|
||||
{this.uuid,
|
||||
required this.tag,
|
||||
this.product,
|
||||
String? internalId,
|
||||
this.location})
|
||||
: internalId = internalId ?? const Uuid().v4();
|
||||
class Tag extends BaseTag {
|
||||
Tag({
|
||||
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();
|
||||
@ -31,15 +32,19 @@ class Tag {
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Tag copyWith({
|
||||
String? tag,
|
||||
ProductModel? product,
|
||||
String? location,
|
||||
String? internalId,
|
||||
}) {
|
||||
return Tag(
|
||||
uuid: uuid,
|
||||
tag: tag ?? this.tag,
|
||||
product: product ?? this.product,
|
||||
location: location ?? this.location,
|
||||
internalId: internalId ?? this.internalId,
|
||||
);
|
||||
}
|
||||
|
||||
@ -60,7 +65,7 @@ extension TagModelExtensions on Tag {
|
||||
..productUuid = product?.uuid;
|
||||
}
|
||||
|
||||
CreateTagBodyModel toCreateTagBodyModel() {
|
||||
CreateTagBodyModel toCreateTagBodyModel() {
|
||||
return CreateTagBodyModel()
|
||||
..tag = tag ?? ''
|
||||
..productUuid = product?.uuid;
|
||||
|
Reference in New Issue
Block a user