Guest User

Untitled

a guest
Feb 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. <a class="action-menu-item"
  2. data-bind="attr: {href: $action().href},
  3. text: $action().label,
  4. click: $col.getActionHandler($action())"
  5. data-repeat-index="0"
  6. href="http://.../index.php/admin/customer/index/edit/id/1/">Edit</a>
  7.  
  8. $actions['alert'] = [
  9. 'label' => __('Alert'),
  10. 'callback' => 'function() {alert("Action!")}'
  11. ];
  12.  
  13. "alert": {
  14. "label": "Alert",
  15. "callback": "function() {alert("Action!")}"
  16. }
  17.  
  18. getActionHandler: function (action) {
  19. var index = action.index,
  20. rowIndex = action.rowIndex;
  21.  
  22. if (this.isHandlerRequired(index, rowIndex)) {
  23. return this.applyAction.bind(this, index, rowIndex);
  24. }
  25. },
  26.  
  27. applyAction: function (actionIndex, rowIndex) {
  28. debugger
  29. var action = this.getAction(rowIndex, actionIndex),
  30. callback = this._getCallback(action);
  31.  
  32. action.confirm ?
  33. this._confirm(action, callback) :
  34. callback();
  35.  
  36. return this;
  37. },
  38.  
  39. _getCallback: function (action) {
  40. var args = [action.index, action.recordId, action],
  41. callback = action.callback;
  42.  
  43. if (utils.isObject(callback)) {
  44. args.unshift(callback.target);
  45.  
  46. callback = registry.async(callback.provider);
  47. } else if (_.isArray(callback)) {
  48. return this._getCallbacks(action);
  49. } else if (!_.isFunction(callback)) {
  50. callback = this.defaultCallback.bind(this);
  51. }
  52.  
  53. return function () {
  54. callback.apply(callback, args);
  55. };
  56. },
Add Comment
Please, Sign In to add comment