Refactoring

pull/15806/head
Salih 3 years ago
parent a6c43a6522
commit 7e58ee46cf

@ -191,6 +191,11 @@ public abstract class
set => _abpDatePickerOptionsImplementation.ClearButton = value;
}
public bool SingleOpenAndClearButton {
get => _abpDatePickerOptionsImplementation.SingleOpenAndClearButton;
set => _abpDatePickerOptionsImplementation.SingleOpenAndClearButton = value;
}
public bool? IsUtc {
get => _abpDatePickerOptionsImplementation.IsUtc;
set => _abpDatePickerOptionsImplementation.IsUtc = value;

@ -90,7 +90,7 @@ public abstract class AbpDatePickerBaseTagHelperService<TTagHelper> : AbpTagHelp
? await ProcessButtonAndGetContentAsync(context, output, "calendar", "open")
: "";
var clearButtonContent = TagHelper.ClearButton
? await ProcessButtonAndGetContentAsync(context, output, "times", "clear")
? await ProcessButtonAndGetContentAsync(context, output, "times", "clear", visible:!TagHelper.SingleOpenAndClearButton)
: "";
var labelContent = await GetLabelAsHtmlAsync(context, output, TagHelperOutput);
@ -369,6 +369,11 @@ public abstract class AbpDatePickerBaseTagHelperService<TTagHelper> : AbpTagHelp
attrList.Add("id", options.PickerId);
}
if(!options.SingleOpenAndClearButton)
{
attrList.Add("data-single-open-and-clear-button", options.SingleOpenAndClearButton.ToString().ToLowerInvariant());
}
return attrList;
}
@ -564,13 +569,18 @@ public abstract class AbpDatePickerBaseTagHelperService<TTagHelper> : AbpTagHelp
}
protected virtual async Task<string> ProcessButtonAndGetContentAsync(TagHelperContext context,
TagHelperOutput output, string icon, string type)
TagHelperOutput output, string icon, string type, bool visible = true)
{
var abpButtonTagHelper = ServiceProvider.GetRequiredService<AbpButtonTagHelper>();
var attributes =
new TagHelperAttributeList { new("type", "button"), new("tabindex", "-1"), new("data-type", type) };
abpButtonTagHelper.ButtonType = AbpButtonType.Outline_Secondary;
abpButtonTagHelper.Icon = icon;
if (!visible)
{
attributes.AddClass("d-none");
}
return await abpButtonTagHelper.RenderAsync(attributes, context, Encoder, "button", TagMode.StartTagAndEndTag);
}

@ -33,6 +33,7 @@ public class AbpDatePickerOptions : IAbpDatePickerOptions
public string DateFormat { get; set; }
public bool OpenButton { get; set; } = true;
public bool ClearButton { get; set; } = true;
public bool SingleOpenAndClearButton { get; set; } = true;
public bool? IsUtc { get; set; }
public bool? IsIso { get; set; }
public object Options { get; set; }

@ -153,6 +153,11 @@ public class DatePickerOptionsAttribute : Attribute, IAbpDatePickerOptions
set => _abpDatePickerOptionsImplementation.ClearButton = value;
}
public bool SingleOpenAndClearButton {
get => _abpDatePickerOptionsImplementation.SingleOpenAndClearButton;
set => _abpDatePickerOptionsImplementation.SingleOpenAndClearButton = value;
}
public bool? IsUtc {
get => _abpDatePickerOptionsImplementation.IsUtc;
set => _abpDatePickerOptionsImplementation.IsUtc = value;

@ -82,14 +82,14 @@ public interface IAbpDatePickerOptions
[CanBeNull]
string ParentEl { get; set; }
// DatePickerType Type { get; set; } = DatePickerType.Date;
[CanBeNull]
string DateFormat { get; set; }
bool OpenButton { get; set; }
bool ClearButton { get; set; }
bool SingleOpenAndClearButton { get; set; }
bool? IsUtc { get; set; }

Loading…
Cancel
Save