Tenant.cshtml 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. @using Microsoft.AspNetCore.Mvc.Rendering
  2. @using VberAdmin.Web.Models.Input
  3. @using VberAdmin.Web.Models.Modals
  4. @using VberAdmin.Web.Models.Search
  5. @using VberAdmin.Web.Models.Table
  6. @using VberZero
  7. @{
  8. string activeMenu = PermissionNames.VberSystemMgTenantMg; //The menu item will be active for this page.
  9. ViewBag.ActiveMenu = activeMenu;
  10. ViewBag.Title = L("TenantTitle");
  11. string activeType = ViewBag.IsActive;
  12. string[] activeType2 = ViewBag.IsActive2;
  13. var search = new List<VmSearchItem>()
  14. {
  15. new VmSearchItem("tenancyName", L("tenancyName")),
  16. new VmSearchItem("name", L("tenantName")),
  17. new VmSearchItem("isActive", L("activeState"), FType.B, EType.Equal).WithRadio(activeType2),
  18. };
  19. var searchForm = new VmSearch(search);
  20. var table = new VmTable(VzConsts.ApiAppUrl + "Tenant/GetAll", activeMenu, searchForm).AddItems(new List<VmTableItem>()
  21. {
  22. new VmTableItem("tenancyName", L("tenancyName")),
  23. new VmTableItem("name", L("tenantName")),
  24. new VmTableItem("isActive", L("activeState"), "ActiveStateFormatter"),
  25. });
  26. var modalBody = new VmModalBody().AddGroup(new List<VmInputBase>()
  27. {
  28. new VmInputHidden("id"),
  29. new VmInput("tenancyName", L("tenancyName")),
  30. new VmInput("name", L("tenantName")),
  31. new VmInput("adminEmailAddress", L("adminEmailAddress")),
  32. new VmInput("isActive", L("activeState")).WithRadio(activeType2)
  33. },2);
  34. var modal = new VmModal().WithHeaderAndFooter(L("tenant"), "").WithBody(modalBody);
  35. }
  36. @await Html.PartialAsync("_Table", table)
  37. @await Html.PartialAsync("_Modal", modal)
  38. @section scripts
  39. {
  40. <script type="text/javascript">
  41. $(function() {
  42. var $table = $('#table');
  43. var funs = LoadTable();
  44. funs["btnCreate"] = function() {
  45. BtnCreate({
  46. data: { isActive: "true" }
  47. });
  48. };
  49. funs["btnUpdate"] = function() {
  50. var row = $table.VbTable("getSelection");
  51. if (row) {
  52. BtnUpdate({ disabled: "tenancyName,adminEmailAddress", row: row });
  53. }
  54. };
  55. });
  56. </script>
  57. <script>
  58. function ActiveStateFormatter(v) {
  59. var name = $('#hid-activeType option[value="' + v + '"]').text();
  60. if (v) {
  61. return '<span class="label label-success"> ' + name + '</span>';
  62. }
  63. return '<span class="label label-danger"> ' + name + '</span>';
  64. }
  65. </script>
  66. }
  67. <section style="display:none">
  68. <select id="hid-activeType">
  69. @Html.Raw(activeType)
  70. </select>
  71. </section>