-
Notifications
You must be signed in to change notification settings - Fork 0
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
Generic dialog to create new request #22
base: develop
Are you sure you want to change the base?
Conversation
} | ||
|
||
public static HeroCard GetChoiceCard() | ||
private static HeroCard ChoiceCard() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method name should contain verb.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed
return false; | ||
} | ||
|
||
if (formData["Button"].ToString() == Cancel) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constant instead of magic string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constant added
{ | ||
GetInfoCard().ToAttachment() | ||
additionalFieldsValues.Add(additionalFieldsData[i].Last.ToString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is type of additionalFieldsData[i]
?
return await stepContext.PromptAsync(nameof(TextPrompt), | ||
new PromptOptions | ||
|
||
if (string.IsNullOrEmpty(formData["Title"].ToString()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constants.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constant added
|
||
var createRequestTypeFields = | ||
(await this.mediator.Send(new GetServiceDeskRequestTypesQuery(), cancellationToken)) | ||
.First(requestTypeDTO => requestTypeDTO.Id == Convert.ToInt32(formData["TypeId"].ToString())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constant added
} | ||
|
||
var createRequestTypeFields = | ||
(await this.mediator.Send(new GetServiceDeskRequestTypesQuery(), cancellationToken)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move getting of request type fields to separate method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved
|
||
var newRequest = new CreateRequestDTO | ||
{ | ||
Title = formData["Title"].ToString(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constants.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constant added
switch (field.FieldType) | ||
{ | ||
case RequestTypeUIFieldType.Year: | ||
textBlock = new AdaptiveTextBlock("Enter a year"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Year of what? A field name should be added somewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
var promptOptions = new PromptOptions | ||
{ | ||
Prompt = (Activity)MessageFactory.Attachment(InputFormCard(cardBody, Actions)), | ||
RetryPrompt = MessageFactory.Text("Not all fields are filled. Repeat") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is it used?
{ | ||
Title = "In Development", | ||
Buttons = new List<CardAction> | ||
return await stepContext.ReplaceDialogAsync(nameof(MainDialog), null, cancellationToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably, it is better to send user to previous dialog instead of main dialog in such case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
}; | ||
} | ||
|
||
private static Attachment InputFormCard(List<AdaptiveElement> body, List<AdaptiveAction> actions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is verb?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
private const string Cancel = "Cancel"; | ||
private const string Yes = "Yes"; | ||
private const string No = "No"; | ||
private const string Button = "Button"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose it should be the same as property name in line 200. In that case you'd better introduce new private interface like interface IButtonData { string Button { get; set; } }
and use nameof(IButtonData.Button)
. Then you will never forgot to change value in one place after changing in another.
|
||
new AdaptiveTextInput { Id = TypeId, Value = requestTypeDTO.Id.ToString(), IsVisible = false }, | ||
|
||
new AdaptiveTextBlock(Title), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to use constants everywhere or at least you need to separate constants used for ids to prevent misprints when accessing form values from constants used to show user in UI.
You use title of text block and it's input placeholder only here, you don't need to access them later from anywhere - thus you don't have to use constant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
private const string Description = "Description"; | ||
private const string ExecutionDate = "Execution Date"; | ||
private const string Username = "[email protected]"; | ||
private readonly IRequestTypeUIFactory requestTypeUIFactory; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add empty line between constants and fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
{ | ||
var attachments = new[] | ||
var formData = (JObject)promptContext.Context.Activity.Value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You use same code thrice - to validate, in choice step and to get final values. It could be better to create internal class which will represent form data and return parsed form values from a method.
No description provided.