Skip to content

Commit ef8d5ff

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents 91f3e07 + f42fcd2 commit ef8d5ff

File tree

4 files changed

+122
-36
lines changed

4 files changed

+122
-36
lines changed

app/Http/Requests/SaveUserRequest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ public function response(array $errors)
3333
public function rules()
3434
{
3535
$rules = [
36-
'department_id' => 'nullable|exists:departments,id',
36+
'department_id' => 'nullable|integer|exists:departments,id',
3737
'manager_id' => 'nullable|exists:users,id',
38-
'company_id' => ['nullable','exists:companies,id']
38+
'company_id' => ['nullable', 'integer', 'exists:companies,id']
3939
];
4040

4141
switch ($this->method()) {

resources/views/locations/view.blade.php

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,42 @@
157157

158158

159159
<div class="tab-content">
160-
<div class="tab-pane active" id="users">
160+
161+
<div class="tab-pane active" id="assets">
162+
<h2 class="box-title">{{ trans('admin/locations/message.current_location') }}</h2>
163+
164+
<div class="table table-responsive">
165+
@include('partials.asset-bulk-actions')
166+
<table
167+
data-columns="{{ \App\Presenters\AssetPresenter::dataTableLayout() }}"
168+
data-cookie-id-table="assetsListingTable"
169+
data-pagination="true"
170+
data-id-table="assetsListingTable"
171+
data-search="true"
172+
data-side-pagination="server"
173+
data-show-columns="true"
174+
data-show-export="true"
175+
data-show-refresh="true"
176+
data-sort-order="asc"
177+
data-toolbar="#assetsBulkEditToolbar"
178+
data-bulk-button-id="#bulkAssetEditButton"
179+
data-bulk-form-id="#assetsBulkForm"
180+
data-click-to-select="true"
181+
id="assetsListingTable"
182+
class="table table-striped snipe-table"
183+
data-url="{{route('api.assets.index', ['location_id' => $location->id]) }}"
184+
data-export-options='{
185+
"fileName": "export-locations-{{ str_slug($location->name) }}-assets-{{ date('Y-m-d') }}",
186+
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
187+
}'>
188+
</table>
189+
190+
</div><!-- /.table-responsive -->
191+
</div><!-- /.tab-pane -->
192+
193+
194+
195+
<div class="tab-pane" id="users">
161196
<h2 class="box-title">{{ trans('general.users') }}</h2>
162197
<div class="table table-responsive">
163198
@include('partials.users-bulk-actions')
@@ -188,37 +223,6 @@ class="table table-striped snipe-table"
188223
</div><!-- /.table-responsive -->
189224
</div><!-- /.tab-pane -->
190225

191-
<div class="tab-pane" id="assets">
192-
<h2 class="box-title">{{ trans('admin/locations/message.current_location') }}</h2>
193-
194-
<div class="table table-responsive">
195-
@include('partials.asset-bulk-actions')
196-
<table
197-
data-columns="{{ \App\Presenters\AssetPresenter::dataTableLayout() }}"
198-
data-cookie-id-table="assetsListingTable"
199-
data-pagination="true"
200-
data-id-table="assetsListingTable"
201-
data-search="true"
202-
data-side-pagination="server"
203-
data-show-columns="true"
204-
data-show-export="true"
205-
data-show-refresh="true"
206-
data-sort-order="asc"
207-
data-toolbar="#assetsBulkEditToolbar"
208-
data-bulk-button-id="#bulkAssetEditButton"
209-
data-bulk-form-id="#assetsBulkForm"
210-
data-click-to-select="true"
211-
id="assetsListingTable"
212-
class="table table-striped snipe-table"
213-
data-url="{{route('api.assets.index', ['location_id' => $location->id]) }}"
214-
data-export-options='{
215-
"fileName": "export-locations-{{ str_slug($location->name) }}-assets-{{ date('Y-m-d') }}",
216-
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
217-
}'>
218-
</table>
219-
220-
</div><!-- /.table-responsive -->
221-
</div><!-- /.tab-pane -->
222226

223227
<div class="tab-pane" id="assets_assigned">
224228
<h2 class="box-title">

resources/views/reports/custom.blade.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,11 @@ class="form-control select2"
627627
>
628628
<option></option>
629629
@foreach($report_templates as $savedTemplate)
630-
<option value="{{ $savedTemplate->id }}" @selected($savedTemplate->is(request()->route()->parameter('reportTemplate')))>
630+
<option
631+
value="{{ $savedTemplate->id }}"
632+
data-route="{{ route('report-templates.show', $savedTemplate->id) }}"
633+
@selected($savedTemplate->is(request()->route()->parameter('reportTemplate')))
634+
>
631635
{{ $savedTemplate->name }}
632636
</option>
633637
@endforeach
@@ -774,7 +778,7 @@ class="form-control"
774778
775779
$('#saved_report_select')
776780
.on('select2:select', function (event) {
777-
window.location.href = '/reports/templates/' + event.params.data.id;
781+
window.location.href = event.params.data.element.dataset.route;
778782
});
779783
780784
$('#dataConfirmModal').on('show.bs.modal', function (event) {
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
3+
namespace Tests\Feature\Users\Api;
4+
5+
use App\Models\Company;
6+
use App\Models\Department;
7+
use App\Models\User;
8+
use Illuminate\Testing\Fluent\AssertableJson;
9+
use Tests\TestCase;
10+
11+
class StoreUsersTest extends TestCase
12+
{
13+
public function testRequiresPermission()
14+
{
15+
$this->actingAsForApi(User::factory()->create())
16+
->postJson(route('api.users.store'), [
17+
'first_name' => 'Joe',
18+
'username' => 'joe',
19+
'password' => 'joe_password',
20+
'password_confirmation' => 'joe_password',
21+
])
22+
->assertForbidden();
23+
}
24+
25+
public function testCompanyIdNeedsToBeInteger()
26+
{
27+
$company = Company::factory()->create();
28+
29+
$this->actingAsForApi(User::factory()->createUsers()->create())
30+
->postJson(route('api.users.store'), [
31+
'company_id' => [$company->id],
32+
'first_name' => 'Joe',
33+
'username' => 'joe',
34+
'password' => 'joe_password',
35+
'password_confirmation' => 'joe_password',
36+
])
37+
->assertStatusMessageIs('error')
38+
->assertJson(function (AssertableJson $json) {
39+
$json->has('messages.company_id')->etc();
40+
});
41+
}
42+
43+
public function testDepartmentIdNeedsToBeInteger()
44+
{
45+
$department = Department::factory()->create();
46+
47+
$this->actingAsForApi(User::factory()->createUsers()->create())
48+
->postJson(route('api.users.store'), [
49+
'department_id' => [$department->id],
50+
'first_name' => 'Joe',
51+
'username' => 'joe',
52+
'password' => 'joe_password',
53+
'password_confirmation' => 'joe_password',
54+
])
55+
->assertStatusMessageIs('error')
56+
->assertJson(function (AssertableJson $json) {
57+
$json->has('messages.department_id')->etc();
58+
});
59+
}
60+
61+
public function testCanStoreUser()
62+
{
63+
$this->actingAsForApi(User::factory()->createUsers()->create())
64+
->postJson(route('api.users.store'), [
65+
'first_name' => 'Darth',
66+
'username' => 'darthvader',
67+
'password' => 'darth_password',
68+
'password_confirmation' => 'darth_password',
69+
])
70+
->assertStatusMessageIs('success')
71+
->assertOk();
72+
73+
$this->assertDatabaseHas('users', [
74+
'first_name' => 'Darth',
75+
'username' => 'darthvader',
76+
]);
77+
}
78+
}

0 commit comments

Comments
 (0)