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

Text field editors #2946

Merged
merged 2 commits into from
Dec 31, 2018
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@model OrchardCore.ContentFields.ViewModels.EditTextFieldViewModel
@using OrchardCore.ContentManagement.Metadata.Models
@using OrchardCore.ContentFields.Settings;

@{
var settings = Model.PartFieldDefinition.Settings.ToObject<TextFieldSettings>();
}

<fieldset class="form-group">
<label asp-for="Text">@Model.PartFieldDefinition.DisplayName()</label>
<input asp-for="Text" class="form-control content-preview-text" type="color" />
@if (!String.IsNullOrEmpty(settings.Hint))
{
<span class="hint">@settings.Hint</span>
}
</fieldset>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@{
string currentEditor = Model.Editor;
}
<option value="Color" selected="@String.IsNullOrEmpty(currentEditor)">@T["Color"]</option>
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not right. It should be @(currentEditor == "Color")

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@model OrchardCore.ContentFields.ViewModels.EditTextFieldViewModel
@using OrchardCore.ContentManagement.Metadata.Models
@using OrchardCore.ContentFields.Settings;

@{
var settings = Model.PartFieldDefinition.Settings.ToObject<TextFieldSettings>();
}

<fieldset class="form-group">
<label asp-for="Text">@Model.PartFieldDefinition.DisplayName()</label>
<div class="input-group mb-2">
<div class="input-group-prepend">
<div class="input-group-text">@@</div>
</div>
<input asp-for="Text" class="form-control content-preview-text" type="email" />
</div>
@if (!String.IsNullOrEmpty(settings.Hint))
{
<span class="hint">@settings.Hint</span>
}
</fieldset>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@{
string currentEditor = Model.Editor;
}
<option value="Email" selected="@(currentEditor == "Email")">@T["Email"]</option>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@model OrchardCore.ContentFields.ViewModels.EditTextFieldViewModel
@using OrchardCore.ContentManagement.Metadata.Models
@using OrchardCore.ContentFields.Settings;

@{
var settings = Model.PartFieldDefinition.Settings.ToObject<TextFieldSettings>();
}

<fieldset class="form-group">
<label asp-for="Text">@Model.PartFieldDefinition.DisplayName()</label>
<input asp-for="Text" class="form-control content-preview-text" type="tel" />
Copy link
Contributor

@Skrypt Skrypt Jan 9, 2019

Choose a reason for hiding this comment

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

This should also add a pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}" attribute to the input else this will render as a simple textbox. Right now this input has no validation ; I could add letters to it, though someone could say that this is for supporting phone numbers like "1-800-MY-APPLE"

Copy link
Member

Choose a reason for hiding this comment

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

Don't add any validation, or more patterns. It's very locale specific, and leaving the browser do that is fine right now. Otherwise just remove the editor.

Copy link
Contributor

@Skrypt Skrypt Jan 9, 2019

Choose a reason for hiding this comment

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

We could give the option of a pattern and if the pattern is null then don't render one. Else this field is a textbox.

Copy link
Member

Choose a reason for hiding this comment

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

Too complex. At that point better teach them how to write a custom editor. There are way too many options to handle phone numbers.

Copy link
Contributor

Choose a reason for hiding this comment

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

Documentation then

@if (!String.IsNullOrEmpty(settings.Hint))
{
<span class="hint">@settings.Hint</span>
}
</fieldset>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@{
string currentEditor = Model.Editor;
}
<option value="Tel" selected="@String.IsNullOrEmpty(currentEditor)">@T["Phone"]</option>
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not right. It should be @(currentEditor == "Tel")

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@model OrchardCore.ContentFields.ViewModels.EditTextFieldViewModel
@using OrchardCore.ContentManagement.Metadata.Models
@using OrchardCore.ContentFields.Settings;

@{
var settings = Model.PartFieldDefinition.Settings.ToObject<TextFieldSettings>();
}

<fieldset class="form-group">
<label asp-for="Text">@Model.PartFieldDefinition.DisplayName()</label>
<input asp-for="Text" class="form-control content-preview-text" type="url" />
@if (!String.IsNullOrEmpty(settings.Hint))
{
<span class="hint">@settings.Hint</span>
}
</fieldset>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@{
string currentEditor = Model.Editor;
}
<option value="Url" selected="@String.IsNullOrEmpty(currentEditor)">@T["Url"]</option>
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not right. It should be @(currentEditor == "Url")