Skip to content

Commit

Permalink
SS4 UPGRADE (#86)
Browse files Browse the repository at this point in the history
* basic code upgrade with name spaced php classes and templates

* typo fixed on composer module type

* little tweaks for parent calls

* fixed namespaces in yaml

* JS bundled via Yarn  / Webpack, and updated the select dropdowns on selectors

* listen to on key up

* desing the displayLogicCriteria on the instance than the Extension it self.

* added conditionals tests for the rules to be checked in in the JS

* removed the criteria from being in the field's owner. and moved back in to the extension

* updated the namespaces

* renamed the display logic wrapper templates

* updated the name selector for the select dropdowns

* class renaming and behat

* Behat tests
  • Loading branch information
Aaron Carlino committed Feb 18, 2018
1 parent b3552c4 commit eece1d7
Show file tree
Hide file tree
Showing 42 changed files with 6,841 additions and 928 deletions.
6 changes: 6 additions & 0 deletions .eslintignore
@@ -0,0 +1,6 @@
# Ignore dist files
client/dist/

# Ignore vendor
node_modules/

1 change: 1 addition & 0 deletions .eslintrc.js
@@ -0,0 +1 @@
module.exports = require('@silverstripe/webpack-config/.eslintrc');
2 changes: 2 additions & 0 deletions .gitignore
@@ -1 +1,3 @@
.idea
/node_modules/
/src/DisplayLogicTestPage.php
9 changes: 6 additions & 3 deletions README.md
Expand Up @@ -91,6 +91,9 @@ $shipping->displayIf("ProductType")->isEqualTo("furniture")
## Kitchen sink example, with chaining
```php
<?php

use UncleCheese\DisplayLogic\Wrapper;
//...
public function getCMSFields() {
$f = parent::getCMSFields();
$f->addFieldsToTab("Root.Test", array(
Expand All @@ -116,7 +119,7 @@ $shipping->displayIf("ProductType")->isEqualTo("furniture")
TextField::create("ExternalLink", "Link to external page")
->displayIf("LinkType")->isEqualTo("external")
->end(),
DisplayLogicWrapper::create(
Wrapper::create(
ReadonlyField::create('URL','Base URL','http://example.com')
)->displayIf('LinkType')->isEqualTo('internal')->end(),
TextField::create("LinkLabel", "Label for link")
Expand All @@ -138,9 +141,9 @@ $shipping->displayIf("ProductType")->isEqualTo("furniture")
```

## Dealing with non-standard form fields
Sometimes you will want to wrap display logic around a form field that does not use the standard FormField template, such as GridField or LiteralField. For these cases, you can wrap the form field in DisplayLogicWrapper().
Sometimes you will want to wrap display logic around a form field that does not use the standard FormField template, such as GridField or LiteralField. For these cases, you can wrap the form field in UncleCheese\DisplayLogic\Wrapper.
```php
$fields->addFieldToTab("Root.Main", DisplayLogicWrapper::create(
$fields->addFieldToTab("Root.Main", Wrapper::create(
LiteralField::create("foo","<h2>Hello</h2>")
)
->displayIf("Title")->isEmpty()->end()
Expand Down
3 changes: 0 additions & 3 deletions _config.php

This file was deleted.

8 changes: 3 additions & 5 deletions _config/display_logic.yml → _config/config.yml
@@ -1,4 +1,4 @@
DisplayLogicCriteria:
UncleCheese\DisplayLogic\Criteria:
comparisons:
- isEqualTo
- isNotEqualTo
Expand All @@ -21,8 +21,6 @@ DisplayLogicCriteria:
- fade
default_animation: toggle

FormField:
SilverStripe\Forms\FormField:
extensions:
- DisplayLogicFormField
DisplayLogic:
jquery_included: true
- UncleCheese\DisplayLogic\Extensions\DisplayLogic
37 changes: 37 additions & 0 deletions behat.yml
@@ -0,0 +1,37 @@
# Run display-logic behat tests with this command (installed with silverstripe/installer)
# Note that display-logic behat tests require CMS module
# ========================================================================= #
# vendor/bin/selenium-server-standalone -Dwebdriver.firefox.bin="/Applications/Firefox31.app/Contents/MacOS/firefox-bin"
# vendor/bin/serve --bootstrap-file vendor/silverstripe/cms/tests/behat/serve-bootstrap.php
# vendor/bin/behat @display-logic
# ========================================================================= #
default:
suites:
display-logic:
paths:
- %paths.modules.display-logic%/tests/behat/features
- %paths.modules.display-logic%/tests/behat/bootstrap/remove-test-page.feature
contexts:
- UncleCheese\DisplayLogic\Tests\Behaviour\FeatureContext
- SilverStripe\Framework\Tests\Behaviour\CmsFormsContext
- SilverStripe\Framework\Tests\Behaviour\CmsUiContext
- SilverStripe\BehatExtension\Context\BasicContext
- SilverStripe\BehatExtension\Context\EmailContext
- SilverStripe\BehatExtension\Context\LoginContext
-
SilverStripe\Framework\Tests\Behaviour\ConfigContext:
- %paths.modules.display-logic%/tests/behat/files/
-
UncleCheese\DisplayLogic\Tests\Behaviour\FixtureContext:
- %paths.modules.display-logic%/tests/behat/bootstrap/

extensions:
SilverStripe\BehatExtension\Extension:
bootstrap_file: vendor/silverstripe/cms/tests/behat/serve-bootstrap.php
screenshot_path: %paths.base%/artifacts/screenshots
retry_seconds: 4 # default is 2
SilverStripe\BehatExtension\MinkExtension:
default_session: selenium2
javascript_session: selenium2
selenium2:
browser: firefox
1 change: 1 addition & 0 deletions client/dist/js/bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/dist/js/bundle.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions client/dist/styles/bundle.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/dist/styles/bundle.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/src/bundles/bundle.js
@@ -0,0 +1 @@
require('../components/display_logic.js');

0 comments on commit eece1d7

Please sign in to comment.