mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-15 17:47:53 +00:00
validation fix
This commit is contained in:
@ -70,8 +70,7 @@ class CreateSpaceModelBloc
|
|||||||
_space = event.spaceTemplate;
|
_space = event.spaceTemplate;
|
||||||
final String? errorMessage = _checkDuplicateModelName(
|
final String? errorMessage = _checkDuplicateModelName(
|
||||||
event.allModels ?? [], event.spaceTemplate.modelName);
|
event.allModels ?? [], event.spaceTemplate.modelName);
|
||||||
|
emit(CreateSpaceModelLoaded(_space!, errorMessage: errorMessage));
|
||||||
emit(CreateSpaceModelLoaded(_space!,errorMessage: errorMessage ?? ''));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
on<AddSubspacesToSpaceTemplate>((event, emit) {
|
on<AddSubspacesToSpaceTemplate>((event, emit) {
|
||||||
@ -136,7 +135,7 @@ class CreateSpaceModelBloc
|
|||||||
final updatedSpace =
|
final updatedSpace =
|
||||||
currentState.space.copyWith(subspaceModels: updatedSubspaces);
|
currentState.space.copyWith(subspaceModels: updatedSubspaces);
|
||||||
|
|
||||||
emit(CreateSpaceModelLoaded(updatedSpace));
|
emit(CreateSpaceModelLoaded(updatedSpace,errorMessage: currentState.errorMessage));
|
||||||
} else {
|
} else {
|
||||||
emit(CreateSpaceModelError("Space template not initialized"));
|
emit(CreateSpaceModelError("Space template not initialized"));
|
||||||
}
|
}
|
||||||
@ -243,7 +242,7 @@ class CreateSpaceModelBloc
|
|||||||
for (var tag in newSubspace.tags!) {
|
for (var tag in newSubspace.tags!) {
|
||||||
tagUpdates.add(TagModelUpdate(
|
tagUpdates.add(TagModelUpdate(
|
||||||
action: Action.add,
|
action: Action.add,
|
||||||
uuid: tag.uuid,
|
uuid: tag.uuid == '' ? null : tag.uuid,
|
||||||
tag: tag.tag,
|
tag: tag.tag,
|
||||||
productUuid: tag.product?.uuid));
|
productUuid: tag.product?.uuid));
|
||||||
}
|
}
|
||||||
@ -330,7 +329,7 @@ class CreateSpaceModelBloc
|
|||||||
tagUpdates.add(TagModelUpdate(
|
tagUpdates.add(TagModelUpdate(
|
||||||
action: Action.add,
|
action: Action.add,
|
||||||
tag: newTag.tag,
|
tag: newTag.tag,
|
||||||
uuid: newTag.uuid,
|
uuid: newTag.uuid == '' ? null : newTag.uuid,
|
||||||
productUuid: newTag.product?.uuid));
|
productUuid: newTag.product?.uuid));
|
||||||
processedTags.add(newTag.tag);
|
processedTags.add(newTag.tag);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
class TagBodyModel {
|
class TagBodyModel {
|
||||||
late String uuid;
|
late String? uuid;
|
||||||
late String tag;
|
late String tag;
|
||||||
late final String? productUuid;
|
late final String? productUuid;
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ class TagModel extends BaseTag {
|
|||||||
extension TagModelExtensions on TagModel {
|
extension TagModelExtensions on TagModel {
|
||||||
TagBodyModel toTagBodyModel() {
|
TagBodyModel toTagBodyModel() {
|
||||||
return TagBodyModel()
|
return TagBodyModel()
|
||||||
..uuid = uuid ?? ''
|
..uuid = uuid
|
||||||
..tag = tag ?? ''
|
..tag = tag ?? ''
|
||||||
..productUuid = product?.uuid;
|
..productUuid = product?.uuid;
|
||||||
}
|
}
|
||||||
|
@ -52,12 +52,14 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
|||||||
create: (_) {
|
create: (_) {
|
||||||
final bloc = CreateSpaceModelBloc(_spaceModelApi);
|
final bloc = CreateSpaceModelBloc(_spaceModelApi);
|
||||||
if (spaceModel != null) {
|
if (spaceModel != null) {
|
||||||
bloc.add(UpdateSpaceTemplate(spaceModel!,otherSpaceModels));
|
bloc.add(UpdateSpaceTemplate(spaceModel!, otherSpaceModels));
|
||||||
} else {
|
} else {
|
||||||
bloc.add(UpdateSpaceTemplate(SpaceTemplateModel(
|
bloc.add(UpdateSpaceTemplate(
|
||||||
modelName: '',
|
SpaceTemplateModel(
|
||||||
subspaceModels: const [],
|
modelName: '',
|
||||||
),otherSpaceModels));
|
subspaceModels: const [],
|
||||||
|
),
|
||||||
|
otherSpaceModels));
|
||||||
}
|
}
|
||||||
|
|
||||||
spaceNameController.addListener(() {
|
spaceNameController.addListener(() {
|
||||||
@ -127,11 +129,6 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
|||||||
context
|
context
|
||||||
.read<CreateSpaceModelBloc>()
|
.read<CreateSpaceModelBloc>()
|
||||||
.add(AddSubspacesToSpaceTemplate(updatedSubspaces));
|
.add(AddSubspacesToSpaceTemplate(updatedSubspaces));
|
||||||
|
|
||||||
context.read<CreateSpaceModelBloc>().add(
|
|
||||||
UpdateSpaceTemplateName(
|
|
||||||
name: spaceNameController.text,
|
|
||||||
allModels: otherSpaceModels ?? []));
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
@ -163,10 +160,8 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
|||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
onPressed: ( state.errorMessage == null) &&
|
onPressed: (state.errorMessage == null)
|
||||||
isNameValid
|
|
||||||
? () {
|
? () {
|
||||||
|
|
||||||
final updatedSpaceTemplate =
|
final updatedSpaceTemplate =
|
||||||
updatedSpaceModel.copyWith(
|
updatedSpaceModel.copyWith(
|
||||||
modelName:
|
modelName:
|
||||||
@ -243,10 +238,10 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
|||||||
: null,
|
: null,
|
||||||
backgroundColor: ColorsManager.secondaryColor,
|
backgroundColor: ColorsManager.secondaryColor,
|
||||||
borderRadius: 10,
|
borderRadius: 10,
|
||||||
foregroundColor:
|
foregroundColor: (state.errorMessage != null &&
|
||||||
state.errorMessage == null && isNameValid
|
state.errorMessage != '')
|
||||||
? ColorsManager.whiteColors
|
? ColorsManager.whiteColorsWithOpacity
|
||||||
: ColorsManager.whiteColorsWithOpacity,
|
: ColorsManager.whiteColors,
|
||||||
child: const Text('OK'),
|
child: const Text('OK'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user