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 * Category validation rules
*/ */
public $rules = array( public $rules = array(
'user_id' => 'numeric', 'user_id' => 'numeric|nullable',
'name' => 'required|min:1|max:255|unique_undeleted', 'name' => 'required|min:1|max:255|unique_undeleted',
'category_type' => 'required', 'category_type' => 'required',
); );

View file

@ -116,7 +116,7 @@ class AccessoryPresenter extends Presenter
); );
} }
if (Gate::allows('update', $this->model)) { 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)) { if (Gate::allows('delete', $this->model)) {
$actions .= Helper::generateDatatableButton( $actions .= Helper::generateDatatableButton(
@ -167,4 +167,9 @@ class AccessoryPresenter extends Presenter
{ {
return route('accessories.show', $this->id); 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) public function forDataTable($all_custom_fields)
{ {
// Actions // Actions
$inout = ''; $inout = '';
@ -80,15 +79,12 @@ class AssetPresenter extends Presenter
$results['model_number'] = $this->model->model_number; $results['model_number'] = $this->model->model_number;
$results['category'] = $this->categoryUrl(); $results['category'] = $this->categoryUrl();
$results['manufacturer'] = $this->manufacturerUrl(); $results['manufacturer'] = $this->manufacturerUrl();
$results['status_label'] = ''; $results['status_label'] = '';
$results['assigned_to'] = ''; $results['assigned_to'] = '';
if($assigned = $this->model->assignedTo) { if ($assigned = $this->model->assignedTo) {
$results['status_label'] = 'Deployed';
$results['assigned_to'] = $assigned->present()->glyph() . ' ' . $assigned->present()->nameUrl(); $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'] = ''; $results['location'] = '';
if (isset($assigned) and !empty($assignedLoc = $this->model->assetLoc)) { if (isset($assigned) and !empty($assignedLoc = $this->model->assetLoc)) {
$results['location'] = $assignedLoc->present()->nameUrl(); $results['location'] = $assignedLoc->present()->nameUrl();
@ -249,6 +245,13 @@ class AssetPresenter extends Presenter
return $interval; return $interval;
} }
public function statusText()
{
if ($this->model->assignedTo) {
return trans('general.deployed');
}
return $this->model->assetstatus->name;
}
/** /**
* Date the warantee expires. * Date the warantee expires.
* @return false|string * @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", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"hash": "a6f845a1b9e14f61c4e525868db1ec95", "hash": "09c9f9ab068ae672a965656f1591be6d",
"content-hash": "275081182145ff404e84b759d8f166b5", "content-hash": "275081182145ff404e84b759d8f166b5",
"packages": [ "packages": [
{ {
"name": "aws/aws-sdk-php", "name": "aws/aws-sdk-php",
"version": "3.20.11", "version": "3.20.12",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/aws/aws-sdk-php.git", "url": "https://github.com/aws/aws-sdk-php.git",
"reference": "39d122b903813da2f53312fd3146acaa83a6d9f6" "reference": "8725e67cb77b057b55596b4468ce9a1a95c5fe96"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/39d122b903813da2f53312fd3146acaa83a6d9f6", "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/8725e67cb77b057b55596b4468ce9a1a95c5fe96",
"reference": "39d122b903813da2f53312fd3146acaa83a6d9f6", "reference": "8725e67cb77b057b55596b4468ce9a1a95c5fe96",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -85,7 +85,7 @@
"s3", "s3",
"sdk" "sdk"
], ],
"time": "2016-12-22 20:47:16" "time": "2016-12-30 00:41:36"
}, },
{ {
"name": "aws/aws-sdk-php-laravel", "name": "aws/aws-sdk-php-laravel",
@ -340,16 +340,16 @@
}, },
{ {
"name": "doctrine/annotations", "name": "doctrine/annotations",
"version": "v1.3.0", "version": "v1.3.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/annotations.git", "url": "https://github.com/doctrine/annotations.git",
"reference": "30e07cf03edc3cd3ef579d0dd4dd8c58250799a5" "reference": "bd4461328621bde0ae6b1b2675fbc6aca4ceb558"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/annotations/zipball/30e07cf03edc3cd3ef579d0dd4dd8c58250799a5", "url": "https://api.github.com/repos/doctrine/annotations/zipball/bd4461328621bde0ae6b1b2675fbc6aca4ceb558",
"reference": "30e07cf03edc3cd3ef579d0dd4dd8c58250799a5", "reference": "bd4461328621bde0ae6b1b2675fbc6aca4ceb558",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -404,7 +404,7 @@
"docblock", "docblock",
"parser" "parser"
], ],
"time": "2016-10-24 11:45:47" "time": "2016-12-30 15:59:45"
}, },
{ {
"name": "doctrine/cache", "name": "doctrine/cache",
@ -2920,23 +2920,24 @@
}, },
{ {
"name": "swiftmailer/swiftmailer", "name": "swiftmailer/swiftmailer",
"version": "v5.4.4", "version": "v5.4.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/swiftmailer/swiftmailer.git", "url": "https://github.com/swiftmailer/swiftmailer.git",
"reference": "545ce9136690cea74f98f86fbb9c92dd9ab1a756" "reference": "cd142238a339459b10da3d8234220963f392540c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/545ce9136690cea74f98f86fbb9c92dd9ab1a756", "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/cd142238a339459b10da3d8234220963f392540c",
"reference": "545ce9136690cea74f98f86fbb9c92dd9ab1a756", "reference": "cd142238a339459b10da3d8234220963f392540c",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.3" "php": ">=5.3.3"
}, },
"require-dev": { "require-dev": {
"mockery/mockery": "~0.9.1" "mockery/mockery": "~0.9.1",
"symfony/phpunit-bridge": "~3.2"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
@ -2969,7 +2970,7 @@
"mail", "mail",
"mailer" "mailer"
], ],
"time": "2016-11-24 01:01:23" "time": "2016-12-29 10:02:40"
}, },
{ {
"name": "symfony/console", "name": "symfony/console",
@ -4908,16 +4909,16 @@
}, },
{ {
"name": "phpunit/phpunit", "name": "phpunit/phpunit",
"version": "5.7.4", "version": "5.7.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git", "url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "af91da3f2671006ff5d0628023de3b7ac4d1ef09" "reference": "50fd2be8f3e23e91da825f36f08e5f9633076ffe"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/af91da3f2671006ff5d0628023de3b7ac4d1ef09", "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/50fd2be8f3e23e91da825f36f08e5f9633076ffe",
"reference": "af91da3f2671006ff5d0628023de3b7ac4d1ef09", "reference": "50fd2be8f3e23e91da825f36f08e5f9633076ffe",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -4986,7 +4987,7 @@
"testing", "testing",
"xunit" "xunit"
], ],
"time": "2016-12-13 16:19:44" "time": "2016-12-28 07:18:51"
}, },
{ {
"name": "phpunit/phpunit-mock-objects", "name": "phpunit/phpunit-mock-objects",

View file

@ -10,7 +10,7 @@
"jquery": "^3.1.0", "jquery": "^3.1.0",
"laravel-elixir": "^6.0.0-11", "laravel-elixir": "^6.0.0-11",
"laravel-elixir-codeception-standalone": "^0.1.0", "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-vue-2": "^0.2.0",
"laravel-elixir-webpack-official": "^1.0.2", "laravel-elixir-webpack-official": "^1.0.2",
"lodash": "^4.16.2", "lodash": "^4.16.2",

View file

@ -11,6 +11,7 @@ return array(
'edit' => 'Edit Category', 'edit' => 'Edit Category',
'eula_text' => 'Category EULA', '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.', '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.', '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_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', 'required_eula' => 'This user will be emailed a copy of the EULA',

View file

@ -8,7 +8,7 @@
@section('inputFields') @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 --> <!-- Type -->
<div class="form-group {{ $errors->has('category_type') ? ' has-error' : '' }}"> <div class="form-group {{ $errors->has('category_type') ? ' has-error' : '' }}">

View file

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