Skip to content

Commit 1c18192

Browse files
committed
Add Create link in TableView
1 parent 99c585b commit 1c18192

File tree

3 files changed

+44
-18
lines changed

3 files changed

+44
-18
lines changed

AdminLTEWithASPNETCore.App/Models/UI/CommonTables/TableUI.cs

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,32 @@ public class TableUI
1919
public string ApiUrl { get; set; }
2020

2121
/// <summary>
22-
/// Gets or sets the fields.
23-
/// </summary>
24-
/// <value>The fields.</value>
25-
[JsonProperty("fields")]
26-
public FieldUI[] Fields { get; set; }
27-
/// <summary>
28-
/// Gets or sets the edit URL.
22+
/// Gets or sets the create URL.
2923
/// </summary>
30-
/// <value>The edit URL.</value>
31-
[JsonProperty("editUrl")]
32-
public string EditUrl { get; set; }
24+
/// <value>The create URL.</value>
25+
[JsonProperty("createUrl")]
26+
public string CreateUrl { get; set; }
27+
3328
/// <summary>
3429
/// Gets or sets the delete URL.
3530
/// </summary>
3631
/// <value>The delete URL.</value>
3732
[JsonProperty("editUrl")]
3833
public string DeleteUrl { get; set; }
34+
3935
/// <summary>
40-
/// Gets or sets the view URL.
36+
/// Gets or sets the edit URL.
4137
/// </summary>
42-
/// <value>The view URL.</value>
43-
[JsonProperty("viewUrl")]
44-
public string ViewUrl { get; set; }
38+
/// <value>The edit URL.</value>
39+
[JsonProperty("editUrl")]
40+
public string EditUrl { get; set; }
41+
42+
/// <summary>
43+
/// Gets or sets the fields.
44+
/// </summary>
45+
/// <value>The fields.</value>
46+
[JsonProperty("fields")]
47+
public FieldUI[] Fields { get; set; }
4548

4649
/// <summary>
4750
/// Returns a string with the list of fields
@@ -66,22 +69,38 @@ public string FieldString
6669
}
6770

6871
/// <summary>
69-
/// Gets or sets a value indicating whether this instance is edit allow.
72+
/// Gets a value indicating whether this instance is create allow.
7073
/// </summary>
71-
/// <value><c>true</c> if this instance is edit allow; otherwise, <c>false</c>.</value>
72-
[JsonProperty("isEditAllow")]
73-
public bool IsEditAllow => !string.IsNullOrEmpty(EditUrl);
74+
/// <value><c>true</c> if this instance is create allow; otherwise, <c>false</c>.</value>
75+
[JsonProperty("isCreateAllow")]
76+
public bool IsCreateAllow => !string.IsNullOrEmpty(CreateUrl);
77+
7478
/// <summary>
7579
/// Gets or sets a value indicating whether this instance is delete allow.
7680
/// </summary>
7781
/// <value><c>true</c> if this instance is delete allow; otherwise, <c>false</c>.</value>
7882
[JsonProperty("isDeleteAllow")]
7983
public bool IsDeleteAllow => !string.IsNullOrEmpty(DeleteUrl);
84+
85+
/// <summary>
86+
/// Gets or sets a value indicating whether this instance is edit allow.
87+
/// </summary>
88+
/// <value><c>true</c> if this instance is edit allow; otherwise, <c>false</c>.</value>
89+
[JsonProperty("isEditAllow")]
90+
public bool IsEditAllow => !string.IsNullOrEmpty(EditUrl);
91+
8092
/// <summary>
8193
/// Gets or sets a value indicating whether this instance is view allow.
8294
/// </summary>
8395
/// <value><c>true</c> if this instance is view allow; otherwise, <c>false</c>.</value>
8496
[JsonProperty("isViewAllow")]
8597
public bool IsViewAllow => !string.IsNullOrEmpty(ViewUrl);
98+
99+
/// <summary>
100+
/// Gets or sets the view URL.
101+
/// </summary>
102+
/// <value>The view URL.</value>
103+
[JsonProperty("viewUrl")]
104+
public string ViewUrl { get; set; }
86105
}
87106
}

AdminLTEWithASPNETCore/Areas/Tables/Controllers/CountriesController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public IActionResult Index()
2828
new FieldUI() { Label = "Country", Data = "Name" },
2929
new FieldUI() { Label = "Order", Data = "Order"}
3030
},
31+
CreateUrl = "/Tables/Countries/Create",
3132
EditUrl = "/Tables/Countries/Edit"
3233
};
3334

AdminLTEWithASPNETCore/Views/Shared/TableView.cshtml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
<div class="card">
88
<div class="card-header">
99
<h3 class="card-title">@ViewData["TableTitle"]</h3>
10+
<div class="card-tools">
11+
@if (Model.IsCreateAllow)
12+
{
13+
<a href="@Model.CreateUrl"><i class="far fa-plus-square"></i> Add new</a>
14+
}
15+
</div>
1016
</div>
1117
<div class="card-body">
1218
<table id="list" class="table table-bordered table-hover display">

0 commit comments

Comments
 (0)