All Projects → ziffmedia → nova-select-plus

ziffmedia / nova-select-plus

Licence: MIT license
A Laravel Nova Select Field

Programming Languages

PHP
23972 projects - #3 most used programming language
Vue
7211 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to nova-select-plus

select
Vue-based selsect component
Stars: ✭ 14 (-79.1%)
Mutual labels:  select, vue-select
Vue Select
Everything you wish the HTML <select> element could do, wrapped up into a lightweight, extensible Vue component.
Stars: ✭ 4,115 (+6041.79%)
Mutual labels:  select, vue-select
react-multi-select-component
Lightweight (~5KB gzipped) multiple selection dropdown component
Stars: ✭ 279 (+316.42%)
Mutual labels:  select, multiselect
React Selectrix
A beautiful, materialized and flexible React Select control
Stars: ✭ 166 (+147.76%)
Mutual labels:  multiselect, ajax
Downshift
🏎 A set of primitives to build simple, flexible, WAI-ARIA compliant React autocomplete, combobox or select dropdown components.
Stars: ✭ 10,183 (+15098.51%)
Mutual labels:  select, multiselect
Nb Choices
Angular wrapper for choices.js, vanilla, lightweight, configurable select box/text input plugin
Stars: ✭ 32 (-52.24%)
Mutual labels:  select, multiselect
svelecte
Selectize-like component written in Svelte, also usable as custom-element 💪⚡
Stars: ✭ 121 (+80.6%)
Mutual labels:  select, multiselect
Angular2 Multiselect Dropdown
Angular 2 Dropdown Multiselect
Stars: ✭ 225 (+235.82%)
Mutual labels:  select, multiselect
Multiselect
Vue 3 multiselect component with single select, multiselect and tagging options.
Stars: ✭ 92 (+37.31%)
Mutual labels:  select, multiselect
Ngx Select Dropdown
Custom Dropdown for Angular 4+ with multiple and single selection options
Stars: ✭ 91 (+35.82%)
Mutual labels:  select, multiselect
React Multi Select
A Multi Select component built with and for React
Stars: ✭ 111 (+65.67%)
Mutual labels:  select, multiselect
Ng Select
⭐ Native angular select component
Stars: ✭ 2,781 (+4050.75%)
Mutual labels:  select, multiselect
disaster-crawler
Data sources from Kimono currently unavailable
Stars: ✭ 13 (-80.6%)
Mutual labels:  ajax
nova-algolia-card
A Laravel Nova card for Algolia
Stars: ✭ 22 (-67.16%)
Mutual labels:  nova
Enterprise-Web3.0
Enterprise™ for the Web3.0™
Stars: ✭ 32 (-52.24%)
Mutual labels:  ajax
upload-file-to-backblaze-b2-from-browser-example
Demonstrates calling the b2_upload_file Backblaze B2 Cloud Storage API from a web browser using AJAX.
Stars: ✭ 28 (-58.21%)
Mutual labels:  ajax
Questions
Web app inspired by Quora, allowing users ask question and get answers
Stars: ✭ 15 (-77.61%)
Mutual labels:  ajax
efw3.X
Ajax Framework By Server Side JavaScript for Java Web-App.
Stars: ✭ 16 (-76.12%)
Mutual labels:  ajax
nubuilder4
This repository is no longer maintained!
Stars: ✭ 22 (-67.16%)
Mutual labels:  ajax
earthquakes-mapper
"Earthquakes Mapper" was created using React with no backend persistence. Users can view earthquakes from around the world on a Google Map and filter based on specific times and earthquake magnitude. Earthquake data from USGS.
Stars: ✭ 14 (-79.1%)
Mutual labels:  ajax

Nova Select Plus

Installation

composer require ziffmedia/nova-select-plus

Versions & Compatibility

  • Version ^1.0 supports Nova 2-3
  • Version ^2.0 supports Nova 4 (with Vue 3, dark mode support, etc)

Description & Use Cases

alt text

This Nova component was built to satisfy the use cases just beyond Nova's built-in <select> component. Here are some scenarios where you might want SelectPlus (which uses vue-select) over the simple Select:

Select For BelongsToMany and MorphsToMany On the Form Screen

The default Nova experience for BelongsToMany and MorphsToMany is to have a separate UI screen for attaching/detaching and syncing relationships through a "Pivot" model. For simple relationships (relationships that do not have addition pivot values or the only value in the pivot table is there for ordering), it is benefitial to move this Selection to the Form workflow instead of a separate workflow.

Ajax For Options

For Select's that have between a handful to several 1000 options, it is more peformant to load the full list of options only on the screen that needs it: the Form screen.

There are 2 options for Ajax Options, the default is to load them all on the Form load. The second is to allow for full option searching (in this case you can write you own ajax search resolver).

Reordering Simple Pivot/BelongsToMany Relations

Through ->reorderable(), you can enable a SelectPlus field to be reorderable. This allows, at BelongsToMany->sync() time, to populate a pivot value useful for ordering relations.

Usage

use ZiffMedia\NovaSelectPlus\SelectPlus;
    // setup model like normal:
    public function statesLivedIn()
    {
        return $this->belongsToMany(State::class, 'state_user_lived_in')->withTimestamps();
    }

    // add Nova Resource Field
    SelectPlus::make('States Lived In', 'statesLivedIn', State::class),

Options & Examples

->label(string|closure $attribute) Pick a different attribute to use as the label

Default: 'name'

SelectPlus::make('States Lived In', 'statesLivedIn', State::class)
  ->label('code')

If a closure is provided, it will be called and the value can be utilized. Additionally, the output may be HTML as the component will v-html the output on the frontend:

// Using php 7.4 short functions:
SelectPlus::make('States Visited', 'statesVisited', State::class)
    ->label(fn ($state) => $state->name . " <span class=\"text-xs\">({$state->code})</span>")

->usingIndexLabel() & ->usingDetailLabel()

Default is to produce a count of the number of items on the index and detail screen

alt text

If a string name is provided, the name attribute is plucked and comma joined:

SelectPlus::make('States Lived In', 'statesLivedIn', State::class)
  ->usingIndexLabel('name'),

alt text

If a closure is provided, it will be called, and the value will be utilized. If the value is a string, it will be placed:

SelectPlus::make('States Lived In', 'statesLivedIn', State::class)
  ->usingIndexLabel(fn($models) => $models->first()->name ?? ''),

alt text

If an array is returned, the Index and Detail screens will produce a <ol> or <ul> list:

SelectPlus::make('States Lived In', 'statesLivedIn', State::class)
  ->usingIndexLabel(fn($models) => $models->pluck('name')),

alt text

->reorderable(string $pivotOrderAttribute) - Ability to reorder multiple selects

    // assuming in the User model:
    public function statesVisited()
    {
        return $this->belongsToMany(State::class, 'state_user_visited')
            ->withPivot('order')
            ->orderBy('order')
            ->withTimestamps();
    }

    // inside the Nova resource:
    SelectPlus::make('States Lived In', 'statesLivedIn', State::class)
        ->reorderable('order'),

alt text

->optionsQuery(closure) - Ability to apply changes to options query object

    // inside the Nova resource (exclude all states that start with C)
    SelectPlus::make('States Lived In', 'statesLivedIn', State::class)
        ->optionsQuery(function (Builder $query) {
            $query->where('name', 'NOT LIKE', 'C%');
        })
  • Note: this will apply before any ajaxSearchable() functionality, it will not replace it but be applied along with ajaxSearchable() if it exists

->ajaxSearchable(string|closure|true) Ajax search for values

Given a string, models will be search the resources via the provided attribute using WHERE LIKE. Given a callback, returning a Collection will populate the dropdown:

    SelectPlus::make('States Visited', 'statesVisited', State::class)
        ->ajaxSearchable(function ($search) {
            return StateModel::where('name', 'LIKE', "%{$search}%")->limit(5);
        })

alt text

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].