Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to display company names to labels #4405

Merged
merged 11 commits into from
Nov 9, 2017

Conversation

madd15
Copy link
Contributor

@madd15 madd15 commented Nov 9, 2017

Feature Request #4374

This PR will add an option in the labels settings page to show the company name on the asset labels when they are generated. The company name will not shown if the asset has the company_id set to NULL or 0 even if the option is enabled.

As always open to feedback and any changes needed.

@madd15 madd15 requested a review from snipe as a code owner November 9, 2017 02:22
Copy link
Owner

@snipe snipe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few small comments here - it looks worse than it is, I promise :D

@@ -118,6 +118,11 @@
<br>
@endif
</div>
<div class="pull-left">
@if (($settings->labels_display_company_name=='1') && ($asset->company_id!='0') && (!(is_null($asset->company_id))) && (\App\Models\Company::find($asset->company_id)->name!=''))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we maybe just do something like:

@if (($settings->labels_display_company_name=='1') && ($asset->company))

?

If the company isn't valid or if the asset doesn't have one, that should (I'd think) all be covered there.

@@ -179,6 +179,10 @@
{{ Form::checkbox('labels_display_tag', '1', Input::old('labels_display_tag', $setting->labels_display_tag),array('class' => 'minimal')) }}
{{ trans('admin/hardware/form.tag') }}
</label>
<label>
{{ Form::checkbox('labels_display_company_name', '1', Input::old('labels_display_company_name', $setting->labels_display_company_name),array('class' => 'minimal')) }}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nitpicky, but can you use the square brace array notation, just to keep it consistent with other blades?

 {{ Form::checkbox('labels_display_company_name', '1', Input::old('labels_display_company_name',   $setting->labels_display_company_name),['class' => 'minimal']) }}

@@ -11,6 +11,7 @@
'checkout_date' => 'Checkout Date',
'checkin_date' => 'Checkin Date',
'checkout_to' => 'Checkout to',
'company_name' => 'Company Name',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to create a new string here (that all those poor bastards have to translate). We have "Company Name" in admin/companies/table.name

$setting->labels_display_company_name = 1;
} else {
$setting->labels_display_company_name = 0;
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few small (again, nitpicky) things here:

  1. We've been switching over to the more modern $request->input('foo') (or in this case, $request->has('foo')) notation (instead of the older Input::get() facade) for request data (and this method already passes it as part of the signature)

  2. For something small like this, I usually like to keep the annotation simpler, like:

$setting->labels_display_company_name = $request->input('labels_display_company_name', '0');

We don't really need all the if/else business, we just need to tell the code to take the value if there is one submitted, and if not set the value to 0.

public function up()
{
Schema::table('settings', function (Blueprint $table) {
$table->tinyInteger('labels_display_company_name')->default(0);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better to make this is boolean?

$table->boolean('labels_display_company_name')->default(0);

@madd15
Copy link
Contributor Author

madd15 commented Nov 9, 2017

I think I have covered all changes, plus I made the square brace change on all the Form:: arrays

@if (($settings->labels_display_company_name=='1') && ($asset->company))
C: {{ $asset->company->name }}
@endif
</div>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more thing - do we want the empty divs if company support isn't enabled on labels? Maybe:

@if (($settings->labels_display_company_name=='1') && ($asset->company))
<div class="pull-left">
     C: {{ $asset->company->name }}
</div>
@endif

I'm honestly not sure - the labels are pretty cramped anyway, so I'm guessing we wouldn't want it, but def open to discussion.

@madd15
Copy link
Contributor Author

madd15 commented Nov 9, 2017

@snipe all right all changed

@snipe snipe merged commit 172c7c7 into snipe:develop Nov 9, 2017
@snipe
Copy link
Owner

snipe commented Nov 9, 2017

Nice, thanks!
cat juggle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants