2017 © Pedro Peláez
 

yii2-extension handpicked-list

Widget (helper) for Yii2. Based on bootstrap. Help you build admin interface. You can select some elements in pretty pop-up and see selected items in another pretty compact interface.

image

atlant5/handpicked-list

Widget (helper) for Yii2. Based on bootstrap. Help you build admin interface. You can select some elements in pretty pop-up and see selected items in another pretty compact interface.

  • Monday, June 5, 2017
  • by EvgenyVetrov
  • Repository
  • 1 Watchers
  • 1 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Handpicked list (yii2 widget)

This widget help you with building admin interface. You can select some elements in pretty interface and see selected items in another pretty compact interface., (*1)

Features: 1. "read-only" condition if you want 2. easy search in elements 3. bootstrap admin LTE integration, (*2)

Usage:

In view:, (*3)

<?= HandpickedList::widget([
    'dataProvider' => $handpickedListProvider,
    'modelWithRelations' => 'GeneralPages[manageWidgets]',
    'title' => 'Блоки страницы',
    'readOnly' => false,
    'collapse' => true,
    'usingColumns' => ['id', 'name', 'code', 'own_description'],
    'customSelectionColumn' => 'id',
    'customSelection' => $selectedItems,
]) ?>

Result:
Base block (every item is clickable):
screenshot, (*4)

Hint:
screenshot, (*5)

Pop-up with all elemnts:
screenshot, (*6)

Collapsed base block:
screenshot, (*7)

 , (*8)

Disable all options:

<?= HandpickedList::widget([
    'dataProvider' => $handpickedListProvider,
    'modelWithRelations' => 'GeneralPages[manageWidgets]',
    'title' => 'Блоки страницы',
    'readOnly' => true,
    'collapse' => false,
    'usingColumns' => ['id', 'name', 'code', 'own_description'],
    'customSelectionColumn' => 'id',
    'customSelection' => $selectedItems,
]) ?>

screenshot, (*9)

 , (*10)

About options:

1. dataProvider (array | object)

Seems like:
'dataProvider' => $handpickedListProvider,, (*11)

$handpickedListProvider must be an array:, (*12)

[
    0 => [
        'name' => 'название'
        'code' => '123'
        'checked' => false
        'type' => ''
        'id' => '4'
    ]
    1 => [
        'name' => 'Второй блок для теста'
        'code' => 'html2'
        'checked' => true
        'type' => ''
        'id' => '5'
    ]
]

OR object from ArrayDataProvider, (*13)

yii\data\ArrayDataProvider#1
   (
       [key] => null
       [allModels] => [
           0 => [
               'id' => '4'
               'code' => '123'
               'name' => 'название'
               'own_description' => 'примечание'
           ]
           1 => [
               'id' => '5'
               'code' => 'html2'
               'name' => 'Второй блок для теста'
               'own_description' => ''
           ]
       ]
       [modelClass] => null
       [id] => null
       [yii\data\BaseDataProvider:_sort] => null
       [yii\data\BaseDataProvider:_pagination] => null
       [yii\data\BaseDataProvider:_keys] => null
       [yii\data\BaseDataProvider:_models] => null
       [yii\data\BaseDataProvider:_totalCount] => null
       [yii\base\Component:_events] => []
       [yii\base\Component:_behaviors] => null

2. usingColumns (array)

Columns, which will be used for display in widget. Example:
'usingColumns' => ['id', 'name', 'code'],, (*14)

First normal column will be text title for element. Here is 'name', (*15)

3. customSelectionColumn (string)

Column name, which detect selected elements. default = 'id', (*16)

4. customSelection (array)

Array of selected elements in customSelectionColumn. For example:
'customSelection' => [4, 5], (*17)

That`s mean elements with id=4 and id=5 will be selected, (*18)

5. detectedColumns (array)

key - value array, which 'key' is column 'value' is value. For example:
'detectedColumns' => ['code' => 123];, (*19)

Every element where code == 123 will be selected., (*20)

You can make many rules: 'detectedColumns' => ['code' => 123, 'id' => '5']; , but dont create it :-), (*21)

Default ['active' => true], (*22)

6. modelWithRelations (string)

Specify the model and relations names, which will be save input data (selected items). For example: 'modelWithRelations' => 'GeneralPages'
or
'modelWithRelations' => 'GeneralPages[manageWidgets][anyRelation]', (*23)

in view 'modelWithRelations' => 'GeneralPages[manageWidgets]' shows as:, (*24)

<input type="hidden" name="GeneralPages[manageWidgets][]" value="5">

and savings via manageWidgets relation., (*25)

    p.s.
    Sorry for this ugly method
    Help me to create good solution., (*26)

 , (*27)

Warring!:

Widget has no paginate! Don`t use it if you have more than 1000 elements.  , (*28)

About:

On GitHub: https://github.com/EvgenyVetrov/handpicked-list
On Packagist: https://packagist.org/packages/atlant5/handpicked-list, (*29)

The Versions

05/06 2017

dev-master

9999999-dev https://github.com/EvgenyVetrov/handpicked-list

Widget (helper) for Yii2. Based on bootstrap. Help you build admin interface. You can select some elements in pretty pop-up and see selected items in another pretty compact interface.

  Sources   Download

GPL

The Requires

 

extension yii2 yii yii 2 widget list selector atlant5 handpicked handpicked-list handpicked list