Fix validation of metric thresholds. Closes #3549

This commit is contained in:
James Brooks
2019-06-23 08:35:55 +01:00
parent 76e9f41e55
commit 2efbaebe63
2 changed files with 2 additions and 12 deletions

View File

@@ -45,8 +45,7 @@ class MetricController extends Controller
public function showAddMetric() public function showAddMetric()
{ {
return View::make('dashboard.metrics.add') return View::make('dashboard.metrics.add')
->withPageTitle(trans('dashboard.metrics.add.title').' - '.trans('dashboard.dashboard')) ->withPageTitle(trans('dashboard.metrics.add.title').' - '.trans('dashboard.dashboard'));
->withAcceptableThresholds(Metric::ACCEPTABLE_THRESHOLDS);
} }
/** /**
@@ -132,8 +131,7 @@ class MetricController extends Controller
{ {
return View::make('dashboard.metrics.edit') return View::make('dashboard.metrics.edit')
->withPageTitle(trans('dashboard.metrics.edit.title').' - '.trans('dashboard.dashboard')) ->withPageTitle(trans('dashboard.metrics.edit.title').' - '.trans('dashboard.dashboard'))
->withMetric($metric) ->withMetric($metric);
->withAcceptableThresholds(Metric::ACCEPTABLE_THRESHOLDS);
} }
/** /**

View File

@@ -62,13 +62,6 @@ class Metric extends Model implements HasPresenter
*/ */
const VISIBLE_HIDDEN = 2; const VISIBLE_HIDDEN = 2;
/**
* Array of acceptable threshold minutes.
*
* @var int[]
*/
const ACCEPTABLE_THRESHOLDS = [1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60];
/** /**
* The model's attributes. * The model's attributes.
* *
@@ -134,7 +127,6 @@ class Metric extends Model implements HasPresenter
'default_value' => 'required|numeric', 'default_value' => 'required|numeric',
'places' => 'required|numeric|between:0,4', 'places' => 'required|numeric|between:0,4',
'default_view' => 'required|numeric|between:0,3', 'default_view' => 'required|numeric|between:0,3',
'threshold' => 'required|numeric|between:0,10',
'visible' => 'required|numeric|between:0,2', 'visible' => 'required|numeric|between:0,2',
]; ];