Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bot details updating fixed #87

Merged
merged 1 commit into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,7 @@
<data name="DataRefreshed" xml:space="preserve">
<value>Successfully updated</value>
</data>
<data name="DataCreated" xml:space="preserve">
<value>Successfully created</value>
</data>
</root>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,7 @@
<data name="DataRefreshed" xml:space="preserve">
<value>Успешно обновлено</value>
</data>
<data name="DataCreated" xml:space="preserve">
<value>Успешно создано</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
<FormSection
Title="@Localizer["BotDetails"]"
HelpText="@Localizer["BotDetailsHelp"]">
@foreach (var item in FormModel.BotDetails.Where(b => StagesState.SupportedLanguages.Contains(b.LanguageId)))
@foreach (var language in StagesState.SupportedLanguages)
{
var item = FormModel.BotDetails.FirstOrDefault(l => l.LanguageId == language);
if (item is null)
item = FormModel.AddEmptyItem(language);

<BotDetailsItemEditor Item="item"/>
}
</FormSection>
Expand Down Expand Up @@ -68,7 +72,9 @@

public async Task SubmitForm()
{
if (_fluentValidationValidator is null || !await _fluentValidationValidator.ValidateAsync())
FormModel.FilterByLanguage(StagesState.SupportedLanguages);

if (_fluentValidationValidator is null || !await _fluentValidationValidator!.ValidateAsync())
return;

await OnValidSubmit.InvokeAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,29 @@ public BotDetailsFormModel Apply(GetBotDetailsResult botDetails)

return this;
}

public void FilterByLanguage(IReadOnlyCollection<string> languageIds)
{
ArgumentNullException.ThrowIfNull(languageIds);
var filteredList = _botDetails.Where(b => languageIds.Contains(b.LanguageId)).ToArray();

_botDetails.Clear();
_botDetails.AddRange(filteredList);
}

public BotDetailsItemFormModel AddEmptyItem(string languageId)
{
ArgumentNullException.ThrowIfNull(languageId);

var item = new BotDetailsItemFormModel
{
LanguageId = languageId
};

_botDetails.Add(item);

return item;
}

public SetBotDetailsCommand ToCommand(string token)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@

var notificationsService = ServiceProvider.GetRequiredService<INotificationsService>();

notificationsService.Publish(Notification.Info(Localizer["DataRefreshed"]));
notificationsService.Publish(Notification.Info(
_stagesState.Id.HasValue ?
Localizer["DataRefreshed"] : Localizer["DataCreated"]));

await NavRouter.MoveToRoute("constructor");
}
Expand Down
Loading