All Data Structures Functions Variables Pages
OpenTasksRelatedListView.php
1 <?php
2  /*********************************************************************************
3  * Zurmo is a customer relationship management program developed by
4  * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.
5  *
6  * Zurmo is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  *
13  * Zurmo is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  *
23  * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive
24  * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
25  *
26  * The interactive user interfaces in original and modified versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  *
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the Zurmo
32  * logo and Zurmo copyright notice. If the display of the logo is not reasonably
33  * feasible for technical reasons, the Appropriate Legal Notices must display the words
34  * "Copyright Zurmo Inc. 2017. All rights reserved".
35  ********************************************************************************/
36 
38  {
42  public static function getDefaultMetadata()
43  {
44  $metadata = array(
45  'perUser' => array(
46  'title' => "eval:Zurmo::t('TasksModule', 'Open TasksModulePluralLabel', LabelUtil::getTranslationParamsForAllModules())",
47  ),
48  'global' => array(
49  'toolbar' => array(
50  'elements' => array(
51  array( 'type' => 'CreateFromRelatedModalLink',
52  'portletId' => 'eval:$this->params["portletId"]',
53  'routeModuleId' => 'eval:$this->moduleId',
54  'routeParameters' => 'eval:$this->getCreateLinkRouteParameters()',
55  'ajaxOptions' => 'eval:TasksUtil::resolveAjaxOptionsForModalView("Create")',
56  'uniqueLayoutId' => 'eval:$this->uniqueLayoutId',
57  'modalContainerId' => 'eval:TasksUtil::getModalContainerId()'
58  ),
59  array( 'type' => 'ListByRelatedModelLink',
60  'routeModuleId' => 'eval:$this->moduleId',
61  'routeParameters' => 'eval:$this->getRelatedListLinkRouteParametersForTasks()',
62  'label' => 'View All Related ' . Zurmo::t('TasksModule', 'Open TasksModulePluralLabel', LabelUtil::getTranslationParamsForAllModules())),
63  ),
64  ),
65  'rowMenu' => array(
66  'elements' => array(
67  array( 'type' => 'EditModalLink',
68  'htmlOptions' => 'eval:$this->getActionModalLinksHtmlOptions("Edit")'
69  ),
70  array( 'type' => 'CopyModalLink',
71  'htmlOptions' => 'eval:$this->getActionModalLinksHtmlOptions("Copy")'
72  ),
73  array('type' => 'TaskRelatedDeleteLink'),
74  ),
75  ),
76  'derivedAttributeTypes' => array(
77  'CloseTaskCheckBox',
78  ),
79  'nonPlaceableAttributeNames' => array(
80  'latestDateTime',
81  ),
82  'gridViewType' => RelatedListView::GRID_VIEW_TYPE_STACKED,
83  'panels' => array(
84  array(
85  'rows' => array(
86  array('cells' =>
87  array(
88  array(
89  'elements' => array(
90  array('attributeName' => 'null', 'type' => 'CloseTaskCheckBox'),
91  ),
92  ),
93  )
94  ),
95  array('cells' =>
96  array(
97  array(
98  'elements' => array(
99  array('attributeName' => 'name', 'type' => 'Text', 'isLink' => true),
100  ),
101  ),
102  )
103  ),
104  ),
105  ),
106  ),
107  ),
108  );
109  return $metadata;
110  }
111 
115  protected function makeSearchAttributeData()
116  {
117  $searchAttributeData = array();
118  $searchAttributeData['clauses'] = array(
119  1 => array(
120  'attributeName' => 'activityItems',
121  'relatedAttributeName' => 'id',
122  'operatorType' => 'equals',
123  'value' => (int)$this->params['relationModel']->getClassId('Item'),
124  ),
125  2 => array(
126  'attributeName' => 'status',
127  'operatorType' => 'doesNotEqual',
128  'value' => Task::STATUS_COMPLETED
129  )
130  );
131  $searchAttributeData['structure'] = '(1 and 2)';
132  return $searchAttributeData;
133  }
134 
138  public static function getModuleClassName()
139  {
140  return 'TasksModule';
141  }
142 
146  public function getLinkString($attributeString, $attribute)
147  {
148  return array($this, 'resolveLinkString');
149  }
150 
157  public function resolveLinkString($data, $row)
158  {
159  $content = TasksUtil::getModalDetailsLink($data, $this->controllerId,
160  $this->moduleId,
161  $this->getActionModuleClassName(), false);
162  return $content;
163  }
164 
169  protected function getCreateLinkRouteParameters()
170  {
171  $routeParams = array_merge( array('sourceId' => $this->getGridViewId()),
172  parent::getCreateLinkRouteParameters());
173  if (($redirectUrl = ArrayUtil::getArrayValue($routeParams, 'redirectUrl')) != null)
174  {
175  $routeParams['redirectUrl'] = TasksUtil::resolveOpenTasksActionsRedirectUrlForDetailsAndRelationsView($redirectUrl);
176  }
177  return $routeParams;
178  }
179 
183  protected function renderScripts()
184  {
185  parent::renderScripts();
186  Yii::app()->custom->registerTaskModalDetailsScript($this->getGridViewId());
189  TasksUtil::registerTaskModalDeleteScript($this->getGridViewId());
190  }
191 
197  protected function getActionModalLinksHtmlOptions($type)
198  {
199  if ($type == "Edit")
200  {
201  return array('class' => 'edit-related-open-task');
202  }
203  elseif ($type == "Copy")
204  {
205  return array('class' => 'copy-related-open-task');
206  }
207  }
208 
213  protected function resolveRowMenuColumnClass()
214  {
215  return Yii::app()->custom->resolveRowMenuColumnClassForOpenTaskPortlet($this->getRelationAttributeName());
216  }
217 
222  protected function getSortAttributeForDataProvider()
223  {
224  return 'dueDateTime';
225  }
226 
230  public function renderPortletHeadContent()
231  {
232  $parentContent = parent::renderPortletHeadContent();
233  $defaultOptionsContent = $this->renderWrapperAndActionElementMenu(Zurmo::t('Core', 'Options'));
234  $wrappedContent = Yii::app()->custom->renderHeadContentForPortletOnDetailsAndRelationsView(get_class($this),
235  $this->params,
236  $defaultOptionsContent,
237  $parentContent);
238  return $wrappedContent;
239  }
240  }
241 ?>
static getTranslationParamsForAllModules()
Definition: LabelUtil.php:75
static getModalDetailsLink(Task $task, $controllerId, $moduleId, $moduleClassName, $isOwnerRequiredInDisplay=true)
Definition: TasksUtil.php:163
static getArrayValue($array, $element, $defaultValue=null)
Definition: ArrayUtil.php:45
static resolveOpenTasksActionsRedirectUrlForDetailsAndRelationsView($redirectUrl)
Definition: TasksUtil.php:942
static registerTaskModalDeleteScript($sourceId)
Definition: TasksUtil.php:863
static registerTaskModalCopyScript($sourceId, $routeParams)
Definition: TasksUtil.php:814
static registerTaskModalEditScript($sourceId, $routeParams)
Definition: TasksUtil.php:799
Generated on Wed Feb 26 2020 07:10:41