All Data Structures Functions Variables Pages
ByTimeWorkflowWizardView.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  public function getTitle()
46  {
47  return parent::getTitle() . ' - ' . Zurmo::t('WorkflowsModule', 'Time-Based');
48  }
49 
54  protected function renderContainingViews(WizardActiveForm $form)
55  {
56  $moduleForWorkflowWizardView = new ModuleForWorkflowWizardView ($this->model, $form);
57  $timeTriggerForWorkflowWizardView = new TimeTriggerForWorkflowWizardView($this->model, $form, true);
58  $triggersForWorkflowWizardView = new TriggersForWorkflowWizardView($this->model, $form, true);
59  $actionsForWorkflowWizardView = new ActionsForWorkflowWizardView($this->model, $form, true);
60  $emailMessagesForWorkflowWizardView = new EmailMessagesForWorkflowWizardView($this->model, $form, true);
61  $generalDataForWorkflowWizardView = new GeneralDataForWorkflowWizardView($this->model, $form, true);
62 
63  $gridView = new GridView(6, 1);
64  $gridView->setView($moduleForWorkflowWizardView, 0, 0);
65  $gridView->setView($timeTriggerForWorkflowWizardView, 1, 0);
66  $gridView->setView($triggersForWorkflowWizardView, 2, 0);
67  $gridView->setView($actionsForWorkflowWizardView, 3, 0);
68  $gridView->setView($emailMessagesForWorkflowWizardView, 4, 0);
69  $gridView->setView($generalDataForWorkflowWizardView, 5, 0);
70  return $gridView->render();
71  }
72 
77  protected function renderConfigSaveAjax($formName)
78  {
79  assert('is_string($formName)');
80  return "linkId = $('#" . $formName . "').find('.attachLoadingTarget').attr('id');
81  if (linkId == '" . ModuleForWorkflowWizardView::getNextPageLinkId() . "')
82  {
83  $('#" . static::getValidationScenarioInputId() . "').val('" .
84  WorkflowWizardForm::TIME_TRIGGER_VALIDATION_SCENARIO . "');
85  $('#ModuleForWorkflowWizardView').hide();
86  " . $this->renderLoadTimeTriggerAttributeScriptContent($formName) . "
87  $('#TimeTriggerForWorkflowWizardView').show();
88  $('.StepsAndProgressBarForWizardView').find('.progress-bar').width('33%');
89  $('.StepsAndProgressBarForWizardView').find('.current-step').removeClass('current-step').next().addClass('current-step');
90  }
92  {
93  $('#" . static::getValidationScenarioInputId() . "').val('" .
94  WorkflowWizardForm::TRIGGERS_VALIDATION_SCENARIO . "');
95  $('#TimeTriggerForWorkflowWizardView').hide();
96  " . static::renderTreeViewAjaxScriptContent($formName, 'TriggersForWorkflowWizardView', $this->model->type) . "
97  $('#TriggersForWorkflowWizardView').show();
98  $('.StepsAndProgressBarForWizardView').find('.progress-bar').width('50%');
99  $('.StepsAndProgressBarForWizardView').find('.current-step').removeClass('current-step').next().addClass('current-step');
100  }
101  if (linkId == '" . TriggersForWorkflowWizardView::getNextPageLinkId() . "')
102  {
103  $('#" . static::getValidationScenarioInputId() . "').val('" .
104  WorkflowWizardForm::ACTIONS_VALIDATION_SCENARIO . "');
105  $('#TriggersForWorkflowWizardView').hide();
106  $('#ActionsForWorkflowWizardView').show();
107  var actionsList = $('#ActionsForWorkflowWizardView').find('ul:first').children();
108  $.each(actionsList, function()
109  {
110  if ( $(this).hasClass('expanded-row') )
111  {
112  $(this).toggleClass('expanded-row');
113  $('.edit-dynamic-row-link', this).toggle();
114  $('.toggle-me', this).toggle();
115  }
116  });
117  $('.StepsAndProgressBarForWizardView').find('.progress-bar').width('67%');
118  $('.StepsAndProgressBarForWizardView').find('.current-step').removeClass('current-step').next().addClass('current-step');
119  }
120  if (linkId == '" . ActionsForWorkflowWizardView::getNextPageLinkId() . "')
121  {
122  $('#" . static::getValidationScenarioInputId() . "').val('" .
123  WorkflowWizardForm::EMAIL_MESSAGES_VALIDATION_SCENARIO . "');
124  $('#ActionsForWorkflowWizardView').hide();
125  $('#EmailMessagesForWorkflowWizardView').show();
126  $('.StepsAndProgressBarForWizardView').find('.progress-bar').width('83%');
127  $('.StepsAndProgressBarForWizardView').find('.current-step').removeClass('current-step').next().addClass('current-step');
128  }
130  {
131  $('#" . static::getValidationScenarioInputId() . "').val('" .
132  WorkflowWizardForm::GENERAL_DATA_VALIDATION_SCENARIO . "');
133  $('#EmailMessagesForWorkflowWizardView').hide();
134  $('#GeneralDataForWorkflowWizardView').show();
135  $('.StepsAndProgressBarForWizardView').find('.progress-bar').width('100%');
136  $('.StepsAndProgressBarForWizardView').find('.current-step').removeClass('current-step').next().addClass('current-step');
137  }
138 
139  var rowData = $('#" . $formName . "').find('.attachLoadingTarget').data() || {};
140  if (rowData.purpose === 'validate-action')
141  {
142  $('#' + rowData.row.toString()).toggleClass('expanded-row');
143  $('#' + rowData.row.toString() + ' .toggle-me').toggle();
144  $('#' + rowData.row.toString() + ' .edit-dynamic-row-link').toggle();
145  $('#' + rowData.row.toString()).siblings().show();
146  $('#actionsNextLink').parent().parent().show();
147  $('#actionType').removeAttr('disabled');
148  }
149 
150  if (linkId == '" . GeneralDataForWorkflowWizardView::getNextPageLinkId() . "')
151  {
152  " . $this->getSaveAjaxString($formName) . "
153  }
154  else
155  {
156  $('#" . $formName . "').find('.attachLoadingTarget').removeClass('loading');
157  $('#" . $formName . "').find('.attachLoadingTarget').removeClass('loading-ajax-submit');
158  $('#" . $formName . "').find('.attachLoadingTarget').removeClass('attachLoadingTarget');
159  }
160  ";
161  }
162 
163  protected function registerClickFlowScript()
164  {
165  Yii::app()->clientScript->registerScript('clickflow', "
166  $('#" . ModuleForWorkflowWizardView::getPreviousPageLinkId() . "').unbind('click');
167  $('#" . ModuleForWorkflowWizardView::getPreviousPageLinkId() . "').bind('click', function()
168  {
169  url = '" . Yii::app()->createUrl(static::getModuleId() . '/' . static::getControllerId() . '/index') . "';
170  window.location.href = url;
171  return false;
172  }
173  );
174  $('#" . TimeTriggerForWorkflowWizardView::getPreviousPageLinkId() . "').unbind('click');
175  $('#" . TimeTriggerForWorkflowWizardView::getPreviousPageLinkId() . "').bind('click', function()
176  {
177  $('#" . static::getValidationScenarioInputId() . "').val('" .
178  WorkflowWizardForm::MODULE_VALIDATION_SCENARIO . "');
179  $('#" . WizardActiveForm::makeErrorsSummaryId(static::getFormId()) . "').hide();
180  $('#ModuleForWorkflowWizardView').show();
181  $('#TimeTriggerForWorkflowWizardView').hide();
182  $('.StepsAndProgressBarForWizardView').find('.progress-bar').width('16.5%');
183  $('.StepsAndProgressBarForWizardView').find('.current-step').removeClass('current-step').prev().addClass('current-step');
184  return false;
185  }
186  );
187  $('#" . TriggersForWorkflowWizardView::getPreviousPageLinkId() . "').unbind('click');
188  $('#" . TriggersForWorkflowWizardView::getPreviousPageLinkId() . "').bind('click', function()
189  {
190  $('#" . static::getValidationScenarioInputId() . "').val('" .
191  WorkflowWizardForm::TIME_TRIGGER_VALIDATION_SCENARIO . "');
192  $('#TimeTriggerForWorkflowWizardView').show();
193  $('#TriggersForWorkflowWizardView').hide();
194  $('.StepsAndProgressBarForWizardView').find('.progress-bar').width('33%');
195  $('.StepsAndProgressBarForWizardView').find('.current-step').removeClass('current-step').prev().addClass('current-step');
196  return false;
197  }
198  );
199  $('#" . ActionsForWorkflowWizardView::getPreviousPageLinkId() . "').unbind('click');
200  $('#" . ActionsForWorkflowWizardView::getPreviousPageLinkId() . "').bind('click', function()
201  {
202  $('#" . static::getValidationScenarioInputId() . "').val('" . WorkflowWizardForm::TRIGGERS_VALIDATION_SCENARIO . "');
203  $('#TriggersForWorkflowWizardView').show();
204  $('#ActionsForWorkflowWizardView').hide();
205  $('.StepsAndProgressBarForWizardView').find('.progress-bar').width('50%');
206  $('.StepsAndProgressBarForWizardView').find('.current-step').removeClass('current-step').prev().addClass('current-step');
207  return false;
208  }
209  );
210  $('#" . EmailMessagesForWorkflowWizardView::getPreviousPageLinkId() . "').unbind('click');
211  $('#" . EmailMessagesForWorkflowWizardView::getPreviousPageLinkId() . "').bind('click', function()
212  {
213  $('#" . static::getValidationScenarioInputId() . "').val('" . WorkflowWizardForm::ACTIONS_VALIDATION_SCENARIO . "');
214  $('#ActionsForWorkflowWizardView').show();
215  $('#EmailMessagesForWorkflowWizardView').hide();
216  $('.StepsAndProgressBarForWizardView').find('.progress-bar').width('67%');
217  $('.StepsAndProgressBarForWizardView').find('.current-step').removeClass('current-step').prev().addClass('current-step');
218  return false;
219  }
220  );
221  $('#" . GeneralDataForWorkflowWizardView::getPreviousPageLinkId() . "').unbind('click');
222  $('#" . GeneralDataForWorkflowWizardView::getPreviousPageLinkId() . "').bind('click', function()
223  {
224  $('#" . static::getValidationScenarioInputId() . "').val('" . WorkflowWizardForm::EMAIL_MESSAGES_VALIDATION_SCENARIO . "');
225  $('#EmailMessagesForWorkflowWizardView').show();
226  $('#GeneralDataForWorkflowWizardView').hide();
227  $('.StepsAndProgressBarForWizardView').find('.progress-bar').width('83%');
228  $('.StepsAndProgressBarForWizardView').find('.current-step').removeClass('current-step').prev().addClass('current-step');
229  return false;
230  }
231  );
232  ");
233  }
234 
235  protected function registerScripts()
236  {
237  parent::registerScripts();
238  $this->registerTimeTriggerAttributeDropDownOnChangeScript();
239  }
240 
245  protected function renderLoadTimeTriggerAttributeScriptContent($formName)
246  {
247  assert('is_string($formName)');
248  $url = Yii::app()->createUrl(static::getModuleId() . '/' . static::getControllerId() . '/getAvailableAttributesForTimeTrigger',
249  array_merge($_GET, array('type' => $this->model->type)));
250  // Begin Not Coding Standard
251  $script = "
252  $.ajax({
253  url : '" . $url . "',
254  type : 'POST',
255  data : $('#" . $formName . "').serialize(),
256  dataType: 'json',
257  success : function(data)
258  {
259  rebuildSelectInputFromDataAndLabels('ByTimeWorkflowWizardForm_timeTriggerAttribute', data);
260  },
261  error : function()
262  {
263  //todo: error call
264  }
265  });
266  ";
267  // End Not Coding Standard
268  return $script;
269  }
270 
271  protected function registerTimeTriggerAttributeDropDownOnChangeScript()
272  {
273  $id = 'ByTimeWorkflowWizardForm_timeTriggerAttribute';
274  $inputDivId = 'time-trigger-container';
275  $url = Yii::app()->createUrl(static::getModuleId() . '/' . static::getControllerId() . '/addOrChangeTimeTriggerAttribute',
276  array_merge($_GET, array('type' => $this->model->type)));
277  // Begin Not Coding Standard
278  $ajaxSubmitScript = ZurmoHtml::ajax(array(
279  'type' => 'GET',
280  'data' => 'js:\'attributeIndexOrDerivedType=\' + $(this).val() +
281  \'&moduleClassName=\' +
282  $("input:radio[name=\"ByTimeWorkflowWizardForm[moduleClassName]\"]:checked").val()',
283  'url' => $url,
284  'beforeSend' => 'js:function(){
285  //$("#' . $inputDivId . '").html("<span class=\"loading z-spinner\"></span>");
286  //attachLoadingSpinner("' . $inputDivId . '", true, "dark");
287  }',
288  'success' => 'js:function(data){
290  $("#time-trigger-container").show();
291  $("#' . $inputDivId . ' ul").html(data);
292  }',
293  ));
294  $script = "$('#" . $id . "').unbind('change'); $('#" . $id . "').bind('change', function()
295  {
296  if ($('#" . $id . "').val() == '')
297  {
298  $('#" . $inputDivId . " ul').html('');
300  }
301  else
302  {
303  $ajaxSubmitScript
304  }
305  }
306  );";
307  // End Not Coding Standard
308  Yii::app()->clientScript->registerScript('timeTriggerAttributeDropDownOnChangeScript', $script);
309  }
310 
311  protected function registerModuleClassNameChangeScriptExtraPart()
312  {
313  $timeTriggerSelectId = get_class($this->model) . '_timeTriggerAttribute';
314  return " $('#time-trigger-container').find('li').remove();
316  $('#" . $timeTriggerSelectId . "').find('option[value!=\"\"]').remove();
317  ";
318  }
319  }
320 ?>
renderContainingViews(WizardActiveForm $form)
getSaveAjaxString($formName, $redirectAfterSave=true, array $additionalAjaxOptions=array())
Definition: WizardView.php:281
Generated on Sat Feb 22 2020 07:10:34