Abstract Class humhub\modules\ui\helpers\models\ItemDrop

Inheritancehumhub\modules\ui\helpers\models\ItemDrop » yii\base\Model
Available since version1.4

Class ItemDrop

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$formName string Form submit name humhub\modules\ui\helpers\models\ItemDrop
$index integer New model index humhub\modules\ui\helpers\models\ItemDrop
$modelClass string ActiveRecord model class humhub\modules\ui\helpers\models\ItemDrop
$modelId integer humhub\modules\ui\helpers\models\ItemDrop
$sortOrderField string The sort order field of the model humhub\modules\ui\helpers\models\ItemDrop
$sortQuery \yii\db\ActiveQuery Can be set instead of overwritting [getSortItemsQuery()] humhub\modules\ui\helpers\models\ItemDrop
$targetId integer|null The id of the target used for dragging items between lists humhub\modules\ui\helpers\models\ItemDrop
$targetIdField string|null A targetId field of the model e.g. list_id humhub\modules\ui\helpers\models\ItemDrop

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
beginTransaction() humhub\modules\ui\helpers\models\ItemDrop
getModel() Loads and caches the model instance to resort. humhub\modules\ui\helpers\models\ItemDrop
getSortItemsQuery() Returns a query responsible for loading all items to resort. humhub\modules\ui\helpers\models\ItemDrop
getSortOrder() Returns the sort order (index) value of an model (by default a sort_order field). humhub\modules\ui\helpers\models\ItemDrop
getTableName() humhub\modules\ui\helpers\models\ItemDrop
loadModel() Loads the model instance to resort humhub\modules\ui\helpers\models\ItemDrop
run() Moves the given humhub\modules\ui\helpers\models\ItemDrop
updateSortOrder() Updates the sort_order (index) of the given model instance (by default a sort_order field). humhub\modules\ui\helpers\models\ItemDrop
updateTarget() Responsible for updating the target on the model e.g: humhub\modules\ui\helpers\models\ItemDrop
validateIndex() Makes sure we use a valid sort index. humhub\modules\ui\helpers\models\ItemDrop

Property Details

$formName public property

Form submit name

public string $formName 'ItemDrop'
$index public property

New model index

public integer $index null
$modelClass public property

ActiveRecord model class

public string $modelClass null
$modelId public property
public integer $modelId null
$sortOrderField public property

The sort order field of the model

public string $sortOrderField 'sort_order'
$sortQuery public property

Can be set instead of overwritting [getSortItemsQuery()]

See also getSortItemsQuery().

public \yii\db\ActiveQuery $sortQuery null
$targetId public property

The id of the target used for dragging items between lists

public integer|null $targetId null
$targetIdField public property

A targetId field of the model e.g. list_id

public string|null $targetIdField null

Method Details

beginTransaction() protected method

protected \yii\db\Transaction beginTransaction ( )
formName() public method

public void formName ( )
getModel() protected method

Loads and caches the model instance to resort.

protected \yii\db\ActiveRecord getModel ( )
getSortItemsQuery() protected method

Returns a query responsible for loading all items to resort.

This this can be for example all models within a list:

return MyItem::find()->where(['listId' => $this->targetId]);
protected \yii\db\ActiveQuery getSortItemsQuery ( )
getSortOrder() protected method

Returns the sort order (index) value of an model (by default a sort_order field).

This may be overwritten if the model uses another sort order field.

protected mixed getSortOrder ( \yii\db\ActiveRecord $model )
$model
getTableName() protected method

protected string getTableName ( )
return string

Returns the table name of the model

loadModel() protected method

Loads the model instance to resort

protected \yii\db\ActiveRecord loadModel ( )
rules() public method

public void rules ( )
run() protected method

Moves the given

protected boolean run ( )
throws Throwable
throws \yii\db\Exception
save() public method

Handles the resorting of the list

public boolean save ( )
updateSortOrder() protected method

Updates the sort_order (index) of the given model instance (by default a sort_order field).

This may be overwritten if the model uses another sort order field.

protected mixed updateSortOrder ( \yii\db\ActiveRecord $model, $sortOrder )
$model
$sortOrder
updateTarget() protected method

Responsible for updating the target on the model e.g:

protected void updateTarget ( )
validateIndex() protected method

Makes sure we use a valid sort index.

protected integer validateIndex ( $newIndex, $itemsToSort )
$newIndex
$itemsToSort