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

Plugins Libraries not attached #29

Open
ericchew87 opened this issue Mar 14, 2018 · 0 comments
Open

Plugins Libraries not attached #29

ericchew87 opened this issue Mar 14, 2018 · 0 comments

Comments

@ericchew87
Copy link

Unless I'm doing something wrong, it appears that libraries defined by FullcalendarOption plugins will never be attached. Looking at the FullCalendar ViewStyle plugin, you have this method:

  /**
   * Load libraries.
   */
  protected function prepareAttached() {
    /* @var \Drupal\fullcalendar\Plugin\fullcalendar\type\FullCalendar $plugin */
    $attached['attach']['library'][] = 'fullcalendar/drupal.fullcalendar';

    foreach ($this->getPlugins() as $plugin_id => $plugin) {
      $definition = $plugin->getPluginDefinition();

      foreach (['css', 'js'] as $type) {
        if ($definition[$type]) {
          $attached['attach']['library'][] = 'fullcalendar/drupal.fullcalendar.' . $type;
        }
      }
    }

    if ($this->displayHandler->getOption('use_ajax')) {
      $attached['attach']['library'][] = 'fullcalendar/drupal.fullcalendar.ajax';
    }

    $settings = $this->prepareSettings();

    $attached['attach']['drupalSettings']['fullcalendar'] = [
      '.js-view-dom-id-' . $this->view->dom_id => $settings,
    ];

    if (!empty($settings['fullcalendar']['modalWindow'])) {
      // FIXME all of these libraries are needed?
      $attached['attach']['library'][] = 'core/drupal.ajax';
      $attached['attach']['library'][] = 'core/drupal.dialog';
      $attached['attach']['library'][] = 'core/drupal.dialog.ajax';
    }

    return $attached['attach'];
  }

In the nested foreach...you'll see that the library is hard-coded to always be 'fullcalendar/drupal.fullcalendar.' . $type;. I installed the fork of this project that adds Scheduler support, but it doesnt work because the scheduler library isnt loaded from libraries/fullcalendar-scheduler. This fixes it:

    foreach ($this->getPlugins() as $plugin_id => $plugin) {
      $definition = $plugin->getPluginDefinition();

      foreach (['css', 'js'] as $type) {
        if ($definition[$type]) {
          $attached['attach']['library'][] = $plugin_id.'/drupal.'.$plugin_id.'.' . $type;
        }
      }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant