More minor fixes (#3126)

* Update composer phpcs

* Minor Fixes found while working.
ALlow user_id to be nullable in category model validation

Point to the correct route in accessoriespresenter datatable.  Also add name() method

Add a translated category name

Fix typo in translation

* Add a method to the asset presenter to show deployed when asset is deployed.  Fixes #3114
This commit is contained in:
Daniel Meltzer 2017-01-03 18:55:43 -06:00 committed by snipe
parent f999c797e5
commit 816d2fd095
8 changed files with 43 additions and 33 deletions

View file

@ -28,7 +28,7 @@ class Category extends SnipeModel
* Category validation rules
*/
public $rules = array(
'user_id' => 'numeric',
'user_id' => 'numeric|nullable',
'name' => 'required|min:1|max:255|unique_undeleted',
'category_type' => 'required',
);

View file

@ -116,7 +116,7 @@ class AccessoryPresenter extends Presenter
);
}
if (Gate::allows('update', $this->model)) {
$actions .= Helper::generateDatatableButton('edit', route('accessories.update', $this->id));
$actions .= Helper::generateDatatableButton('edit', route('accessories.edit', $this->id));
}
if (Gate::allows('delete', $this->model)) {
$actions .= Helper::generateDatatableButton(
@ -167,4 +167,9 @@ class AccessoryPresenter extends Presenter
{
return route('accessories.show', $this->id);
}
public function name()
{
return $this->model->name;
}
}

View file

@ -20,7 +20,6 @@ class AssetPresenter extends Presenter
*/
public function forDataTable($all_custom_fields)
{
// Actions
$inout = '';
@ -80,15 +79,12 @@ class AssetPresenter extends Presenter
$results['model_number'] = $this->model->model_number;
$results['category'] = $this->categoryUrl();
$results['manufacturer'] = $this->manufacturerUrl();
$results['status_label'] = '';
$results['assigned_to'] = '';
if($assigned = $this->model->assignedTo) {
$results['status_label'] = 'Deployed';
if ($assigned = $this->model->assignedTo) {
$results['assigned_to'] = $assigned->present()->glyph() . ' ' . $assigned->present()->nameUrl();
} else if($this->model->assetstatus) {
$results['status_label'] = $this->model->assetstatus->name;
}
$results['status_label'] = $this->statusText();
$results['location'] = '';
if (isset($assigned) and !empty($assignedLoc = $this->model->assetLoc)) {
$results['location'] = $assignedLoc->present()->nameUrl();
@ -249,6 +245,13 @@ class AssetPresenter extends Presenter
return $interval;
}
public function statusText()
{
if ($this->model->assignedTo) {
return trans('general.deployed');
}
return $this->model->assetstatus->name;
}
/**
* Date the warantee expires.
* @return false|string

45
composer.lock generated
View file

@ -4,21 +4,21 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "a6f845a1b9e14f61c4e525868db1ec95",
"hash": "09c9f9ab068ae672a965656f1591be6d",
"content-hash": "275081182145ff404e84b759d8f166b5",
"packages": [
{
"name": "aws/aws-sdk-php",
"version": "3.20.11",
"version": "3.20.12",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "39d122b903813da2f53312fd3146acaa83a6d9f6"
"reference": "8725e67cb77b057b55596b4468ce9a1a95c5fe96"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/39d122b903813da2f53312fd3146acaa83a6d9f6",
"reference": "39d122b903813da2f53312fd3146acaa83a6d9f6",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/8725e67cb77b057b55596b4468ce9a1a95c5fe96",
"reference": "8725e67cb77b057b55596b4468ce9a1a95c5fe96",
"shasum": ""
},
"require": {
@ -85,7 +85,7 @@
"s3",
"sdk"
],
"time": "2016-12-22 20:47:16"
"time": "2016-12-30 00:41:36"
},
{
"name": "aws/aws-sdk-php-laravel",
@ -340,16 +340,16 @@
},
{
"name": "doctrine/annotations",
"version": "v1.3.0",
"version": "v1.3.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine/annotations.git",
"reference": "30e07cf03edc3cd3ef579d0dd4dd8c58250799a5"
"reference": "bd4461328621bde0ae6b1b2675fbc6aca4ceb558"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/annotations/zipball/30e07cf03edc3cd3ef579d0dd4dd8c58250799a5",
"reference": "30e07cf03edc3cd3ef579d0dd4dd8c58250799a5",
"url": "https://api.github.com/repos/doctrine/annotations/zipball/bd4461328621bde0ae6b1b2675fbc6aca4ceb558",
"reference": "bd4461328621bde0ae6b1b2675fbc6aca4ceb558",
"shasum": ""
},
"require": {
@ -404,7 +404,7 @@
"docblock",
"parser"
],
"time": "2016-10-24 11:45:47"
"time": "2016-12-30 15:59:45"
},
{
"name": "doctrine/cache",
@ -2920,23 +2920,24 @@
},
{
"name": "swiftmailer/swiftmailer",
"version": "v5.4.4",
"version": "v5.4.5",
"source": {
"type": "git",
"url": "https://github.com/swiftmailer/swiftmailer.git",
"reference": "545ce9136690cea74f98f86fbb9c92dd9ab1a756"
"reference": "cd142238a339459b10da3d8234220963f392540c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/545ce9136690cea74f98f86fbb9c92dd9ab1a756",
"reference": "545ce9136690cea74f98f86fbb9c92dd9ab1a756",
"url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/cd142238a339459b10da3d8234220963f392540c",
"reference": "cd142238a339459b10da3d8234220963f392540c",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"mockery/mockery": "~0.9.1"
"mockery/mockery": "~0.9.1",
"symfony/phpunit-bridge": "~3.2"
},
"type": "library",
"extra": {
@ -2969,7 +2970,7 @@
"mail",
"mailer"
],
"time": "2016-11-24 01:01:23"
"time": "2016-12-29 10:02:40"
},
{
"name": "symfony/console",
@ -4908,16 +4909,16 @@
},
{
"name": "phpunit/phpunit",
"version": "5.7.4",
"version": "5.7.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "af91da3f2671006ff5d0628023de3b7ac4d1ef09"
"reference": "50fd2be8f3e23e91da825f36f08e5f9633076ffe"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/af91da3f2671006ff5d0628023de3b7ac4d1ef09",
"reference": "af91da3f2671006ff5d0628023de3b7ac4d1ef09",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/50fd2be8f3e23e91da825f36f08e5f9633076ffe",
"reference": "50fd2be8f3e23e91da825f36f08e5f9633076ffe",
"shasum": ""
},
"require": {
@ -4986,7 +4987,7 @@
"testing",
"xunit"
],
"time": "2016-12-13 16:19:44"
"time": "2016-12-28 07:18:51"
},
{
"name": "phpunit/phpunit-mock-objects",

View file

@ -10,7 +10,7 @@
"jquery": "^3.1.0",
"laravel-elixir": "^6.0.0-11",
"laravel-elixir-codeception-standalone": "^0.1.0",
"laravel-elixir-phpcs": "^0.6.1",
"laravel-elixir-phpcs": "^1.0.0-4",
"laravel-elixir-vue-2": "^0.2.0",
"laravel-elixir-webpack-official": "^1.0.2",
"lodash": "^4.16.2",

View file

@ -11,6 +11,7 @@ return array(
'edit' => 'Edit Category',
'eula_text' => 'Category EULA',
'eula_text_help' => 'This field allows you to customize your EULAs for specific types of assets. If you only have one EULA for all of your assets, you can check the box below to use the primary default.',
'name' => 'Category Name',
'require_acceptance' => 'Require users to confirm acceptance of assets in this category.',
'required_acceptance' => 'This user will be emailed with a link to confirm acceptance of this item.',
'required_eula' => 'This user will be emailed a copy of the EULA',

View file

@ -8,7 +8,7 @@
@section('inputFields')
@include ('partials.forms.edit.name', ['translated_name' => trans('admin/categories/general.`name')])
@include ('partials.forms.edit.name', ['translated_name' => trans('admin/categories/general.name')])
<!-- Type -->
<div class="form-group {{ $errors->has('category_type') ? ' has-error' : '' }}">

View file

@ -74,7 +74,7 @@
&nbsp; &nbsp;</span>
</span>
@endif
{{ $asset->assetstatus->name }}
{{ $asset->present()->statusText() }}
({{ $asset->assetstatus->getStatuslabelType() }})
</td>