Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makes planning actions sticky #378

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions assets/css/planning.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,18 @@

$tableBoxSize: 40px;

.planning-actions-container-wrapper {
width: 100vw;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line forces the page to always have an horizontal scrollbar event with only one displayed day

background-color: white;
position: sticky;
top: 0;
z-index: 1;
will-change: transform;
}

.planning-actions-container {
margin-bottom: 20px;
padding: 10px;

.btn:hover {
opacity: 0.8;
Expand All @@ -26,6 +36,8 @@ $tableBoxSize: 40px;
.planning {
margin-bottom: 40px;
width: auto;
position: relative;
z-index: 0;

thead {
th {
Expand All @@ -34,7 +46,7 @@ $tableBoxSize: 40px;
position: sticky;
white-space: nowrap;
z-index: 99;
top: 0;
top: 90px;

&[data-day] {
cursor: pointer;
Expand Down Expand Up @@ -75,7 +87,7 @@ $tableBoxSize: 40px;

tr.hours {
th {
top: 30px;
top: 120px;
}
}
}
Expand Down Expand Up @@ -150,6 +162,10 @@ $tableBoxSize: 40px;
}

@media screen and (max-width: 1000px) {
.planning-actions-container-wrapper {
position: static;
}

.planning-actions-container {
.display-more-container {
position: initial;
Expand All @@ -166,6 +182,18 @@ $tableBoxSize: 40px;
th {
position: relative !important;
}

thead {
th {
top: 0;
}

tr.hours {
th {
top: 0;
}
}
}
}
}
}
9 changes: 9 additions & 0 deletions assets/js/planning.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,13 @@ $(document).ready(function () {
// The table is hidden by default for performances reason
$planning.css('display', 'table');
$('#loader').hide();

const actionContainer = document.querySelector('.planning-actions-container-wrapper');
const [planning] = $planning;

if (planning?.clientWidth > window.innerWidth) {
window.addEventListener('scroll', () => {
actionContainer.style.transform = `translate3d(${document.scrollingElement.scrollLeft}px, 0, 0)`;
});
}
});
74 changes: 38 additions & 36 deletions templates/organization/planning/_results.html.twig
Original file line number Diff line number Diff line change
@@ -1,43 +1,45 @@
{% set displayActions = app.user.parent is empty %}
<div class="container planning-actions-container">
<div class="row">
<div class="col-md">
<div class="text-center" id="loader">
<div class="spinner-border" role="status">
<span class="sr-only">{{ 'action.loading' | trans }}</span>
<div class="planning-actions-container-wrapper">
<div class="container planning-actions-container">
<div class="row">
<div class="col-md">
<div class="text-center" id="loader">
<div class="spinner-border" role="status">
<span class="sr-only">{{ 'action.loading' | trans }}</span>
</div>
</div>
<div class="display-more-container form-check">
<input class="form-check-input" type="checkbox" id="display-more">
<label class="form-check-label" for="display-more">
{{ 'action.displayMore' | trans }}
</label>
</div>
</div>
<div class="display-more-container form-check">
<input class="form-check-input" type="checkbox" id="display-more">
<label class="form-check-label" for="display-more">
{{ 'action.displayMore' | trans }}
</label>
</div>
{% if displayActions %}
<div class="col-md">
<button class="btn btn-sm btn-block trigger-update booked" action="book" data-status="booked" data-status-with-comment data-href="{{ path('planning_update', { action: 'book' }) }}">{{ 'organization.asset.markAsBooked' | trans }}</button>
<button class="btn btn-sm btn-block trigger-update available" action="allow" data-status="available" data-href="{{ path('planning_update', { action: 'allow' }) }}">{{ 'organization.asset.markAsAvailable' | trans }}</button>
</div>
<div class="col-md">
<button class="btn btn-sm btn-block trigger-update locked" action="lock" data-status="locked" data-status-with-comment data-href="{{ path('planning_update', { action: 'lock' }) }}">{{ 'organization.asset.markAsLocked' | trans }}</button>
<button class="btn btn-sm btn-block trigger-update unknown" action="delete" data-status="unknown" data-href="{{ path('planning_update', { action: 'delete' }) }}">{{ 'organization.asset.markAsUnavailable' | trans }}</button>
</div>
{% else %}
<div class="col-md">
<ul class="list-unstyled planning-legend-container">
<li><span class="availability-legend unknown"></span> <em>{{ 'organization.asset.unavailable' | trans }}</em></li>
<li><span class="availability-legend available"></span> <em>{{ 'organization.asset.available' | trans }}</em></li>
</ul>
</div>
<div class="col-md">
<ul class="list-unstyled planning-legend-container">
<li><span class="availability-legend booked"></span> <em>{{ 'organization.asset.booked' | trans }}</em></li>
<li><span class="availability-legend engaged"></span> <em>{{ 'organization.asset.engaged' | trans }}</em></li>
<li><span class="availability-legend locked"></span> <em>{{ 'organization.asset.locked' | trans }}</em></li>
</ul>
</div>
{% endif %}
</div>
{% if displayActions %}
<div class="col-md">
<button class="btn btn-sm btn-block trigger-update booked" action="book" data-status="booked" data-status-with-comment data-href="{{ path('planning_update', { action: 'book' }) }}">{{ 'organization.asset.markAsBooked' | trans }}</button>
<button class="btn btn-sm btn-block trigger-update available" action="allow" data-status="available" data-href="{{ path('planning_update', { action: 'allow' }) }}">{{ 'organization.asset.markAsAvailable' | trans }}</button>
</div>
<div class="col-md">
<button class="btn btn-sm btn-block trigger-update locked" action="lock" data-status="locked" data-status-with-comment data-href="{{ path('planning_update', { action: 'lock' }) }}">{{ 'organization.asset.markAsLocked' | trans }}</button>
<button class="btn btn-sm btn-block trigger-update unknown" action="delete" data-status="unknown" data-href="{{ path('planning_update', { action: 'delete' }) }}">{{ 'organization.asset.markAsUnavailable' | trans }}</button>
</div>
{% else %}
<div class="col-md">
<ul class="list-unstyled planning-legend-container">
<li><span class="availability-legend unknown"></span> <em>{{ 'organization.asset.unavailable' | trans }}</em></li>
<li><span class="availability-legend available"></span> <em>{{ 'organization.asset.available' | trans }}</em></li>
</ul>
</div>
<div class="col-md">
<ul class="list-unstyled planning-legend-container">
<li><span class="availability-legend booked"></span> <em>{{ 'organization.asset.booked' | trans }}</em></li>
<li><span class="availability-legend engaged"></span> <em>{{ 'organization.asset.engaged' | trans }}</em></li>
<li><span class="availability-legend locked"></span> <em>{{ 'organization.asset.locked' | trans }}</em></li>
</ul>
</div>
{% endif %}
</div>
</div>

Expand Down