Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' of https://github.com/microweber/microweber into dev
# Conflicts: # src/MicroweberPackages/Product/resources/views/admin/product/livewire/table-filters/tags.blade.php
- Loading branch information
Showing
90 changed files
with
2,162 additions
and
945 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 139 additions & 0 deletions
139
src/MicroweberPackages/Admin/Http/Livewire/AutoCompleteComponent.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
<?php | ||
|
||
namespace MicroweberPackages\Admin\Http\Livewire; | ||
|
||
use Livewire\Component; | ||
|
||
class AutoCompleteComponent extends Component | ||
{ | ||
/** | ||
* The eloquent laravel model | ||
* @var | ||
*/ | ||
public $model; | ||
|
||
/** | ||
* Selected item when we have single selection autocomplete | ||
* @var string | ||
*/ | ||
public $selectedItem; | ||
|
||
/** | ||
* Selected item key when we fire a event with key and value | ||
* @var string | ||
*/ | ||
public $selectedItemKey = 'auto_complete_id'; | ||
|
||
/** | ||
* The model query | ||
* @var | ||
*/ | ||
public $query; | ||
|
||
/** | ||
* Sended data to view | ||
* @var | ||
*/ | ||
public $data; | ||
|
||
/** | ||
* Show/Hide dropdown on view | ||
* @var bool | ||
*/ | ||
public $showDropdown = false; | ||
|
||
|
||
/** | ||
* Default view of single selection autocomplete | ||
* @var string | ||
*/ | ||
public string $view = 'admin::livewire.auto-complete'; | ||
|
||
|
||
/** | ||
* Placeholder text on ui | ||
* @var string | ||
*/ | ||
public string $placeholder = 'Type to search...'; | ||
|
||
/** | ||
* Searching text on ui | ||
* @var string | ||
*/ | ||
public string $searchingText = 'Searching...'; | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function mount() | ||
{ | ||
if ($this->selectedItem) { | ||
$this->refreshQueryData(); | ||
} | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function updatedQuery() | ||
{ | ||
$this->selectedItem = false; | ||
$this->refreshQueryData(); | ||
} | ||
|
||
/** | ||
* Set your model query logic to search results | ||
* @return void | ||
*/ | ||
public function refreshQueryData() | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function closeDropdown() | ||
{ | ||
$this->showDropdown = false; | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function showDropdown() | ||
{ | ||
$this->showDropdown = true; | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function resetProperties() | ||
{ | ||
$this->query = ''; | ||
$this->data = false; | ||
} | ||
|
||
/** | ||
* When we apply a one selection item | ||
* @param string $item | ||
* @return void | ||
*/ | ||
public function selectItem(string $item) | ||
{ | ||
$this->selectedItem = $item; | ||
$this->refreshQueryData(); | ||
$this->emitSelf('$refresh'); | ||
|
||
$this->emit('autoCompleteSelectItem', $this->selectedItemKey, $this->selectedItem); | ||
} | ||
|
||
/** | ||
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View | ||
*/ | ||
public function render() | ||
{ | ||
return view($this->view); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/MicroweberPackages/Admin/Http/Livewire/AutoCompleteMultipleItemsComponent.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace MicroweberPackages\Admin\Http\Livewire; | ||
|
||
|
||
class AutoCompleteMultipleItemsComponent extends AutoCompleteComponent | ||
{ | ||
/** | ||
* Array of multiple selected items | ||
* @var array | ||
*/ | ||
public $selectedItems = []; | ||
|
||
/** | ||
* Default view of multiple selection autocomplete | ||
* @var string | ||
*/ | ||
public string $view = 'admin::livewire.auto-complete-multiple-items'; | ||
|
||
/** | ||
* When we apply a multiple selections | ||
* @param $items | ||
* @return void | ||
*/ | ||
public function updatedSelectedItems($items) | ||
{ | ||
$this->refreshQueryData(); | ||
$this->emitSelf('$refresh'); | ||
$this->emit('autoCompleteSelectItem', $this->selectedItemKey, $this->selectedItems); | ||
$this->closeDropdown(); | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
src/MicroweberPackages/Admin/Http/Livewire/TagsAutoComplete.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace MicroweberPackages\Admin\Http\Livewire; | ||
|
||
use MicroweberPackages\Tag\Model\Tag; | ||
|
||
class TagsAutoComplete extends AutoCompleteMultipleItemsComponent | ||
{ | ||
public $model = Tag::class; | ||
public $selectedItemKey = 'tags'; | ||
public string $placeholder = 'Type to search tags...'; | ||
|
||
public function refreshQueryData() | ||
{ | ||
$this->closeDropdown(); | ||
|
||
$query = $this->model::query(); | ||
|
||
$keyword = trim($this->query); | ||
|
||
if (!empty($keyword)) { | ||
$query->where('slug', 'like', '%' . $keyword . '%'); | ||
$query->orWhere('name', 'like', '%' . $keyword . '%'); | ||
} | ||
|
||
$query->limit(30); | ||
|
||
$get = $query->get(); | ||
|
||
if ($get != null) { | ||
$this->showDropdown(); | ||
$this->data = []; | ||
foreach ($get as $item) { | ||
$this->data[] = ['key'=>$item->slug, 'value'=>$item->name]; | ||
} | ||
} | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/MicroweberPackages/Admin/Http/Livewire/UsersAutoComplete.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace MicroweberPackages\Admin\Http\Livewire; | ||
|
||
use MicroweberPackages\User\Models\User; | ||
|
||
class UsersAutoComplete extends AutoCompleteComponent | ||
{ | ||
public $model = User::class; | ||
public $selectedItemKey = 'userId'; | ||
public string $placeholder = 'Type to search users...'; | ||
|
||
public function refreshQueryData() | ||
{ | ||
$this->closeDropdown(); | ||
|
||
$query = $this->model::query(); | ||
|
||
if ($this->selectedItem > 0) { | ||
$query->where('id', $this->selectedItem); | ||
$query->limit(1); | ||
$get = $query->first(); | ||
if ($get != null) { | ||
$this->data = []; | ||
$this->showDropdown = true; | ||
$this->query = $get->displayName() . ' (#'.$get->id.')'; | ||
} | ||
return; | ||
} | ||
|
||
$keyword = trim($this->query); | ||
|
||
if (!empty($keyword)) { | ||
$query->where('first_name', 'like', '%' . $keyword . '%'); | ||
$query->orWhere('last_name', 'like', '%' . $keyword . '%'); | ||
$query->orWhere('email', 'like', '%' . $keyword . '%'); | ||
} | ||
|
||
$query->limit(200); | ||
|
||
$get = $query->get(); | ||
|
||
if ($get != null) { | ||
$this->showDropdown(); | ||
$this->data = []; | ||
foreach ($get as $item) { | ||
$this->data[] = ['key'=>$item->id, 'value'=>$item->displayName() . ' (#'.$item->id.')']; | ||
} | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/MicroweberPackages/Admin/resources/views/livewire/auto-complete-multiple-items.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<div class=""> | ||
<input class="form-control" | ||
type="search" | ||
wire:model.debounce.500ms="query" | ||
wire:keydown.escape="resetProperties" | ||
wire:keydown.enter="refreshQueryData" | ||
wire:click="refreshQueryData" | ||
wire:blur="closeDropdown" | ||
|
||
placeholder="{{$placeholder}}"> | ||
|
||
<div wire:loading wire:target="query"> | ||
{{$searchingText}} | ||
</div> | ||
|
||
@if($showDropdown) | ||
<ul class="list-group position-absolute" style="z-index: 200;max-height: 300px;overflow-x:hidden; overflow-y: scroll;"> | ||
@if(!empty($data)) | ||
@foreach($data as $item) | ||
<li class="list-group-item list-group-item-action cursor-pointer"> | ||
<input class="form-check-input me-1" type="checkbox" wire:model="selectedItems" value="{{ $item['key'] }}" id="checkbox-{{ $item['key'] }}"> | ||
<label class="form-check-label stretched-link" for="checkbox-{{ $item['key'] }}">{{ $item['value'] }}</label> | ||
</li> | ||
@endforeach | ||
@endif | ||
</ul> | ||
@endif | ||
|
||
</div> |
28 changes: 28 additions & 0 deletions
28
src/MicroweberPackages/Admin/resources/views/livewire/auto-complete.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<div class=""> | ||
<input class="form-control" | ||
type="search" | ||
wire:model.debounce.500ms="query" | ||
wire:keydown.escape="resetProperties" | ||
wire:keydown.enter="refreshQueryData" | ||
wire:click="refreshQueryData" | ||
wire:blur="closeDropdown" | ||
|
||
placeholder="{{$placeholder}}"> | ||
|
||
<div wire:loading wire:target="query"> | ||
{{$searchingText}} | ||
</div> | ||
|
||
@if($showDropdown) | ||
<ul class="list-group position-absolute" style="z-index: 200;max-height: 300px;overflow-x:hidden; overflow-y: scroll;"> | ||
@if(!empty($data)) | ||
@foreach($data as $item) | ||
<li class="list-group-item list-group-item-action cursor-pointer" wire:click="selectItem('{{$item['key']}}')"> | ||
{{ $item['value'] }} | ||
</li> | ||
@endforeach | ||
@endif | ||
</ul> | ||
@endif | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.