Skip to content

Commit

Permalink
Merge branch 'main' into hishamco/translation-provider
Browse files Browse the repository at this point in the history
  • Loading branch information
hishamco authored Jun 17, 2024
2 parents 49920ba + 1c0aef7 commit ef0a4b2
Show file tree
Hide file tree
Showing 17 changed files with 57 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public override IDisplayResult Edit(LinkField field, BuildFieldEditorContext con
var settings = context.PartFieldDefinition.GetSettings<LinkFieldSettings>();
model.Url = context.IsNew && field.Url == null ? settings.DefaultUrl : field.Url;
model.Text = context.IsNew && field.Text == null ? settings.DefaultText : field.Text;
model.Target = context.IsNew && field.Target == null ? settings.DefaultTarget : field.Target;

model.Field = field;
model.Part = context.ContentPart;
Expand All @@ -67,7 +68,7 @@ public override IDisplayResult Edit(LinkField field, BuildFieldEditorContext con

public override async Task<IDisplayResult> UpdateAsync(LinkField field, IUpdateModel updater, UpdateFieldEditorContext context)
{
var modelUpdated = await updater.TryUpdateModelAsync(field, Prefix, f => f.Url, f => f.Text);
var modelUpdated = await updater.TryUpdateModelAsync(field, Prefix, f => f.Url, f => f.Text, f => f.Target);

if (modelUpdated)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ public class LinkField : ContentField
public string Url { get; set; }

public string Text { get; set; }

public string Target { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public LinkFieldQueryObjectType()

Field(x => x.Url, nullable: true).Description("the url of the link");
Field(x => x.Text, nullable: true).Description("the text of the link");
Field(x => x.Target, nullable: true).Description("the target of the link");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public override Task BuildIndexAsync(LinkField field, BuildFieldIndexContext con
{
context.DocumentIndex.Set(key, field.Url, options);
context.DocumentIndex.Set(key, field.Text, options);
context.DocumentIndex.Set(key, field.Target, options);
}

return Task.CompletedTask;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class LinkFieldIndex : ContentFieldIndex
public string BigUrl { get; set; }
public string Text { get; set; }
public string BigText { get; set; }
public string Target { get; set; }
}

public class LinkFieldIndexProvider : ContentFieldIndexProvider
Expand Down Expand Up @@ -92,6 +93,7 @@ public override void Describe(DescribeContext<ContentItem> context)
BigUrl = pair.Field.Url,
Text = pair.Field.Text?[..Math.Min(pair.Field.Text.Length, LinkFieldIndex.MaxTextSize)],
BigText = pair.Field.Text,
Target = pair.Field.Target,
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class LinkFieldSettings
public string TextPlaceholder { get; set; }
public string DefaultUrl { get; set; }
public string DefaultText { get; set; }
public string DefaultTarget { get; set; }

public LinkFieldSettings()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public override IDisplayResult Edit(ContentPartFieldDefinition partFieldDefiniti
model.TextPlaceholder = settings.TextPlaceholder;
model.DefaultUrl = settings.DefaultUrl;
model.DefaultText = settings.DefaultText;
model.DefaultTarget = settings.DefaultTarget;
}).Location("Content");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class DisplayLinkFieldViewModel
{
public string Url => Field.Url;
public string Text => Field.Text;
public string Target => Field.Target;
public LinkField Field { get; set; }
public ContentPart Part { get; set; }
public ContentPartFieldDefinition PartFieldDefinition { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class EditLinkFieldViewModel
{
public string Url { get; set; }
public string Text { get; set; }
public string Target { get; set; }
public LinkField Field { get; set; }
public ContentPart Part { get; set; }
public ContentPartFieldDefinition PartFieldDefinition { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,27 @@
</div>
}
</div>
<div class="row">
<div class="col-md-6" asp-validation-class-for="Target">
<label asp-for="Target" class="@Orchard.GetLabelClasses()">
@T["Target"]
</label>
<div class="@Orchard.GetEndClasses()">
<input asp-for="Target" list="targetOptions" class="form-control" />
<datalist id="targetOptions">
<option value="_self">@T["Opens the linked document in the same frame as it was clicked (default)."]</option>
<option value="_blank">@T["Opens the linked document in a new window or tab."]</option>
<option value="_parent">@T["Opens the linked document in the parent frame."]</option>
<option value="_top">@T["Opens the linked document in the full body of the window."]</option>
</datalist>
<span class="hint">
@T["The target attribute of the anchor tag, see more:"]
<a class="seedoc" target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target">
@T["Target"]
</a>
</span>
</div>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@

href = href.ToUriComponents();
}

var target = !string.IsNullOrWhiteSpace(Model.Target) ? Model.Target : "_self";
}
<div class="field field-type-linkfield field-name-@name">
<a href="@href">@text</a>
<a href="@href" target="@target">@text</a>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,18 @@
<span asp-validation-for="DefaultText" class="text-danger"></span>
</div>
</div>

<div class="row">
<div class="mb-3 col-md-6">
<label asp-for="DefaultTarget" class="form-label">@T["Default value of the Target"]</label>
<input asp-for="DefaultTarget" list="targetOptions" class="form-control" />
<datalist id="targetOptions">
<option value="_self">@T["Opens the linked document in the same frame as it was clicked (default)."]</option>
<option value="_blank">@T["Opens the linked document in a new window or tab."]</option>
<option value="_parent">@T["Opens the linked document in the parent frame."]</option>
<option value="_top">@T["Opens the linked document in the full body of the window."]</option>
</datalist>
<span class="hint">@T["The default target proposed when creating a content item."]</span>
<span asp-validation-for="DefaultTarget" class="text-danger"></span>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@ public static async ValueTask<Completion> WriteToAsync(List<FilterArgument> argu
definition.SetCultures(culture.Split(_separators, StringSplitOptions.RemoveEmptyEntries));
}

if (!string.IsNullOrEmpty(dependsOn))
{
definition.SetDependencies(dependsOn.Split(_separators, StringSplitOptions.RemoveEmptyEntries));
}
definition.SetDependencies(dependsOn.Split(_separators, StringSplitOptions.RemoveEmptyEntries));

if (appendVersion.HasValue)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public FileDocumentStore(IOptions<ShellOptions> shellOptions, ShellSettings shel
if (loaded != null)
{
// Return the already loaded document but indicating that it should not be cached.
return (false, loaded as T);
return (false, loaded);
}

return (true, await GetDocumentAsync<T>() ?? await (factoryAsync?.Invoke() ?? Task.FromResult((T)null)) ?? new T());
Expand Down
1 change: 1 addition & 0 deletions src/docs/reference/modules/Email.Azure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ You may configure the Default Azure Email Service provider by the configuration
"DefaultSender": "",
"ConnectionString": ""
}
```

For more information about configurations, please refer to [Configuration](../../core/Configuration/README.md).

Expand Down
2 changes: 1 addition & 1 deletion src/docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mkdocs>=1.6.0
mkdocs-material>=9.5.26
mkdocs-material>=9.5.27
mkdocs-git-authors-plugin>=0.9.0
mkdocs-git-revision-date-localized-plugin>=1.2.6
pymdown-extensions>=10.8.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ await context.UsingTenantScopeAsync(async scope =>
};
scriptExternalLoginEventHandler.UpdateUserInternal(updateContext, loginSettings);

if (await AccountController.UpdateUserPropertiesAsync(userManager, user as User, updateContext))
if (await AccountController.UpdateUserPropertiesAsync(userManager, user, updateContext))
{
await userManager.UpdateAsync(user);
}
Expand Down

0 comments on commit ef0a4b2

Please sign in to comment.