Fixed #5138 - added default_label flag to status labels

This commit is contained in:
snipe 2018-03-05 22:04:16 -08:00
parent d05dfb18a7
commit 1e22b8e567
8 changed files with 49 additions and 3 deletions

View file

@ -235,7 +235,7 @@ class Helper
*/ */
public static function statusLabelList() 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(); ->pluck('name', 'id')->toArray();
return $statuslabel_list; return $statuslabel_list;
} }

View file

@ -22,7 +22,7 @@ class StatuslabelsController extends Controller
public function index(Request $request) public function index(Request $request)
{ {
$this->authorize('view', Statuslabel::class); $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'); $statuslabels = Statuslabel::withCount('assets');

View file

@ -93,9 +93,9 @@ class StatuslabelsController extends Controller
$statusLabel->archived = $statusType['archived']; $statusLabel->archived = $statusType['archived'];
$statusLabel->color = Input::get('color'); $statusLabel->color = Input::get('color');
$statusLabel->show_in_nav = Input::get('show_in_nav', 0); $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()) { if ($statusLabel->save()) {
// Redirect to the new Statuslabel page // Redirect to the new Statuslabel page
return redirect()->route('statuslabels.index')->with('success', trans('admin/statuslabels/message.create.success')); 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->archived = $statustype['archived'];
$statuslabel->color = Input::get('color'); $statuslabel->color = Input::get('color');
$statuslabel->show_in_nav = Input::get('show_in_nav', 0); $statuslabel->show_in_nav = Input::get('show_in_nav', 0);
$statuslabel->default_label = Input::get('default_label', 0);
// Was the asset created? // Was the asset created?

View file

@ -26,6 +26,7 @@ class StatuslabelsTransformer
'type' => $statuslabel->getStatuslabelType(), 'type' => $statuslabel->getStatuslabelType(),
'color' => ($statuslabel->color) ? e($statuslabel->color) : null, 'color' => ($statuslabel->color) ? e($statuslabel->color) : null,
'show_in_nav' => ($statuslabel->show_in_nav=='1') ? true : false, 'show_in_nav' => ($statuslabel->show_in_nav=='1') ? true : false,
'default_label' => ($statuslabel->default_label =='1') ? true : false,
'assets_count' => (int) $statuslabel->assets_count, 'assets_count' => (int) $statuslabel->assets_count,
'notes' => e($statuslabel->notes), 'notes' => e($statuslabel->notes),
'created_at' => Helper::getFormattedDateObject($statuslabel->created_at, 'datetime'), 'created_at' => Helper::getFormattedDateObject($statuslabel->created_at, 'datetime'),

View file

@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddDefaultFlagOnStatuslabels extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('status_labels', function (Blueprint $table) {
$table->boolean('default_label')->default(0);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('status_labels', function (Blueprint $table) {
$table->dropColumn('default_label');
});
}
}

View file

@ -5,6 +5,8 @@ return array(
'archived' => 'Archived', 'archived' => 'Archived',
'create' => 'Create Status Label', 'create' => 'Create Status Label',
'color' => 'Chart Color', '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', '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.', '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', 'name' => 'Status Name',

View file

@ -53,6 +53,15 @@
</label> </label>
</div> </div>
<!-- Set as Default -->
<div class="form-group{{ $errors->has('default_label') ? ' has-error' : '' }}">
<label class="col-md-offset-3" style="padding-left: 15px;">
<input type="checkbox" value="1" name="default_label" id="default_label" class="minimal" {{ Input::old('default_label', $item->default_label) == '1' ? ' checked="checked"' : '' }}> {{ trans('admin/statuslabels/table.default_label') }}
</label>
<p class="col-md-offset-3 help-block"> {{ trans('admin/statuslabels/table.default_label_help') }}</p>
</div>
@stop @stop
@section('moar_scripts') @section('moar_scripts')

View file

@ -48,6 +48,7 @@
<th data-sortable="true" data-field="assets_count">{{ trans('general.assets') }}</th> <th data-sortable="true" data-field="assets_count">{{ trans('general.assets') }}</th>
<th data-sortable="true" data-field="color" data-formatter="colorSqFormatter">{{ trans('admin/statuslabels/table.color') }}</th> <th data-sortable="true" data-field="color" data-formatter="colorSqFormatter">{{ trans('admin/statuslabels/table.color') }}</th>
<th class="text-center" data-sortable="true" data-field="show_in_nav" data-formatter="trueFalseFormatter">{{ trans('admin/statuslabels/table.show_in_nav') }}</th> <th class="text-center" data-sortable="true" data-field="show_in_nav" data-formatter="trueFalseFormatter">{{ trans('admin/statuslabels/table.show_in_nav') }}</th>
<th class="text-center" data-sortable="true" data-field="default_label" data-formatter="trueFalseFormatter">{{ trans('admin/statuslabels/table.default_label') }}</th>
<th data-formatter="statuslabelsActionsFormatter" data-searchable="false" data-sortable="false" data-field="actions">{{ trans('table.actions') }}</th> <th data-formatter="statuslabelsActionsFormatter" data-searchable="false" data-sortable="false" data-field="actions">{{ trans('table.actions') }}</th>
</tr> </tr>
</thead> </thead>