Skip to content

Commit 69acc27

Browse files
committed
Merge branch 'features/whiteboards' into develop
# Conflicts: # app/Models/OrganisationMember.php # app/Services/Campaign/Import/Mappers/EntityMapper.php # public/build/assets/family-tree-vue-C8D0cfy6.js # public/build/assets/family-tree-vue-UYH4NCmq.js # public/build/assets/family-tree-vue-oLSglbqg.js # public/build/manifest.json
2 parents d587970 + 85e12d1 commit 69acc27

156 files changed

Lines changed: 3343 additions & 388 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace App\Datagrids\Filters;
4+
5+
use App\Facades\Module;
6+
7+
class WhiteboardFilter extends DatagridFilter
8+
{
9+
/**
10+
* Filters available for timelines
11+
*/
12+
public function build()
13+
{
14+
$name = Module::singular(config('entities.ids.whiteboard'));
15+
$placeholder = __('crud.placeholders.whiteboard');
16+
if (! empty($name)) {
17+
$placeholder = __('crud.placeholders.fallback', ['module' => $name]);
18+
}
19+
$this
20+
->add('name')
21+
->add('type')
22+
->isPrivate()
23+
->template()
24+
->hasImage()
25+
->hasEntityFiles()
26+
->hasAttributes()
27+
->tags()
28+
->attributes()
29+
->connections();
30+
}
31+
}

app/Http/Controllers/Campaign/SidebarController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function index(Campaign $campaign)
2727
'campaigns.sidebar.index',
2828
compact(
2929
'campaign',
30-
'layout'
30+
'layout',
3131
)
3232
);
3333
}

app/Http/Controllers/Search/LiveController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ public function index(Request $request, Campaign $campaign)
3434
if ($request->has('posts')) {
3535
$this->searchService->posts()->new();
3636
}
37+
if ($request->has('thumb')) {
38+
$size = min(max($request->get('thumb'), 64), 512);
39+
$this->searchService->thumb($size);
40+
}
3741

3842
$this->searchService
3943
->term($term)
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Whiteboards;
4+
5+
use App\Datagrids\Filters\WhiteboardFilter;
6+
use App\Http\Controllers\CrudController as BaseCrudController;
7+
use App\Http\Requests\StoreWhiteboard;
8+
use App\Models\Campaign;
9+
use App\Models\EntityType;
10+
use App\Models\Whiteboard;
11+
12+
class CrudController extends BaseCrudController
13+
{
14+
protected string $view = 'whiteboards';
15+
16+
protected string $route = 'whiteboards';
17+
18+
protected string $model = Whiteboard::class;
19+
20+
protected string $filter = WhiteboardFilter::class;
21+
22+
protected string $module = 'whiteboards';
23+
24+
public function create(Campaign $campaign)
25+
{
26+
if (! $campaign->isWyvernPremium()) {
27+
return view('whiteboards.cta')
28+
->with('campaign', $campaign);
29+
}
30+
31+
return $this->campaign($campaign)->crudCreate();
32+
}
33+
34+
public function store(StoreWhiteboard $request, Campaign $campaign)
35+
{
36+
if (! $campaign->isWyvernPremium()) {
37+
return view('whiteboards.cta')
38+
->with('campaign', $campaign);
39+
}
40+
41+
return $this->campaign($campaign)->crudStore($request);
42+
}
43+
44+
/**
45+
* Display the specified resource.
46+
*/
47+
public function show(Campaign $campaign, Whiteboard $whiteboard)
48+
{
49+
return $this->campaign($campaign)->crudShow($whiteboard);
50+
}
51+
52+
/**
53+
* Show the form for editing the specified resource.
54+
*/
55+
public function edit(Campaign $campaign, Whiteboard $whiteboard)
56+
{
57+
return $this->campaign($campaign)->crudEdit($whiteboard);
58+
}
59+
60+
/**
61+
* Update the specified resource in storage.
62+
*/
63+
public function update(StoreWhiteboard $request, Campaign $campaign, Whiteboard $whiteboard)
64+
{
65+
return $this->campaign($campaign)->crudUpdate($request, $whiteboard);
66+
}
67+
68+
/**
69+
* Remove the specified resource from storage.
70+
*/
71+
public function destroy(Campaign $campaign, Whiteboard $whiteboard)
72+
{
73+
return $this->campaign($campaign)->crudDestroy($whiteboard);
74+
}
75+
76+
protected function getEntityType(): EntityType
77+
{
78+
return EntityType::where('id', config('entities.ids.whiteboard'))->first();
79+
}
80+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Whiteboards;
4+
5+
use App\Http\Controllers\Controller;
6+
use App\Http\Requests\Whiteboards\UpdateRequest;
7+
use App\Models\Campaign;
8+
use App\Models\Whiteboard;
9+
use App\Services\Whiteboards\ApiService;
10+
use App\Traits\CampaignAware;
11+
use App\Traits\GuestAuthTrait;
12+
13+
class DrawController extends Controller
14+
{
15+
use CampaignAware;
16+
use GuestAuthTrait;
17+
18+
public function __construct(protected ApiService $apiService) {}
19+
20+
public function show(Campaign $campaign, Whiteboard $whiteboard)
21+
{
22+
$this->campaign($campaign)->authEntityView($whiteboard->entity);
23+
24+
return view('whiteboards.draw', compact('campaign', 'whiteboard'));
25+
}
26+
27+
public function api(Campaign $campaign, Whiteboard $whiteboard)
28+
{
29+
$this->campaign($campaign)->authEntityView($whiteboard->entity);
30+
31+
return response()->json(
32+
$this->apiService->campaign($campaign)->whiteboard($whiteboard)->load()
33+
);
34+
}
35+
36+
public function save(UpdateRequest $request, Campaign $campaign, Whiteboard $whiteboard)
37+
{
38+
$this->authorize('view', $campaign);
39+
$this->authorize('update', $whiteboard->entity);
40+
41+
$whiteboard->update($request->only('data'));
42+
43+
return response()->json([
44+
'success' => true,
45+
'toast' => __('whiteboards.update.success'),
46+
]);
47+
}
48+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
namespace App\Http\Requests;
4+
5+
use App\Traits\ApiRequest;
6+
use Illuminate\Foundation\Http\FormRequest;
7+
8+
class StoreWhiteboard extends FormRequest
9+
{
10+
use ApiRequest;
11+
12+
/**
13+
* Determine if the user is authorized to make this request.
14+
*
15+
* @return bool
16+
*/
17+
public function authorize()
18+
{
19+
return true;
20+
}
21+
22+
/**
23+
* Get the validation rules that apply to the request.
24+
*
25+
* @return array
26+
*/
27+
public function rules()
28+
{
29+
$rules = [
30+
'name' => 'required|max:191',
31+
'type' => 'nullable|string|max:45',
32+
'entity_image_uuid' => 'nullable|exists:images,id',
33+
'entity_header_uuid' => 'nullable|exists:images,id',
34+
'template_id' => 'nullable',
35+
];
36+
37+
return $this->clean($rules);
38+
}
39+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace App\Http\Requests\Whiteboards;
4+
5+
use App\Models\Whiteboard;
6+
use Illuminate\Foundation\Http\FormRequest;
7+
8+
class CreateRequest extends FormRequest
9+
{
10+
/**
11+
* Determine if the user is authorized to make this request.
12+
*/
13+
public function authorize(): bool
14+
{
15+
return $this->user()->can('create', Whiteboard::class);
16+
}
17+
18+
/**
19+
* Get the validation rules that apply to the request.
20+
*
21+
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
22+
*/
23+
public function rules(): array
24+
{
25+
return [
26+
'name' => 'required|string|max:255',
27+
'data' => 'required',
28+
];
29+
}
30+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace App\Http\Requests\Whiteboards;
4+
5+
use Illuminate\Foundation\Http\FormRequest;
6+
7+
class UpdateRequest extends FormRequest
8+
{
9+
/**
10+
* Determine if the user is authorized to make this request.
11+
*/
12+
public function authorize(): bool
13+
{
14+
return $this->user()->can('update', $this->whiteboard->entity);
15+
}
16+
17+
/**
18+
* Get the validation rules that apply to the request.
19+
*
20+
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
21+
*/
22+
public function rules(): array
23+
{
24+
return [
25+
'name' => 'required|string|max:255',
26+
'data' => 'nullable|array',
27+
];
28+
}
29+
}

app/Models/Ability.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@ class Ability extends MiscModel
6464
'ability_id',
6565
];
6666

67-
/**
68-
* Entity type
69-
*/
70-
protected string $entityType = 'ability';
71-
7267
protected array $exportFields = [
7368
'base',
7469
'charges',

app/Models/AttributeTemplate.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ class AttributeTemplate extends MiscModel
3737
'is_enabled',
3838
];
3939

40-
/**
41-
* Entity type
42-
*/
43-
protected string $entityType = 'attribute_template';
44-
4540
/**
4641
* Searchable fields
4742
*/

0 commit comments

Comments
 (0)