subAccountRole merged
This commit is contained in:
@@ -15,6 +15,6 @@ namespace AccountManagement.Application.Contracts.SubAccount
|
||||
public string PhoneNumber { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string ProfilePhoto { get; set; }
|
||||
public List<long> WorkshopIds { get; set; }
|
||||
//public List<long> WorkshopIds { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,5 +8,6 @@ namespace AccountManagement.Application.Contracts.SubAccount
|
||||
public string Title { get; set; }
|
||||
public long AccountId { get; set; }
|
||||
public List<int> Permissions { get; set; }
|
||||
public List<long> WorkshopIds { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace AccountManagement.Application.Contracts.SubAccount
|
||||
public string PhoneNumber { get; set; }
|
||||
public string RePassword { get; set; }
|
||||
public long SubAccountRoleId { get; set; }
|
||||
public List<long> WorkshopIds { get; set; }
|
||||
//public List<long> WorkshopIds { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -7,5 +7,6 @@ namespace AccountManagement.Application.Contracts.SubAccount
|
||||
public long Id { get; set; }
|
||||
public string Title { get; set; }
|
||||
public List<int> Permissions { get; set; }
|
||||
public List<long> WorkshopIds { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,12 +113,12 @@ namespace AccountManagement.Application
|
||||
if (cmd.PhoneNumber.Length != 11)
|
||||
return op.Failed("شماره تلفن همراه نامعتبر است");
|
||||
|
||||
if (!cmd.WorkshopIds.Any())
|
||||
return op.Failed("حداقل یک کارگاه را انتخاب کنید");
|
||||
//if (!cmd.WorkshopIds.Any())
|
||||
// return op.Failed("حداقل یک کارگاه را انتخاب کنید");
|
||||
|
||||
|
||||
if (!cmd.WorkshopIds.All(x => accountWorkshopsList.Contains(x)))
|
||||
return op.Failed("خطای سیستمی");
|
||||
//if (!cmd.WorkshopIds.All(x => accountWorkshopsList.Contains(x)))
|
||||
// return op.Failed("خطای سیستمی");
|
||||
|
||||
|
||||
if (cmd.SubAccountRoleId == 0 || !_subAccountRoleRepository.Exists(x => cmd.SubAccountRoleId == x.id))
|
||||
@@ -131,6 +131,10 @@ namespace AccountManagement.Application
|
||||
_cameraAccountRepository.Exists(x => x.Username == cmd.Username))
|
||||
return op.Failed("نام کاربری نمی تواند تکراری باشد");
|
||||
|
||||
var role = _subAccountRoleRepository.Get(cmd.SubAccountRoleId);
|
||||
var workshopId = role.RoleWorkshops.Select(x => x.WorkshopId).ToList();
|
||||
|
||||
|
||||
var entity = new SubAccount(cmd.AccountId, cmd.SubAccountRoleId, cmd.NationalCode, cmd.FName, cmd.LName, cmd.PhoneNumber, cmd.Username, _passwordHasher.Hash(cmd.Password),
|
||||
cmd.ProfilePhoto);
|
||||
|
||||
@@ -142,7 +146,7 @@ namespace AccountManagement.Application
|
||||
_subAccountRepository.SaveChanges();
|
||||
|
||||
|
||||
var workshops = cmd.WorkshopIds.Select(x => new WorkshopSubAccount(x, entity.id));
|
||||
var workshops = workshopId.Select(x => new WorkshopSubAccount(x, entity.id));
|
||||
|
||||
foreach (var w in workshops)
|
||||
_workshopSubAccountRepository.Create(w);
|
||||
@@ -175,22 +179,22 @@ namespace AccountManagement.Application
|
||||
|
||||
|
||||
|
||||
if (!cmd.WorkshopIds.All(x => accountWorkshopsList.Contains(x)))
|
||||
return op.Failed("خطای سیستمی");
|
||||
//if (!cmd.WorkshopIds.All(x => accountWorkshopsList.Contains(x)))
|
||||
// return op.Failed("خطای سیستمی");
|
||||
|
||||
|
||||
if (cmd.SubAccountRoleId == 0 || !_subAccountRoleRepository.Exists(x => cmd.SubAccountRoleId == x.id))
|
||||
return op.Failed("نقش مورد نظر وجود ندارد");
|
||||
|
||||
var workshopSubAccounts = _workshopSubAccountRepository.GetWorkshopsSubAccountEntityBySubAccountId(entity.id);
|
||||
foreach (var workshopSubAccount in workshopSubAccounts)
|
||||
_workshopSubAccountRepository.Remove(workshopSubAccount);
|
||||
//var workshopSubAccounts = _workshopSubAccountRepository.GetWorkshopsSubAccountEntityBySubAccountId(entity.id);
|
||||
//foreach (var workshopSubAccount in workshopSubAccounts)
|
||||
// _workshopSubAccountRepository.Remove(workshopSubAccount);
|
||||
|
||||
|
||||
var workshops = cmd.WorkshopIds.Select(x => new WorkshopSubAccount(x, entity.id));
|
||||
//var workshops = cmd.WorkshopIds.Select(x => new WorkshopSubAccount(x, entity.id));
|
||||
|
||||
foreach (var w in workshops)
|
||||
_workshopSubAccountRepository.Create(w);
|
||||
//foreach (var w in workshops)
|
||||
// _workshopSubAccountRepository.Create(w);
|
||||
|
||||
entity.Edit(cmd.SubAccountRoleId, cmd.NationalCode, cmd.FName, cmd.LName, cmd.ProfilePhoto);
|
||||
_workshopSubAccountRepository.SaveChanges();
|
||||
@@ -227,7 +231,8 @@ namespace AccountManagement.Application
|
||||
{
|
||||
Id = entity.id,
|
||||
Title = entity.Title,
|
||||
Permissions = entity.RolePermissions.Select(x => x.PermissionCode).ToList()
|
||||
Permissions = entity.RolePermissions.Select(x => x.PermissionCode).ToList(),
|
||||
WorkshopIds = entity.RoleWorkshops.Select(x=>x.WorkshopId).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
@@ -241,7 +246,7 @@ namespace AccountManagement.Application
|
||||
OperationResult op = new();
|
||||
if (_subAccountRoleRepository.Exists(x => x.AccountId == command.AccountId && x.Title.Trim() == command.Title.Trim()))
|
||||
return op.Failed("یک نقش با این عنوان وجود دارد");
|
||||
var role = new SubAccountRole(command.Title, command.Permissions, command.AccountId);
|
||||
var role = new SubAccountRole(command.Title, command.Permissions, command.AccountId,command.WorkshopIds);
|
||||
_subAccountRoleRepository.Create(role);
|
||||
_subAccountRoleRepository.SaveChanges();
|
||||
return op.Succcedded(role.id);
|
||||
@@ -254,7 +259,23 @@ namespace AccountManagement.Application
|
||||
var entity = _subAccountRoleRepository.Get(cmd.Id);
|
||||
if (entity == null)
|
||||
return op.Failed(ApplicationMessages.RecordNotFound);
|
||||
entity.Edit(cmd.Title, cmd.Permissions);
|
||||
entity.Edit(cmd.Title, cmd.Permissions,cmd.WorkshopIds);
|
||||
|
||||
var subAccountRoles = _subAccountRepository.GetBySubAccountRole(cmd.Id);
|
||||
|
||||
foreach (var subAccount in subAccountRoles)
|
||||
{
|
||||
var workshopSubAccounts = _workshopSubAccountRepository.GetWorkshopsSubAccountEntityBySubAccountId(subAccount.id);
|
||||
foreach (var workshopSubAccount in workshopSubAccounts)
|
||||
_workshopSubAccountRepository.Remove(workshopSubAccount);
|
||||
|
||||
|
||||
var workshops = cmd.WorkshopIds.Select(x => new WorkshopSubAccount(x, subAccount.id));
|
||||
|
||||
foreach (var w in workshops)
|
||||
_workshopSubAccountRepository.Create(w);
|
||||
}
|
||||
|
||||
_subAccountRoleRepository.SaveChanges();
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using _0_Framework.Domain;
|
||||
using AccountManagement.Application.Contracts.SubAccount;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
|
||||
namespace AccountManagement.Domain.SubAccountAgg
|
||||
{
|
||||
@@ -13,5 +14,6 @@ namespace AccountManagement.Domain.SubAccountAgg
|
||||
SubAccount GetDetails(long subAccountId);
|
||||
SubAccount GetBy(string commandUsername);
|
||||
SubAccountViewModel GetByVerifyCodeAndPhoneNumber(string code, string phone);
|
||||
List<SubAccount> GetBySubAccountRole(long subAccountRoleId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,17 +13,21 @@ namespace AccountManagement.Domain.SubAccountRoleAgg
|
||||
|
||||
public List<SubAccountRolePermission> RolePermissions { get; private set; }
|
||||
public List<SubAccount> SubAccounts { get; private set; }
|
||||
public List<SubAccountRoleWorkshop> RoleWorkshops { get; set; }
|
||||
|
||||
private SubAccountRole()
|
||||
{
|
||||
}
|
||||
|
||||
public SubAccountRole(string title, List<int> permissions, long accountId)
|
||||
public SubAccountRole(string title, List<int> permissions, long accountId, List<long> workshopIds)
|
||||
{
|
||||
Title = title;
|
||||
RolePermissions = permissions.Select(x => new SubAccountRolePermission(x, id)).ToList();
|
||||
AccountId = accountId;
|
||||
RoleWorkshops = workshopIds.Select(x => new SubAccountRoleWorkshop(x, id)).ToList();
|
||||
|
||||
}
|
||||
|
||||
public void ChangeTitle(string title)
|
||||
{
|
||||
Title = title;
|
||||
@@ -32,10 +36,12 @@ namespace AccountManagement.Domain.SubAccountRoleAgg
|
||||
{
|
||||
RolePermissions.AddRange(permissionIds.Select(x => new SubAccountRolePermission(x, id)));
|
||||
}
|
||||
public void Edit(string title, List<int> permissions)
|
||||
public void Edit(string title, List<int> permissions,List<long> workshopIds)
|
||||
{
|
||||
Title = title;
|
||||
RolePermissions = permissions.Select(x => new SubAccountRolePermission(x, id)).ToList();
|
||||
RoleWorkshops = workshopIds.Select(x => new SubAccountRoleWorkshop(x, id)).ToList();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using _0_Framework.Domain;
|
||||
|
||||
namespace AccountManagement.Domain.SubAccountRoleAgg;
|
||||
|
||||
public class SubAccountRoleWorkshop:EntityBase
|
||||
{
|
||||
public SubAccountRoleWorkshop(long workshopId, long subAccountId)
|
||||
{
|
||||
WorkshopId = workshopId;
|
||||
SubAccountId = subAccountId;
|
||||
}
|
||||
|
||||
public long WorkshopId { get; set; }
|
||||
public long SubAccountId { get; set; }
|
||||
public SubAccountRole SubAccountRole { get; set; }
|
||||
}
|
||||
@@ -21,6 +21,10 @@ namespace AccountMangement.Infrastructure.EFCore.Mappings
|
||||
opt.WithOwner(x => x.SubAccountRole);
|
||||
});
|
||||
|
||||
builder.OwnsMany(x => x.RoleWorkshops, roleWorkshop =>
|
||||
{
|
||||
roleWorkshop.WithOwner(x => x.SubAccountRole).HasForeignKey(x => x.SubAccountId);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1303
AccountMangement.Infrastructure.EFCore/Migrations/20250530133036_add workshop to subAccountRole.Designer.cs
generated
Normal file
1303
AccountMangement.Infrastructure.EFCore/Migrations/20250530133036_add workshop to subAccountRole.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AccountMangement.Infrastructure.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class addworkshoptosubAccountRole : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "SubAccountRoleWorkshop",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
SubAccountId = table.Column<long>(type: "bigint", nullable: false),
|
||||
WorkshopId = table.Column<long>(type: "bigint", nullable: false),
|
||||
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_SubAccountRoleWorkshop", x => new { x.SubAccountId, x.id });
|
||||
table.ForeignKey(
|
||||
name: "FK_SubAccountRoleWorkshop_SubAccountRoles_SubAccountId",
|
||||
column: x => x.SubAccountId,
|
||||
principalTable: "SubAccountRoles",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "SubAccountRoleWorkshop");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1078,6 +1078,33 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations
|
||||
|
||||
modelBuilder.Entity("AccountManagement.Domain.SubAccountRoleAgg.SubAccountRole", b =>
|
||||
{
|
||||
b.OwnsMany("AccountManagement.Domain.SubAccountRoleAgg.SubAccountRoleWorkshop", "RoleWorkshops", b1 =>
|
||||
{
|
||||
b1.Property<long>("SubAccountId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b1.Property<long>("id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property<long>("id"));
|
||||
|
||||
b1.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b1.Property<long>("WorkshopId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b1.HasKey("SubAccountId", "id");
|
||||
|
||||
b1.ToTable("SubAccountRoleWorkshop");
|
||||
|
||||
b1.WithOwner("SubAccountRole")
|
||||
.HasForeignKey("SubAccountId");
|
||||
|
||||
b1.Navigation("SubAccountRole");
|
||||
});
|
||||
|
||||
b.OwnsMany("AccountManagement.Domain.SubAccountRoleAgg.SubAccountRolePermission", "RolePermissions", b1 =>
|
||||
{
|
||||
b1.Property<long>("id")
|
||||
@@ -1105,6 +1132,8 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations
|
||||
});
|
||||
|
||||
b.Navigation("RolePermissions");
|
||||
|
||||
b.Navigation("RoleWorkshops");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AccountManagement.Domain.TaskAgg.Tasks", b =>
|
||||
|
||||
@@ -77,5 +77,10 @@ namespace AccountMangement.Infrastructure.EFCore.Repository
|
||||
Username = entity.Username
|
||||
};
|
||||
}
|
||||
|
||||
public List<SubAccount> GetBySubAccountRole(long subAccountRoleId)
|
||||
{
|
||||
return _context.SubAccounts.Where(x => x.SubAccountRoleId == subAccountRoleId).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
}
|
||||
|
||||
|
||||
|
||||
public IActionResult OnPostShiftDate()
|
||||
{
|
||||
//var startRollCall = new DateTime(2025, 2, 19);
|
||||
@@ -79,6 +80,40 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
ViewData["message"] = "تومام یک";
|
||||
return Page();
|
||||
}
|
||||
public async Task<IActionResult> OnPostShiftDateNew2()
|
||||
{
|
||||
//var startRollCall = new DateTime(2025, 3, 21);
|
||||
//var rollCalls = _context.RollCalls.Where(x => x.StartDate >= startRollCall && x.EndDate != null ).ToList();
|
||||
//var r1 = rollCalls.Skip(10000).Take(10000).ToList();
|
||||
|
||||
//Console.ForegroundColor = ConsoleColor.DarkRed;
|
||||
//Console.WriteLine("endStep 1 ============");
|
||||
//SetRollCall(r1);
|
||||
|
||||
await SetWorkshopRoleSubAccount();
|
||||
ViewData["message"] = "تومام دو";
|
||||
return Page();
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task SetWorkshopRoleSubAccount()
|
||||
{
|
||||
var subAccountRoles = _accountContext.SubAccountRoles.Include(x=>x.SubAccounts).ToList();
|
||||
|
||||
subAccountRoles.ForEach(role =>
|
||||
{
|
||||
var getSubAccount = role.SubAccounts.FirstOrDefault();
|
||||
if (getSubAccount != null)
|
||||
{
|
||||
var subAccount = getSubAccount.id;
|
||||
|
||||
var workshopIds = _context.WorkshopSubAccounts.Where(x => x.SubAccountId == subAccount).Select(x => x.WorkshopId).ToList();
|
||||
role.Edit(role.Title, role.RolePermissions.Select(x => x.PermissionCode).ToList(), workshopIds);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
await _accountContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
|
||||
private void SetEntityIdForCheckoutValuesTemp()
|
||||
@@ -214,20 +249,6 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostShiftDateNew2()
|
||||
{
|
||||
//var startRollCall = new DateTime(2025, 3, 21);
|
||||
//var rollCalls = _context.RollCalls.Where(x => x.StartDate >= startRollCall && x.EndDate != null ).ToList();
|
||||
//var r1 = rollCalls.Skip(10000).Take(10000).ToList();
|
||||
|
||||
//Console.ForegroundColor = ConsoleColor.DarkRed;
|
||||
//Console.WriteLine("endStep 1 ============");
|
||||
//SetRollCall(r1);
|
||||
|
||||
await SetCalculationDateInSalaryAid();
|
||||
ViewData["message"] = "تومام دو";
|
||||
return Page();
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task SetCalculationDateInSalaryAid()
|
||||
{
|
||||
|
||||
@@ -348,9 +348,9 @@
|
||||
</div> *@
|
||||
<!-- End Modal From Bottom For Advance Search -->
|
||||
|
||||
|
||||
<div id="MainModal" class="modal fade " aria-labelledby="myModalLabel" aria-hidden="true" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" style="display: none;">
|
||||
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable">
|
||||
@* modal-dialog-scrollable *@
|
||||
<div id="MainModal" class="modal fade" aria-labelledby="myModalLabel" aria-hidden="true" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" style="display: none;">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content" id="ModalContent">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -112,7 +112,8 @@ namespace ServiceHost.Areas.Client.Pages.Company.SubAccounts
|
||||
{
|
||||
Id = getDetails.Id,
|
||||
Title = getDetails.Title,
|
||||
Permissions = getDetails.Permissions
|
||||
Permissions = getDetails.Permissions,
|
||||
WorkshopIds = getDetails.WorkshopIds
|
||||
};
|
||||
return Partial("ModalEditRole", command);
|
||||
}
|
||||
@@ -250,15 +251,6 @@ namespace ServiceHost.Areas.Client.Pages.Company.SubAccounts
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#region Sub Account
|
||||
public IActionResult OnPostSendSms()
|
||||
{
|
||||
|
||||
@@ -16,17 +16,51 @@
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="container-fluid p-0">
|
||||
<div class="form-role-section">
|
||||
<div class="form-role-workshop-section">
|
||||
<div class="workshop">
|
||||
<div class="workshop__label">انتخاب کارگاه</div>
|
||||
<div class="workshop__mobile">
|
||||
<svg width="59" height="4" viewBox="0 0 59 4" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="59" height="4" rx="2" fill="#909090"/>
|
||||
</svg>
|
||||
<div class="workshop__label-mobile mb-3">انتخاب کارگاه برای دسترسی این گروه</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12 my-1">
|
||||
<div id="workshopItems">
|
||||
|
||||
</div>
|
||||
|
||||
<div class="workshop-mobile-footer">
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<button type="button" class="btn-cancel" onclick="hideModalWorkshop()">انصراف</button>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<button type="button" class="btn-success" onclick="chooseWorkshops()">انتخاب</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-role-all-section">
|
||||
<div class="row">
|
||||
<div class="col-12 mb-1">
|
||||
<div class="from-group position-relative">
|
||||
<input type="text" asp-for="@Model.Title" class="form-control ModelTitle m-0" placeholder="عنوان نقش">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12 my-1">
|
||||
<div class="col-12 d-md-none mb-1">
|
||||
<button type="button" class="d-flex align-items-center justify-content-between workshop-mobile-btn" onclick="showModalWorkshop()">
|
||||
<div>انتخاب کارگاه</div>
|
||||
<div class="workshop-mobile-btn__badge-number" style="display: none"></div>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<div class="permissionBox">
|
||||
<div id="search-container">
|
||||
<input type="text" id="search-input" class="form-control bg-white my-2" placeholder="جستجو سریع...">
|
||||
@@ -35,7 +69,8 @@
|
||||
<div id="tree" class="tree-row">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -70,6 +105,7 @@
|
||||
<script>
|
||||
var antiForgeryToken = $(`@Html.AntiForgeryToken()`).val();
|
||||
var saveNewRoleSubAccountAjax = `@Url.Page("./Index", "CreateRole")`;
|
||||
var workshopListAjax = `@Url.Page("./Index", "WorkshopList")`;
|
||||
var permissionListAjax = `@Url.Page("./Index", "Permissions")`;
|
||||
</script>
|
||||
<script src="~/assetsclient/pages/SubAccounts/js/ModalCreateRole.js?ver=@clientVersion"></script>
|
||||
@@ -35,13 +35,13 @@
|
||||
<div class="row customHeight">
|
||||
|
||||
<div class="col-12 my-1">
|
||||
<div class="from-group position-relative my-1">
|
||||
@* <div class="from-group position-relative my-1">
|
||||
<span class="spanTitleText">کارگاه</span>
|
||||
<div class="select-workshop-alert">
|
||||
<select class="form-select select2OptionWorkshop" aria-label="انتخاب کارگاه ..." asp-for="@Model.WorkshopIds" id="workshopSelect" multiple>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div> *@
|
||||
<div class="from-group position-relative my-1">
|
||||
<span class="spanTitleText">نقش</span>
|
||||
<div class="select-role-alert">
|
||||
|
||||
@@ -18,18 +18,53 @@
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<div class="container-fluid">
|
||||
<div class="container-fluid p-0">
|
||||
<div class="form-role-section">
|
||||
<div class="form-role-workshop-section">
|
||||
<div class="workshop">
|
||||
<div class="workshop__label">انتخاب کارگاه</div>
|
||||
<div class="workshop__mobile">
|
||||
<svg width="59" height="4" viewBox="0 0 59 4" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="59" height="4" rx="2" fill="#909090"/>
|
||||
</svg>
|
||||
<div class="workshop__label-mobile mb-3">انتخاب کارگاه برای دسترسی این گروه</div>
|
||||
</div>
|
||||
|
||||
<div id="workshopItems">
|
||||
|
||||
</div>
|
||||
|
||||
<div class="workshop-mobile-footer">
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<button type="button" class="btn-cancel" onclick="hideModalWorkshop()">انصراف</button>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<button type="button" class="btn-success" onclick="chooseWorkshops()">انتخاب</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-role-all-section">
|
||||
<div class="row">
|
||||
|
||||
<input type="hidden" name="Id" id="Id" value="@Model.Id" />
|
||||
<div class="col-12 my-1">
|
||||
<input type="hidden" name="Id" id="Id" value="@Model.Id"/>
|
||||
<div class="col-12 mb-1">
|
||||
<div class="from-group position-relative">
|
||||
<input type="text" name="Title" id="Title" value="@Model.Title" class="form-control ModelTitle m-0" placeholder="عنوان نقش">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12 my-1">
|
||||
<div class="col-12 d-md-none mb-1">
|
||||
<button type="button" class="d-flex align-items-center justify-content-between workshop-mobile-btn" onclick="showModalWorkshop()">
|
||||
<div>انتخاب کارگاه</div>
|
||||
<div class="workshop-mobile-btn__badge-number" style="display: none"></div>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<div class="permissionBox">
|
||||
<div id="search-container">
|
||||
<input type="text" id="search-input" class="form-control bg-white my-2" placeholder="جستجو سریع...">
|
||||
@@ -39,8 +74,9 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -75,6 +111,8 @@
|
||||
var antiForgeryToken = $(`@Html.AntiForgeryToken()`).val();
|
||||
var saveEditRoleSubAccountAjax = `@Url.Page("./Index", "EditRole")`;
|
||||
var permissionListAjax = `@Url.Page("./Index", "Permissions")`;
|
||||
var workshopListAjax = `@Url.Page("./Index", "WorkshopList")`;
|
||||
var itemsPermission = @Html.Raw(Json.Serialize(Model.Permissions));
|
||||
var selctedWorkshopslist = @Html.Raw(Json.Serialize(Model.WorkshopIds));
|
||||
</script>
|
||||
<script src="~/assetsclient/pages/SubAccounts/js/ModalEditRole.js?ver=@clientVersion"></script>
|
||||
@@ -37,13 +37,13 @@
|
||||
|
||||
<input type="hidden" name="Command.SubAccountId" value="@Model.Id" placeholder="SubAccountId">
|
||||
|
||||
<div class="from-group position-relative my-2">
|
||||
@* <div class="from-group position-relative my-2">
|
||||
<span class="spanTitleText">کارگاه</span>
|
||||
<div class="select-workshop-alert">
|
||||
<select class="form-select select2OptionWorkshop" aria-label="انتخاب کارگاه ..." name="Command.WorkshopIds" id="workshopSelect" multiple>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div> *@
|
||||
<div class="from-group position-relative my-2">
|
||||
<span class="spanTitleText">نقش</span>
|
||||
<div class="select-role-alert">
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
.errored {
|
||||
.modal-dialog {
|
||||
max-width: 750px;
|
||||
}
|
||||
|
||||
.errored {
|
||||
animation: shake 300ms;
|
||||
color: #eb3434 !important;
|
||||
background-color: #fef2f2 !important;
|
||||
@@ -30,7 +34,191 @@
|
||||
width: 80px;
|
||||
}*/
|
||||
|
||||
.form-role-section {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(6, minmax(0, 1fr));
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.form-role-workshop-section {
|
||||
grid-column: span 2 / span 2;
|
||||
}
|
||||
|
||||
.workshop__mobile {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.workshop-mobile-footer {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.form-role-workshop-section-mobile {
|
||||
position: fixed;
|
||||
display: block !important;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
width: 100%;
|
||||
height: 350px;
|
||||
z-index: 120;
|
||||
}
|
||||
|
||||
.form-role-workshop-section-mobile::before {
|
||||
content: "";
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
background: #000000;
|
||||
opacity: 0.5;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.form-role-workshop-section-mobile .workshop__mobile {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.form-role-workshop-section-mobile .workshop__mobile .workshop__label-mobile {
|
||||
font-size: 16px;
|
||||
color: #292929;
|
||||
font-weight: 700 !important;
|
||||
}
|
||||
|
||||
.form-role-workshop-section-mobile .workshop__mobile svg {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
.form-role-workshop-section-mobile .workshop {
|
||||
border: none;
|
||||
border-radius: 7px 7px 0 0;
|
||||
z-index: 120;
|
||||
}
|
||||
|
||||
.form-role-workshop-section-mobile .workshop .workshop__label {
|
||||
display: none
|
||||
}
|
||||
|
||||
.form-role-workshop-section-mobile .workshop #workshopItems {
|
||||
height: 207px;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
.form-role-workshop-section-mobile .workshop .workshop-mobile-footer {
|
||||
display: block;
|
||||
border-top: 1px solid #D5D5D5;
|
||||
padding: 11px 0;
|
||||
margin: 11px 0;
|
||||
}
|
||||
|
||||
.form-role-workshop-section-mobile .workshop .workshop-mobile-footer button {
|
||||
width: 100%;
|
||||
color: #fff;
|
||||
padding: 5px 0;
|
||||
border-radius: 5px;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
.form-role-workshop-section-mobile .workshop .workshop-mobile-footer button.btn-cancel {
|
||||
background-color: #1F2937;
|
||||
}
|
||||
|
||||
.form-role-workshop-section-mobile .workshop .workshop-mobile-footer button.btn-success {
|
||||
background-color: #84CC16;
|
||||
}
|
||||
|
||||
|
||||
.form-role-all-section {
|
||||
grid-column: span 4 / span 4;
|
||||
}
|
||||
|
||||
.workshop {
|
||||
position: relative;
|
||||
background-color: #ffffff;
|
||||
border: 1px solid #D1D1D1;
|
||||
border-radius: 7px;
|
||||
padding: 10px;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.workshop__label {
|
||||
position: absolute;
|
||||
top: -11px;
|
||||
right: 10px;
|
||||
font-size: 12px;
|
||||
color: #797979;
|
||||
text-shadow: -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff;
|
||||
}
|
||||
|
||||
.workshop__item {
|
||||
width: 100%;
|
||||
margin: 0 0 4px 0;
|
||||
}
|
||||
|
||||
.workshop__checkbox {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.workshop__label-text {
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
color: #0F8080;
|
||||
background-color: #ffffff;
|
||||
border: 1px solid #1D9D9D;
|
||||
padding: 6px 9px;
|
||||
border-radius: 9px;
|
||||
width: 100%;
|
||||
transition: all 0.3s ease-in-out;
|
||||
cursor: pointer;
|
||||
-webkit-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
/*.workshop__label-text:hover {
|
||||
color: #ffffff;
|
||||
background-color: #1c7474;
|
||||
border-color: #23A8A8;
|
||||
}*/
|
||||
|
||||
/* Rectangle 4252 */
|
||||
|
||||
/*box-sizing: border-box;
|
||||
|
||||
position: absolute;
|
||||
width: 320px;
|
||||
height: 30px;
|
||||
left: 28px;
|
||||
top: 127px;*/
|
||||
/* linear */
|
||||
/*background: linear-gradient(93.83deg, #2EBEBE 1.59%, #1E9D9D 47.86%, #0B7878 101.16%);
|
||||
border-radius: 7px;*/
|
||||
|
||||
|
||||
.workshop__checkbox:checked + .workshop__label-text {
|
||||
color: #ffffff;
|
||||
background-color: #1D9D9D;
|
||||
}
|
||||
|
||||
.workshop-mobile-btn {
|
||||
width: 100%;
|
||||
color: #ffffff;
|
||||
background: linear-gradient(93.83deg, #2EBEBE 1.59%, #1E9D9D 47.86%, #0B7878 101.16%);
|
||||
font-size: 14px;
|
||||
padding: 6px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.workshop-mobile-btn__badge-number {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
background: #fff;
|
||||
border-radius: 4px;
|
||||
color: #158c8c;
|
||||
}
|
||||
/************************ checkbox Button Input () ************************/
|
||||
.form-check-input[type="checkbox"] {
|
||||
width: 15px;
|
||||
@@ -100,7 +288,7 @@
|
||||
}
|
||||
|
||||
.permissionBox {
|
||||
margin: 10px 0 0 0;
|
||||
/*margin: 10px 0 0 0;*/
|
||||
border: 1px solid #D1D1D1;
|
||||
background-color: #FAFAFA;
|
||||
border-radius: 7px;
|
||||
@@ -179,8 +367,23 @@
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
@media (max-width:1366px) {
|
||||
@media (max-width: 1366px) {
|
||||
#tree {
|
||||
height: 360px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.modal-dialog {
|
||||
max-width: 530px;
|
||||
}
|
||||
|
||||
.form-role-workshop-section {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.form-role-all-section {
|
||||
grid-column: span 6 / span 6;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
$(document).ready(function () {
|
||||
ajaxPermissionsList();
|
||||
ajaxWorkshops();
|
||||
|
||||
$('#search-input').on('keyup', function () {
|
||||
var searchText = $(this).val().toLowerCase();
|
||||
@@ -203,6 +204,77 @@ function ajaxPermissionsList() {
|
||||
});
|
||||
}
|
||||
|
||||
function ajaxWorkshops() {
|
||||
var html = '';
|
||||
$.ajax({
|
||||
url: workshopListAjax,
|
||||
type: 'GET',
|
||||
success: function (response) {
|
||||
if (response.success) {
|
||||
var items = response.data;
|
||||
items.forEach(function (item) {
|
||||
html += `<div class="workshop__item">
|
||||
<input type="checkbox" id="workshop_${item.id}" name="WorkshopIds[]" class="workshop__checkbox">
|
||||
<label for="workshop_${item.id}" value="${item.id}" class="workshop__label-text workshop__label-text--outlined">${item.name}</label>
|
||||
</div>`;
|
||||
});
|
||||
$('#workshopItems').html(html);
|
||||
} else {
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text(response.message);
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
}, 3500);
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function showModalWorkshop() {
|
||||
$('.form-role-workshop-section').addClass('form-role-workshop-section-mobile');
|
||||
$('body').css('overflow', 'hidden');
|
||||
}
|
||||
|
||||
function hideModalWorkshop() {
|
||||
$('.form-role-workshop-section').removeClass('form-role-workshop-section-mobile');
|
||||
$('body').css('overflow', 'auto');
|
||||
}
|
||||
|
||||
function chooseWorkshops() {
|
||||
|
||||
const checkedWorkshops = $('input[name="WorkshopIds[]"]:checked');
|
||||
|
||||
if (checkedWorkshops.length === 0) {
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا کارگاه مورد نظر را انتخاب کنید');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
countSelectWorkshops();
|
||||
hideModalWorkshop();
|
||||
}
|
||||
|
||||
function countSelectWorkshops() {
|
||||
|
||||
const checkedWorkshops = $('input[name="WorkshopIds[]"]:checked');
|
||||
|
||||
if (checkedWorkshops.length === 0) {
|
||||
$('.workshop-mobile-btn__badge-number').hide().text(checkedWorkshops.length);
|
||||
} else {
|
||||
$('.workshop-mobile-btn__badge-number').show().text(checkedWorkshops.length);
|
||||
}
|
||||
|
||||
hideModalWorkshop();
|
||||
}
|
||||
|
||||
$('#createData').on('click', SaveDataAjax);
|
||||
function SaveDataAjax() {
|
||||
var loading = $('#createData .spinner-loading');
|
||||
@@ -219,6 +291,24 @@ function SaveDataAjax() {
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
var workshops = [];
|
||||
const checkedWorkshops = $('input[name="WorkshopIds[]"]:checked');
|
||||
checkedWorkshops.each(function () {
|
||||
if (this.checked || this.indeterminate) {
|
||||
const number = Number(this.id.split("_")[1]);
|
||||
workshops.push(number);
|
||||
}
|
||||
});
|
||||
|
||||
if (checkedWorkshops.length === 0) {
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا کارگاه مورد نظر را انتخاب کنید');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
var selectedPermissions = [];
|
||||
$('input[name="Permissions"]').each(function () {
|
||||
@@ -241,9 +331,9 @@ function SaveDataAjax() {
|
||||
|
||||
var data = {
|
||||
Title: Title.val(),
|
||||
Permissions: selectedPermissions
|
||||
Permissions: selectedPermissions,
|
||||
WorkshopIds: workshops
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
async: false,
|
||||
dataType: 'json',
|
||||
|
||||
@@ -258,7 +258,7 @@ function SaveDataAjax() {
|
||||
var loading = $('#createData .spinner-loading');
|
||||
|
||||
|
||||
var workshopSelect = $('#workshopSelect').val();
|
||||
/* var workshopSelect = $('#workshopSelect').val();*/
|
||||
var roleSelect = $('#roleSelect').val();
|
||||
var nationalCode = $('#NationalCode');
|
||||
var fName = $('#FName');
|
||||
@@ -268,17 +268,17 @@ function SaveDataAjax() {
|
||||
var password = $('#Password');
|
||||
|
||||
|
||||
if (workshopSelect.length === 0) {
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا کارگاه را مشخص نمائید.');
|
||||
$('.select-workshop-alert').addClass('errored');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
$('.select-workshop-alert').removeClass('errored');
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
//if (workshopSelect.length === 0) {
|
||||
// $('.alert-msg').show();
|
||||
// $('.alert-msg p').text('لطفا کارگاه را مشخص نمائید.');
|
||||
// $('.select-workshop-alert').addClass('errored');
|
||||
// setTimeout(function () {
|
||||
// $('.alert-msg').hide();
|
||||
// $('.alert-msg p').text('');
|
||||
// $('.select-workshop-alert').removeClass('errored');
|
||||
// }, 3500);
|
||||
// return;
|
||||
//}
|
||||
|
||||
if (roleSelect === "0") {
|
||||
$('.alert-msg').show();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
$(document).ready(function () {
|
||||
ajaxPermissionsList();
|
||||
|
||||
ajaxWorkshops();
|
||||
$('#search-input').on('keyup', function () {
|
||||
var searchText = $(this).val().toLowerCase();
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
$(document).on('click', '.togglePermission > span', function () {
|
||||
$(this).siblings('ul').toggle();
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -227,6 +228,7 @@ function updateParentCheckbox(childCheckbox) {
|
||||
let childCheckboxes = parentLi.find('ul .node-checkbox');
|
||||
let checkedChildren = childCheckboxes.filter(':checked');
|
||||
|
||||
|
||||
let allChecked = childCheckboxes.length === checkedChildren.length;
|
||||
let anyChecked = checkedChildren.length > 0;
|
||||
|
||||
@@ -237,6 +239,81 @@ function updateParentCheckbox(childCheckbox) {
|
||||
}
|
||||
}
|
||||
|
||||
function ajaxWorkshops() {
|
||||
var html = '';
|
||||
|
||||
$.ajax({
|
||||
url: workshopListAjax,
|
||||
type: 'GET',
|
||||
success: function (response) {
|
||||
if (response.success) {
|
||||
var items = response.data;
|
||||
items.forEach(function (item) {
|
||||
var isChecked = selctedWorkshopslist.includes(Number(item.id)) ? 'checked' : '';
|
||||
console.log(typeof item.id)
|
||||
html += `<div class="workshop__item">
|
||||
<input type="checkbox" id="workshop_${item.id}" data-id="${item.id}" name="WorkshopIds[]" class="workshop__checkbox" ${isChecked}>
|
||||
<label for="workshop_${item.id}" value="${item.id}" class="workshop__label-text workshop__label-text--outlined">${item.name}</label>
|
||||
</div>`;
|
||||
});
|
||||
$('#workshopItems').html(html);
|
||||
} else {
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text(response.message);
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
}, 3500);
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function showModalWorkshop() {
|
||||
$('.form-role-workshop-section').addClass('form-role-workshop-section-mobile');
|
||||
$('body').css('overflow', 'hidden');
|
||||
|
||||
}
|
||||
|
||||
function hideModalWorkshop() {
|
||||
$('.form-role-workshop-section').removeClass('form-role-workshop-section-mobile');
|
||||
$('body').css('overflow', 'auto');
|
||||
}
|
||||
|
||||
function chooseWorkshops() {
|
||||
|
||||
const checkedWorkshops = $('input[name="WorkshopIds[]"]:checked');
|
||||
|
||||
if (checkedWorkshops.length === 0) {
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا کارگاه مورد نظر را انتخاب کنید');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
countSelectWorkshops();
|
||||
hideModalWorkshop();
|
||||
}
|
||||
|
||||
function countSelectWorkshops() {
|
||||
|
||||
const checkedWorkshops = $('input[name="WorkshopIds[]"]:checked');
|
||||
|
||||
if (checkedWorkshops.length === 0) {
|
||||
$('.workshop-mobile-btn__badge-number').hide().text(checkedWorkshops.length);
|
||||
} else {
|
||||
$('.workshop-mobile-btn__badge-number').show().text(checkedWorkshops.length);
|
||||
}
|
||||
|
||||
hideModalWorkshop();
|
||||
}
|
||||
|
||||
$('#createData').on('click', SaveDataAjax);
|
||||
function SaveDataAjax() {
|
||||
var loading = $('#createData .spinner-loading');
|
||||
@@ -257,6 +334,18 @@ function SaveDataAjax() {
|
||||
return;
|
||||
}
|
||||
|
||||
const checkedWorkshops = $('input[name="WorkshopIds[]"]:checked');
|
||||
|
||||
if (checkedWorkshops.length === 0) {
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا کارگاه مورد نظر را انتخاب کنید');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
var selectedPermissions = [];
|
||||
$('input[name="Permissions"]').each(function () {
|
||||
if (this.checked || this.indeterminate) {
|
||||
@@ -264,6 +353,12 @@ function SaveDataAjax() {
|
||||
}
|
||||
});
|
||||
|
||||
var selectedWorkshopIds = [];
|
||||
|
||||
document.querySelectorAll('input[name="WorkshopIds[]"]:checked').forEach(function (input) {
|
||||
selectedWorkshopIds.push(input.getAttribute('data-id'));
|
||||
});
|
||||
|
||||
if (selectedPermissions.length === 0) {
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا دسترسیها را انتخاب نمائید');
|
||||
@@ -279,7 +374,8 @@ function SaveDataAjax() {
|
||||
var data = {
|
||||
Id: Id.val(),
|
||||
Title: Title.val(),
|
||||
Permissions: selectedPermissions
|
||||
Permissions: selectedPermissions,
|
||||
WorkshopIds: selectedWorkshopIds
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
|
||||
@@ -28,7 +28,7 @@ $(".select2OptionRole").select2({
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
ajaxWorkshops();
|
||||
//ajaxWorkshops();
|
||||
ajaxRoles();
|
||||
});
|
||||
|
||||
@@ -150,7 +150,7 @@ function SaveDataAjax() {
|
||||
var loading = $('#createData .spinner-loading');
|
||||
|
||||
|
||||
var workshopSelect = $('#workshopSelect').val();
|
||||
/* var workshopSelect = $('#workshopSelect').val();*/
|
||||
var roleSelect = $('#roleSelect').val();
|
||||
var nationalCode = $('#NationalCode');
|
||||
var fName = $('#FName');
|
||||
@@ -159,17 +159,17 @@ function SaveDataAjax() {
|
||||
var username = $('#Username');
|
||||
var password = $('#Password');
|
||||
|
||||
if (workshopSelect.length === 0) {
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا کارگاه را مشخص نمائید.');
|
||||
$('.select-workshop-alert').addClass('errored');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
$('.select-workshop-alert').removeClass('errored');
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
//if (workshopSelect.length === 0) {
|
||||
// $('.alert-msg').show();
|
||||
// $('.alert-msg p').text('لطفا کارگاه را مشخص نمائید.');
|
||||
// $('.select-workshop-alert').addClass('errored');
|
||||
// setTimeout(function () {
|
||||
// $('.alert-msg').hide();
|
||||
// $('.alert-msg p').text('');
|
||||
// $('.select-workshop-alert').removeClass('errored');
|
||||
// }, 3500);
|
||||
// return;
|
||||
//}
|
||||
|
||||
if (roleSelect === '0') {
|
||||
$('.alert-msg').show();
|
||||
|
||||
Reference in New Issue
Block a user