Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
KanbanBoardOptionsElement.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 
42  {
43  protected function renderControlEditable()
44  {
45  assert('$this->model instanceof SearchForm');
46  assert('$this->attribute == null');
47  assert('$this->model->getKanbanBoard() != null');
48  $content = ZurmoHtml::tag('div', array('class' => 'kanban-board-options-panel'), $this->renderSelectionContent());
49  $content .= ZurmoHtml::tag('div', array('class' => 'kanban-board-options-panel'), $this->renderThemeContent());
50  $content = ZurmoHtml::tag('div', array('class' => 'attributesContainer clearfix'), $content);
51  $linkContent = $this->renderApplyResetContent() . $this->renderApplyLinkContent();
52  $linkContent = ZurmoHtml::tag('div', array('class' => 'form-toolbar clearfix'), $linkContent);
53  $this->registerThemeScript();
54  return $content . ZurmoHtml::tag('div', array('class' => 'view-toolbar-container'), $linkContent);
55  }
56 
61  protected function renderControlNonEditable()
62  {
63  throw new NotSupportedException();
64  }
65 
70  protected function renderLabel()
71  {
72  return null;
73  }
74 
75  protected function renderSelectionContent()
76  {
77  $content = ZurmoHtml::tag('h3', array(), Zurmo::t('Core', 'Visible Columns'));
78  $content .= ZurmoHtml::checkBoxList(
79  $this->getEditableInputName(KanbanBoard::GROUP_BY_ATTRIBUTE_VISIBLE_VALUES),
80  $this->model->getKanbanBoard()->getGroupByAttributeVisibleValues(),
81  $this->model->getKanbanBoard()->getGroupByDataAndTranslatedLabels(),
82  $this->getEditableValuesHtmlOptions()
83  );
84  return $content;
85  }
86 
91  protected function renderThemeContent()
92  {
93  $gameLevel = GameLevel::resolveByTypeAndPerson(GameLevel::TYPE_GENERAL, Yii::app()->user->userModel);
94  $content = ZurmoHtml::tag('h3', array(), Zurmo::t('Core', 'Theme'));
95  $content .= ZurmoHtml::radioButtonList(
96  $this->getEditableInputName(KanbanBoard::SELECTED_THEME),
97  $this->model->getKanbanBoard()->getSelectedTheme(),
98  $this->resolveThemeColorNamesAndLabelsForLocking($gameLevel),
99  $this->getEditableThemeHtmlOptions(),
100  array(),
101  $this->resolveDataHtmlOptions($gameLevel)
102  );
103  return $content;
104  }
105 
106  protected function getEditableValuesHtmlOptions()
107  {
108  return array(
109  'template' => '<div class="multi-select-checkbox-input">{input}{label}</div>',
110  'separator' => '',
111  'id' => $this->getEditableInputId(KanbanBoard::GROUP_BY_ATTRIBUTE_VISIBLE_VALUES),
112  'class' => 'ignore-clearform'
113  );
114  }
115 
116  protected function getEditableThemeHtmlOptions()
117  {
118  $htmlOptions = array();
119  $htmlOptions['id'] = $this->getEditableInputId(KanbanBoard::SELECTED_THEME);
120  $htmlOptions['separator'] = '';
121  $htmlOptions['template'] = '<div class="radio-input texture-swatch {value}">{input}{label}</div>';
122  $htmlOptions['class'] = 'ignore-clearform';
123  return $htmlOptions;
124  }
125 
126  public function registerThemeScript()
127  {
128  //todo: implement
129  //return;
130  $removeScript = null;
131  foreach ($this->model->getKanbanBoard()->getThemeNamesAndLabels() as $value => $notUsed)
132  {
133  $removeScript .= '$("#kanban-holder").removeClass("' . $value . '");' . "\n";
134  }
135  // Begin Not Coding Standard
136  $script = "$('input[name=\"" . $this->getEditableInputName(KanbanBoard::SELECTED_THEME) . "\"]').live('change', function(){
137  $removeScript
138  $('#kanban-holder').addClass(this.value);
139  });
140  ";
141  // End Not Coding Standard
142  Yii::app()->clientScript->registerScript('changeKanbanBoardTheme', $script);
143  }
144 
145  protected function renderApplyLinkContent()
146  {
147  $params = array();
148  $params['label'] = Zurmo::t('Core', 'Apply');
149  $params['htmlOptions'] = array('id' => 'kanban-board-options-apply',
150  'onclick' => 'js:$(this).addClass("attachLoadingTarget");');
151  $element = new SaveButtonActionElement(null, null, null, $params);
152  return $element->render();
153  }
154 
155  protected function renderApplyResetContent()
156  {
157  $params = array();
158  $params['label'] = Zurmo::t('Core', 'Reset');
159  $params['htmlOptions'] = array('id' => 'kanban-board-options-reset',
160  'class' => 'default-btn',
161  'onclick' => 'js:$(this).addClass("attachLoadingTarget");' . $this->renderResetScript());
162  $element = new SaveButtonActionElement(null, null, null, $params);
163  return $element->render();
164  }
165 
166  protected function renderResetScript()
167  {
168  // Begin Not Coding Standard
169  return "
170  $('.kanban-board-options-view').hide();
171  var inputName = '" .$this->getEditableInputName(KanbanBoard::GROUP_BY_ATTRIBUTE_VISIBLE_VALUES) . "[]';
172  $('input[name=\"' + inputName + '\"]').each(function()
173  {
174  $(this).attr('checked', true);
175  $(this).parent().addClass('c_on');
176  });
177  $('input[name=\"" . $this->getEditableInputName(KanbanBoard::SELECTED_THEME) . "\"]').each(function()
178  {
179  if ($(this).val() == '')
180  {
181  $(this).attr('checked', true);
182  }
183  else
184  {
185  $(this).attr('checked', false);
186  }
187  });
188  ";
189  // End Not Coding Standard
190  }
191 
192  protected function resolveThemeColorNamesAndLabelsForLocking(GameLevel $gameLevel)
193  {
194  $namesAndUnlockedAtLevels = $this->model->getKanbanBoard()->getThemeColorNamesAndUnlockedAtLevel();
195  $data = array();
196  foreach ($this->model->getKanbanBoard()->getThemeNamesAndLabels() as $name => $label)
197  {
198  $label = '<span class="background-texture-1"></span>' . $label;
199  $unlockedAtLevel = $namesAndUnlockedAtLevels[$name];
200  if ($unlockedAtLevel > (int)$gameLevel->value)
201  {
202  $title = Zurmo::t('GamificationModule', 'Unlocked at level {level}', array('{level}' => $unlockedAtLevel));
203  $content = '<span id="background-texture-tooltip-' . $name. '" title="' . $title . '"><i class="icon-lock"></i></span>' . $label; // Not Coding Standard
204  $qtip = new ZurmoTip();
205  $qtip->addQTip("#background-texture-tooltip-" . $name);
206  }
207  else
208  {
209  $content = $label;
210  }
211  $data[$name] = $content;
212  }
213  return $data;
214  }
215 
216  protected function resolveDataHtmlOptions(GameLevel $gameLevel)
217  {
218  $dataHtmlOptions = array();
219  foreach ($this->model->getKanbanBoard()->getThemeColorNamesAndUnlockedAtLevel() as $name => $unlockedAtLevel)
220  {
221  $dataHtmlOptions[$name] = array();
222  if ($unlockedAtLevel > (int)$gameLevel->value)
223  {
224  $dataHtmlOptions[$name]['class'] = 'locked';
225  $dataHtmlOptions[$name]['disabled'] = 'disabled';
226  }
227  }
228  return $dataHtmlOptions;
229  }
230  }
231 ?>
static resolveByTypeAndPerson($type, Item $person)
Definition: GameLevel.php:90
static checkBoxList($name, $select, $data, $htmlOptions=array())
Definition: ZurmoHtml.php:520
static radioButtonList($name, $select, $data, $htmlOptions=array(), $dataSelectOptions=array(), $dataHtmlOptions=array())
Definition: ZurmoHtml.php:170
getEditableInputName($attributeName=null, $relationAttributeName=null)
Definition: Element.php:303
getEditableInputId($attributeName=null, $relationAttributeName=null)
Definition: Element.php:277
Generated on Mon Jul 6 2020 07:10:29
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.