File tree 3 files changed +61
-25
lines changed
Block/Adminhtml/System/Config/Fieldset
view/adminhtml/web/js/system/action 3 files changed +61
-25
lines changed Original file line number Diff line number Diff line change 14
14
class ApiDetails extends Fieldset
15
15
{
16
16
/**
17
- * Return extra Js
17
+ * Return header html for fieldset
18
18
*
19
19
* @param AbstractElement $element
20
20
* @return string
21
21
*/
22
- protected function _getExtraJs ($ element )
22
+ protected function _getHeaderHtml ($ element )
23
23
{
24
- $ initialScript = parent ::_getExtraJs ($ element );
25
- $ extendedScript = "require(['jquery'], function ($) {
26
- $('#cm_payments_general_api_details_mode').change(function () {
27
- let modeContainerId = $(this).closest('tr').attr('id'),
28
- parentTable = $(this).parents().find('table'),
29
- mode = $(this).val();
30
- parentTable.find('tr').each(function () {
31
- let containerId = $(this).attr('id');
32
- if (containerId !== modeContainerId) {
33
- if (containerId.indexOf('_' + mode + '_') == -1) {
34
- $(this).hide();
35
- } else {
36
- $(this).show();
37
- }
38
- }
39
- });
40
- });
41
-
42
- $('#cm_payments_general_api_details_mode').trigger('change');
43
- }); " ;
44
-
45
- return $ initialScript . $ this ->_jsHelper ->getScript ($ extendedScript );
24
+ return parent ::_getHeaderHtml ($ element ) .
25
+ '<div class="api-details-extra" ' .
26
+ 'data-mage-init= \'{"CM_Payments/js/system/action/api-details-config": ' .
27
+ '{"modeContainerSelector": "#cm_payments_general_api_details_mode"}} \'></div> ' ;
46
28
}
47
29
}
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Copyright © CM.com. All rights reserved.
3
+ * See LICENSE.txt for license details.
4
+ */
5
+ define ( [
6
+ 'uiComponent' ,
7
+ 'jquery'
8
+ ] , function (
9
+ Component ,
10
+ $
11
+ ) {
12
+ 'use strict' ;
13
+
14
+ return Component . extend ( {
15
+ modeContainerSelector : null ,
16
+
17
+ /**
18
+ * Initialization of component
19
+ *
20
+ * @returns {Object }
21
+ */
22
+ initialize : function ( ) {
23
+ this . _super ( ) ;
24
+ $ ( this . modeContainerSelector ) . change ( this . changeApiDetailsMode ) ;
25
+ $ ( this . modeContainerSelector ) . trigger ( 'change' ) ;
26
+
27
+ return this ;
28
+ } ,
29
+
30
+ /**
31
+ * Changing of API Details Mode
32
+ */
33
+ changeApiDetailsMode : function ( ) {
34
+ let modeContainerId = $ ( this ) . closest ( 'tr' ) . attr ( 'id' ) ,
35
+ parentTable = $ ( this ) . parents ( ) . find ( 'table' ) ,
36
+ mode = $ ( this ) . val ( ) ;
37
+ parentTable . find ( 'tr' ) . each ( function ( ) {
38
+ let containerId = $ ( this ) . attr ( 'id' ) ;
39
+ if ( containerId !== modeContainerId ) {
40
+ if ( containerId . indexOf ( '_' + mode + '_' ) == - 1 ) {
41
+ $ ( this ) . hide ( ) ;
42
+ } else {
43
+ $ ( this ) . show ( ) ;
44
+ }
45
+ }
46
+ } ) ;
47
+ }
48
+ } ) ;
49
+ } )
Original file line number Diff line number Diff line change @@ -12,16 +12,21 @@ define([
12
12
$ ,
13
13
alert
14
14
) {
15
+ 'use strict' ;
16
+
15
17
return Component . extend ( {
16
18
wrapperContainerSelector : null ,
17
19
modeContainerSelector : null ,
18
20
checkApiConnectionUrl : null ,
19
21
resultContainerSelector : null ,
20
22
23
+ /**
24
+ * Check API Connection function
25
+ */
21
26
checkApiConnection : function ( ) {
22
27
let mode = $ ( this . modeContainerSelector ) . val ( ) ,
23
28
merchant_name = $ ( '#cm_payments_general_api_details_' + mode + '_merchant_name' ) . val ( ) ,
24
- merchant_password = $ ( '#cm_payments_general_api_details_' + mode + '_merchant_password' ) . val ( ) ,
29
+ merchant_password = $ ( '#cm_payments_general_api_details_' + mode + '_merchant_password' ) . val ( ) ,
25
30
merchant_key = $ ( '#cm_payments_general_api_details_' + mode + '_merchant_key' ) . val ( ) ,
26
31
container = $ ( this . wrapperContainerSelector ) ,
27
32
result = $ ( this . resultContainerSelector ) ,
You can’t perform that action at this time.
0 commit comments