Skip to content

Commit 3d2c20d

Browse files
new release 1.2.0
- add page with document of app - add download button for charts - add responsive sizes for small screens
1 parent 9c60860 commit 3d2c20d

File tree

12 files changed

+175
-34
lines changed

12 files changed

+175
-34
lines changed

crud/App_Code/CommonHelper.cshtml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@using crud.Models
2+
3+
@helper DisplayCategoryList(List<Category> categories, string categorySelected = null)
4+
{
5+
<select class="form-control form-control-sm" name="CategoryId">
6+
@foreach (Category c in categories)
7+
{
8+
if (!string.IsNullOrEmpty(categorySelected) && c.Name == categorySelected)
9+
{
10+
<option value="@c.Id" selected>@c.Name</option>
11+
}
12+
else
13+
{
14+
<option value="@c.Id">@c.Name</option>
15+
}
16+
}
17+
</select>
18+
}

crud/App_Start/BundleConfig.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ public static void RegisterBundles(BundleCollection bundles)
3030
// El archivo jquery.dataTables.min.css no viene junto al paquete Nugget
3131
// de la solución, se instala aparte desde https://cdn.datatables.net/1.13.4/css/jquery.dataTables.css
3232
bundles.Add(new StyleBundle("~/Content/datatables").Include(
33-
"~/Content/jquery.dataTables.min.css"
33+
"~/Content/jquery.dataTables.min.css",
34+
"~/Content/datatables-custom.css"
3435
));
3536

3637
// El archivo buttons.dataTables.min.css no viene en el paquete Nugget "datatables buttons"
3738
// se instala aparte desde https://cdn.datatables.net/buttons/2.4.2/css/buttons.dataTables.min.css
3839
bundles.Add(new StyleBundle("~/Content/datatables-buttons").Include(
39-
"~/Content/buttons.dataTables.min.css",
40-
"~/Content/datatables-buttons-custom.css"
40+
"~/Content/buttons.dataTables.min.css"
4141
));
4242

4343
bundles.Add(new ScriptBundle("~/bundles/datatables-articles").Include(

crud/Content/datatables-buttons-custom.css

Lines changed: 0 additions & 8 deletions
This file was deleted.

crud/Content/datatables-custom.css

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
div.dt-buttons {
2+
margin-left: 1.2em;
3+
height: 40.8px;
4+
}
5+
6+
div.dt-buttons > .dt-button {
7+
height: 35.8px;
8+
}
9+
10+
@media (max-width: 575px) {
11+
/* ############################################################################### */
12+
/* cancel properties */
13+
/* ############################################################################### */
14+
#table-articles_length {
15+
/*border: 1px dotted red;*/
16+
padding-right: 0;
17+
}
18+
19+
div.dt-buttons {
20+
/*border: 1px dotted blue;*/
21+
margin-left: 0;
22+
width: 100%;
23+
}
24+
/* "Mostrar: [__] registros" */
25+
#table-articles_length label {
26+
margin: 0;
27+
}
28+
29+
/* "[ Exportar ]" */
30+
.dt-button.buttons-collection {
31+
/*padding: 0 !important;*/
32+
margin: 0 !important;
33+
/*background-color:red;*/
34+
width: 100%;
35+
}
36+
37+
#table-articles_filter {
38+
/*border: 1px dotted green;*/
39+
margin-bottom: 0.4em;
40+
}
41+
42+
#table-articles_filter label {
43+
width: 100%;
44+
}
45+
46+
#table-articles_filter input {
47+
width: 100%;
48+
margin-left: 0;
49+
}
50+
51+
.dataTables_filter {
52+
/*border: 1px dotted yellow;*/
53+
margin-top: 0 !important;
54+
}
55+
56+
/* "Buscar: [__]" */
57+
.dataTables_filter label {
58+
/*border: 1px solid black;*/
59+
margin: 0;
60+
}
61+
/* ############################################################################### */
62+
/* common properties */
63+
/* ############################################################################### */
64+
#table-articles_length,
65+
div.dt-buttons,
66+
.dataTables_filter {
67+
display: flex;
68+
align-content: center;
69+
align-items: center;
70+
justify-content: center;
71+
height: 6vh;
72+
}
73+
}

crud/Controllers/HomeController.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,21 @@ public class HomeController : BaseController
1212
{
1313
public ActionResult Index()
1414
{
15-
return View();
15+
var data = new ViewDataDictionary()
16+
{
17+
{ "urlJquery", "https://jquery.com/" },
18+
{ "urlBootstrap", "https://getbootstrap.com/" },
19+
{ "urlDatatables", "https://datatables.net/"},
20+
{ "urlEF6", "https://www.nuget.org/packages/EntityFramework/" },
21+
{ "urlChartjs", "https://www.chartjs.org/" },
22+
{ "urlJszip", "https://stuk.github.io/jszip/" },
23+
{ "urlPdfmake", "http://pdfmake.org/#/" },
24+
{ "title", "Información del proyecto" },
25+
{ "message", "Sistema CRUD hecho en C# ASP.NET" },
26+
{ "repository", "https://github.com/manuel-chinchi/crud-mvc-aspnet" }
27+
};
28+
29+
return View(data);
1630
}
1731
}
1832
}

crud/Scripts/chartjs-custom.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,26 @@ $(document).ready(function () {
7878
console.log(error);
7979
}
8080
});
81+
82+
$("#btn-download-chart").on("click", function () {
83+
var chartIns;
84+
var chartName;
85+
86+
if (!chartPie.is(":hidden")) {
87+
chartIns = chartInstance;
88+
chartName = "chart_pie.png";
89+
}
90+
if (!chartBar.is(":hidden")) {
91+
chartIns = chartInstance2;
92+
chartName = "chart_bar.png";
93+
}
94+
95+
var image = chartIns.toBase64Image();
96+
var a = document.createElement('a');
97+
a.href = image;
98+
a.download = chartName;
99+
100+
a.click();
101+
});
81102
});
82103

crud/Scripts/datatables-custom.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ $(document).ready(function () {
99
infoEmpty: '',
1010
infoFiltered: '',
1111
zeroRecords: 'No se encontraron registros coincidentes',
12-
search: 'Buscar:',
12+
search: '',
13+
searchPlaceholder: 'Buscar',
1314
lengthMenu: 'Mostrar _MENU_ registros',
1415
paginate: {
1516
previous: 'Anterior',

crud/Views/Article/Create.cshtml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@
2323

2424
<div class="form-group">
2525
@Html.LabelFor(model => model.Category)
26-
<select class="form-control form-control-sm" name="CategoryId">
27-
@foreach (Category item in ViewBag.Categories)
28-
{
29-
<option value="@item.Id">@item.Name</option>
30-
}
31-
</select>
26+
@CommonHelper.DisplayCategoryList(ViewBag.Categories)
3227
</div>
3328

3429
<div class="form-group">

crud/Views/Article/Edit.cshtml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,7 @@
2626

2727
<div class="form-group">
2828
@Html.LabelFor(model => model.Category, new { @class = "control-label" })
29-
<select class="form-control form-control-sm" name="CategoryId">
30-
@foreach (Category item in ViewBag.Categories)
31-
{
32-
if (item.Name == Model.Category.Name)
33-
{
34-
<option value="@item.Id" selected>@item.Name</option>
35-
}
36-
else
37-
{
38-
<option value="@item.Id">@item.Name</option>
39-
}
40-
}
41-
</select>
29+
@CommonHelper.DisplayCategoryList(ViewBag.Categories, Model.Category.Name)
4230
@Html.ValidationMessageFor(model => model.Category, "", new { @class = "text-danger" })
4331
</div>
4432

crud/Views/Home/Index.cshtml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,38 @@
1-

1+
@model ViewDataDictionary
2+
3+
<style>
4+
.card-info-app {
5+
/*height: 480px;*/
6+
/*margin-top: 10vh;*/
7+
}
8+
</style>
9+
10+
<h3>@Model["title"]</h3>
11+
<p>@Model["message"]</p>
12+
<br />
13+
14+
<div class="card card-info-app">
15+
<div class="card-header">
16+
Versión: 1.2.0
17+
</div>
18+
<div class="card-body">
19+
<p>Esta aplicación cuenta con el uso de las siguientes librerías:</p>
20+
<ul class="ml-3">
21+
<li><a href="@Model["urlJquery"]">jQuery 3.5.1</a></li>
22+
<li><a href="@Model["urlBootstrap"]">Bootstrap 4.3.1</a></li>
23+
<li><a href="@Model["urlDatatables"]">DataTables 1.13.4</a></li>
24+
<li><a href="@Model["urlEF6"]">Entity Framework 6.4.4</a></li>
25+
<li><a href="@Model["urlChartjs"]">Chart.js 3.7.1</a></li>
26+
<li>
27+
Exportación a otros formatos
28+
<ul>
29+
<li>Excel: <a href="@Model["urlJszip"]">JSZip v3.10.1</a></li>
30+
<li>PDF: <a href="@Model["urlPdfmake"]">PDFMake v0.1.53</a></li>
31+
</ul>
32+
</li>
33+
</ul>
34+
<p>Puede descargar el código del proyecto desde <a href="@Model["repository"]">aquí</a></p>
35+
</div>
36+
<br />
37+
<br />
38+
</div>

0 commit comments

Comments
 (0)