mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-17 10:35:14 +00:00
duplicate name validation
This commit is contained in:
@ -52,12 +52,12 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
||||
create: (_) {
|
||||
final bloc = CreateSpaceModelBloc(_spaceModelApi);
|
||||
if (spaceModel != null) {
|
||||
bloc.add(UpdateSpaceTemplate(spaceModel!));
|
||||
bloc.add(UpdateSpaceTemplate(spaceModel!,otherSpaceModels));
|
||||
} else {
|
||||
bloc.add(UpdateSpaceTemplate(SpaceTemplateModel(
|
||||
modelName: '',
|
||||
subspaceModels: const [],
|
||||
)));
|
||||
),otherSpaceModels));
|
||||
}
|
||||
|
||||
spaceNameController.addListener(() {
|
||||
@ -127,6 +127,11 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
||||
context
|
||||
.read<CreateSpaceModelBloc>()
|
||||
.add(AddSubspacesToSpaceTemplate(updatedSubspaces));
|
||||
|
||||
context.read<CreateSpaceModelBloc>().add(
|
||||
UpdateSpaceTemplateName(
|
||||
name: spaceNameController.text,
|
||||
allModels: otherSpaceModels ?? []));
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
@ -150,16 +155,18 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
||||
Expanded(
|
||||
child: CancelButton(
|
||||
label: 'Cancel',
|
||||
onPressed: (){
|
||||
Navigator.of(context).pop();},
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: DefaultButton(
|
||||
onPressed: state.errorMessage == null &&
|
||||
onPressed: ( state.errorMessage == null) &&
|
||||
isNameValid
|
||||
? () {
|
||||
|
||||
final updatedSpaceTemplate =
|
||||
updatedSpaceModel.copyWith(
|
||||
modelName:
|
||||
@ -236,10 +243,10 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
||||
: null,
|
||||
backgroundColor: ColorsManager.secondaryColor,
|
||||
borderRadius: 10,
|
||||
foregroundColor: state.errorMessage == null &&
|
||||
isNameValid
|
||||
? ColorsManager.whiteColors
|
||||
: ColorsManager.whiteColorsWithOpacity,
|
||||
foregroundColor:
|
||||
state.errorMessage == null && isNameValid
|
||||
? ColorsManager.whiteColors
|
||||
: ColorsManager.whiteColorsWithOpacity,
|
||||
child: const Text('OK'),
|
||||
),
|
||||
),
|
||||
|
Reference in New Issue
Block a user