Skip to content

Commit

Permalink
Show remove Field and part button when it is not system defined field…
Browse files Browse the repository at this point in the history
…/part (#17028)
  • Loading branch information
MikeAlhayek authored Nov 18, 2024
1 parent bdf74c8 commit 6e767bf
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,15 @@
{
<a asp-route-action="EditField" asp-route-id="@Model.TypeDefinition.Name" asp-route-name="@fieldDefinition.Name" asp-route-returnUrl="@FullRequestPath" class="btn btn-primary btn-sm" role="button">@T["Edit"]</a>
}
@if (!settings.IsSystemDefined)
@if (settings.IsSystemDefined)
{
<div class="d-inline" data-bs-toggle="tooltip" data-bs-title="@T["System-defined fields are integral components of the system and cannot be removed."]">
<button type="button" class="btn btn-danger btn-sm" disabled>
@T["Remove"]
</button>
</div>
}
else
{
<a asp-route-action="RemoveFieldFrom" asp-route-id="@Model.TypeDefinition.Name" asp-route-name="@fieldDefinition.Name" class="btn btn-danger btn-sm" role="button" data-url-af="UnsafeUrl RemoveUrl">@T["Remove"]</a>
}
Expand Down Expand Up @@ -137,6 +145,14 @@
<div class="float-end">
<a asp-route-action="EditTypePart" asp-route-id="@Model.TypeDefinition.Name" asp-route-name="@partDefinition.Name" class="btn btn-primary btn-sm" role="button">@T["Edit"]</a>
@if (settings.IsSystemDefined)
{
<div class="d-inline" data-bs-toggle="tooltip" data-bs-title="@T["System-defined parts are integral components of the system and cannot be removed."]">
<button type="button" class="btn btn-danger btn-sm" disabled>
@T["Remove"]
</button>
</div>
}
else
{
<a asp-route-action="RemovePart" asp-route-id="@Model.TypeDefinition.Name" asp-route-name="@partDefinition.Name" class="btn btn-danger btn-sm" role="button" data-url-af="UnsafeUrl RemoveUrl">@T["Remove"]</a>
}
Expand Down Expand Up @@ -170,7 +186,15 @@
<div class="mb-3">
<button class="btn btn-primary save" type="submit" name="submit.Save" value="Save">@T["Save"]</button>

@if (!contentSettings.IsSystemDefined)
@if (contentSettings.IsSystemDefined)
{
<div class="d-inline" data-bs-toggle="tooltip" data-bs-title="@T["System-defined types are integral components of the system and cannot be removed."]">
<button type="button" class="btn btn-danger" disabled>
@T["Remove"]
</button>
</div>
}
else
{
<button class="btn btn-danger delete" type="submit" name="submit.Delete" value="Delete" data-url-af="RemoveUrl">@T["Delete"]</button>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,27 @@
<ul class="list-group sortable" id="fields" style="cursor: move;">
@foreach (var field in orderedFields)
{
var settings = field.GetSettings<ContentSettings>();

<li class="list-group-item">
<div class="w-100">
<div class="float-end">
@if (fields.Any(x => x.Name.Equals(field.FieldDefinition.Name, StringComparison.OrdinalIgnoreCase)))
{
<a asp-route-action="EditField" asp-route-id="@Model.PartDefinition.Name" asp-route-name="@field.Name" asp-route-returnUrl="@FullRequestPath" class="btn btn-primary btn-sm" role="button">@T["Edit"]</a>
}
<a asp-route-action="RemoveFieldFrom" asp-route-id="@Model.PartDefinition.Name" asp-route-name="@field.Name" class="btn btn-danger btn-sm" role="button" data-url-af="UnsafeUrl RemoveUrl">@T["Remove"]</a>
@if (settings.IsSystemDefined)
{
<div class="d-inline" data-bs-toggle="tooltip" data-bs-title="@T["System-defined fields are integral components of the system and cannot be removed."]">
<button type="button" class="btn btn-danger btn-sm" disabled>
@T["Remove"]
</button>
</div>
}
else
{
<a asp-route-action="RemoveFieldFrom" asp-route-id="@Model.PartDefinition.Name" asp-route-name="@field.Name" class="btn btn-danger btn-sm" role="button" data-url-af="UnsafeUrl RemoveUrl">@T["Remove"]</a>
}
</div>
@field.DisplayName() <span class="hint dashed">@field.FieldDefinition.Name.CamelFriendly()</span>
</div>
Expand Down

0 comments on commit 6e767bf

Please sign in to comment.