Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamminf committed Apr 28, 2016
2 parents 616674b + 9e1e31c commit 39449d3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions neo/elementtypes/Neo_BlockElementType.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $crit
$query->join('neoblocktypes neoblocktypes', 'neoblocktypes.id = neoblocks.typeId');
$query->andWhere(DbHelper::parseParam('neoblocktypes.handle', $criteria->type, $query->params));
}

if($criteria->level && $criteria->level !== 'neoblocks.level')
{
$query->andWhere(DbHelper::parseParam('neoblocks.level', $criteria->level, $query->params));
}
}

public function populateElementModel($row)
Expand Down
4 changes: 2 additions & 2 deletions neo/fieldtypes/NeoFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public function getInputHtml($name, $value)
'sortOrder' => $block->sortOrder,
'collapsed' => (bool) $block->collapsed,
'enabled' => (bool) $block->enabled,
'level' => $block->level,
'level' => intval($block->level) - 1,
'tabs' => $this->_getBlockHtml($block, $name),
];
}
Expand Down Expand Up @@ -442,7 +442,7 @@ public function prepValueFromPost($data)
$block->setOwner($this->element);
$block->enabled = (isset($blockData['enabled']) ? (bool) $blockData['enabled'] : true);
$block->collapsed = (isset($blockData['collapsed']) ? (bool) $blockData['collapsed'] : false);
$block->level = (isset($blockData['level']) ? intval($blockData['level']) : 0);
$block->level = (isset($blockData['level']) ? intval($blockData['level']) + 1 : 1);

$ownerContentPostLocation = $this->element->getContentPostLocation();

Expand Down
13 changes: 13 additions & 0 deletions neo/migrations/m160428_202308_Neo_UpdateBlockLevels.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
namespace Craft;

class m160428_202308_Neo_UpdateBlockLevels extends BaseMigration
{
public function safeUp()
{
$tableName = (new Neo_BlockRecord())->getTableName();
craft()->db->createCommand()->update($tableName, ['level' => new \CDbExpression('level + 1')]);

return true;
}
}

0 comments on commit 39449d3

Please sign in to comment.