Commit 083a458b authored by Mingsong Hu's avatar Mingsong Hu

Description dialog refactoring

parent 5bf870c3
......@@ -116,10 +116,11 @@
let thisEvent = info.event;
let viewIndex = parseInt(this.el.getAttribute("calendar-view-index"));
let viewSettings = drupalSettings.fullCalendarView[viewIndex];
let des = thisEvent.extendedProps.des;
// Show the event detail in a pop up dialog.
if (viewSettings.dialogWindow) {
let dataDialogOptionsDetails = {};
if (thisEvent.url == '') {
if ( des == '') {
return false;
}
......@@ -130,10 +131,10 @@
let posOffset = dialogIndex * 20;
// Dialog options.
let dialogOptions = JSON.parse(viewSettings.dialog_options);
dialogOptions.left += posOffset;
dialogOptions.top += posOffset;
dialogOptions.left += posOffset + info.jsEvent.clientX;
dialogOptions.top += posOffset + info.jsEvent.clientY;
dialogOptions.title = thisEvent.title.replace(/(<([^>]+)>)/ig,"");
dialogOptions.url = thisEvent.url;
dialogOptions.html = des;
//Create window
dialogs[dialogIndex] = jsFrame.create(dialogOptions);
......
......@@ -107,14 +107,6 @@ class FullcalendarViewPreprocess {
// Custom timezone or user timezone.
$timezone = !empty($start_field_option['settings']['timezone_override']) ?
$start_field_option['settings']['timezone_override'] : date_default_timezone_get();
/* // Calendar entries linked to entity.
$link_to_entity = FALSE;
if (isset($fields[$title_field]->options['settings']['link_to_entity'])) {
$link_to_entity = $fields[$title_field]->options['settings']['link_to_entity'];
}
elseif (isset($fields[$title_field]->options['settings']['link'])) {
$link_to_entity = $fields[$title_field]->options['settings']['link'];
} */
// Set the first day setting.
$first_day = isset($options['firstDay']) ? intval($options['firstDay']) : 0;
// Left side buttons.
......@@ -151,9 +143,9 @@ class FullcalendarViewPreprocess {
$end_dates = empty($end_field) || !$current_entity->hasField($end_field) ? '' :
$current_entity->get($end_field)->getValue();
// Render all other fields to so they can be used in rewrite.
foreach ($fields as $field) {
foreach ($fields as $name => $field) {
if (method_exists($field, 'advancedRender')) {
$field->advancedRender($row);
$des = $field->advancedRender($row);
}
}
// Event title.
......@@ -183,6 +175,7 @@ class FullcalendarViewPreprocess {
'id' => $row->index . "-$i",
'eid' => $entity_id,
'url' => $link_url,
'des' => isset($des) ? $des : ''
];
// Event duration.
if (!empty($duration_field) && !empty($fields[$duration_field])) {
......@@ -334,12 +327,16 @@ class FullcalendarViewPreprocess {
// For reference of JSFrame options see:
// https://github.com/riversun/JSFrame.js/
$dialog_options = [
'left' => 40,
'top' => 60,
'left' => 0,
'top' => 0,
'width' => 640,
'height' => 480,
'movable' => true, //Enable to be moved by mouse
'resizable' => true, //Enable to be resized by mouse
'style' => [
'backgroundColor' => 'rgba(255,255,255,0.9)',
'font-size' => '1rem'
]
];
// Load the fullcalendar js library.
......@@ -349,6 +346,10 @@ class FullcalendarViewPreprocess {
$variables['#attached']['library'][] = 'fullcalendar_view/libraries.jsframe';
}
$variables['view_index'] = $view_index;
// View name.
$variables['view_id'] = $view->storage->id();
// Display name.
$variables['display_id'] = $view->current_display;
// Pass data to js file.
$variables['#attached']['drupalSettings']['fullCalendarView'][$view_index] = [
// Allow client to select language, if it is 1.
......
......@@ -349,8 +349,15 @@ class FullCalendarDisplay extends StylePluginBase {
'#type' => 'checkbox',
'#fieldset' => 'display',
'#default_value' => (empty($this->options['dialogWindow'])) ? 0 : $this->options['dialogWindow'],
'#title' => $this->t('Open event links in dialog window.'),
'#description' => $this->t('If this option is selected and the title field is linked to entity, event links in the calendar will open in a dialog window.'),
'#title' => $this->t('Show event description in dialog window.'),
'#description' => $this->t('If this option is selected, the description (the last field in the fields list) will show in a dialog window once clicking on the event.'),
];
// Open details in new window.
$form['openEntityInNewTab'] = [
'#type' => 'checkbox',
'#fieldset' => 'display',
'#default_value' => !isset($this->options['openEntityInNewTab']) ? 1 : $this->options['openEntityInNewTab'],
'#title' => $this->t('Open entities (calendar items) into new tabs'),
];
// Create new event link.
$form['createEventLink'] = [
......@@ -360,13 +367,6 @@ class FullCalendarDisplay extends StylePluginBase {
'#title' => $this->t('Create a new event via the Off-Canvas dialog.'),
'#description' => $this->t('If this option is selected, there will be an Add Event link below the calendar that provides the ability to create an event In-Place.'),
];
// Open details in new window.
$form['openEntityInNewTab'] = [
'#type' => 'checkbox',
'#fieldset' => 'display',
'#default_value' => !isset($this->options['openEntityInNewTab']) ? 1 : $this->options['openEntityInNewTab'],
'#title' => $this->t('Open entities (calendar items) into new tabs'),
];
// Legend colors.
$form['colors'] = [
'#type' => 'details',
......
......@@ -23,7 +23,7 @@
]
%}
<div{{ attributes.addClass(classes) }}>
<div class="js-drupal-fullcalendar" calendar-view-index="{{ view_index }}"></div>
<div class="js-drupal-fullcalendar" calendar-view-index="{{ view_index }}" calendar-view-name="{{ view_id }}" calendar-display="{{ display_id }}"></div>
<div id="bottom-buttons fc-button-group">
{% if showAddEvent %}
<div class="fullcalendar-bottom-btn add-event-btn">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment