Revert "formatted all files."

This reverts commit 04250ebc98.
This commit is contained in:
Faris Armoush
2025-06-12 16:04:49 +03:00
parent 218f43bacb
commit c642ba2644
473 changed files with 4335 additions and 5417 deletions

View File

@ -2,20 +2,18 @@ import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_m
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
class SpaceHelper {
static SpaceModel? findSpaceByUuid(
String? uuid, List<CommunityModel> communities) {
for (final community in communities) {
for (final space in community.spaces) {
static SpaceModel? findSpaceByUuid(String? uuid, List<CommunityModel> communities) {
for (var community in communities) {
for (var space in community.spaces) {
if (space.uuid == uuid) return space;
}
}
return null;
}
static SpaceModel? findSpaceByInternalId(
String? internalId, List<SpaceModel> spaces) {
static SpaceModel? findSpaceByInternalId(String? internalId, List<SpaceModel> spaces) {
if (internalId != null) {
for (final space in spaces) {
for (var space in spaces) {
if (space.internalId == internalId) return space;
}
}
@ -23,22 +21,21 @@ class SpaceHelper {
return null;
}
static String generateUniqueSpaceName(
String originalName, List<SpaceModel> spaces) {
static String generateUniqueSpaceName(String originalName, List<SpaceModel> spaces) {
final baseName = originalName.replaceAll(RegExp(r'\(\d+\)$'), '').trim();
var maxNumber = 0;
int maxNumber = 0;
for (final space in spaces) {
for (var space in spaces) {
final match = RegExp(r'^(.*?)\((\d+)\)$').firstMatch(space.name);
if (match != null && match.group(1)?.trim() == baseName) {
final existingNumber = int.parse(match.group(2)!);
int existingNumber = int.parse(match.group(2)!);
if (existingNumber > maxNumber) {
maxNumber = existingNumber;
}
}
}
return '$baseName(${maxNumber + 1})';
return "$baseName(${maxNumber + 1})";
}
static bool isSave(List<SpaceModel> spaces) {
@ -54,13 +51,10 @@ class SpaceHelper {
return space == selectedSpace ||
selectedSpace.parent?.internalId == space.internalId ||
selectedSpace.children
.any((child) => child.internalId == space.internalId) ==
true;
selectedSpace.children?.any((child) => child.internalId == space.internalId) == true;
}
static bool isNameConflict(
String value, SpaceModel? parentSpace, SpaceModel? editSpace) {
static bool isNameConflict(String value, SpaceModel? parentSpace, SpaceModel? editSpace) {
final siblings = parentSpace?.children
.where((child) => child.internalId != editSpace?.internalId)
.toList() ??
@ -71,19 +65,17 @@ class SpaceHelper {
.toList() ??
[];
final editSiblingConflict =
editSiblings.any((child) => child.name == value);
final editSiblingConflict = editSiblings.any((child) => child.name == value);
final siblingConflict = siblings.any((child) => child.name == value);
final parentConflict = parentSpace?.name == value &&
parentSpace?.internalId != editSpace?.internalId;
final parentConflict =
parentSpace?.name == value && parentSpace?.internalId != editSpace?.internalId;
final parentOfEditSpaceConflict = editSpace?.parent?.name == value &&
editSpace?.parent?.internalId != editSpace?.internalId;
final parentOfEditSpaceConflict =
editSpace?.parent?.name == value && editSpace?.parent?.internalId != editSpace?.internalId;
final childConflict =
editSpace?.children.any((child) => child.name == value) ?? false;
final childConflict = editSpace?.children.any((child) => child.name == value) ?? false;
return siblingConflict ||
parentConflict ||

View File

@ -24,7 +24,7 @@ class TagHelper {
final modifiedSubspaces = List<dynamic>.from(subspaces ?? []);
if (subspaces != null) {
for (final subspace in subspaces) {
for (var subspace in subspaces) {
getSubspaceTags(subspace)?.removeWhere(
(tag) => !modifiedTags.any(
(updatedTag) => getInternalId(updatedTag) == getInternalId(tag)),
@ -32,7 +32,7 @@ class TagHelper {
}
}
for (final tag in modifiedTags.toList()) {
for (var tag in modifiedTags.toList()) {
if (modifiedSubspaces.isEmpty) continue;
final prevIndice = checkTagExistInSubspace(tag, modifiedSubspaces);
@ -131,7 +131,8 @@ class TagHelper {
static List<String> getAvailableTagModels(
List<String> allTags, List<Tag> currentTags, Tag currentTag) {
final availableTagsForTagModel = TagHelper.getAvailableTags<Tag>(
List<String> availableTagsForTagModel =
TagHelper.getAvailableTags<Tag>(
allTags: allTags,
currentTags: currentTags,
currentTag: currentTag,
@ -144,14 +145,14 @@ class TagHelper {
List<Tag>? spaceTagModels,
List<SubspaceTemplateModel>? subspaces,
}) {
final initialTags = <Tag>[];
final List<Tag> initialTags = [];
if (spaceTagModels != null) {
initialTags.addAll(spaceTagModels);
}
if (subspaces != null) {
for (final subspace in subspaces) {
for (var subspace in subspaces) {
if (subspace.tags != null) {
initialTags.addAll(
subspace.tags!.map(
@ -173,14 +174,14 @@ class TagHelper {
List<Tag>? spaceTags,
List<SubspaceModel>? subspaces,
}) {
final initialTags = <Tag>[];
final List<Tag> initialTags = [];
if (spaceTags != null) {
initialTags.addAll(spaceTags);
}
if (subspaces != null) {
for (final subspace in subspaces) {
for (var subspace in subspaces) {
if (subspace.tags != null) {
initialTags.addAll(
subspace.tags!.map(
@ -199,8 +200,8 @@ class TagHelper {
}
static Map<ProductModel, int> groupTags(List<BaseTag> tags) {
final groupedTags = <ProductModel, int>{};
for (final tag in tags) {
final Map<ProductModel, int> groupedTags = {};
for (var tag in tags) {
if (tag.product != null) {
final product = tag.product!;
groupedTags[product] = (groupedTags[product] ?? 0) + 1;
@ -211,10 +212,10 @@ class TagHelper {
static List<SelectedProduct> createInitialSelectedProducts(
List<Tag>? tags, List<SubspaceTemplateModel>? subspaces) {
final productCounts = <ProductModel, int>{};
final Map<ProductModel, int> productCounts = {};
if (tags != null) {
for (final tag in tags) {
for (var tag in tags) {
if (tag.product != null) {
productCounts[tag.product!] = (productCounts[tag.product!] ?? 0) + 1;
}
@ -222,9 +223,9 @@ class TagHelper {
}
if (subspaces != null) {
for (final subspace in subspaces) {
for (var subspace in subspaces) {
if (subspace.tags != null) {
for (final tag in subspace.tags!) {
for (var tag in subspace.tags!) {
if (tag.product != null) {
productCounts[tag.product!] =
(productCounts[tag.product!] ?? 0) + 1;
@ -246,10 +247,10 @@ class TagHelper {
static List<SelectedProduct> createInitialSelectedProductsForTags(
List<Tag>? tags, List<SubspaceModel>? subspaces) {
final productCounts = <ProductModel, int>{};
final Map<ProductModel, int> productCounts = {};
if (tags != null) {
for (final tag in tags) {
for (var tag in tags) {
if (tag.product != null) {
productCounts[tag.product!] = (productCounts[tag.product!] ?? 0) + 1;
}
@ -257,9 +258,9 @@ class TagHelper {
}
if (subspaces != null) {
for (final subspace in subspaces) {
for (var subspace in subspaces) {
if (subspace.tags != null) {
for (final tag in subspace.tags!) {
for (var tag in subspace.tags!) {
if (tag.product != null) {
productCounts[tag.product!] =
(productCounts[tag.product!] ?? 0) + 1;
@ -279,13 +280,14 @@ class TagHelper {
.toList();
}
static int? checkTagExistInSubspaceModels(Tag tag, List<dynamic>? subspaces) {
static int? checkTagExistInSubspaceModels(
Tag tag, List<dynamic>? subspaces) {
if (subspaces == null) return null;
for (var i = 0; i < subspaces.length; i++) {
for (int i = 0; i < subspaces.length; i++) {
final subspace = subspaces[i] as SubspaceTemplateModel; // Explicit cast
if (subspace.tags == null) continue;
for (final t in subspace.tags!) {
for (var t in subspace.tags!) {
if (tag.internalId == t.internalId) {
return i;
}
@ -312,11 +314,11 @@ class TagHelper {
final processedSubspaces =
List<SubspaceTemplateModel>.from(result['subspaces'] as List<dynamic>);
for (final subspace in processedSubspaces) {
for (var subspace in processedSubspaces) {
final subspaceTags = subspace.tags;
if (subspaceTags != null) {
for (var i = 0; i < subspaceTags.length; i++) {
for (int i = 0; i < subspaceTags.length; i++) {
final tag = subspaceTags[i];
// Find the updated tag inside processedTags
@ -339,10 +341,10 @@ class TagHelper {
static int? checkTagExistInSubspace(Tag tag, List<dynamic>? subspaces) {
if (subspaces == null) return null;
for (var i = 0; i < subspaces.length; i++) {
for (int i = 0; i < subspaces.length; i++) {
final subspace = subspaces[i];
if (subspace.tags == null) continue;
for (final t in subspace.tags!) {
for (var t in subspace.tags!) {
if (tag.internalId == t.internalId) {
return i;
}
@ -369,11 +371,11 @@ class TagHelper {
final processedSubspaces =
List<SubspaceModel>.from(result['subspaces'] as List<dynamic>);
for (final subspace in processedSubspaces) {
for (var subspace in processedSubspaces) {
final subspaceTags = subspace.tags;
if (subspaceTags != null) {
for (var i = 0; i < subspaceTags.length; i++) {
for (int i = 0; i < subspaceTags.length; i++) {
final tag = subspaceTags[i];
final changedTag = updatedTags.firstWhere(
@ -395,10 +397,10 @@ class TagHelper {
static List<String> getAllTagValues(
List<CommunityModel> communities, List<SpaceTemplateModel>? spaceModels) {
final allTags = <String>{};
final Set<String> allTags = {};
if (spaceModels != null) {
for (final model in spaceModels) {
for (var model in spaceModels) {
allTags.addAll(model.listAllTagValues());
}
}