diff --git a/app/controllers/SiteController.php b/app/controllers/SiteController.php index c992021ec6..bf0ef74a4b 100644 --- a/app/controllers/SiteController.php +++ b/app/controllers/SiteController.php @@ -119,14 +119,12 @@ public function getGraphData(){ */ public function lrs(){ $opts = ['user' => \Auth::user()]; - $lrs = $this->lrs->index($opts); - if ($lrs) { - foreach ($lrs as $l) { - $l->statement_total = $this->statement->count($l->_id); - } - } - return Response::json($lrs); - + $lrss = $this->lrs->index($opts); + + return Response::json(array_map(function ($lrs) { + $lrs->statement_total = $this->statement->count($lrs->_id); + return $lrs; + }, $lrss)); } public function apps() { diff --git a/app/locker/repository/Lrs/EloquentRepository.php b/app/locker/repository/Lrs/EloquentRepository.php index 62f85acbc9..c963ad0a21 100644 --- a/app/locker/repository/Lrs/EloquentRepository.php +++ b/app/locker/repository/Lrs/EloquentRepository.php @@ -56,14 +56,13 @@ protected function validateData(array $data) { * @return Model */ protected function constructStore(Model $model, array $data, array $opts) { - \Auth::user(); // Merges and validates data with defaults. $data = array_merge(array_merge($this->defaults, $data), [ 'api' => [ 'basic_key' => Helpers::getRandomValue(), 'basic_secret' => Helpers::getRandomValue() ], - 'owner' => [['_id'] => $opts['user']->_id], + 'owner' => ['_id' => $opts['user']->_id], 'users' => [[ '_id' => $opts['user']->_id, 'email' => $opts['user']->email, @@ -80,7 +79,7 @@ protected function constructStore(Model $model, array $data, array $opts) { $model->owner = $data['owner']; $model->users = $data['users']; - Event::fire('user.create_lrs', array('user' => $user)); + Event::fire('user.create_lrs', ['user' => $opts['user']]); return $model; } @@ -109,13 +108,25 @@ protected function constructUpdate(Model $model, array $data, array $opts) { */ public function index(array $opts) { if ($opts['user']->role === 'super') { - return parent::index($opts); + $query = $this->where($opts); + } else { + $query = $this->where('users._id', $opts['user']->_id)->remember(10); } - $query = $this->where('users._id', $opts['user']->_id)->remember(10); - return $query->get()->each(function (Model $model) { + $obj_result = $query->get()->sortBy(function (Model $model) { + return strtolower($model->title); + })->each(function (Model $model) { return $this->format($model); }); + + // Annoying hack to convert stupid Laravel collection object to an array + // WITHOUT converting the models to associative arrays!!! + $result = []; + foreach ($obj_result->getIterator() as $model) { + $result[] = $model; + } + + return $result; } /** diff --git a/public/assets/css/app.css b/public/assets/css/app.css index 0887e09ee4..7de60d8d23 100644 --- a/public/assets/css/app.css +++ b/public/assets/css/app.css @@ -210,7 +210,6 @@ table.break-words td, table.break-words th { max-width: 100%; } - /* Bootstrap extensions (note: looks like we're not using LESS?) --------------------------------------------------------------*/ @media(max-width: 480px){ @@ -219,6 +218,14 @@ table.break-words td, table.break-words th { } } +@media(min-width: 768px) { + .nav .dropdown-menu { + max-height: 400px; + overflow-y: scroll; + overflow-x: hidden; + } +} +