Reservations with url update
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_title')
|
||||
Cierres -Reservas
|
||||
Cierres - Reservas
|
||||
@endsection
|
||||
|
||||
@section('page_content')
|
||||
@ -143,6 +143,7 @@
|
||||
|
||||
const project_id = event.currentTarget.dataset.id
|
||||
reservations.show.results()
|
||||
reservations.update.url(project_id)
|
||||
|
||||
if (project_id === this.current_project) {
|
||||
this.hide()
|
||||
@ -167,6 +168,10 @@
|
||||
})
|
||||
}
|
||||
|
||||
load(project_id) {
|
||||
this.component.querySelector(`.item.link[data-id="${project_id}"]`).click()
|
||||
}
|
||||
|
||||
show() {
|
||||
this.component.style.display = this.display.projects
|
||||
this.title_component.style.display = 'none'
|
||||
@ -462,6 +467,19 @@
|
||||
return Promise.any(promises).then(() => {
|
||||
reservations.loading.hide()
|
||||
})
|
||||
},
|
||||
pathname: project_id => {
|
||||
const current_url = new URL(window.location.href)
|
||||
if (project_id === null) {
|
||||
if (current_url.pathname.includes('project')) {
|
||||
return current_url.pathname.replace(/\/project\/\d+/, '')
|
||||
}
|
||||
return current_url.pathname
|
||||
}
|
||||
if (current_url.pathname.includes('project')) {
|
||||
return current_url.pathname.replace(/project\/\d+/, `project/${project_id}`)
|
||||
}
|
||||
return `${current_url.pathname}/project/${project_id}`
|
||||
}
|
||||
},
|
||||
loading: {
|
||||
@ -472,6 +490,11 @@
|
||||
reservations.components.loader.style.display = 'none'
|
||||
}
|
||||
},
|
||||
update: {
|
||||
url: project_id => {
|
||||
window.history.pushState(null, '', reservations.get.pathname(project_id))
|
||||
}
|
||||
},
|
||||
action: {
|
||||
reset: event => {
|
||||
event.preventDefault()
|
||||
@ -481,12 +504,14 @@
|
||||
reservations.components.reservations[key].hide()
|
||||
})
|
||||
reservations.show.projects()
|
||||
reservations.update.url(null)
|
||||
return false
|
||||
},
|
||||
up: event => {
|
||||
event.preventDefault()
|
||||
Object.values(reservations.components.reservations).forEach(reservations => reservations.hide())
|
||||
reservations.show.projects()
|
||||
reservations.update.url(null)
|
||||
return false
|
||||
},
|
||||
add: event => {
|
||||
@ -544,6 +569,11 @@
|
||||
this.show.projects()
|
||||
|
||||
this.components.modals.add = new AddReservationModal(configuration.ids.projects)
|
||||
|
||||
const project_id = {{ $project_id ?? 'null' }};
|
||||
if (project_id !== null) {
|
||||
reservations.components.projects.load(project_id)
|
||||
}
|
||||
}
|
||||
}
|
||||
$(document).ready(() => {
|
||||
|
Reference in New Issue
Block a user