- Dodati operacije na pozicijo dela projekta

- Dodatna tabela z operacijami in stanjem (končano/nekončano)
  - šifrant operacij - možnost določevanje privzetih operacij

- Opombe na pozicij dela projekta

- Pogled kooperacij na poziciji dela projekta
  - Izpisano številka kooperacije in kooperant
This commit is contained in:
2026-02-28 09:37:13 +01:00
parent 7d64e423c3
commit 9d0fb30bf0
15 changed files with 3774 additions and 56 deletions

View File

@@ -0,0 +1,32 @@
@model EveryThing.Pages.CodeTableOperations.IndexModel.AddEditCodeTableOperation
<div class="modal" tabindex="-1" role="dialog" id="divModalAddEditCodeTableOperation">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="modalAddEditCodeTableOperationTitle">Dodajanje nove operacije</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<input id="inpModalAddEditCodeTableOperationIdCodeTableOperation" type="hidden" asp-for="@Model.IdCodeTableOperation" />
<input id="inpModalAddEditCodeTableOperationEdit" type="hidden" asp-for="@Model.Edit" />
<div class="form-group">
<label asp-for="Operation.Title" class="control-label"></label>
<input id="inpModalAddEditCodeTableOperationTitle" asp-for="Operation.Title" class="form-control" />
<span asp-validation-for="Operation.Title" class="text-danger"></span>
</div>
<div class="form-group form-check">
<label class="form-check-label">
<input id="inpModalAddEditCodeTableOperationDefault" class="form-check-input" asp-for="Operation.Default" /> @Html.DisplayNameFor(model => model.Operation.Default)
</label>
</div>
</div>
<div class="modal-footer">
<button id="btnModalAddEditCodeTableOperationConfirm" type="button" class="btn btn-primary">Shrani</button>
<button id="btnModalAddEditCodeTableOperationCancel" type="button" class="btn btn-secondary">Prekliči</button>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,112 @@
@page
@model EveryThing.Pages.CodeTableOperations.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">Operacije /</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 operacij
</h6>
<table class="table">
<thead>
<tr>
<th class="w-100">
@Html.DisplayNameFor(model => model.Operation[0].Title)
</th>
<th class="text-right" style="white-space: nowrap; width: 1%;">
@Html.DisplayNameFor(model => model.Operation[0].Default)
</th>
<th class="text-right" style="white-space: nowrap; width: 1%;"></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.Operation)
{
<tr data-idCodeTableOperation="@item.Id">
<td>
@Html.DisplayFor(modelItem => item.Title)
</td>
<td class="text-right" style="white-space: nowrap; width: 1%;">
@Html.DisplayFor(modelItem => item.Default)
</td>
<td class="text-right" style="white-space: nowrap; width: 1%;">
<a class="btn btn-xs icon-btn btn-outline-secondary borderless" href="javascript:;" onclick="editCodeTableOperation(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="deleteCodeTableOperation(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="addNewCodeTableOperation();" >Vnos operacije</button>
</div>
<div id="divModalCodeTableOperationAddEditPlaceholder"></div>
</div>
@Html.AntiForgeryToken()
@section Scripts {
<script src="~/js/codeTableOperationHelper.js" asp-append-version="true"></script>
<script>
$('[data-toggle="tooltip"]').tooltip({container: 'table'});
function addNewCodeTableOperation() {
codeTableOperationAddEdit('#divModalCodeTableOperationAddEditPlaceholder', false, null, (idCodeTableOperation) => {
document.getElementById('btnSubmit').click();
});
}
function editCodeTableOperation(element) {
let idCodeTableOperation = parseInt($(element).parent().parent().attr('data-idCodeTableOperation'));
codeTableOperationAddEdit('#divModalCodeTableOperationAddEditPlaceholder', true, idCodeTableOperation, (idCodeTableOperation) => {
document.getElementById('btnSubmit').click();
});
}
function deleteCodeTableOperation(element) {
let row = $(element).parent().parent();
let idCodeTableOperation = parseInt(row.attr('data-idCodeTableOperation'));
codeTableOperationDelete(idCodeTableOperation, (idCodeTableOperation) => {
row.remove();
});
}
</script>
}

View File

@@ -0,0 +1,168 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using EveryThing.Data;
using EveryThing.Models;
using EveryThing.Models.CodeTable;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Authorization;
using Microsoft.VisualStudio.Debugger.Contracts;
using System.Globalization;
namespace EveryThing.Pages.CodeTableOperations
{
[Authorize(Roles = "Administrator,InvoicingUser,ProjecThingUser")]
public class IndexModel : PageModel
{
public class AddEditCodeTableOperation
{
public CodeTableOperation Operation { get; set; }
public bool Edit { get; set; }
public int IdCodeTableOperation { get; set; }
}
private readonly ApplicationDbContext _context;
private readonly UserManager<IdentityApplicationUser> _userManager;
private readonly SignInManager<IdentityApplicationUser> _loginManager;
private readonly RoleManager<IdentityApplicationRole> _roleManager;
public IndexModel(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager, SignInManager<IdentityApplicationUser> loginManager, RoleManager<IdentityApplicationRole> roleManager)
{
_context = context;
_userManager = userManager;
_loginManager = loginManager;
_roleManager = roleManager;
}
public IList<CodeTableOperation> Operation { get; set; }
public async Task OnGetAsync(string searchString)
{
var user = _userManager.GetUserAsync(User).Result;
ViewData["SearchString"] = searchString ?? "";
var search = !string.IsNullOrEmpty(searchString);
var query = _context.CodeTableOperations.AsQueryable();
if (search)
{
query = query.Where(x => EF.Functions.Like(x.Title, $"%{searchString}%"));
}
Operation = await query
.OrderByDescending(x => x.Id)
.Take(100)
.ToListAsync();
}
public IActionResult OnGetCodeTableOperationModal(bool edit, int idCodeTableOperation)
{
CodeTableOperation operation = null;
if (edit)
{
operation = _context.CodeTableOperations
.FirstOrDefault(x => x.Id == idCodeTableOperation);
}
operation ??= new CodeTableOperation();
return Partial("AddEditOperationModal", new AddEditCodeTableOperation
{
Operation = operation,
Edit = edit,
IdCodeTableOperation = idCodeTableOperation
});
}
public IActionResult OnPostCodeTableOperation(string title, bool defaultValue, bool edit, int idCodeTableOperation)
{
var successful = true;
var error = "";
if (edit)
{
var operation = _context.CodeTableOperations
.FirstOrDefault(x => x.Id == idCodeTableOperation);
if (operation != null)
{
operation.Title = title;
operation.Default = defaultValue;
_context.SaveChanges();
}
else
{
successful = false;
error = $"Code-table operation with ID: {idCodeTableOperation} not found";
}
}
else
{
var operation = new CodeTableOperation
{
Title = title,
Default = defaultValue
};
_context.CodeTableOperations.Add(operation);
_context.SaveChanges();
idCodeTableOperation = operation.Id;
}
return new JsonResult(new { idCodeTableOperation, error, successful });
}
public IActionResult OnGetCodeTableOperation(int idCodeTableOperation)
{
var successful = true;
var error = "";
var inUse = false;
var operation = _context.CodeTableOperations
.Include(x => x.ProjectPartItemOperation)
.FirstOrDefault(x => x.Id == idCodeTableOperation);
if (operation == null)
{
successful = false;
error = $"Code-table operation with ID: {idCodeTableOperation} not found";
}
else
{
inUse = operation.ProjectPartItemOperation != null && operation.ProjectPartItemOperation.Count > 0;
operation.ProjectPartItemOperation = null;
}
return new JsonResult(new { operation, error, successful, inUse });
}
public IActionResult OnDeleteCodeTableOperation(int idCodeTableOperation)
{
var successful = true;
var error = "";
var operation = _context.CodeTableOperations
.FirstOrDefault(x => x.Id == idCodeTableOperation);
if (operation != null)
{
_context.CodeTableOperations.Remove(operation);
_context.SaveChanges();
}
else
{
successful = false;
error = $"Code-table operation with ID: {idCodeTableOperation} not found";
}
return new JsonResult(new { idCodeTableOperation, error, successful });
}
}
}