Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 1.0.x
  • 2.0.x
  • 1.0.1
  • 1.0.2
  • 1.0.3
  • 2.0.0
  • 2.0.0-beta1
7 results

Target

Select target project
  • project/ajax_command_page_reload
  • issue/ajax_command_page_reload-3286016
  • issue/ajax_command_page_reload-3376232
  • issue/ajax_command_page_reload-3397446
  • issue/ajax_command_page_reload-3428823
  • issue/ajax_command_page_reload-3475849
6 results
Select Git revision
  • 1.0.x
  • 3397446-attach-library-with-command
  • 1.0.1
  • 1.0.2
4 results
Show changes
Commits on Source (3)
################
# GitLabCI template for Drupal projects.
#
# This template is designed to give any Contrib maintainer everything they need to test, without requiring modification.
# It is also designed to keep up to date with Core Development automatically through the use of include files that can be centrally maintained.
# As long as you include the project, ref and three files below, any future updates added by the Drupal Association will be used in your
# pipelines automatically. However, you can modify this template if you have additional needs for your project.
# The full documentation is on https://project.pages.drupalcode.org/gitlab_templates/
################
# For information on alternative values for 'ref' see https://project.pages.drupalcode.org/gitlab_templates/info/templates-version/
# To test a Drupal 7 project, change the first include filename from .main.yml to .main-d7.yml
include:
- project: $_GITLAB_TEMPLATES_REPO
ref: $_GITLAB_TEMPLATES_REF
file:
- "/includes/include.drupalci.main.yml"
- "/includes/include.drupalci.variables.yml"
- "/includes/include.drupalci.workflows.yml"
################
# Pipeline configuration variables are defined with default values and descriptions in the file
# https://git.drupalcode.org/project/gitlab_templates/-/blob/main/includes/include.drupalci.variables.yml
# Uncomment the lines below if you want to override any of the variables. The following is just an example.
################
# variables:
# SKIP_ESLINT: '1'
# OPT_IN_TEST_NEXT_MAJOR: '1'
# _CURL_TEMPLATES_REF: 'main'
#
# Start custom overrides.
# Based on https://git.drupalcode.org/project/keycdn/-/blob/8.x-1.x/.gitlab-ci.yml
#
variables:
OPT_IN_TEST_MAX_PHP: 1
# Broaden test coverage.
OPT_IN_TEST_PREVIOUS_MAJOR: 1
OPT_IN_TEST_PREVIOUS_MINOR: 1
OPT_IN_TEST_NEXT_MINOR: 1
OPT_IN_TEST_NEXT_MAJOR: 1
# Ajax Command Page Reload
## Usage
See [Drupal Core AJAX API](https://www.drupal.org/docs/drupal-apis/ajax-api) for general documentation.
~~~
$response = new AjaxResponse();
$response->addCommand(new PageReloadCommand());
return $response;
~~~
Ajax Command Page Reload
Usage:
Add the library to the page with something like:
`$form['#attached']['library'][] = "ajax_command_page_reload/ajax_commands";`
Then a callback can send the command:
`$response->addCommand(new PageReloadCommand());`
name: 'Ajax Command Page Reload'
type: module
description: 'Reload the current page from JS.'
core_version_requirement: ^8 || ^9 || ^10
core_version_requirement: ^8 || ^9 || ^10 || ^11
{
"name": "ajax_command_page_reload",
"name": "drupal/ajax_command_page_reload",
"type": "drupal-module",
"description": "Reload the current page from JS.",
"keywords": [],
"license": "GPL-2.0-or-later",
"minimum-stability": "dev",
"homepage": "https://www.drupal.org/project/ajax_command_page_reload",
"authors": [
{
"name": "PSF_",
"email": "aaaaa976@gmail.com"
"email": "aaaaa976@gmail.com",
"homepage": "https://www.drupal.org/u/psf_",
"role": "Maintainer"
},
{
"name": "mably",
"homepage": "https://www.drupal.org/u/mably",
"role": "Maintainer"
}
],
"minimum-stability": "dev",
"support": {
"issues": "https://www.drupal.org/project/issues/ajax_command_page_reload",
"source": "http://cgit.drupalcode.org/ajax_command_page_reload"
"source": "https://git.drupalcode.org/project/ajax_command_page_reload"
}
}
......@@ -3,10 +3,12 @@
* Trigger page reloading from Drupal backend.
*/
(function (location) {
'use strict';
Drupal.AjaxCommands.prototype.pageReload = function () {
location.reload();
(() => {
Drupal.AjaxCommands.prototype.pageReload = () => {
// Reload the page without possible form resubmit:
if (window.history.replaceState) {
window.history.replaceState(null, null, window.location.href);
}
window.location = window.location.href;
};
})(window.location);
})();
......@@ -3,11 +3,13 @@
namespace Drupal\ajax_command_page_reload\Ajax;
use Drupal\Core\Ajax\CommandInterface;
use Drupal\Core\Ajax\CommandWithAttachedAssetsInterface;
use Drupal\Core\Asset\AttachedAssets;
/**
* Trigger "window.location.reload()" within the frontend.
*/
class PageReloadCommand implements CommandInterface {
class PageReloadCommand implements CommandInterface, CommandWithAttachedAssetsInterface {
/**
* {@inheritdoc}
......@@ -18,4 +20,13 @@ class PageReloadCommand implements CommandInterface {
];
}
/**
* {@inheritdoc}
*/
public function getAttachedAssets() {
$assets = new AttachedAssets();
$assets->setLibraries(['ajax_command_page_reload/ajax_commands']);
return $assets;
}
}