From 2a959edeba195b3a9d151aa2b9ae26b54c603856 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 17 Jan 2018 19:18:48 -0800 Subject: [PATCH] Added - Setting to allow archived assets in List All --- app/Http/Controllers/Api/AssetsController.php | 15 ++++++--- app/Http/Controllers/SettingsController.php | 1 + ...17_184354_add_archived_in_list_setting.php | 32 +++++++++++++++++++ resources/lang/en/admin/settings/general.php | 2 ++ resources/views/settings/general.blade.php | 16 ++++++++++ 5 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 database/migrations/2018_01_17_184354_add_archived_in_list_setting.php diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index 0d155bfa1f..4f1716bd58 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -56,6 +56,7 @@ class AssetsController extends Controller { $this->authorize('index', Asset::class); + $settings = Setting::getSettings(); $allowed_columns = [ 'id', @@ -197,11 +198,15 @@ class AssetsController extends Controller $assets->where('assets.assigned_to', '>', '0'); break; default: - // terrible workaround for complex-query Laravel bug in fulltext - $assets->join('status_labels AS status_alias',function ($join) { - $join->on('status_alias.id', "=", "assets.status_id") - ->where('status_alias.archived', '=', 0); - }); + + if ($settings->show_archived_in_list!='1') { + // terrible workaround for complex-query Laravel bug in fulltext + $assets->join('status_labels AS status_alias',function ($join) { + $join->on('status_alias.id', "=", "assets.status_id") + ->where('status_alias.archived', '=', 0); + }); + } + } if (count($filter) > 0) { diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index 543d956ddb..4bc9b7444d 100755 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -316,6 +316,7 @@ class SettingsController extends Controller $setting->full_multiple_companies_support = $request->input('full_multiple_companies_support', '0'); $setting->load_remote = $request->input('load_remote', '0'); + $setting->show_archived_in_list = $request->input('show_archived_in_list', '0'); $setting->email_domain = $request->input('email_domain'); $setting->email_format = $request->input('email_format'); $setting->username_format = $request->input('username_format'); diff --git a/database/migrations/2018_01_17_184354_add_archived_in_list_setting.php b/database/migrations/2018_01_17_184354_add_archived_in_list_setting.php new file mode 100644 index 0000000000..970e218cdc --- /dev/null +++ b/database/migrations/2018_01_17_184354_add_archived_in_list_setting.php @@ -0,0 +1,32 @@ +boolean('show_archived_in_list')->default(0); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('settings', function (Blueprint $table) { + $table->dropColumn('show_archived_in_list'); + }); + } +} diff --git a/resources/lang/en/admin/settings/general.php b/resources/lang/en/admin/settings/general.php index d6b6abbc23..c68e1d3bb6 100644 --- a/resources/lang/en/admin/settings/general.php +++ b/resources/lang/en/admin/settings/general.php @@ -92,6 +92,8 @@ return array( 'setting' => 'Setting', 'settings' => 'Settings', 'show_alerts_in_menu' => 'Show alerts in top menu', + 'show_archived_in_list' => 'Archived Assets', + 'show_archived_in_list_text' => 'Show archived assets in the "all assets" listing', 'site_name' => 'Site Name', 'slack_botname' => 'Slack Botname', 'slack_channel' => 'Slack Channel', diff --git a/resources/views/settings/general.blade.php b/resources/views/settings/general.blade.php index 67ebadeeb8..85a7de45d6 100644 --- a/resources/views/settings/general.blade.php +++ b/resources/views/settings/general.blade.php @@ -199,6 +199,22 @@ + + + +
+
+ {{ Form::label('show_archived_in_list', + trans('admin/settings/general.show_archived_in_list')) }} +
+
+ {{ Form::checkbox('show_archived_in_list', '1', Input::old('show_archived_in_list', $setting->show_archived_in_list),array('class' => 'minimal')) }} + {{ trans('admin/settings/general.show_archived_in_list_text') }} + {!! $errors->first('show_archived_in_list', ':message') !!} + +
+
+