Reservations with url update
This commit is contained in:
@ -3,6 +3,7 @@
|
|||||||
use Incoviba\Controller\Ventas\Reservations as Cierres;
|
use Incoviba\Controller\Ventas\Reservations as Cierres;
|
||||||
|
|
||||||
$app->group('/cierres', function($app) {
|
$app->group('/cierres', function($app) {
|
||||||
|
$app->get('/project/{project_id}', Cierres::class);
|
||||||
$app->get('[/]', Cierres::class);
|
$app->get('[/]', Cierres::class);
|
||||||
});
|
});
|
||||||
$app->group('/cierre/{cierre_id}', function($app) {
|
$app->group('/cierre/{cierre_id}', function($app) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
@extends('layout.base')
|
@extends('layout.base')
|
||||||
|
|
||||||
@section('page_title')
|
@section('page_title')
|
||||||
Cierres -Reservas
|
Cierres - Reservas
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@section('page_content')
|
@section('page_content')
|
||||||
@ -143,6 +143,7 @@
|
|||||||
|
|
||||||
const project_id = event.currentTarget.dataset.id
|
const project_id = event.currentTarget.dataset.id
|
||||||
reservations.show.results()
|
reservations.show.results()
|
||||||
|
reservations.update.url(project_id)
|
||||||
|
|
||||||
if (project_id === this.current_project) {
|
if (project_id === this.current_project) {
|
||||||
this.hide()
|
this.hide()
|
||||||
@ -167,6 +168,10 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
load(project_id) {
|
||||||
|
this.component.querySelector(`.item.link[data-id="${project_id}"]`).click()
|
||||||
|
}
|
||||||
|
|
||||||
show() {
|
show() {
|
||||||
this.component.style.display = this.display.projects
|
this.component.style.display = this.display.projects
|
||||||
this.title_component.style.display = 'none'
|
this.title_component.style.display = 'none'
|
||||||
@ -462,6 +467,19 @@
|
|||||||
return Promise.any(promises).then(() => {
|
return Promise.any(promises).then(() => {
|
||||||
reservations.loading.hide()
|
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: {
|
loading: {
|
||||||
@ -472,6 +490,11 @@
|
|||||||
reservations.components.loader.style.display = 'none'
|
reservations.components.loader.style.display = 'none'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
update: {
|
||||||
|
url: project_id => {
|
||||||
|
window.history.pushState(null, '', reservations.get.pathname(project_id))
|
||||||
|
}
|
||||||
|
},
|
||||||
action: {
|
action: {
|
||||||
reset: event => {
|
reset: event => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
@ -481,12 +504,14 @@
|
|||||||
reservations.components.reservations[key].hide()
|
reservations.components.reservations[key].hide()
|
||||||
})
|
})
|
||||||
reservations.show.projects()
|
reservations.show.projects()
|
||||||
|
reservations.update.url(null)
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
up: event => {
|
up: event => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
Object.values(reservations.components.reservations).forEach(reservations => reservations.hide())
|
Object.values(reservations.components.reservations).forEach(reservations => reservations.hide())
|
||||||
reservations.show.projects()
|
reservations.show.projects()
|
||||||
|
reservations.update.url(null)
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
add: event => {
|
add: event => {
|
||||||
@ -544,6 +569,11 @@
|
|||||||
this.show.projects()
|
this.show.projects()
|
||||||
|
|
||||||
this.components.modals.add = new AddReservationModal(configuration.ids.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(() => {
|
$(document).ready(() => {
|
||||||
|
@ -13,7 +13,7 @@ class Reservations
|
|||||||
{
|
{
|
||||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response,
|
public function __invoke(ServerRequestInterface $request, ResponseInterface $response,
|
||||||
Service\Proyecto $proyectoService, Repository\Region $regionRepository,
|
Service\Proyecto $proyectoService, Repository\Region $regionRepository,
|
||||||
View $view): ResponseInterface
|
View $view, ?int $project_id = null): ResponseInterface
|
||||||
{
|
{
|
||||||
$projects = [];
|
$projects = [];
|
||||||
try {
|
try {
|
||||||
@ -23,6 +23,6 @@ class Reservations
|
|||||||
try {
|
try {
|
||||||
$regions = $regionRepository->fetchAll();
|
$regions = $regionRepository->fetchAll();
|
||||||
} catch (EmptyResult) {}
|
} catch (EmptyResult) {}
|
||||||
return $view->render($response, 'ventas.reservations', compact('projects', 'regions'));
|
return $view->render($response, 'ventas.reservations', compact('projects', 'regions', 'project_id'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user