kreta/KretaWeb/Areas/DualisKepzes/Views/DualisKepzohely/Index.cshtml
2024-03-13 00:33:46 +01:00

269 lines
12 KiB
Text

@using Kreta.Web.Helpers.Grid;
@using Kreta.Web.Areas.DualisKepzes.Models;
@using Kreta.Enums.ManualEnums;
@using Kreta.Resources;
@using Kreta.Web.Security;
@model DualisKepzohelySearchModel
@{
const string gridName = "DualisKepzohelyGrid";
const string searchFormName = "searchForm";
}
@section AddSearchPanel {
@using (Html.SearchPanelSideBar(searchFormName, gridName))
{
@Html.HiddenFor(x => x.SzervezetId)
@Html.KretaTextBoxFor(x => x.KepzohelyNeve).RenderSearchPanelSideBar()
@Html.KretaTextBoxFor(x => x.KepzohelyAdoszama).RenderSearchPanelSideBar()
@Html.KretaTextBoxFor(x => x.KepzohelyCime).RenderSearchPanelSideBar()
@Html.KretaRangeNumericSideBar(x => x.TanulokSzamaTol, x => x.TanulokSzamaIg, precision: 0, needTolIgLabels: true, step: 1.0)
@Html.KretaRangeNumericSideBar(x => x.OktatokSzamaTol, x => x.OktatokSzamaIg, precision: 0, needTolIgLabels: true, step: 1.0)
@Html.KretaRangeNumericSideBar(x => x.CsoportokSzamaTol, x => x.CsoportokSzamaIg, precision: 0, needTolIgLabels: true, step: 1.0)
@Html.KretaRangeNumericSideBar(x => x.TantargyakSzamaTol, x => x.TantargyakSzamaIg, precision: 0, needTolIgLabels: true, step: 1.0)
@Html.KretaRangeNumericSideBar(x => x.HelyszinSzamaTol, x => x.HelyszinSzamaIg, precision: 0, needTolIgLabels: true, step: 1.0)
}
}
@{
var rowFunctions = new List<RowFunction> { };
var functionCommands = new List<FunctionCommand> { };
var conditionalRowFunctions = new List<RowFunction> { };
conditionalRowFunctions.Add(new RowFunction { Name = IntezmenyResource.Modositas, ClientAction = "DualisKepzohelyHelper.openModify", IconEnum = GridRowFunctionIconEnum.Modositas });
rowFunctions.Add(new RowFunction { Name = IntezmenyResource.Adatok, ClientAction = "DualisKepzohelyHelper.openInfo", IconEnum = GridRowFunctionIconEnum.Adatok });
conditionalRowFunctions.Add(new RowFunction { Name = IntezmenyResource.Torles, ClientAction = "DualisKepzohelyHelper.deleteConfirm", IconEnum = GridRowFunctionIconEnum.Torles });
if (ClaimData.FelhasznaloSzerepkor == Kreta.Enums.SzerepkorTipusEnum.Adminisztrator)
{
functionCommands.Add(new FunctionCommand { Name = IntezmenyResource.Uj, ClientAction = "DualisKepzohelyHelper.openNew" });
functionCommands.Add(new FunctionCommand { Name = IntezmenyResource.KijeloltekTorlese, ClientAction = "function() { DualisKepzohelyHelper.deleteSelected('" + gridName + "'); }", Classes = "kendo-gridFunctionKommandRed" });
}
functionCommands.Add(new FunctionCommand
{
Name = ImportExportCommonResource.Export.ToUpper(),
NestedCommands = new List<FunctionCommand>
{
new FunctionCommand { Name = ImportExportCommonResource.Export, ClientAction = "DualisKepzohelyHelper.getExport" }
}
});
var grid =
Html.KretaGrid<DualisKepzohelyGridModel>
(
name: gridName,
getUrl: new GridApiUrl(Constants.ApiControllers.DualisKepzohelyApi, "GetDualisKepzohelyGrid", new Dictionary<string, string> { { "parentId", "" } }),
dataParameterFunction: searchFormName,
clientTemplate: "detailGrid-template",
clientTemplateUrl: @Url.Action("GetAlSzervezetek", Constants.Controllers.DualisKepzohely, new { area = Constants.Areas.DualisKepzes }),
allowScrolling: true,
sort: sort => sort.Add(m => m.KepzohelyNeve).Ascending()
)
.SelectBoxColumn(Html, string.Empty);
if (!ClaimData.IsSelectedTanevIsElozo)
{
grid.LinkButtonColumn(string.Empty, c => c.KepzohelyNeve, "DualisKepzohelyHelper.openModifyOropenInfo", GridButtonsEnum.Modositas, width: "20%");
}
else
{
grid.Columns(columns => {columns.Bound(c => c.KepzohelyNeve).Width("20%"); });
}
grid.Columns(columns =>
{
columns.Bound(c => c.ID).Hidden();
columns.Bound(c => c.KepzohelyAdoszama).Width("20%");
columns.Bound(c => c.KepzohelyCime);
columns.Bound(c => c.TanulokSzama);
columns.Bound(c => c.OktatokSzama);
columns.Bound(c => c.CsoportokSzama);
columns.Bound(c => c.TantargyakSzama);
columns.Bound(c => c.HelyszinekSzama);
})
.ConditionalRowFunction(Html, new List<RowFunction> {
new RowFunction { Name = IntezmenyResource.Uj, ClientAction = "DualisKepzohelyHelper.openNewSub", IconEnum = GridRowFunctionIconEnum.Uj }
}, "DualisKepzohelyHelper.isUjAdhato", 1)
.RowFunction(Html, rowFunctions)
.FunctionCommand(Html, functionCommands)
.ConditionalRowFunction(Html, conditionalRowFunctions, "DualisKepzohelyHelper.isSzerkesztheto", 2)
.Sortable(sortable => sortable
.AllowUnsort(true)
.SortMode(GridSortMode.MultipleColumn));
}
<div>
@(grid)
</div>
@Html.KretaGridTemplate("detailGrid-template")
<script type="text/javascript">
var DualisKepzohelyHelper = (function () {
var gridName = "@gridName";
var formName = "DualisKepzohelyForm";
var searchFormName = "@searchFormName";
var popupId = "DualisKepzohelyWindow";
var dualisKepzohelyHelper = function () { };
var isEditable =false;
var url = {
DeleteDualisKepzoHely: "@Url.HttpRouteUrl(Constants.RouteKey.ActionApi, new { controller = Constants.ApiControllers.DualisKepzohelyApi, action = "DeleteDualisKepzoHely" })",
OpenNewModify: "@Url.Action("OpenModifyAddPopup", Constants.Controllers.DualisKepzohely, new { area = Constants.Areas.DualisKepzes })",
OpenInfo: "@Url.Action("OpenInfoPopup", Constants.Controllers.DualisKepzohely, new { area = Constants.Areas.DualisKepzes })",
DeleteSelected: "@Url.HttpRouteUrl(Constants.RouteKey.ActionApi, new {controller = Constants.ApiControllers.DualisKepzohelyApi, action= "DeleteSelectedDualisKepzoHely" })",
ValidateSaveModifiedOrNew: "@Url.HttpRouteUrl(Constants.RouteKey.ActionApi, new { controller = Constants.ApiControllers.DualisKepzohelyApi, action = "ValidateSaveModifiedOrNewDualisKepzoHely" })",
SaveDualisKepzoHely: "@Url.HttpRouteUrl(Constants.RouteKey.ActionApi, new { controller = Constants.ApiControllers.DualisKepzohelyApi, action = "SaveDualisKepzoHely" })",
GetExport: "@Url.HttpRouteUrl(Constants.RouteKey.ActionApi, new { controller = Constants.ApiControllers.DualisKepzohelyApi, action = "GetExport" })"
};
dualisKepzohelyHelper.getExport = function () {
KretaGridHelper.getExportBySearchForm(gridName, url.GetExport, searchFormName)
}
dualisKepzohelyHelper.openModify = function (rowData) {
isEditable = true;
AjaxHelper.DoGet(url.OpenNewModify, { Id: rowData.ID, parentSzervezetId: rowData.ParentSzervezetId }, popUpModify);
}
dualisKepzohelyHelper.openNew = function (data) {
AjaxHelper.DoGet(url.OpenNewModify, { Id: null, parentSzervezetId: null }, popUpNew);
}
dualisKepzohelyHelper.openNewSub = function (data) {
AjaxHelper.DoGet(url.OpenNewModify, { Id: null, parentSzervezetId: data.ID }, popUpNew);
}
dualisKepzohelyHelper.openInfo = function (rowData) {
isEditable = false;
AjaxHelper.DoGet(url.OpenInfo, { Id: rowData.ID }, popUpModify);
}
dualisKepzohelyHelper.deleteConfirm = function (rowData) {
var postData = { id: rowData.ID };
KretaWindowHelper.confirmWindow("@(CommonResource.Figyelmeztetes)", "@(CommonResource.BiztosanTorli)", deleteDualisKepzohely, postData);
}
dualisKepzohelyHelper.deleteSelected = function (currentGridName) {
var selectedRows = KretaGridHelper.getSelectedRowsByGridName(currentGridName);
if (!selectedRows.every((x) => dualisKepzohelyHelper.isSzerkesztheto(x)))
{
KretaWindowHelper.warningWindow("@(CommonResource.Figyelmeztetes)", "@(IntezmenyResource.NincsMindenKijeloltElemhezSzerkesztesTorlesJogosultsaga)");
return;
}
if (selectedRows.length > 0) {
KretaWindowHelper.confirmWindow("@(CommonResource.Figyelmeztetes)", "@(IntezmenyResource.ARendszerCsakAzonSorokatTorliAmelyeknekNincsenekKapcsolataiARendszerbenBiztosanTorliAzAdatokat)", function () { deleteSelected(selectedRows); });
}
else {
KretaWindowHelper.feedbackWindow("@(CommonResource.Figyelmeztetes)", "@(IntezmenyResource.AKijeloltElemekTorlesehezJeloljonKiLegalabbEgyElemet)", true, KretaWindowHelper.destroyAllWindow);
}
}
dualisKepzohelyHelper.modifyAddSave = function () {
var formObject = $("#" + formName).toObject();
AjaxHelper.DoValidationPost(url.SaveDualisKepzoHely, formName, formObject, modifyAddSaveFeedBackOk);
}
dualisKepzohelyHelper.openModifyOropenInfo = function (data) {
if (!dualisKepzohelyHelper.isSzerkesztheto(data)) {
dualisKepzohelyHelper.openInfo(data);
}
else {
dualisKepzohelyHelper.openModify(data);
}
}
dualisKepzohelyHelper.modifyAddCancel = function () {
KretaWindowHelper.destroyWindow(popupId);
}
dualisKepzohelyHelper.isSzerkesztheto = function (data)
{
return CommonUtils.parseBool(data.IsSzerkesztheto);
}
dualisKepzohelyHelper.isUjAdhato = function (data)
{
return data.ParentSzervezetId === null;
}
function modifyAddSaveFeedBackOk(data) {
KretaWindowHelper.successFeedBackWindow(KretaWindowHelper.destroyAllWindow);
if (data && data.parentId) {
KretaGridHelper.refreshGrid("DualisKepzohelyGrid_" + data.parentId);
}
else {
KretaGridHelper.refreshGridSearchPanel(gridName, searchFormName);
}
}
function popUpModify(data) {
var config = KretaWindowHelper.getWindowConfigContainer();
if (isEditable) {
config.title = "@(DualisResource.KepzohelyModositasa)";
}
else {
config.title = "@(DualisResource.KepzohelyAdatai)";
}
config.content = data;
var modal = KretaWindowHelper.createWindow(popupId, config);
KretaWindowHelper.openWindow(modal, true);
var title = $("#" +popupId+"_wnd_title").text();
var kepzohelyneve = $(".kepzohelyneve").val();
var kepzohelyadoszama = $(".kepzohelyadoszama").val();
if (CommonUtils.isNullOrUndefined(kepzohelyneve)) {
kepzohelyneve = $("[displayfor='KepzohelyNeve']").text();
}
if (CommonUtils.isNullOrUndefined(kepzohelyadoszama)) {
kepzohelyadoszama = $("[displayfor='KepzohelyAdoszama']").text();
}
if (!CommonUtils.isNullOrUndefined(kepzohelyneve))
{
title += " [" + kepzohelyneve;
if (!CommonUtils.isNullOrUndefined(kepzohelyadoszama))
{
title += " - " + kepzohelyadoszama;
}
title += "] ";
$("#" + popupId + "_wnd_title").text(title);
}
}
function popUpNew(data) {
var config = KretaWindowHelper.getWindowConfigContainer();
config.title = "@(DualisResource.KepzohelyFelvetele)";
config.content = data;
var modal = KretaWindowHelper.createWindow(popupId, config);
KretaWindowHelper.openWindow(modal, true);
}
function deleteDualisKepzohely(postData) {
AjaxHelper.DoPostQuery(url.DeleteDualisKepzoHely, null, postData, deleteSuccessCallBack, deleteErrorCallBack);
}
function deleteErrorCallBack(data) {
var message = data.responseJSON.Message;
KretaWindowHelper.feedbackWindow(Globalization.Hiba /*HIBA*/, message, true, KretaWindowHelper.destroyAllWindow);
}
function deleteSelected(selectedRows) {
var parameters = [];
$.each(selectedRows, function (index, value) {
parameters.push(value.ID);
});
AjaxHelper.DoPost(url.DeleteSelected, parameters, deleteSelectedResponseOk, deleteSelectedResponseError);
}
function deleteSelectedResponseError(data) {
KretaGridHelper.refreshGridSearchPanel(gridName, searchFormName);
AjaxHelper.ShowError(data);
}
function deleteSelectedResponseOk(data) {
KretaWindowHelper.successFeedBackWindow(KretaWindowHelper.destroyAllWindow, data.Message);
KretaGridHelper.refreshGridSearchPanel(gridName, searchFormName);
}
function deleteSuccessCallBack() {
KretaGridHelper.refreshGrid(gridName);
}
return dualisKepzohelyHelper;
})();
</script>