Skip to content

Commit

Permalink
Final issues resolution for Voyager 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
classiebit committed Nov 14, 2019
1 parent 0c1c37f commit 1689caf
Show file tree
Hide file tree
Showing 12 changed files with 803 additions and 392 deletions.
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "classiebit/eventmie",
"version": "1.0.5",
"version": "1.0.6",
"description": "Eventmie Lite",
"keywords": [
"eventmie-lite",
Expand All @@ -24,9 +24,8 @@
}
],
"require": {
"intervention/image": "*",
"tightenco/ziggy": "*",
"tcg/voyager": "*"
"tightenco/ziggy": "~0.8",
"tcg/voyager": "~1.3"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion publishable/assets/css/app.css

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions resources/sass/_rtl.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[dir=rtl] .brand-name,
[dir=rtl] .brand-slogan {
left: unset;
right: 90px;
}
[dir=rtl] .lgx-nav-right.navbar-right {
float: left !important;
}
[dir=rtl] .nav.navbar-nav.lgx-nav.navbar-right {
float: left !important;
margin-left: 25px !important;
}
1 change: 1 addition & 0 deletions resources/sass/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@
@import "milestone";
@import "breadcrumb";
@import "pagination";
@import "rtl";
180 changes: 128 additions & 52 deletions resources/views/vendor/voyager/bookings/browse.blade.php

Large diffs are not rendered by default.

165 changes: 131 additions & 34 deletions resources/views/vendor/voyager/contacts/browse.blade.php

Large diffs are not rendered by default.

506 changes: 293 additions & 213 deletions resources/views/vendor/voyager/events/browse.blade.php

Large diffs are not rendered by default.

68 changes: 57 additions & 11 deletions resources/views/vendor/voyager/settings/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@
margin-bottom: 10px;
cursor: pointer;
z-index: 9;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.new-setting-btn {
Expand Down Expand Up @@ -240,12 +245,35 @@
@foreach($settings as $group => $group_settings)
<div id="{{ \Illuminate\Support\Str::slug($group) }}" class="tab-pane fade in @if($group == $active) active @endif">
@foreach($group_settings as $setting)
{{-- Info for Google Callback --}}
@if($setting->key == 'apps.google_client_id')
<br>
<div class="alert alert-info">
Set Callback URL on your Google App Dashboard - <code>{{ route('eventmie.google_callback') }}</code>
</div>
@endif

{{-- Info for Facebook Callback --}}
@if($setting->key == 'apps.facebook_app_id')
<br>
<div class="alert alert-info">
Set Callback URL on your Facebook App Dashboard - <code>{{ route('eventmie.facebook_callback') }}</code>
</div>
@endif

{{-- Info for PayPal Callback --}}
@if($setting->key == 'apps.paypal_client_id')
<br>
<div class="alert alert-info">
Set Callback URL on your PayPal Dashboard - <code>{{ route('eventmie.bookings_paypal_callback') }}</code>
</div>
@endif

<div class="panel-heading">
<h3 class="panel-title">
{{ $setting->display_name }} @if(config('voyager.show_dev_tips'))<code>setting('{{ $setting->key }}')</code>@endif
</h3>

@if (config('voyager.pkg_dev_mode'))
<div class="panel-actions">
<a href="{{ route('voyager.settings.move_up', $setting->id) }}">
Expand All @@ -254,10 +282,12 @@
<a href="{{ route('voyager.settings.move_down', $setting->id) }}">
<i class="sort-icons voyager-sort-desc"></i>
</a>
@can('delete', Voyager::model('Setting'))
<i class="voyager-trash"
data-id="{{ $setting->id }}"
data-display-key="{{ $setting->key }}"
data-display-name="{{ $setting->display_name }}"></i>
@endcan
</div>
@endif

Expand All @@ -278,16 +308,24 @@
@elseif($setting->type == "image" || $setting->type == "file")
@if(isset( $setting->value ) && !empty( $setting->value ) && Storage::disk(config('voyager.storage.disk'))->exists($setting->value))
<div class="img_settings_container">

@if (config('voyager.pkg_dev_mode'))
<a href="{{ route('voyager.settings.delete_value', $setting->id) }}" class="voyager-x delete_value"></a>
@endif

<img src="{{ Storage::disk(config('voyager.storage.disk'))->url($setting->value) }}" style="width:10%; height:auto; padding:2px; border:1px solid #ddd; margin-bottom:10px;">
<img src="{{ Storage::disk(config('voyager.storage.disk'))->url($setting->value) }}" style="width:200px; height:auto; padding:2px; border:1px solid #ddd; margin-bottom:10px;">
</div>
<div class="clearfix"></div>
@elseif($setting->type == "file" && isset( $setting->value ))
<div class="fileType">{{ $setting->value }}</div>
@if(json_decode($setting->value) !== null)
@foreach(json_decode($setting->value) as $file)
<div class="fileType">
<a class="fileType" target="_blank" href="{{ Storage::disk(config('voyager.storage.disk'))->url($file->download_link) }}">
{{ $file->original_name }}
</a>
<a href="{{ route('voyager.settings.delete_value', $setting->id) }}" class="voyager-x delete_value"></a>
</div>
@endforeach
@endif
@endif
<input type="file" name="{{ $setting->key }}">
@elseif($setting->type == "select_dropdown")
Expand Down Expand Up @@ -328,19 +366,24 @@
@endif
@endif
</div>

@if (config('voyager.pkg_dev_mode'))
<div class="col-md-2 no-padding-left-right">
@if(config('voyager.pkg_dev_mode'))
<select class="form-control group_select" name="{{ $setting->key }}_group">
@foreach($groups as $group)
<option value="{{ $group }}" {!! $setting->group == $group ? 'selected' : '' !!}>{{ $group }}</option>
@endforeach
</select>
</div>
@endif
@else
@foreach($groups as $group)
@if($setting->group == $group)
<input type="hidden" name="{{ $setting->key }}_group" value="{{ $group }}">
@endif
@endforeach
</select>
@endif

</div>
</div>

@if(!$loop->last)
<hr>
@endif
Expand All @@ -355,7 +398,6 @@
</form>

<div style="clear:both"></div>

@if (config('voyager.pkg_dev_mode'))
@can('add', Voyager::model('Setting'))
<div class="panel" style="margin-top:10px;">
Expand Down Expand Up @@ -422,6 +464,7 @@
@endif
</div>

@can('delete', Voyager::model('Setting'))
<div class="modal modal-danger fade" tabindex="-1" id="delete_modal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
Expand All @@ -444,6 +487,7 @@
</div>
</div>
</div>
@endcan

@stop

Expand All @@ -459,6 +503,7 @@
}
});
@can('delete', Voyager::model('Setting'))
$('.panel-actions .voyager-trash').click(function () {
var display = $(this).data('display-name') + '/' + $(this).data('display-key');
Expand All @@ -467,6 +512,7 @@
$('#delete_form')[0].action = '{{ route('voyager.settings.delete', [ 'id' => '__id' ]) }}'.replace('__id', $(this).data('id'));
$('#delete_modal').modal('show');
});
@endcan
$('.toggleswitch').bootstrapToggle();
Expand Down
101 changes: 67 additions & 34 deletions src/Http/Controllers/Voyager/BookingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use TCG\Voyager\Facades\Voyager;
use TCG\Voyager\Http\Controllers\Traits\BreadRelationshipParser;
use Illuminate\Http\RedirectResponse;

use Auth;


Expand Down Expand Up @@ -61,25 +60,27 @@ public function index(Request $request)
// GET THE DataType based on the slug
$dataType = Voyager::model('DataType')->where('slug', '=', $slug)->first();

// Check permission
$this->authorize('browse', app($dataType->model_name));

$getter = $dataType->server_side ? 'paginate' : 'get';

$search = (object) ['value' => $request->get('s'), 'key' => $request->get('key'), 'filter' => $request->get('filter')];
$searchable = $dataType->server_side ? array_keys(SchemaManager::describeTable(app($dataType->model_name)->getTable())->toArray()) : '';

$searchNames = [];
if ($dataType->server_side) {
$searchable = SchemaManager::describeTable(app($dataType->model_name)->getTable())->pluck('name')->toArray();
$dataRow = Voyager::model('DataRow')->whereDataTypeId($dataType->id)->get();
foreach ($searchable as $key => $value) {
$displayName = $dataRow->where('field', $value)->first()->getTranslatedAttribute('display_name');
$searchNames[$value] = $displayName ?: ucwords(str_replace('_', ' ', $value));
}
}

$orderBy = $request->get('order_by', $dataType->order_column);
$sortOrder = $request->get('sort_order', null);
$usesSoftDeletes = false;
$showSoftDeleted = false;
$orderColumn = [];
if ($orderBy) {
$index = $dataType->browseRows->where('field', $orderBy)->keys()->first() + 1;
$orderColumn = [[$index, 'desc']];
if (!$sortOrder && isset($dataType->order_direction)) {
$sortOrder = $dataType->order_direction;
$orderColumn = [[$index, $dataType->order_direction]];
} else {
$orderColumn = [[$index, 'desc']];
}
}

// Next Get or Paginate the actual content from the MODEL that corresponds to the slug DataType
if (strlen($dataType->model_name) != 0) {
Expand Down Expand Up @@ -141,48 +142,75 @@ public function index(Request $request)
// Check if a default search key is set
$defaultSearchKey = $dataType->default_search_key ?? null;


// Actions
$actions = [];
if (!empty($dataTypeContent->first())) {
foreach (Voyager::actions() as $action) {
$action = new $action($dataType, $dataTypeContent->first());

if ($action->shouldActionDisplayOnDataType()) {
$actions[] = $action;
}
}
}

// Define showCheckboxColumn
$showCheckboxColumn = false;
if (Auth::user()->can('delete', app($dataType->model_name))) {
$showCheckboxColumn = true;
} else {
foreach ($actions as $action) {
if (method_exists($action, 'massAction')) {
$showCheckboxColumn = true;
}
}
}

// Define orderColumn
$orderColumn = [];
if ($orderBy) {
$index = $dataType->browseRows->where('field', $orderBy)->keys()->first() + ($showCheckboxColumn ? 1 : 0);
$orderColumn = [[$index, 'desc']];
if (!$sortOrder && isset($dataType->order_direction)) {
$sortOrder = $dataType->order_direction;
$orderColumn = [[$index, $dataType->order_direction]];
} else {
$orderColumn = [[$index, 'desc']];
}
}

$view = 'eventmie::vendor.voyager.bookings.browse';

return Eventmie::view($view, compact(
'actions',
'dataType',
'dataTypeContent',
'isModelTranslatable',
'search',
'orderBy',
'orderColumn',
'sortOrder',
'searchable',
'searchNames',
'isServerSide',
'defaultSearchKey',
'usesSoftDeletes',
'showSoftDeleted'
'showSoftDeleted',
'showCheckboxColumn'
));
}

//***************************************
// ______
// | ____|
// | |__
// | __|
// | |____
// |______|
//
// Edit an item of our Data Type BR(E)AD
//
//****************************************



// POST BR(E)AD
public function update(Request $request, $id)
{
$slug = $this->getSlug($request);

$dataType = Voyager::model('DataType')->where('slug', '=', $slug)->first();

// Compatibility with Model binding.
$id = $id instanceof Model ? $id->{$id->getKeyName()} : $id;
$id = $id instanceof \Illuminate\Database\Eloquent\Model ? $id->{$id->getKeyName()} : $id;

$model = app($dataType->model_name);
if ($dataType->scope && $dataType->scope != '' && method_exists($model, 'scope'.ucfirst($dataType->scope))) {
Expand All @@ -193,7 +221,7 @@ public function update(Request $request, $id)
} else {
$data = call_user_func([$dataType->model_name, 'findOrFail'], $id);
}

// Check permission
$this->authorize('edit', $data);

Expand All @@ -203,12 +231,17 @@ public function update(Request $request, $id)

event(new BreadDataUpdated($dataType, $data));

return redirect()
->route("voyager.{$dataType->slug}.index")
->with([
'message' => __('voyager::generic.successfully_updated')." {$dataType->display_name_singular}",
if (auth()->user()->can('browse', $model)) {
$redirect = redirect()->route("voyager.{$dataType->slug}.index");
} else {
$redirect = redirect()->back();
}

return $redirect->with([
'message' => __('voyager::generic.successfully_updated')." {$dataType->getTranslatedAttribute('display_name_singular')}",
'alert-type' => 'success',
]);

}


Expand Down
Loading

0 comments on commit 1689caf

Please sign in to comment.