Skip to content

Commit

Permalink
Merge branch '4.0'
Browse files Browse the repository at this point in the history
 # Conflicts:
 #	client/dist/js/bundle.js
  • Loading branch information
robbieaverill committed Nov 22, 2018
2 parents 321091f + b8698c6 commit 954784f
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -26,7 +26,7 @@ matrix:
- php: 7.2
env: DB=MYSQL RECIPE_VERSION=4.x-dev PHPUNIT_TEST=1
- php: 7.2
env: DB=MYSQL RECIPE_VERSION=4.x-dev NPM_TEST=1
env: DB=MYSQL RECIPE_VERSION=4.3.x-dev NPM_TEST=1

before_script:
# Extra $PATH
Expand Down
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion client/src/components/ElementEditor/AddNewButton.js
Expand Up @@ -31,7 +31,8 @@ class AddNewButton extends Component {
const buttonAttributes = {
id: `ElementalArea${elementalAreaId}_AddButton`,
color: 'primary',
onClick: this.toggle
onClick: this.toggle,
className: 'font-icon-plus',
};

return (
Expand Down
Expand Up @@ -3,21 +3,27 @@ import { InputGroup, InputGroupAddon, InputGroupText } from 'reactstrap';
import fieldHolder from 'components/FieldHolder/FieldHolder';

const TextCheckboxGroupField = (props) => {
const { children } = props;
const { children } = props;

const childrenWithProps = React.Children.toArray(
React.Children.map(children, child =>
React.cloneElement(child, { noHolder: true })
)
);
return (
<InputGroup className="text-checkout-group-field">
{childrenWithProps[0]}
<InputGroupAddon addonType="append">
<InputGroupText>{childrenWithProps[1]}</InputGroupText>
</InputGroupAddon>
</InputGroup>
);
const childrenWithProps = React.Children.toArray(
React.Children.map(children, child =>
React.cloneElement(child, { noHolder: true })
)
);

// If the checkbox has been removed, just render the TextField on its own
if (childrenWithProps.length === 1) {
return childrenWithProps[0];
}

return (
<InputGroup className="text-checkout-group-field">
{childrenWithProps[0]}
<InputGroupAddon addonType="append">
<InputGroupText>{childrenWithProps[1]}</InputGroupText>
</InputGroupAddon>
</InputGroup>
);
};

export default fieldHolder(TextCheckboxGroupField);
4 changes: 4 additions & 0 deletions src/Forms/ElementalAreaField.php
Expand Up @@ -229,6 +229,10 @@ public function saveInto(DataObjectInterface $dataObject)
$elementData = $this->Value();
$idPrefixLength = strlen(sprintf(ElementalAreaController::FORM_NAME_TEMPLATE, ''));

if (!$elementData) {
return;
}

foreach ($elementData as $form => $data) {
// Extract the ID
$elementId = (int) substr($form, $idPrefixLength);
Expand Down
22 changes: 22 additions & 0 deletions tests/BaseElementTest.php
Expand Up @@ -175,4 +175,26 @@ public function testEvenOdd()
$this->assertEquals('even', $element2->EvenOdd());
$this->assertEquals('odd', $element3->EvenOdd());
}

public function testOnBeforeWrite()
{
/** @var ElementalArea $area */
$area = $this->objFromFixture(ElementalArea::class, 'area51');

$element1 = new ElementContent();
$element1->ParentID = $area->ID;
$element1->write();
$baselineSort = $element1->Sort;

$element2 = new ElementContent();
$element2->ParentID = $area->ID;
$element2->write();
$this->assertEquals($baselineSort + 1, $element2->Sort, 'Sort order should be higher than the max');

// Use a different element type, ensuring that sort orders are relative to the BaseElement
$element3 = new TestElement();
$element3->ParentID = $area->ID;
$element3->write();
$this->assertEquals($baselineSort + 2, $element3->Sort, 'Sort order should be higher than the max');
}
}

0 comments on commit 954784f

Please sign in to comment.