Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
ComponentWithTreeForWorkflowWizardView.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 
41  {
45  abstract protected function getItemsCount();
46 
51  abstract protected function getItemsContent(& $rowCount);
52 
57  public static function getTreeType()
58  {
59  throw new NotImplementedException();
60  }
61 
65  public static function getTreeDivId()
66  {
67  return static::getTreeType() . 'TreeArea';
68  }
69 
73  protected function renderFormContent()
74  {
75  $content = $this->renderAttributesAndRelationsTreeContent();
76  $content .= ZurmoHtml::tag('div', array('class' => 'dynamic-droppable-area'), $this->renderRightSideContent());
77  return $content;
78  }
79 
83  protected function renderRightSideContent()
84  {
85  $rowCount = 0;
86  $items = $this->getItemsContent($rowCount);
87  if ($this->isListContentSortable())
88  {
89  $itemsContent = $this->getSortableListContent($items, static::getTreeType());
90  }
91  else
92  {
93  $itemsContent = $this->getNonSortableListContent($items);
94  }
95  $idInputHtmlOptions = array('id' => static::resolveRowCounterInputId(static::getTreeType()));
96  $hiddenInputName = static::getTreeType() . 'RowCounter';
97  $dropZone = $this->renderRightSideDropZoneContent();
98  $droppableAttributesContent = ZurmoHtml::tag('div', array('class' => 'dynamic-rows'), $itemsContent);
99  $droppableAttributesContent .= $this->renderExtraDroppableAttributesContent();
100  $content = ZurmoHtml::hiddenField($hiddenInputName, $rowCount, $idInputHtmlOptions);
101  $content .= ZurmoHtml::tag('div', array('class' => 'droppable-dynamic-rows-container ' .
102  static::getTreeType()), $droppableAttributesContent . $dropZone);
103  $content .= ZurmoHtml::tag('div', array('class' => 'zero-components-view ' .
104  static::getTreeType()), $this->getZeroComponentsContent());
105  return $content;
106  }
107 
111  protected function renderRightSideDropZoneContent()
112  {
113  return ZurmoHtml::tag('div', array('class' => 'drop-zone'), ZurmoHtml::tag('div', array(), Zurmo::t('Core', 'Drop Here')));
114  }
115 
120  {
121  }
122 
129  protected function renderItems(& $rowCount, $componentData, $trackableStructurePosition = false)
130  {
131  assert('is_int($rowCount)');
132  assert('is_array($componentData)');
133  assert('is_bool($trackableStructurePosition)');
134  $items = array();
135  $wizardFormClassName = get_class($this->model);
136  foreach ($componentData as $component)
137  {
138  $nodeIdWithoutTreeType = $component->attributeIndexOrDerivedType;
140  resolveInputPrefixData($wizardFormClassName,
141  $this->getTreeType(), $rowCount);
142  $adapter = new WorkflowAttributeToElementAdapter($inputPrefixData, $component,
143  $this->form, $this->getTreeType());
144  $view = new AttributeRowForWorkflowComponentView($adapter,
145  $rowCount, $inputPrefixData,
147  resolveAttributeByNodeId($nodeIdWithoutTreeType),
148  (bool)$trackableStructurePosition, true, static::getTreeType());
149  $view->addWrapper = false;
150  $items[] = array('content' => $view->render());
151  $rowCount++;
152  }
153  return $items;
154  }
155 
156  protected function registerScripts()
157  {
158  parent::registerScripts();
159  $script = '
160  $(".droppable-dynamic-rows-container.' . static::getTreeType() . '").live("drop", function(event, ui)
161  {
162  ' . $this->getAjaxForDroppedAttribute() . '
163  });
164  $(".item-to-place", "#' . static::getTreeType() . 'TreeArea").live("dblclick", function(event)
165  {
166  ' . $this->getAjaxForDoubleClickedAttribute() . '
167  });
168  $(".remove-dynamic-row-link.' . static::getTreeType() . '").live("click", function()
169  {
170  var size = $("#' . get_class($this) . ' .dynamic-rows > ul > li").length;
171  $(this).parent().parent().remove(); //removes the <li>
172  if (size < 2)
173  {
174  $(".' . static::getZeroComponentsClassName() . '").show();
175  }
177  return false;
178  });
179  ';
180  Yii::app()->getClientScript()->registerScript(static::getTreeType() . 'WorkflowComponentForTreeScript', $script);
181  }
182 
186  protected function getAddAttributeUrl()
187  {
188  return Yii::app()->createUrl('workflows/default/addAttributeFromTree',
189  array_merge($_GET, array('type' => $this->model->type,
190  'treeType' => static::getTreeType())));
191  }
192 
196  protected function getAjaxForDroppedAttribute()
197  {
198  $rowCounterInputId = static::resolveRowCounterInputId(static::getTreeType());
199  return ZurmoHtml::ajax(array(
200  'type' => 'POST',
201  'data' => 'js:$("#' . $this->form->getId() . '").serialize()',
202  'url' => 'js:$.param.querystring("' .
203  $this->getAddAttributeUrl() .
204  '", "nodeId=" + ui.helper.attr("id") + "&rowNumber=" + $(\'#' . $rowCounterInputId . '\').val())',
205  'beforeSend' => 'js:function()
206  {
207  $(".ui-overlay-block").fadeIn(50);
208  $(this).makeLargeLoadingSpinner(true, ".ui-overlay-block"); //- add spinner to block anything else
209  }',
210  'success' => 'js:function(data)
211  {
212  $(\'#' . $rowCounterInputId . '\').val(parseInt($(\'#' . $rowCounterInputId . '\').val()) + 1);
213  $(".droppable-dynamic-rows-container.' . static::getTreeType() . '").parent().find(".dynamic-rows").find("ul:first").append(data);
214  ' . $this->getWorkflowAttributeRowAddOrRemoveExtraScript() . '
215  $(".' . static::getZeroComponentsClassName() . '").hide();
216  $(this).makeLargeLoadingSpinner(false, ".ui-overlay-block");
217  $(".ui-overlay-block").fadeOut(50);
218  }'
219  ));
220  }
221 
225  protected function getAjaxForDoubleClickedAttribute()
226  {
227  $rowCounterInputId = static::resolveRowCounterInputId(static::getTreeType());
228  return ZurmoHtml::ajax(array(
229  'type' => 'POST',
230  'data' => 'js:$("#' . $this->form->getId() . '").serialize()',
231  'url' => 'js:$.param.querystring("' . $this->getAddAttributeUrl() . '",
232  "nodeId=" + event.currentTarget.id + "&rowNumber=" + $(\'#' . $rowCounterInputId . '\').val())',
233  'beforeSend' => 'js:function()
234  {
235  $(".ui-overlay-block").fadeIn(50);
236  $(this).makeLargeLoadingSpinner(true, ".ui-overlay-block"); //- add spinner to block anything else
237  }',
238  'success' => 'js:function(data)
239  {
240  $(\'#' . $rowCounterInputId . '\').val(parseInt($(\'#' . $rowCounterInputId . '\').val()) + 1);
241  $(".droppable-dynamic-rows-container.' . static::getTreeType() . '").parent().find(".dynamic-rows").find("ul:first").append(data);
242  ' . $this->getWorkflowAttributeRowAddOrRemoveExtraScript() . '
243  $(".' . static::getZeroComponentsClassName() . '").hide();
244  $(this).makeLargeLoadingSpinner(false, ".ui-overlay-block");
245  $(".ui-overlay-block").fadeOut(50);
246  }'
247  ));
248  }
249 
253  protected function getWorkflowAttributeRowAddOrRemoveExtraScript()
254  {
255  }
256 
260  protected function isListContentSortable()
261  {
262  return false;
263  }
264  }
265 ?>
static resolveInputPrefixData($formModelClassName, $treeType, $rowNumber)
renderItems(&$rowCount, $componentData, $trackableStructurePosition=false)
getSortableListContent(Array $items, $componentType)
Generated on Thu Jul 2 2020 07:10:37
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.