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

Generic dialog to create new request #22

Open
wants to merge 45 commits into
base: develop
Choose a base branch
from

Conversation

laska-sl
Copy link
Contributor

No description provided.

@laska-sl laska-sl linked an issue Apr 25, 2020 that may be closed by this pull request
@laska-sl laska-sl changed the title Generic dialog Generic dialog to create new request Apr 25, 2020
@sponkrashin sponkrashin changed the base branch from develop to feature/dialog-with-requests-types April 27, 2020 02:37
@sponkrashin sponkrashin changed the base branch from feature/dialog-with-requests-types to develop April 27, 2020 02:41
@Duveshka Duveshka changed the base branch from develop to feature/dialog-with-requests-types April 27, 2020 12:13
@Duveshka Duveshka changed the base branch from feature/dialog-with-requests-types to develop April 29, 2020 11:19
}

public static HeroCard GetChoiceCard()
private static HeroCard ChoiceCard()
Copy link
Contributor

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.

Copy link
Contributor

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)
Copy link
Contributor

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.

Copy link
Contributor

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());
Copy link
Contributor

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())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Constants.

Copy link
Contributor

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()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Constant.

Copy link
Contributor

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))
Copy link
Contributor

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.

Copy link
Contributor

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(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Constants.

Copy link
Contributor

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");
Copy link
Contributor

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.

Copy link
Contributor

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")
Copy link
Contributor

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);
Copy link
Contributor

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.

Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is verb?

Copy link
Contributor

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";
Copy link
Contributor

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),
Copy link
Contributor

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.

Copy link
Contributor

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;
Copy link
Contributor

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.

Copy link
Contributor

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;
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add generic dialog for each type of Service Desk request
3 participants