Skip to content

Commit

Permalink
Tweaks to rating element (change field type to decimal, show decimal …
Browse files Browse the repository at this point in the history
…in list JS after AJAX)
  • Loading branch information
cheesegrits committed Jan 23, 2018
1 parent 03acd07 commit e4fe96f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion plugins/fabrik_element/rating/list-rating-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions plugins/fabrik_element/rating/list-rating.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ define(['jquery'], function (jQuery) {
url : '',
'data' : data,
onComplete: function (r) {
r = r.toInt();
this.rating = r;
// leave r as-is, it might be fractional, use for score html, but toInt() for this.rating
this.rating = r.toInt();
Fabrik.loader.stop(ratingDiv);
star.getParent('.fabrikRating').getElement('.ratingScore').set('html', this.rating);
star.getParent('.fabrikRating').getElement('.ratingScore').set('html', r);
var stars = star.getParent('.fabrikRating').getElements('.starRating');
stars.each(function (ii) {
if (r >= this._getRating(ii)) {
Expand Down
20 changes: 10 additions & 10 deletions plugins/fabrik_element/rating/rating.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class PlgFabrik_ElementRating extends PlgFabrik_Element
*
* @var string
*/
protected $fieldDesc = 'TINYINT(%s)';
protected $fieldDesc = 'DECIMAL(3,2)';

/**
* Db table field size
Expand Down Expand Up @@ -452,24 +452,24 @@ public function onAjax_rate()
$rating = $input->getInt('rating');

$this->doRating($listId, $formId, $rowId, $rating);
$this->getRatingAverage('', $listId, $formId, $rowId);

/*
if ($params->get('rating-mode') == 'creator-rating')
/**
* Store in main table (so lists can sort on it, etc). But ... only if it's not a join.
* @TODO - figure out how to do this for joined groups
*/
if (!$this->getGroupModel()->isJoin())
{
// @todo FIX for joins as well
// Store in elements table as well
$db = $listModel->getDb();
$element = $this->getElement();
$query = $db->getQuery(true);
$query->update($list->db_table_name)
->set($element->name . '=' . $rating)->where($list->db_primary_key . ' = ' . $db->q($rowId));
$query->update($db->quoteName($list->db_table_name))
->set($db->quoteName($element->name) . '=' . $db->quote($this->avg))
->where($list->db_primary_key . ' = ' . $db->quote($rowId));
$db->setQuery($query);
$db->execute();
}
*/

$this->getRatingAverage('', $listId, $formId, $rowId);
echo $this->avg;
}

Expand Down
3 changes: 2 additions & 1 deletion plugins/fabrik_form/juser/juser.php
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ public function onAfterProcess()
return;
}

if ($params->get('juser_auto_login', false))
if ($params->get('juser_auto_login', true))
{
$this->autoLogin();
}
Expand Down Expand Up @@ -1014,6 +1014,7 @@ protected function autoLogin()

if ($this->app->login($credentials, $options) === true)
{
$this->app->setUserState('rememberLogin', true);
$this->session->set($context . 'created', true);
$user = JFactory::getUser();

Expand Down

0 comments on commit e4fe96f

Please sign in to comment.