| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- @using GreenTree.Nachtragsmanagement.Web.Models.Global;
- @{
- Layout = "~/Views/Shared/_FunctionLayout.cshtml";
- }
- @model IEnumerable<GreenTree.Nachtragsmanagement.Web.Models.Admin.User.RoleDataModel>
- <script>
- var deleteId;
- var deleteReplaceId = -1;
- function editRole(id) {
- if (!id) return;
- $.ajax({
- url: '@Url.Action("EditRole", "Admin")',
- data: { id: id },
- success: function (response) {
- setTimeout(function () {
- $(".roleEditContainer").remove();
- $("body").append(response);
- }, 200);
- },
- error: function () {
- alert("error occured");
- }
- });
- }
- function confirmDelete(id) {
- if (!id) return;
- deleteId = id;
- $.ajax({
- type: "GET",
- url: '@Url.Action("GetRole", "Admin")',
- data: { id: deleteId },
- success: function (response) {
- if (response == "notFound") return;
- var role = JSON.parse(response);
- $(".deleteValidation").hide();
- var comboBox = MVCxClientComboBox.Cast(devComboBoxRoleDeleteReplaceRole);
- comboBox.PerformCallback();
- var popupControl = MVCxClientPopupControl.Cast(devPopupControlDeleteRole);
- popupControl.SetHeaderText(popupControl.GetHeaderText().replace("{role}", role.Description));
- $(".dialogText").text($(".dialogText").text().replace("{role}", role.Description));
- popupControl.Show();
- }
- });
- }
- function deleteRole() {
- if (devRadioButtonDeleteReplaceRole.GetChecked()) {
- deleteReplaceId = devComboBoxRoleDeleteReplaceRole.GetValue();
- } else {
- deleteReplaceId = -1;
- }
- if (deleteReplaceId == 0) {
- $(".deleteValidation").text("Es muss ein Ersatz ausgewählt werden.");
- $(".deleteValidation").show();
- return;
- }
- if (deleteId == deleteReplaceId) {
- $(".deleteValidation").text("Der Ersatz darf nicht gleich dem zu löschenden Element sein.");
- $(".deleteValidation").show();
- return;
- }
- $.ajax({
- type: "POST",
- url: '@Url.Action("DeleteRole", "Admin")',
- data: { id: deleteId, replaceId: deleteReplaceId },
- success: function (response) {
- var popupControl = MVCxClientPopupControl.Cast(devPopupControlDeleteRole);
- popupControl.Hide();
- setTimeout(function () {
- devGridViewRole.PerformCallback();
- }, 200);
- },
- error: function () {
- alert("error occured");
- }
- });
- }
- </script>
- @Html.DevExpress().PopupControl(s =>
- {
- s.Name = "devPopupControlDeleteRole";
- s.HeaderText = "\"{role}\" löschen";
- s.Modal = false;
- s.Width = new Unit(350, UnitType.Pixel);
- s.CloseAction = CloseAction.CloseButton;
- s.PopupHorizontalAlign = PopupHorizontalAlign.WindowCenter;
- s.PopupVerticalAlign = PopupVerticalAlign.WindowCenter;
- s.AllowDragging = false;
- s.AllowResize = false;
- s.ShowFooter = false;
- s.SetContent(() =>
- {
- ViewContext.Writer.Write("<div class='dialogText' style='padding: 12px'>");
- ViewContext.Writer.Write("Falls Sie \"{role}\" löschen möchten, was soll mit den Benutzern geschehen, die sich bereits in dieser Rolle befinden?");
- ViewContext.Writer.Write("</div>");
- ViewContext.Writer.Write("<div style='padding: 0 12px 12px 12px'>");
- Html.DevExpress().RadioButton(rb =>
- {
- rb.Name = "devRadioButtonDeleteReplaceRole";
- rb.Text = "Eine neue Rolle zuweisen";
- rb.GroupName = "roleDelete";
- rb.Properties.ClientSideEvents.CheckedChanged =
- "function (s, e) { " +
- "devComboBoxRoleDeleteReplaceRole.SetEnabled(s.GetChecked()); " +
- "}";
- }).Render();
- Session.Add("RolesDeleteComboBoxSettings", new Action<ComboBoxSettings>(a =>
- {
- a.Name = "devComboBoxRoleDeleteReplaceRole";
- a.Width = new Unit(100, UnitType.Percentage);
- a.Properties.ValueType = typeof(int);
- a.Properties.ValueField = "Id";
- a.Properties.TextField = "Description";
- a.Properties.ClientSideEvents.BeginCallback = "function (s, e) { e.customArgs['excludedIds'] = [ deleteId ]; }";
- a.Properties.ClientSideEvents.EndCallback = "function (s, e) { s.SetSelectedIndex(0); }";
- a.SelectedIndex = 0;
- a.ClientEnabled = false;
- a.CallbackRouteValues = new
- {
- Controller = "DataCallback",
- Action = "RolesComboBoxExcluded",
- SettingsKey = "RolesDeleteComboBoxSettings"
- };
- }));
- ViewData.Add("RolesComboBoxSettings", "RolesDeleteComboBoxSettings");
- Html.RenderPartial("~/Views/Shared/DataEditorTemplates/_RolesComboBox.cshtml", EmptyIRequireDataModel.Instance, ViewData);
- Html.DevExpress().RadioButton(rb =>
- {
- rb.Name = "devRadioButtonDeleteRemoveRole";
- rb.Text = "Benutzer aus der Rolle entfernen";
- rb.GroupName = "roleDelete";
- rb.Checked = true;
- rb.Properties.ClientSideEvents.CheckedChanged =
- "function (s, e) { " +
- "devComboBoxRoleDeleteReplaceRole.SetEnabled(!s.GetChecked()); " +
- "}";
- }).Render();
- ViewContext.Writer.Write("<div class=\"deleteValidation\" style=\"display: none\"></div>");
- ViewContext.Writer.Write("</div>");
- Html.RenderPartial(
- "~/Views/Shared/_PopupButtonPanelYesNo.cshtml",
- new YesNoDialogModel
- {
- PopupName = "devPopupControlDeleteRole",
- YesFunction = "function (s, e) { deleteRole(); }"
- }
- );
- });
- s.Styles.Content.Paddings.Padding = new Unit(0, UnitType.Pixel);
- }).GetHtml()
- @Html.Partial("~/Views/Admin/Roles/_RoleGridPartial.cshtml", Model)
|