Files
everything2/EveryThing/Pages/CodeTableItems/Index.cshtml
David Štaleker 03b92525d7 Prvi commit
2023-05-12 09:00:07 +02:00

127 lines
4.8 KiB
Plaintext

@page
@model EveryThing.Pages.CodeTableItems.IndexModel
@{
ViewData["Title"] = "Index";
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">Artikli /</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">
<button id="btnSubmit" type="submit" class="btn btn-secondary" aria-label="Osveži" title="Osveži">
<i class="opacity-75 ion ion-md-refresh"></i>
</button>
<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="finishedProjects" @ViewData["FinishedProjects"]> <span>Aktivni artikli</span>
</label>
</div>*@
</div>
</div>
</form>
</div>
</div>
<div class="card">
<h6 class="card-header">
Seznam artiklov
</h6>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Item[0].Title)
</th>
<th>
@Html.DisplayNameFor(model => model.Item[0].Description)
</th>
<th>
@Html.DisplayNameFor(model => model.Item[0].CodeTableItemType)
</th>
<th>
@Html.DisplayNameFor(model => model.Item[0].Active)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.Item)
{
<tr data-idCodeTableItem="@item.IdItem">
<td>
@Html.DisplayFor(modelItem => item.Title)
</td>
<td>
@Html.DisplayFor(modelItem => item.Description)
</td>
<td>
@Html.DisplayFor(modelItem => item.CodeTableItemType)
</td>
<td>
@Html.DisplayFor(modelItem => item.Active)
</td>
<td class="text-right">
<a class="btn btn-xs icon-btn btn-outline-secondary borderless" href="javascript:;" onclick="editCodeTableItem(this);" data-toggle="tooltip" data-placement="top" title="Urejanje" data-state="secondary"><i class="fas fa-pencil-alt"></i></a>
<a class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" href='javascript:;' onclick="deleteCodeTableItem(this)"><i class="fas fa-times"></i></a>
</td>
</tr>
}
</tbody>
</table>
<div class="card-footer py-3 text-right">
<button type="button" class="btn btn-primary" onclick="addNewCodeTableItem();" >Vnos artikla</button>
</div>
<div id="divModalCodetableItemAddEditPlaceholder"></div>
</div>
@Html.AntiForgeryToken()
@section Scripts {
<script src="~/js/codeTableItemHelper.js?v=3" asp-append-version="true"></script>
<script src="~/js/fileHelper.js?v=1" asp-append-version="true"></script>
<script>
$('[data-toggle="tooltip"]').tooltip({container: 'table'});
function addNewCodeTableItem() {
codeTableItemAddEdit('#divModalCodetableItemAddEditPlaceholder', false, null, (idCodeTableItem) => {
document.getElementById('btnSubmit').click();
});
}
function editCodeTableItem(element) {
let idCodeTableItem = parseInt($(element).parent().parent().attr('data-idCodeTableItem'));
codeTableItemAddEdit('#divModalCodetableItemAddEditPlaceholder', true, idCodeTableItem, (idCodeTableItem) => {
document.getElementById('btnSubmit').click();
});
}
function deleteCodeTableItem(element) {
let row = $(element).parent().parent();
let idCodeTableItem = parseInt(row.attr('data-idCodeTableItem'));
codeTableItemDelete(idCodeTableItem, (idCodeTableItem) => {
row.remove();
});
}
</script>
}