Open Journal Systems  3.3.0
ReviewFormGridRow.inc.php
1 <?php
2 
16 import('lib.pkp.classes.controllers.grid.GridRow');
17 import('lib.pkp.classes.linkAction.request.RemoteActionConfirmationModal');
18 
19 class ReviewFormGridRow extends GridRow {
20 
21  //
22  // Overridden methods from GridRow
23  //
27  function initialize($request, $template = null) {
28  parent::initialize($request, $template);
29 
30  // Is this a new row or an existing row?
31  $element = $this->getData();
32  assert(is_a($element, 'ReviewForm'));
33 
34  $rowId = $this->getId();
35 
36  if (!empty($rowId) && is_numeric($rowId)) {
37  // Only add row actions if this is an existing row
38  $router = $request->getRouter();
39 
40  // determine whether or not this Review Form is editable.
41  $canEdit = ($element->getIncompleteCount() == 0 && $element->getCompleteCount() == 0);
42 
43  // if review form is editable, add 'edit' grid row action
44  if($canEdit) {
45  $this->addAction(
46  new LinkAction(
47  'edit',
48  new AjaxModal(
49  $router->url($request, null, null, 'editReviewForm', null, array('rowId' => $rowId)),
50  __('grid.action.edit'),
51  'modal_edit',
52  true
53  ),
54  __('grid.action.edit'),
55  'edit')
56  );
57  }
58 
59  // if review form is not editable, add 'copy' grid row action
60  $this->addAction(
61  new LinkAction(
62  'copy',
64  $request->getSession(),
65  __('manager.reviewForms.confirmCopy'),
66  null,
67  $router->url($request, null, null, 'copyReviewForm', null, array('rowId' => $rowId))
68  ),
69  __('grid.action.copy'),
70  'copy'
71  )
72  );
73 
74  // add 'preview' grid row action
75  $this->addAction(
76  new LinkAction(
77  'preview',
78  new AjaxModal(
79  $router->url($request, null, null, 'editReviewForm', null, array('rowId' => $rowId, 'preview' => 1)),
80  __('grid.action.preview'),
81  'preview',
82  true
83  ),
84  __('grid.action.preview'),
85  'preview'
86  )
87  );
88 
89  // if review form is editable, add 'delete' grid row action.
90  if($canEdit) {
91  $this->addAction(
92  new LinkAction(
93  'delete',
95  $request->getSession(),
96  __('manager.reviewForms.confirmDelete'),
97  null,
98  $router->url($request, null, null, 'deleteReviewForm', null, array('rowId' => $rowId))
99  ),
100  __('grid.action.delete'),
101  'delete')
102  );
103  }
104  }
105  }
106 }
107 
108 
RemoteActionConfirmationModal
Class defining a simple confirmation modal with a remote action and ok/cancel buttons.
Definition: RemoteActionConfirmationModal.inc.php:18
GridRow\addAction
addAction($action, $position=GRID_ACTION_POSITION_DEFAULT)
Definition: GridRow.inc.php:179
GridBodyElement\getId
getId()
Definition: GridBodyElement.inc.php:57
ReviewFormGridRow\initialize
initialize($request, $template=null)
Definition: ReviewFormGridRow.inc.php:27
GridRow
GridRow implements a row of a Grid. See GridHandler for general information about grids.
Definition: GridRow.inc.php:29
AjaxModal
A modal that retrieves its content from via AJAX.
Definition: AjaxModal.inc.php:18
LinkAction
Base class defining an action that can be performed by the user in the user interface.
Definition: LinkAction.inc.php:22
GridRow\getData
& getData()
Definition: GridRow.inc.php:131
ReviewFormGridRow
ReviewForm grid row definition.
Definition: ReviewFormGridRow.inc.php:19