Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Functions | Variables
users_grid_js.phtml File Reference

Go to the source code of this file.

Functions

 registerUserRole (grid, element, checked)
 
 roleUsersRowClick (grid, event)
 
 roleUsersRowInit (grid, row)
 
 massSelectUsers (allCheckbox)
 
 markCheckboxes (value)
 
 onLoad ()
 

Variables

 $myBlock = $block->getLayout()->getBlock('roleUsersGrid')
 
 warning = false
 
 endif
 

Function Documentation

◆ markCheckboxes()

markCheckboxes ( value  )

Definition at line 110 of file users_grid_js.phtml.

110  {
111  <?= /* @escapeNotVerified */ $myBlock->getJsObjectName() ?>.rows.each(function(row)
112  {
113  $(row).getElementsByClassName('checkbox')[0].checked = value;
114  roleUsersRowInit(<?= /* @escapeNotVerified */ $myBlock->getJsObjectName() ?>, row);
115  });
116  }
$block setTitle( 'CMS Block Title') -> setIdentifier('fixture_block') ->setContent('< h1 >Fixture Block Title</h1 >< a href=" store url</a><p> Config value
Definition: block.php:9
roleUsersRowInit(grid, row)
$myBlock

◆ massSelectUsers()

massSelectUsers ( allCheckbox  )

Definition at line 94 of file users_grid_js.phtml.

94  {
95  if (!allCheckbox.checked && _.size(checkBoxes._object) > 0) {
96  allCheckbox.checked = true;
97  confirm({
98  content: "<?= /* @escapeNotVerified */ __('Warning!\r\nThis action will remove those users from already assigned roles\r\nAre you sure?') ?>",
99  actions: {
100  confirm: function () {
101  allCheckbox.checked = false;
102  markCheckboxes(false);
103  }
104  }
105  });
106  } else {
107  markCheckboxes(allCheckbox.checked)
108  }
109  }
markCheckboxes(value)

◆ onLoad()

onLoad ( )

Definition at line 117 of file users_grid_js.phtml.

117  {
118  if (typeof <?= /* @escapeNotVerified */ $myBlock->getJsObjectName() ?> !== 'undefined') {
119  <?= /* @escapeNotVerified */ $myBlock->getJsObjectName() ?>.
120  rowClickCallback = roleUsersRowClick;
121  <?= /* @escapeNotVerified */ $myBlock->getJsObjectName() ?>.
122  initRowCallback = roleUsersRowInit;
123  <?= /* @escapeNotVerified */ $myBlock->getJsObjectName() ?>.
124  checkboxCheckCallback = registerUserRole;
125  <?= /* @escapeNotVerified */ $myBlock->getJsObjectName() ?>.
126  checkCheckboxes = massSelectUsers;
127  <?= /* @escapeNotVerified */ $myBlock->getJsObjectName() ?>.
128  rows.each(function (row) {
129  roleUsersRowInit(<?= /* @escapeNotVerified */ $myBlock->getJsObjectName() ?>, row)
130  });
131  $('in_role_user_old').value = $('in_role_user').value;
132  } else {
133  setTimeout(onLoad, 300);
134  }
135  }
$block setTitle( 'CMS Block Title') -> setIdentifier('fixture_block') ->setContent('< h1 >Fixture Block Title</h1 >< a href=" store url</a><p> Config value
Definition: block.php:9
<?=$myBlock-> getJsObjectName() ?>.rows.each(function(row)
massSelectUsers(allCheckbox)
roleUsersRowInit(grid, row)
$myBlock
registerUserRole(grid, element, checked)
roleUsersRowClick(grid, event)
onLoad()

◆ registerUserRole()

registerUserRole ( grid  ,
element  ,
checked   
)

Definition at line 27 of file users_grid_js.phtml.

28  {
29  if (checked) {
30  checkBoxes.set(element.value, 0);
31  } else {
32  checkBoxes.unset(element.value);
33  }
34  $('in_role_user').value = checkBoxes.toQueryString();
35  grid.reloadParams = {'in_role_user[]':checkBoxes.keys()};
36  }
$block setTitle( 'CMS Block Title') -> setIdentifier('fixture_block') ->setContent('< h1 >Fixture Block Title</h1 >< a href=" store url</a><p> Config value
Definition: block.php:9

◆ roleUsersRowClick()

roleUsersRowClick ( grid  ,
event   
)

Definition at line 38 of file users_grid_js.phtml.

39  {
40  var trElement = Event.findElement(event, 'tr');
41  var isInput = Event.element(event).tagName == 'INPUT';
42  if (trElement) {
43  var checkbox = Element.getElementsBySelector(trElement, 'input');
44  if(checkbox[0]){
45  var checked = isInput ? !checkbox[0].checked : checkbox[0].checked;
46 
47  if (checked) {
48  confirm({
49  content: "<?= /* @escapeNotVerified */ __('Warning!\r\nThis action will remove this user from already assigned role\r\nAre you sure?') ?>",
50  actions: {
51  confirm: function () {
52  checkbox[0].checked = false;
53  checkBoxes.unset(checkbox[0].value);
54  varienElementMethods.setHasChanges(checkbox[0]);
55  },
56  cancel: function () {
57  checkbox[0].checked = true;
58  },
59  always: function () {
60  $('in_role_user').value = checkBoxes.toQueryString();
61  grid.reloadParams = {
62  'in_role_user[]': checkBoxes.keys()
63  };
64  }
65  }
66  });
67  } else {
68  checkbox[0].checked = true;
69  checkBoxes.set(checkbox[0].value, true);
70  $('in_role_user').value = checkBoxes.toQueryString();
71  grid.reloadParams = {
72  'in_role_user[]': checkBoxes.keys()
73  };
74  }
75  }
76  }
77  }
$block setTitle( 'CMS Block Title') -> setIdentifier('fixture_block') ->setContent('< h1 >Fixture Block Title</h1 >< a href=" store url</a><p> Config value
Definition: block.php:9
jquery extjs ext tree checkbox
Definition: tree.phtml:41

◆ roleUsersRowInit()

roleUsersRowInit ( grid  ,
row   
)

Definition at line 79 of file users_grid_js.phtml.

80  {
81  var checkbox = $(row).getElementsByClassName('checkbox')[0];
82  if (checkbox) {
83  if (checkbox.checked) {
84  checkBoxes.set(checkbox.value, checkbox.checked);
85  } else {
86  checkBoxes.unset(checkbox.value);
87  }
88 
89  $('in_role_user').value = checkBoxes.toQueryString();
90  grid.reloadParams = {'in_role_user[]':checkBoxes.keys()};
91  }
92  }
$block setTitle( 'CMS Block Title') -> setIdentifier('fixture_block') ->setContent('< h1 >Fixture Block Title</h1 >< a href=" store url</a><p> Config value
Definition: block.php:9
jquery extjs ext tree checkbox
Definition: tree.phtml:41

Variable Documentation

◆ $myBlock

$myBlock = $block->getLayout()->getBlock('roleUsersGrid')

Copyright © Magento, Inc. All rights reserved. See COPYING.txt for license details.

Definition at line 18 of file users_grid_js.phtml.

◆ endif

endif

Definition at line 137 of file users_grid_js.phtml.

◆ warning

warning = false

Definition at line 21 of file users_grid_js.phtml.