right-side-bar-component.blade.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. {{-- Todo: member-right-sidebar 새탭에 메뉴열기 수정하기 --}}
  2. <!-- Sidebar content -->
  3. <div class="sidebar-section sidebar-user my-0 d-flex align-items-center justify-content-center p-1" id="right-side-bar">
  4. <button class="btn btn-danger w-100 mr-1" id="manual-btn" onclick="show_manual_modal(this)">{{ $form['FormVars']['Title']['SelfManual'] }}</button>
  5. <button class="btn btn-primary w-100 mr-1" onclick="shortcut_in_or_out(1)">{{ $form['FormVars']['Title']['ShortcutIn'] }}</button>
  6. <button class="btn btn-primary w-100" onclick="shortcut_in_or_out(0)">{{ $form['FormVars']['Title']['ShortcutOut'] }}</button>
  7. <button type="button" class="tab-close position-absolute top-0 right-0 color-danger" onclick="close_right_sidebar()">
  8. <i class="fas fa-times fa-xs"></i>
  9. </button>
  10. {{-- <button class="btn btn-primary"><i class="fas fa-sign-in-alt"></i> {{ $form['FormVars']['Title']['ShortcutIn'] }}</button>
  11. <button class="btn btn-primary"><i class="fas fa-sign-out-alt"></i> {{ $form['FormVars']['Title']['ShortcutOut'] }}</button> --}}
  12. </div>
  13. <div class="ml-3 my-1">
  14. <input type="checkbox" value="1" class="text-center" id="open-right-menu-new-tab-check"> <label class="mb-0" for="open-right-menu-new-tab-check">{{ $form['FormVars']['Title']['OpenMenuNewTab'] }}</label>
  15. </div>
  16. <ul class="sidebar-section nav-right-sidebar nav nav-sidebar">
  17. </ul>
  18. <!-- /sidebar content -->
  19. @once
  20. @push('js')
  21. <script>
  22. $(document).ready(async function() {
  23. nav_right_sidebar_init();
  24. // 오른쪽 메뉴클릭 이벤트
  25. $('.nav-right-sidebar a').on('click', function (e) {
  26. if ($(this).attr('href') && ! $(this).closest('li').hasClass('nav-item-submenu')
  27. && $('#right-sidebar-head-box').find('#open-right-menu-new-tab-check').prop('checked')) {
  28. e.preventDefault();
  29. window.open($(this).attr('href'), '_blank');
  30. }
  31. });
  32. $(document).on('hide.bs.modal','#modal-manual', function () {
  33. $('#right-side-bar').find('#manual-btn').prop('disabled', false);
  34. });
  35. });
  36. async function show_manual_modal($this) {
  37. $($this).prop('disabled', true)
  38. const para_name = currentBpa['para_name'];
  39. const para_path = `/etc/self-manual${para_name}`;
  40. const response = await get_para_data('manual', para_path, getParameterByName('bpa'))
  41. if (! isEmpty(response.data.apiStatus)) {
  42. $($this).prop('disabled', false)
  43. return iziToast.error({ title: 'Error', message: response.data.body })
  44. }
  45. get_blades_html('front.outline.static.manual', response['data'], function (html) {
  46. if (! $('#element_in_which_to_insert').find('#modal-manual').length) {
  47. $('#element_in_which_to_insert').append(html);
  48. }
  49. $('#modal-manual').find('#myModalLabel').text(`${currentBpa['menu_name']} 매뉴얼`)
  50. $('#modal-manual').modal('show')
  51. }, 'manual');
  52. // $($this).prop('disabled', false);
  53. }
  54. function close_right_sidebar() {
  55. $('.sidebar-right').addClass('sidebar-collapsed')
  56. $('.sidebar-right').removeClass('sidebar-mobile-expanded')
  57. }
  58. function nav_right_sidebar_init() {
  59. let html = '';
  60. const my_menu = menuPage.filter(menu => menu.IsMymenu == '1')
  61. my_menu.forEach(menu => {
  62. html +=
  63. `<li class="nav-item list-unstyled ml-0 text-left">
  64. <a href="${menu.PageUri}?bpa=${menu.bpa}" target="${menu.IsNewtab == 1 ? '_blank' : '_self'}"
  65. class="nav-link d-block ${menu.MenuCode == menuCode ? 'active text-orange' : 'text-orange'}"><i class="${menu.Icon} mr-2" style="width: 10px;"></i>
  66. ${menu.MenuName}
  67. </a>
  68. </li>`;
  69. });
  70. $('.nav-right-sidebar').html(html);
  71. }
  72. async function shortcut_in_or_out(is_mymenu) {
  73. let user_menu_id = menuPage.filter(menu => menu.MenuCode == menuCode)[0]['UserMenuId']
  74. console.log(user_menu_id)
  75. let response = await get_api_data('is-mymenu-set', {
  76. TableCode: 'users',
  77. MenuId: user_menu_id,
  78. IsMymenu: String(is_mymenu),
  79. })
  80. if (response.status == 200) {
  81. menuPage.map(menu => {
  82. if (menu.MenuCode == menuCode) {
  83. menu.IsMymenu = is_mymenu;
  84. }
  85. return menu;
  86. })
  87. nav_right_sidebar_init();
  88. $.ajax({
  89. url: "/clear-menu-cache",
  90. type:'POST',
  91. data: {
  92. _token:"{{ csrf_token() }}",
  93. },
  94. cache: false,
  95. success: function(response) {
  96. }
  97. });
  98. }
  99. }
  100. const menuPage = {!! json_encode($menuPage) !!};
  101. const currentBpa = {!! json_encode($currentBpa) !!};
  102. </script>
  103. @endpush
  104. @endonce