Skip to content

Commit

Permalink
More context menu fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
V13Axel committed Jul 13, 2024
1 parent 413a8ee commit a7e638c
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 5 deletions.
16 changes: 14 additions & 2 deletions resources/sass/calendar/tooltips.scss
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,23 @@
flex-direction: column;

.context_menu_item {
display: flex;
display: grid;
grid-template-columns: 24px max-content;
align-items: center;
padding: 2px 6px;
padding: 4px 18px 4px 8px;
gap: 4px;
cursor: pointer;

&[disabled] {
background-color: rgba(255, 255, 255, 0.08);
pointer-events: none;
opacity: 55%;
}

& > i {
justify-self: center;
}

&:hover {
background-color: rgba(255, 255, 255, 0.2);
}
Expand Down
4 changes: 2 additions & 2 deletions resources/views/components/context-menu.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
<div
class="context_menu_item"
x-show="shouldBeVisible(item)"
:disabled="shouldDisable(item)"
>
<i :class="item.icon" class="pr-2"></i>
<i :class="item.icon"></i>
<div
x-text="item.name"
@click="item.callback(); deactivate();"
:disabled="shouldDisable(item)"
></div>
</div>
</template>
Expand Down
109 changes: 108 additions & 1 deletion resources/views/layouts/calendar-vertical.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,114 @@
'season_color_enabled': day.season_color,
'preview_day': day.epoch == render_data.preview_epoch && render_data.preview_epoch != render_data.current_epoch,
[day.extra_class]: day.extra_class
}" :epoch="day.epoch">
}" :epoch="day.epoch"
@contextmenu.prevent="$dispatch('context-menu', {
click: $event,
element: $el,
items: [
{
name: 'Set as Current Date',
icon: 'fas fa-hourglass-half',
callback: function() {
var epoch_data = window.evaluated_static_data.epoch_data[day.epoch];
window.dynamic_date_manager.year = convert_year(window.static_data, epoch_data.year);
window.dynamic_date_manager.timespan = epoch_data.timespan_number;
window.dynamic_date_manager.day = epoch_data.day;
window.dynamic_date_manager.epoch = epoch_data.epoch;
window.evaluate_dynamic_change();
},
disabled: function() {
return day.epoch == window.dynamic_data.epoch || !Perms.player_at_least('co-owner');
},
visible: function() {
return Perms.player_at_least('co-owner');
}
},
{
name: 'Set as Preview Date',
icon: 'fas fa-hourglass',
callback: function() {
var epoch_data = window.evaluated_static_data.epoch_data[day.epoch];
window.set_preview_date(epoch_data.year, epoch_data.timespan_number, epoch_data.day, epoch_data.epoch);
},
disabled: function() {
return day.epoch == preview_date.epoch || !window.static_data.settings.allow_view && !Perms.player_at_least('co-owner');
},
visible: function() {
return window.static_data.settings.allow_view || Perms.player_at_least('co-owner');
}
},
{
name: 'Add new event',
icon: 'fas fa-calendar-plus',
callback: function() {
$dispatch('event-editor-modal-new-event', { name: '', epoch: day.epoch });
},
disabled: function() {
return !Perms.player_at_least('player');
},
visible: function() {
return Perms.player_at_least('player');
}
},
{
name: 'Copy link to date',
icon: 'fas fa-link',
callback: function() {
var epoch_data = window.evaluated_static_data.epoch_data[day.epoch];
if (!valid_preview_date(epoch_data.year, epoch_data.timespan_number, epoch_data.day) && !window.hide_copy_warning) {
swal.fire({
title: 'Date inaccessible',
html: `<p>This date is not visible to guests or players, settings such as 'Allow advancing view in calendar' and 'Show only up to current day' can affect this.</p><p>Are you sure you want to copy a link to it?</p>`,
input: 'checkbox',
inputPlaceholder: 'Remember this choice',
inputClass: 'form-control',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes',
icon: 'info'
})
.then((result) => {
if (!result.dismiss) {
window.copy_link(epoch_data);
if (result.value) {
window.hide_copy_warning = true;
}
}
});
} else {
window.copy_link(epoch_data);
}
},
disabled: function() {
return !window.static_data.settings.allow_view && !Perms.player_at_least('co-owner');
},
visible: function() {
return window.static_data.settings.allow_view || Perms.player_at_least('co-owner');
}
},
{
name: 'View events on this date',
icon: 'fas fa-eye',
callback: function() {
console.log(render_data.event_epochs);
let found_events = render_data.event_epochs[day.epoch].events;
$dispatch('event-viewer-modal-view-event', {
event_id: found_events[0].index,
era: found_events[0].era,
epoch: day.epoch
});
}
}
]
})"
>
<div class="day_row text" x-show="day.text" x-text="day.text"></div>
<div class="day_row d-flex justify-content-between">

Expand Down

0 comments on commit a7e638c

Please sign in to comment.