Navigation Menu

Skip to content
This repository has been archived by the owner on Nov 9, 2019. It is now read-only.

Commit

Permalink
enhance search form
Browse files Browse the repository at this point in the history
Fixes #1836.
  • Loading branch information
laufhannes committed May 22, 2016
1 parent 5496abe commit 83c5cff
Show file tree
Hide file tree
Showing 4 changed files with 336 additions and 118 deletions.
2 changes: 1 addition & 1 deletion inc/core/Dataset/Query.php
Expand Up @@ -305,7 +305,7 @@ protected function collectColumnsForKeys(array $keys)
*/
protected function defaultColumns()
{
return array_merge(array('sportid', 'time', 'use_vdot'), $this->AdditionalColumns);
return array_merge(array('sportid', 'time', 'use_vdot', 'is_track'), $this->AdditionalColumns);
}

/**
Expand Down
77 changes: 57 additions & 20 deletions inc/training/search/class.FormularSelectSearchSort.php
Expand Up @@ -3,12 +3,18 @@
* This file contains class::FormularSelectSearchSort
* @package Runalyze\HTML\Formular
*/

use Runalyze\Dataset\Keys;

/**
* Class for a double field for sort value and order
* @author Hannes Christiansen
* @package Runalyze\HTML\Formular
*/
class FormularSelectSearchSort extends FormularField {
/** @var array */
protected $SortByOptions = [];

/**
* Validate value
* @return boolean
Expand All @@ -25,30 +31,61 @@ protected function getFieldCode() {
$code = '<label>'.$this->label.'</label>';
$code .= '<div class="full-size left">';

$sortByOptions = array(
'time' => __('Date'),
'distance' => __('Distance'),
's' => __('Duration'),
'pace' => __('Pace'),
'elevation' => __('Elevation'),
'pulse_avg' => __('avg. Heartrate'),
'pulse_max' => __('max. Heartrate'),
'temperature' => __('Temperature'),
'cadence' => __('Cadence'),
'stride_length' => __('Stride length'),
'groundcontact' => __('Ground contact'),
'vertical_oscillation' => __('Vertical oscillation'),
'vertical_ratio' => __('Vertical ratio'),
'vdot' => __('VDOT'),
'trimp' => __('TRIMP'),
'jd_intensity' => __('JDpoints')
);

$code .= HTML::selectBox('search-sort-by', $sortByOptions);
$this->addOptionsFor([
['time', __('Date')],
Keys::DISTANCE,
Keys::DURATION,
['pace', __('Pace')],
Keys::ELAPSED_TIME,
Keys::ELEVATION,
['gradient', __('Gradient')],
Keys::HEARTRATE_AVG,
Keys::HEARTRATE_MAX,
Keys::TRIMP,
Keys::RPE,
Keys::JD_INTENSITY,
Keys::CALORIES,
Keys::VDOT_VALUE,
Keys::POWER,
Keys::CADENCE,
Keys::STRIDE_LENGTH,
Keys::GROUNDCONTACT,
Keys::GROUNDCONTACT_BALANCE,
Keys::VERTICAL_OSCILLATION,
Keys::VERTICAL_RATIO,
Keys::TOTAL_STROKES,
Keys::SWOLF,
Keys::FIT_VO2MAX_ESTIMATE,
Keys::FIT_RECOVERY_TIME,
Keys::FIT_HRV_ANALYSIS,
Keys::FIT_TRAINING_EFFECT,
Keys::FIT_PERFORMANCE_CONDITION,
Keys::TEMPERATURE,
['wind_speed', __('Wind speed')],
['wind_deg', __('Wind direction')],
Keys::HUMIDITY,
Keys::AIR_PRESSURE
]);

$code .= HTML::selectBox('search-sort-by', $this->SortByOptions);
$code .= HTML::selectBox('search-sort-order', array('DESC' => __('descending'), 'ASC' => __('ascending')));

$code .= '</div>';

return $code;
}

/**
* @param array $keyIds
*/
protected function addOptionsFor(array $keyIds) {
foreach ($keyIds as $keyIdOrArray) {
if (is_array($keyIdOrArray)) {
$this->SortByOptions[$keyIdOrArray[0]] = $keyIdOrArray[1];
} else {
$Key = Keys::get($keyIdOrArray);
$this->SortByOptions[$Key->column()] = $Key->label();
}
}
}
}
59 changes: 39 additions & 20 deletions inc/training/search/class.SearchFormular.php
Expand Up @@ -8,6 +8,8 @@
use Runalyze\Data\Weather\Humidity;
use Runalyze\Data\Weather\WindSpeed;
use Runalyze\Data\Weather\Pressure;
use Runalyze\Dataset;

/**
* Search formular
*
Expand Down Expand Up @@ -157,41 +159,58 @@ protected function initConditions() {
$this->addConditionFieldWithChosen('typeid', 'type', 'name', __('Type'), __('Choose activity type(s)'));
$this->addConditionFieldWithChosen('weatherid', 'weather', 'name', __('Weather'), __('Choose weather conditions'));
$this->addConditionFieldWithChosen('equipmentid', 'equipment', 'name', __('Equipment'), __('Choose equipment'));
$this->addConditionFieldWithChosen('tagid', 'tag', 'tag', __('Tag'), __('Choose tag'));

$this->addConditionFieldWithChosen('tagid', 'tag', 'tag', __('Tag'), __('Choose tag'));

$this->addFieldNotes();

// Currently there's a fixed 3-column layout
// We try to order the fields column-wise, not row-wise
$this->addNumericConditionField('distance', __('Distance'), FormularInput::$SIZE_SMALL, Configuration::General()->distanceUnitSystem()->distanceUnit());
$this->addNumericConditionField('elevation', __('Elevation'), FormularInput::$SIZE_SMALL, Configuration::General()->distanceUnitSystem()->elevationUnit());
$this->addStringConditionField('route', __('Route'), FormularInput::$SIZE_MIDDLE);

$this->addDurationField('s', __('Duration'));
$this->addNumericConditionField('temperature', __('Temperature'), FormularInput::$SIZE_SMALL, Configuration::General()->temperatureUnit()->unit());
$this->addNumericConditionField('humidity', __('Humidity'), FormularInput::$SIZE_SMALL, (new Humidity())->unit());
$this->addNumericConditionField('pressure', __('Pressure'), FormularInput::$SIZE_SMALL, (new Pressure())->unit());
$this->addNumericConditionField('wind_speed', __('Wind Speed'), FormularInput::$SIZE_SMALL, (new WindSpeed())->unit());
$this->addNumericConditionField('gradient', __('Gradient'), FormularInput::$SIZE_SMALL, FormularUnit::$PERCENT);
$this->addStringConditionField('comment', __('Title'), FormularInput::$SIZE_MIDDLE);
$this->addNumericConditionField('pulse_avg', __('avg. HR'), FormularInput::$SIZE_SMALL, FormularUnit::$BPM);
$this->addNumericConditionField('kcal', __('Calories'), FormularInput::$SIZE_SMALL, FormularUnit::$KCAL);
$this->addStringConditionField('partner', __('Partner'), FormularInput::$SIZE_MIDDLE);
$this->addNumericConditionField('pulse_max', __('max. HR'), FormularInput::$SIZE_SMALL, FormularUnit::$BPM);

$this->addNumericConditionField('pace', __('Pace'), FormularInput::$SIZE_SMALL, FormularUnit::$PACE);
$this->addNumericConditionField('cadence', __('Cadence'), FormularInput::$SIZE_SMALL, FormularUnit::$SPM);
$this->addStringConditionField('partner', __('Partner'), FormularInput::$SIZE_MIDDLE);

$this->addNumericConditionField('pulse_avg', __('avg. HR'), FormularInput::$SIZE_SMALL, FormularUnit::$BPM);
$this->addNumericConditionField('stride_length', __('Stride length'), FormularInput::$SIZE_SMALL, Configuration::General()->distanceUnitSystem()->strideLengthUnit());
$this->addBooleanField('is_public', __('Is public'));
$this->addNumericConditionField('jd_intensity', __('JD points'), FormularInput::$SIZE_SMALL);
$this->addNumericConditionField('groundcontact', __('Ground contact'), FormularInput::$SIZE_SMALL, FormularUnit::$MS);
$this->addNumericConditionField('groundcontact_balance', __('Ground Contact Balance'), FormularInput::$SIZE_SMALL, 'L'. FormularUnit::$PERCENT);

$this->addNumericConditionField('pulse_max', __('max. HR'), FormularInput::$SIZE_SMALL, FormularUnit::$BPM);
$this->addNumericConditionFIeld('power', __('Power'), FormularInput::$SIZE_SMALL, FormularUnit::$POWER);
$this->addBooleanField('is_race', __('Is race'));

$this->addNumericConditionField(Configuration::Vdot()->useElevationCorrection() ? 'vdot_with_elevation' : 'vdot', __('VDOT'), FormularInput::$SIZE_SMALL);
$this->addNumericConditionField('vertical_oscillation', __('Vertical oscillation'), FormularInput::$SIZE_SMALL, FormularUnit::$CM);
$this->addNumericConditionField('vertical_ratio', __('Vertical ratio'), FormularInput::$SIZE_SMALL, FormularUnit::$PERCENT);
$this->addNumericConditionField('stride_length', __('Stride length'), FormularInput::$SIZE_SMALL, Configuration::General()->distanceUnitSystem()->strideLengthUnit());
if(Configuration::Vdot()->useElevationCorrection()) {
$this->addNumericConditionField('vdot_with_elevation', __('VDOT'), FormularInput::$SIZE_SMALL);
} else {
$this->addNumericConditionField('vdot', __('VDOT'), FormularInput::$SIZE_SMALL);
}
$this->addBooleanField('use_vdot', __('Uses VDOT'));

$this->addNumericConditionField('trimp', __('TRIMP'), FormularInput::$SIZE_SMALL);
$this->addNumericConditionField('vertical_ratio', __('Vertical ratio'), FormularInput::$SIZE_SMALL, FormularUnit::$PERCENT);
$this->addBooleanField('is_track', __('Track'));

$this->addNumericConditionField('rpe', __('RPE'), FormularInput::$SIZE_SMALL);
$this->addNumericConditionField('groundcontact', __('Ground contact'), FormularInput::$SIZE_SMALL, FormularUnit::$MS);
$this->addNumericConditionField('temperature', __('Temperature'), FormularInput::$SIZE_SMALL, Configuration::General()->temperatureUnit()->unit());

$this->addNumericConditionField('jd_intensity', __('JD points'), FormularInput::$SIZE_SMALL);
$this->addNumericConditionField('groundcontact_balance', __('Ground Contact Balance'), FormularInput::$SIZE_SMALL, 'L'. FormularUnit::$PERCENT);
$this->addNumericConditionField('wind_speed', __('Wind Speed'), FormularInput::$SIZE_SMALL, (new WindSpeed())->unit());

$this->addNumericConditionField('kcal', __('Calories'), FormularInput::$SIZE_SMALL, FormularUnit::$KCAL);
$this->addNumericConditionField('fit_training_effect', __('Training Effect'), FormularInput::$SIZE_SMALL);
$this->addNumericConditionField('humidity', __('Humidity'), FormularInput::$SIZE_SMALL, (new Humidity())->unit());

$this->addNumericConditionField('fit_vdot_estimate', Dataset\Keys::get(Dataset\Keys::FIT_VO2MAX_ESTIMATE)->label(), FormularInput::$SIZE_SMALL);
$this->addNumericConditionField('fit_recovery_time', Dataset\Keys::get(Dataset\Keys::FIT_RECOVERY_TIME)->label(), FormularInput::$SIZE_SMALL);
$this->addNumericConditionField('pressure', __('Pressure'), FormularInput::$SIZE_SMALL, (new Pressure())->unit());

// Currently missing/not supported:
// elapsed_time, fit_hrv_analysis, fit_performance_condition, total_strokes, swolf, wind_deg, is_night
}

/**
Expand Down

0 comments on commit 83c5cff

Please sign in to comment.