diff --git a/resources/assets/js/mixins/global.js b/resources/assets/js/mixins/global.js index fc66494b7..192e7ef9e 100644 --- a/resources/assets/js/mixins/global.js +++ b/resources/assets/js/mixins/global.js @@ -258,8 +258,34 @@ export default { } } //swiper slider for long tabs items + + const slider = document.getElementById('dashboard-slider'); + const scrollLeft = document.getElementById('dashboard-left'); + const scrollRight = document.getElementById('dashboard-right'); + + scrollLeft.addEventListener('click', () => scrollToItem('left')); + scrollRight.addEventListener('click', () => scrollToItem('right')); + + function scrollToItem(direction) { + const visibleItems = Array.from(slider.children); + const sliderRect = slider.getBoundingClientRect(); + + const currentIndex = visibleItems.findIndex(item => { + const itemRect = item.getBoundingClientRect(); + return itemRect.left >= sliderRect.left && itemRect.right <= sliderRect.right; + }); + + const nextIndex = direction === 'right' ? currentIndex + 1 : currentIndex - 1; + if (nextIndex >= 0 && nextIndex < visibleItems.length) { + const nextItem = visibleItems[nextIndex]; + slider.scrollBy({ left: nextItem.getBoundingClientRect().left - sliderRect.left, behavior: 'smooth' }); + } + } + // Dashboard slider }, + + methods: { // Check Default set notify > store / update action checkNotify: function () { diff --git a/resources/views/common/dashboards/show.blade.php b/resources/views/common/dashboards/show.blade.php index 81f5c1023..235e84fad 100644 --- a/resources/views/common/dashboards/show.blade.php +++ b/resources/views/common/dashboards/show.blade.php @@ -106,31 +106,29 @@ @endsection -
-
- - - @foreach ($user_dashboards as $user_dashboard) - - @endforeach - - - - +
+
+ + +
+ @foreach ($user_dashboards as $user_dashboard) + + @endforeach +
+ +
-
+
@can('create-common-widgets') + {{ trans('general.title.new', ['type' => trans_choice('general.dashboards', 1)]) }} @endcan @@ -160,4 +158,4 @@ - + \ No newline at end of file