Removed SG options if no SGs exist from attribute creation/edit

pull/762/head
Iglocska 2015-08-03 15:46:58 +02:00
parent 43905247d2
commit 7cc3a9a6d9
3 changed files with 16 additions and 7 deletions

View File

@ -257,7 +257,6 @@ class AttributesController extends AppController {
$events = $this->Event->findById($eventId);
$this->set('event_id', $events['Event']['id']);
// combobox for distribution
$this->set('distributionLevels', $this->Attribute->distributionLevels);
$this->set('currentDist', $events['Event']['distribution']); // TODO default distribution
// tooltip for distribution
$this->set('distributionDescriptions', $this->Attribute->distributionDescriptions);
@ -266,6 +265,10 @@ class AttributesController extends AppController {
$sgs = $this->SharingGroup->fetchAllAuthorised($this->Auth->user(), 'name', 1);
$this->set('sharingGroups', $sgs);
$distributionLevels = $this->Event->distributionLevels;
if (empty($sgs)) unset ($distributionLevels[4]);
$this->set('distributionLevels', $distributionLevels);
$this->set('attrDescriptions', $this->Attribute->fieldDescriptions);
$this->set('typeDefinitions', $this->Attribute->typeDefinitions);
$this->set('categoryDefinitions', $this->Attribute->categoryDefinitions);
@ -774,8 +777,6 @@ class AttributesController extends AppController {
$categories = $this->_arrayToValuesIndexArray($categories);
$this->set('categories', $categories);
$this->set('currentDist', $this->Event->data['Event']['distribution']);
// combobox for distribution
$this->set('distributionLevels', $this->Attribute->distributionLevels);
// tooltip for distribution
$this->set('distributionDescriptions', $this->Attribute->distributionDescriptions);
@ -783,6 +784,10 @@ class AttributesController extends AppController {
$sgs = $this->SharingGroup->fetchAllAuthorised($this->Auth->user(), 'name', 1);
$this->set('sharingGroups', $sgs);
$distributionLevels = $this->Event->distributionLevels;
if (empty($sgs)) unset ($distributionLevels[4]);
$this->set('distributionLevels', $distributionLevels);
$this->set('attrDescriptions', $this->Attribute->fieldDescriptions);
$this->set('typeDefinitions', $this->Attribute->typeDefinitions);
$this->set('categoryDefinitions', $this->Attribute->categoryDefinitions);

View File

@ -36,10 +36,12 @@
?>
<div id="SGContainer" style="display:none;">
<?php
if (!empty($sharingGroups)) {
echo $this->Form->input('sharing_group_id', array(
'options' => array($sharingGroups),
'label' => 'Sharing Group',
));
}
?>
</div>
<?php

View File

@ -22,10 +22,12 @@
?>
<div id="SGContainer" style="display:none;">
<?php
echo $this->Form->input('sharing_group_id', array(
'options' => array($sharingGroups),
'label' => 'Sharing Group',
));
if (!empty($sharingGroups)) {
echo $this->Form->input('sharing_group_id', array(
'options' => array($sharingGroups),
'label' => 'Sharing Group',
));
}
?>
</div>
<?php