Skip to content

Commit

Permalink
Task techjoomla#199 feat: Save process optimisation
Browse files Browse the repository at this point in the history
  • Loading branch information
ankush-maherwal committed Oct 3, 2019
1 parent aa157e8 commit cc624c5
Show file tree
Hide file tree
Showing 6 changed files with 486 additions and 11 deletions.
6 changes: 6 additions & 0 deletions administrator/models/field.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,12 @@ public function save($data)
$data_unique_name = $client . '_' . $data['client_type'] . '_' . $data['type'] . 'createdby';
}

// To store itemcategory type fields in core UCM hence rename the field name
if ($data['type'] == 'itemcategory')
{
$data_unique_name = $client . '_' . $data['client_type'] . '_' . $data['type'] . 'itemcategory';
}

$data['name'] = $data_unique_name;
}

Expand Down
2 changes: 1 addition & 1 deletion administrator/models/forms/field.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<option value="0">COM_TJFIELDS_NO</option>
</field>

<field name="readonly" type="radio" label="COM_TJFIELDS_FORM_LBL_FIELD_READONLY" description="COM_TJFIELDS_FORM_DESC_FIELD_READONLY" default="0" required="true" class="btn-group">
<field name="readonly" type="radio" label="COM_TJFIELDS_FORM_LBL_FIELD_READONLY" description="COM_TJFIELDS_FORM_DESC_FIELD_READONLY" default="0" required="true" class="btn-group" showon="required:0">
<option value="1">COM_TJFIELDS_YES</option>
<option value="0">COM_TJFIELDS_NO</option>
</field>
Expand Down
23 changes: 19 additions & 4 deletions administrator/models/rules/cluster.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,35 @@ class JFormRuleCluster extends JFormRule
*/
public function test(SimpleXMLElement $element, $value, $group = null, Registry $input = null, JForm $form = null)
{
$required = ($element['required'] instanceof SimpleXMLElement) ? $element['required']->__toString() : 'false';

if ($required == 'true')
{
if ($value == "" || empty($value))
{
return false;
}
}

// Validate if a user has entered valid cluster id
$user = JFactory::getUser();
JLoader::import("/components/com_cluster/includes/cluster", JPATH_ADMINISTRATOR);
$clusterUserModel = ClusterFactory::model('ClusterUser', array('ignore_request' => true));
$clusters = $clusterUserModel->getUsersClusters($user->id);

foreach ($clusters as $cluster)
if ($value != "")
{
if ($value == $cluster->id)
foreach ($clusters as $cluster)
{
return true;
if ($value == $cluster->id)
{
return true;
}
}

return false;
}

return false;
return true;
}
}
25 changes: 21 additions & 4 deletions site/filterFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,30 @@ public function getDataExtra($data, $id = null)
*/
public function saveExtraFields($data)
{
$tjFieldsHelper = new TjfieldsHelper;
if (empty($data['client']))
{
$this->setError(JText::_('COM_TJFIELDS_FORM_SAVE_FAILED_CLIENT_REQUIRED'));

$data['user_id'] = JFactory::getUser()->id;
return false;
}

$result = $tjFieldsHelper->saveFieldsValue($data);
if (empty($data['content_id']))
{
$this->setError(JText::_('COM_TJFIELDS_FORM_SAVE_FAILED_CLIENT_REQUIRED'));

return $result;
return false;
}

if (empty($data['fieldsvalue']))
{
$this->setError(JText::_('COM_TJFIELDS_FORM_SAVE_FAILED_CLIENT_REQUIRED'));

return false;
}

$tjFieldsHelper = new TjfieldsHelper;

return $tjFieldsHelper->saveFieldsValue($data);
}

/**
Expand Down
Loading

0 comments on commit cc624c5

Please sign in to comment.