Fix/editmenulink (#8515)

* Removed useless spaces

* Corrections on ProjectionPart query link (it didn't update the link when changing the selected query).
Added edit link for menu in MenuWidget.

* Added menuId parameter to menu edit link
This commit is contained in:
Andrea Piovanelli
2021-10-25 09:19:50 +02:00
committed by GitHub
parent e771a56c42
commit a8de3afc0f
2 changed files with 43 additions and 2 deletions

View File

@@ -2,13 +2,23 @@
@using Orchard.ContentManagement
@{
var selectedMenuId = -1;
}
<fieldset>
@Html.LabelFor(m => m.CurrentMenuId, T("For Menu"))
<select id="@Html.FieldIdFor(m => m.CurrentMenuId)" name="@Html.FieldNameFor(m => m.CurrentMenuId)">
@foreach(ContentItem menu in Model.Menus) {
@Html.SelectOption(Model.CurrentMenuId, menu.Id, Html.ItemDisplayText(menu, false).ToString())
if (Model.CurrentMenuId == menu.Id) {
selectedMenuId = menu.Id;
}
}
</select>
@if (selectedMenuId != -1) {
@Html.ActionLink(T("Edit Menu").Text, "Index", new { area = "Navigation", menuId = selectedMenuId }, new { id = "editMenuLink" })
}
<span class="hint">@T("Select which menu you want to display")</span>
</fieldset>
@@ -49,3 +59,20 @@
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.ShowFullMenu)">@T("No filter on selected page")</label>
<span class="hint">@T("Check for the menu to be displayed without filtering the selected current page.")</span>
</fieldset>
@using (Script.Foot()) {
<script type="text/javascript">
(function($) {
$("#@Html.FieldIdFor(m => m.CurrentMenuId)").change(function (sender) {
var selected = $(this).val();
var anchor = $("#editMenuLink");
var url = anchor.attr("href");
// Now I need to replace the last part of the url (menuId = ###).
var newUrl = url.substr(0, url.lastIndexOf("?") + 1);
newUrl = newUrl + "menuId=" + selected;
anchor.attr("href", newUrl);
});
})(jQuery);
</script>
}

View File

@@ -52,7 +52,7 @@
}
}
@if (selectedQueryRecordId != -1) {
@Html.ActionLink(T("Edit Query").Text, "Edit", new { area = "Orchard.Projections", id = selectedQueryRecordId }, new { })
@Html.ActionLink(T("Edit Query").Text, "Edit", new { area = "Orchard.Projections", id = selectedQueryRecordId }, new { id = "editQueryLink-" + Model.PartId.ToString() })
}
<span class="hint">@T("The query to display.")</span>
</fieldset>
@@ -137,7 +137,21 @@
//<![CDATA[
(function ($) {
$("fieldset legend").expandoControl(function (controller) { return controller.nextAll(".expando"); }, { collapse: true, remember: false });
$("#@Html.FieldIdFor(m => m.QueryLayoutRecordId)").change(function (sender) {
var selected = $(this).val();
// Removing layout id
selected = selected.substr(0, selected.indexOf(';'));
var anchor = $("#editQueryLink-@Model.PartId.ToString()");
var url = anchor.attr("href");
// Now I need to replace the last part of the url (which is the QueryLayoutRecordId) with the selected id to make to link work properly.
var newUrl = url.substr(0, url.lastIndexOf("/") + 1);
newUrl = newUrl + selected;
anchor.attr("href", newUrl);
});
})(jQuery);
//]]>
</script>
}