Verified Commit 29763eaa authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #956186 by catch, dpolant, SteffenR, yhahn, lauriii, nod_, sokrplare,...

Issue #956186 by catch, dpolant, SteffenR, yhahn, lauriii, nod_, sokrplare, rwaery.11, Supreetam09, effulgentsia, geek-merlin: Allow AJAX to use GET requests
parent d4b59398
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -132,7 +132,7 @@ public function processAttachments(AttachmentsInterface $response) {
   *   An array of commands ready to be returned as JSON.
   */
  protected function buildAttachmentsCommands(AjaxResponse $response, Request $request) {
    $ajax_page_state = $request->request->all('ajax_page_state');
    $ajax_page_state = $request->get('ajax_page_state');

    // Aggregate CSS/JS if necessary, but only during normal site operation.
    $optimize_css = !defined('MAINTENANCE_MODE') && $this->config->get('css.preprocess');
+2 −0
Original line number Diff line number Diff line
@@ -244,6 +244,7 @@ public static function processAjaxForm(&$element, FormStateInterface $form_state
   *   - #ajax['event']
   *   - #ajax['prevent']
   *   - #ajax['url']
   *   - #ajax['type']
   *   - #ajax['callback']
   *   - #ajax['options']
   *   - #ajax['wrapper']
@@ -340,6 +341,7 @@ public static function preRenderAjaxForm($element) {
      // to be substantially different for a JavaScript triggered submission.
      $settings += [
        'url' => NULL,
        'type' => 'POST',
        'options' => ['query' => []],
        'dialogType' => 'ajax',
      ];
+2 −2
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ public function __construct(CsrfTokenGenerator $token_generator, ConfigFactoryIn
   * {@inheritdoc}
   */
  public function applies(RouteMatchInterface $route_match) {
    $ajax_page_state = $this->requestStack->getCurrentRequest()->request->all('ajax_page_state');
    $ajax_page_state = $this->requestStack->getCurrentRequest()->get('ajax_page_state');
    return !empty($ajax_page_state['theme']) && isset($ajax_page_state['theme_token']);
  }

@@ -73,7 +73,7 @@ public function applies(RouteMatchInterface $route_match) {
   * {@inheritdoc}
   */
  public function determineActiveTheme(RouteMatchInterface $route_match) {
    $ajax_page_state = $this->requestStack->getCurrentRequest()->request->all('ajax_page_state');
    $ajax_page_state = $this->requestStack->getCurrentRequest()->get('ajax_page_state');
    $theme = $ajax_page_state['theme'];
    $token = $ajax_page_state['theme_token'];

+9 −1
Original line number Diff line number Diff line
@@ -325,6 +325,13 @@
        elementSettings.url = href;
        elementSettings.event = 'click';
      }
      const type = $linkElement.data('ajax-type');
      /**
       * In case of setting custom ajax type for link we rewrite ajax.type.
       */
      if (type) {
        elementSettings.type = type;
      }
      Drupal.ajax(elementSettings);
    });
  };
@@ -391,6 +398,7 @@
   */
  Drupal.Ajax = function (base, element, elementSettings) {
    const defaults = {
      type: 'POST',
      event: element ? 'mousedown' : null,
      keypress: true,
      selector: base ? `#${base}` : null,
@@ -591,7 +599,7 @@
      },
      dataType: 'json',
      jsonp: false,
      type: 'POST',
      type: ajax.type,
    };

    if (elementSettings.dialog) {
+2 −2
Original line number Diff line number Diff line
@@ -465,7 +465,7 @@ protected function sendNoJsPlaceholders($html, $no_js_placeholders, AttachedAsse
      // - the HTML to load the CSS can be rendered.
      // - the HTML to load the JS (at the top) can be rendered.
      $fake_request = $this->requestStack->getMainRequest()->duplicate();
      $fake_request->request->set('ajax_page_state', ['libraries' => implode(',', $cumulative_assets->getAlreadyLoadedLibraries())]);
      $fake_request->query->set('ajax_page_state', ['libraries' => implode(',', $cumulative_assets->getAlreadyLoadedLibraries())]);
      try {
        $html_response = $this->filterEmbeddedResponse($fake_request, $html_response);
      }
@@ -575,7 +575,7 @@ protected function sendPlaceholders(array $placeholders, array $placeholder_orde
      // - the attachments associated with the response are finalized, which
      //   allows us to track the total set of asset libraries sent in the
      //   initial HTML response plus all embedded AJAX responses sent so far.
      $fake_request->request->set('ajax_page_state', ['libraries' => implode(',', $cumulative_assets->getAlreadyLoadedLibraries())] + $cumulative_assets->getSettings()['ajaxPageState']);
      $fake_request->query->set('ajax_page_state', ['libraries' => implode(',', $cumulative_assets->getAlreadyLoadedLibraries())] + $cumulative_assets->getSettings()['ajaxPageState']);
      try {
        $ajax_response = $this->filterEmbeddedResponse($fake_request, $ajax_response);
      }
Loading