prvi
This commit is contained in:
230
EveryThing/Pages/Projects/Index.cshtml
Normal file
230
EveryThing/Pages/Projects/Index.cshtml
Normal file
@@ -0,0 +1,230 @@
|
||||
@page
|
||||
@using EveryThing.Models.Project
|
||||
@model EveryThing.Pages.Projects.IndexModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Projekti";
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<h4 class="d-flex justify-content-between align-items-center w-100 font-weight-bold py-1 mb-4">
|
||||
<span>
|
||||
<span class="text-muted font-weight-light">Projekti /</span> Pregled
|
||||
</span>
|
||||
</h4>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 mb-2 text-right">
|
||||
<form method="get">
|
||||
<div class="btn-group">
|
||||
<input class="form-control" type="text" name="searchString" value="@ViewData["SearchString"]" placeholder="Iskanje..." autocomplete="off">
|
||||
<select asp-for="Year" class="form-control" asp-items="ViewBag.Years"></select>
|
||||
<div class="btn-group" title="Columns">
|
||||
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown" aria-label="Nastavitve" title="Nastavitve">
|
||||
<i class="opacity-75 ion ion-md-apps"></i>
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<label class="dropdown-item">
|
||||
<input type="checkbox" name="openProjects" @ViewData["OpenProjects"]> <span>Odprti</span>
|
||||
</label>
|
||||
<label class="dropdown-item">
|
||||
<input type="checkbox" name="inProductionProjects" @ViewData["InProductionProjects"]> <span>V izdelavi</span>
|
||||
</label>
|
||||
<label class="dropdown-item">
|
||||
<input type="checkbox" name="finishedProjects" @ViewData["FinishedProjects"]> <span>Zaključeni projekti</span>
|
||||
</label>
|
||||
<label class="dropdown-item">
|
||||
<input type="checkbox" name="offerProjects" @ViewData["OffersProjects"]> <span>Ponudbe</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-secondary" aria-label="Osveži" title="Osveži">
|
||||
<i class="opacity-75 ion ion-md-refresh"></i>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
|
||||
<h6 class="card-header">
|
||||
Seznam projektov
|
||||
</h6>
|
||||
|
||||
<table class="table card-table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 150px;">
|
||||
@Html.DisplayNameFor(model => model.Project[0].ProjectNumberFormatted)
|
||||
</th>
|
||||
<th style="width: 200px;">
|
||||
@Html.DisplayNameFor(model => model.Project[0].Title)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Project[0].IdPartnerFk)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Project[0].Description)
|
||||
</th>
|
||||
<th style="width: 140px">
|
||||
@Html.DisplayNameFor(model => model.Project[0].FirstDeliveryDateString)
|
||||
</th>
|
||||
<th style="width: 100px">
|
||||
@Html.DisplayNameFor(model => model.Project[0].Status)
|
||||
</th>
|
||||
<th style="width: 110px;"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model.Project)
|
||||
{
|
||||
<tr data-idproject="@item.IdProject" data-title="@item.Title">
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ProjectNumberFormatted)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-page="Edit" asp-route-id="@item.IdProject">@Html.DisplayFor(modelItem => item.Title)</a>
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Partner.Title)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Description)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.FirstDeliveryDateString)
|
||||
</td>
|
||||
<td>
|
||||
@switch (item.Status)
|
||||
{
|
||||
case ProjectStatus.Finished:
|
||||
<span class='badge badge-success'>@Html.DisplayFor(modelItem => item.Status)</span>
|
||||
break;
|
||||
case ProjectStatus.InProduction:
|
||||
<span class='badge badge-warning'>@Html.DisplayFor(modelItem => item.Status)</span>
|
||||
break;
|
||||
case ProjectStatus.Offer:
|
||||
<span class='badge badge-default'>@Html.DisplayFor(modelItem => item.Status)</span>
|
||||
break;
|
||||
default:
|
||||
<span class='badge badge-info'>@Html.DisplayFor(modelItem => item.Status)</span>
|
||||
break;
|
||||
}
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<a class="btn btn-xs icon-btn btn-outline-secondary borderless" asp-page="Edit" asp-route-id="@item.IdProject" data-toggle="tooltip" data-placement="top" title="Urejanje" data-state="secondary"><i class="fas fa-pencil-alt"></i></a>
|
||||
<a data-idproject="@item.IdProject" class="btn btn-xs icon-btn btn-outline-secondary borderless" data-toggle="tooltip" data-placement="top" title="Kopiraj projekt" data-state="secondary" href="javascript:;" onclick="copyProject(this);"><i class="far fa-copy"></i></a>
|
||||
<a class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" href='javascript:;' onclick="deleteProject(this)" data-toggle="tooltip" data-placement="top" title="Izbriši"><i class="fas fa-times"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="card-footer py-3 text-right">
|
||||
<a asp-page="Create" class="btn btn-primary">Vnos projekta</a>
|
||||
</div>
|
||||
</div>
|
||||
@Html.AntiForgeryToken()
|
||||
@section Scripts {
|
||||
<script>
|
||||
$('[data-toggle="tooltip"]').tooltip({container: 'table'});
|
||||
|
||||
function deleteProject(element) {
|
||||
let row = $(element).parent().parent();
|
||||
let idProject = $(row).attr('data-idproject');
|
||||
let title = $(row).attr('data-title');
|
||||
|
||||
Swal.fire({
|
||||
title: `Izbrišem projekt ${title}?`,
|
||||
text: "Tega dejanja ni možno razveljaviti!",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Da, izbriši!',
|
||||
cancelButtonText: 'Prekliči!'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.blockUI();
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader("XSRF-TOKEN",
|
||||
$('input:hidden[name="__RequestVerificationToken"]').val());
|
||||
},
|
||||
url: "/Projects/Index/?handler=Project",
|
||||
data: {
|
||||
idProject
|
||||
},
|
||||
success: function (data) {
|
||||
$.unblockUI();
|
||||
if (data.successful) {
|
||||
$(row).remove();
|
||||
} else {
|
||||
console.log(data);
|
||||
Swal.fire('Napaka pri brisanju projekta',
|
||||
data.error,
|
||||
'error');
|
||||
}
|
||||
|
||||
},
|
||||
error: function (xhr, ajaxOptions, thrownError) {
|
||||
console.log(xhr);
|
||||
alert(xhr.responseText);
|
||||
$.unblockUI();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function copyProject(element) {
|
||||
let idProject = $(element).attr('data-idproject');
|
||||
|
||||
Swal.fire({
|
||||
title: `Kopiram projekt?`,
|
||||
text: "Tega dejanja ni možno razveljaviti!",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Da, kopiraj!',
|
||||
cancelButtonText: 'Prekliči!'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.blockUI();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader("XSRF-TOKEN",
|
||||
$('input:hidden[name="__RequestVerificationToken"]').val());
|
||||
},
|
||||
url: "/Projects/Index/?handler=CopyProject",
|
||||
data: {
|
||||
idProject
|
||||
},
|
||||
success: function (data) {
|
||||
$.unblockUI();
|
||||
if (data.successful) {
|
||||
location.reload();
|
||||
} else {
|
||||
Swal.fire('Napaka pri kopiranju projekta',
|
||||
data.error,
|
||||
'error');
|
||||
}
|
||||
|
||||
},
|
||||
error: function (xhr, ajaxOptions, thrownError) {
|
||||
console.log(xhr);
|
||||
alert(xhr.responseText);
|
||||
$.unblockUI();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
}
|
||||
Reference in New Issue
Block a user