Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
new-drupal
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
Koinova Angelika
new-drupal
Commits
4c15e99c
Commit
4c15e99c
authored
Jun 20, 2022
by
Koinova Angelika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
edf35a53
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
92 additions
and
65 deletions
+92
-65
composer.json
app/composer.json
+1
-0
composer.lock
app/composer.lock
+72
-1
ajaxform.libraries.yml
app/docroot/modules/custom/ajaxform/ajaxform.libraries.yml
+2
-0
ajaxform.module
app/docroot/modules/custom/ajaxform/ajaxform.module
+13
-6
modal_form.js
app/docroot/modules/custom/ajaxform/js/modal_form.js
+4
-16
AjaxBuySubmit.php
app/docroot/modules/custom/ajaxform/src/AjaxBuySubmit.php
+0
-42
No files found.
app/composer.json
View file @
4c15e99c
...
...
@@ -16,6 +16,7 @@
"drupal/admin_toolbar"
:
"^2.4"
,
"drupal/commerce"
:
"^2.30"
,
"drupal/commerce_cart_api"
:
"^1.5"
,
"drupal/commerce_stock"
:
"^1.0"
,
"drupal/config_ignore"
:
"^2.3"
,
"drupal/core"
:
"^9.1"
,
"drupal/core-composer-scaffold"
:
"^9"
,
...
...
app/composer.lock
View file @
4c15e99c
...
...
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "
d42bf3cbb31a5025595460282d7ca21e
",
"content-hash": "
8c1b0ee6d799c238a8d91a6f63e5569d
",
"packages": [
{
"name": "asm89/stack-cors",
...
...
@@ -2405,6 +2405,77 @@
"source": "https://git.drupalcode.org/project/commerce"
}
},
{
"name": "drupal/commerce_stock",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://git.drupalcode.org/project/commerce_stock.git",
"reference": "8.x-1.0"
},
"dist": {
"type": "zip",
"url": "https://ftp.drupal.org/files/projects/commerce_stock-8.x-1.0.zip",
"reference": "8.x-1.0",
"shasum": "16d267a34122a8c87a567c5eae5619b023288f5f"
},
"require": {
"drupal/commerce": "~2.0",
"drupal/commerce_order": "*",
"drupal/commerce_product": "*",
"drupal/core": "^8 || ^9"
},
"require-dev": {
"drupal/commerce_product": "*",
"drupal/commerce_stock_local": "*"
},
"type": "drupal-module",
"extra": {
"drupal": {
"version": "8.x-1.0",
"datestamp": "1642166789",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
}
}
},
"notification-url": "https://packages.drupal.org/8/downloads",
"license": [
"GPL-2.0+"
],
"authors": [
{
"name": "guy_schneerson",
"homepage": "https://www.drupal.org/user/755184"
},
{
"name": "iAugur",
"homepage": "https://www.drupal.org/user/750068"
},
{
"name": "olafkarsten",
"homepage": "https://www.drupal.org/user/352745"
},
{
"name": "rfay",
"homepage": "https://www.drupal.org/user/30906"
},
{
"name": "rszrama",
"homepage": "https://www.drupal.org/user/49344"
}
],
"description": "Provides a stock management framework based on rules to manage stock levels of commerce products",
"homepage": "https://www.drupal.org/project/commerce_stock",
"keywords": [
"Drupal"
],
"support": {
"source": "http://cgit.drupalcode.org/commerce_stock",
"issues": "http://drupal.org/project/issues/commerce_stock"
}
},
{
"name": "drupal/commerce_store",
"version": "2.30.0",
...
...
app/docroot/modules/custom/ajaxform/ajaxform.libraries.yml
View file @
4c15e99c
...
...
@@ -4,3 +4,5 @@ modal.from.js:
js/modal_form.js
:
{}
dependencies
:
-
core/drupal.dialog.ajax
-
core/jquery
-
core/jquery.once
app/docroot/modules/custom/ajaxform/ajaxform.module
View file @
4c15e99c
...
...
@@ -7,26 +7,33 @@
use
Drupal\Component\Utility\Html
;
use
Drupal\Core\Ajax\AjaxResponse
;
use
Drupal\Core\Ajax\AlertCommand
;
use
Drupal\Core\Ajax\InvokeCommand
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\ajaxform\AjaxBuySubmit
;
function
ajaxform_form_alter
(
&
$form
,
\Drupal\Core\Form\FormStateInterface
$form_state
,
$form_id
)
{
//$id = $form['#wrapper_id'];
$build_ifo
=
$form_state
->
getBuildInfo
();
$id
=
$build_ifo
[
'base_form_id'
];
if
(
!
empty
(
$id
)){
if
(
$id
==
'commerce_order_item_add_to_cart_form'
)
{
$form
[
'actions'
][
'submit'
][
'#ajax'
]
=
[
'callback'
=>
'Drupal\ajaxform\AjaxBuySubmit::ajaxSubmitCallback'
,
// 'callback' => 'your_module_ajax_callback',
'callback'
=>
'ajaxSubmitCallback'
,
'event'
=>
'click'
,
'progress'
=>
[
'type'
=>
'throbber'
,
],
];
$form
[
'#attached'
][
'library'
][]
=
'ajaxform/modal.from.js'
;
}
}
}
function
ajaxSubmitCallback
(
array
&
$form
,
FormStateInterface
$form_state
)
{
$ajax_response
=
new
AjaxResponse
();
$ajax_response
->
addCommand
(
new
InvokeCommand
(
NULL
,
'myTest'
,
[
'some Var'
]));
return
$ajax_response
;
}
app/docroot/modules/custom/ajaxform/js/modal_form.js
View file @
4c15e99c
(
function
(
$
,
Drupal
,
drupalSettings
)
{
'use strict'
;
Drupal
.
behaviors
.
ajaxform_modal_form_js
=
{
attach
:
function
(
context
,
settings
)
{
$
(
'.button--add-to-cart'
,
context
).
click
(
function
()
{
// 1. Создаём новый XMLHttpRequest-объект
(
function
(
$
)
{
$
.
fn
.
myTest
=
function
(
data
)
{
let
xhr
=
new
XMLHttpRequest
();
// 2. Настраиваем его: GET-запрос по URL
...
...
@@ -50,10 +43,5 @@
});
frontpageModal
.
showModal
();
};
});
}
}
}
(
jQuery
,
Drupal
,
drupalSettings
));
};
})(
jQuery
);
app/docroot/modules/custom/ajaxform/src/AjaxBuySubmit.php
deleted
100644 → 0
View file @
edf35a53
<?php
/**
* @file
* Contains \Drupal\ajaxform\AjaxBuySubmit
*/
namespace
Drupal\ajaxform
;
use
Drupal\Component\Utility\Html
;
use
Drupal\Core\Ajax\AjaxResponse
;
use
Drupal\Core\Ajax\AlertCommand
;
use
Drupal\Core\Ajax\HtmlCommand
;
use
Drupal\Core\Form\FormStateInterface
;
/**
* Class AjaxContactSubmit
* @package Drupal\ajaxform\AjaxBuySubmit
*/
class
AjaxBuySubmit
{
/**
* Ajax form submit callback.
*
* @param array $form
* @param \Drupal\Core\Form\FormStateInterface $form_state
*/
public
function
ajaxSubmitCallback
(
array
&
$form
,
FormStateInterface
$form_state
)
{
// $ajax_response = new AjaxResponse();
// $ajax_response->addCommand(new AlertCommand('Спасибо за заполнение'));
// return $ajax_response;
return
[
'#attached'
=>
[
'library'
=>
[
'ajaxform/modal.from.js'
,
],
],
];
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment