diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index e92f25a2ca..6b0f0f98a3 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -235,7 +235,7 @@ class Helper */ public static function statusLabelList() { - $statuslabel_list = array('' => trans('general.select_statuslabel')) + Statuslabel::orderBy('deployable', 'desc') + $statuslabel_list = array('' => trans('general.select_statuslabel')) + Statuslabel::orderBy('default_label', 'desc')->orderBy('name','asc')->orderBy('deployable','desc') ->pluck('name', 'id')->toArray(); return $statuslabel_list; } diff --git a/app/Http/Controllers/Api/StatuslabelsController.php b/app/Http/Controllers/Api/StatuslabelsController.php index a3c698fa7c..ed6b9e21d5 100644 --- a/app/Http/Controllers/Api/StatuslabelsController.php +++ b/app/Http/Controllers/Api/StatuslabelsController.php @@ -22,7 +22,7 @@ class StatuslabelsController extends Controller public function index(Request $request) { $this->authorize('view', Statuslabel::class); - $allowed_columns = ['id','name','created_at', 'assets_count','color']; + $allowed_columns = ['id','name','created_at', 'assets_count','color','default_label']; $statuslabels = Statuslabel::withCount('assets'); diff --git a/app/Http/Controllers/StatuslabelsController.php b/app/Http/Controllers/StatuslabelsController.php index 1a9b772dd9..a264dd77f7 100755 --- a/app/Http/Controllers/StatuslabelsController.php +++ b/app/Http/Controllers/StatuslabelsController.php @@ -93,9 +93,9 @@ class StatuslabelsController extends Controller $statusLabel->archived = $statusType['archived']; $statusLabel->color = Input::get('color'); $statusLabel->show_in_nav = Input::get('show_in_nav', 0); + $statusLabel->default_label = Input::get('default_label', 0); - // Was the asset created? if ($statusLabel->save()) { // Redirect to the new Statuslabel page return redirect()->route('statuslabels.index')->with('success', trans('admin/statuslabels/message.create.success')); @@ -185,6 +185,7 @@ class StatuslabelsController extends Controller $statuslabel->archived = $statustype['archived']; $statuslabel->color = Input::get('color'); $statuslabel->show_in_nav = Input::get('show_in_nav', 0); + $statuslabel->default_label = Input::get('default_label', 0); // Was the asset created? diff --git a/app/Http/Transformers/StatuslabelsTransformer.php b/app/Http/Transformers/StatuslabelsTransformer.php index e7b356deb2..f1a5460531 100644 --- a/app/Http/Transformers/StatuslabelsTransformer.php +++ b/app/Http/Transformers/StatuslabelsTransformer.php @@ -26,6 +26,7 @@ class StatuslabelsTransformer 'type' => $statuslabel->getStatuslabelType(), 'color' => ($statuslabel->color) ? e($statuslabel->color) : null, 'show_in_nav' => ($statuslabel->show_in_nav=='1') ? true : false, + 'default_label' => ($statuslabel->default_label =='1') ? true : false, 'assets_count' => (int) $statuslabel->assets_count, 'notes' => e($statuslabel->notes), 'created_at' => Helper::getFormattedDateObject($statuslabel->created_at, 'datetime'), diff --git a/database/migrations/2018_03_06_054937_add_default_flag_on_statuslabels.php b/database/migrations/2018_03_06_054937_add_default_flag_on_statuslabels.php new file mode 100644 index 0000000000..54a62bd770 --- /dev/null +++ b/database/migrations/2018_03_06_054937_add_default_flag_on_statuslabels.php @@ -0,0 +1,32 @@ +boolean('default_label')->default(0); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('status_labels', function (Blueprint $table) { + $table->dropColumn('default_label'); + }); + } +} diff --git a/resources/lang/en/admin/statuslabels/table.php b/resources/lang/en/admin/statuslabels/table.php index b9b5b7ec4e..27befb5ef7 100644 --- a/resources/lang/en/admin/statuslabels/table.php +++ b/resources/lang/en/admin/statuslabels/table.php @@ -5,6 +5,8 @@ return array( 'archived' => 'Archived', 'create' => 'Create Status Label', 'color' => 'Chart Color', + 'default_label' => 'Default Label', + 'default_label_help' => 'This is used to ensure your most commonly used status labels appear at the top of the select box when creating/editing assets.', 'deployable' => 'Deployable', 'info' => 'Status labels are used to describe the various states your assets could be in. They may be out for repair, lost/stolen, etc. You can create new status labels for deployable, pending and archived assets.', 'name' => 'Status Name', diff --git a/resources/views/statuslabels/edit.blade.php b/resources/views/statuslabels/edit.blade.php index 158a43a853..67774a4093 100755 --- a/resources/views/statuslabels/edit.blade.php +++ b/resources/views/statuslabels/edit.blade.php @@ -53,6 +53,15 @@ + +
{{ trans('admin/statuslabels/table.default_label_help') }}
+