Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditions + element source improvements #10075

Merged
merged 247 commits into from
Nov 27, 2021

Conversation

brandonkelly
Copy link
Member

@brandonkelly brandonkelly commented Nov 10, 2021

Overview

This is a bit of a loaded PR. It does the following:

Creating conditions

Condition classes must implement craft\conditions\ConditionInterface. A generic base implementation is provided by craft\conditions\BaseCondition, as well as one tailored for modifying a database query: craft\conditions\BaseQueryCondition.

Condition rules must implement craft\conditions\ConditionRuleInterface; query condition rules must also implement craft\conditions\QueryConditionRuleinterface.

A condition builder’s HTML can be generated via $condition->getBuilderHtml(), which supports a few builder-specific options:

  • mainTag – The container tag type (form by default)
  • id – The container ID
  • sortable – Whether the rules should be user-sortable (true by default)
  • singleUseTypes – Whether rules can only be used once within the condition
  • projectConfigTypes - Whether to limit the available rules to those which can be stored in the project config (needed for custom sources)

Element query conditions

Element types can provide their own custom condition classes which extend craft\conditions\elements\ElementQueryCondition. Doing so will give them a chance to include additional element type-specific rules, by overriding conditionRuleTypes() (see EntryQueryCondition for an example).

The element type can return an instance of it from its static createCondition() method.

Field condition rules

Field types can provide a rule type which implements craft\conditions\elements\fields\FieldConditionRuleInterface and uses craft\conditions\elements\fields\FieldConditionRuleTrait.

The field type can return its class name from its getQueryConditionRuleType() method.

To-do

  • Accessibility audit
  • Use Garnish.DragSort for rule sorting
  • Add condition rules for most built-in field types
  • Add element query conditions for all built-in element types
  • Ability to limit custom sources to certain user groups
  • Update the source translation file
  • Update the changelog

lukeholder and others added 30 commits June 1, 2020 20:33
# Conflicts:
#	composer.json
#	src/config/app.php
#	src/services/Structures.php
#	src/web/assets/cp/dist/css/_main.scss
#	src/web/assets/cp/dist/css/craft.css
#	src/web/assets/cp/dist/css/craft.css.map
#	src/web/assets/cp/dist/js/Craft.js
#	src/web/assets/cp/dist/js/Craft.min.js
#	src/web/assets/cp/dist/js/Craft.min.js.map
#	src/web/assets/cp/src/js/LivePreview.js
#	src/web/assets/matrixsettings/dist/MatrixConfigurator.min.js
#	src/web/assets/matrixsettings/dist/MatrixConfigurator.min.js.map
#	tests/unit/services/projectConfig/NoFixturesTest.php
- New condition builder asset
- Hard-coded embed of condition builder on entry index page (to be removed)
- `npm run serve` must be run on the condition builder directory to get the entry index page to render,
# Conflicts:
#	composer.json
#	src/config/app.php
#	src/web/assets/cp/dist/css/craft.css
#	src/web/assets/cp/dist/css/craft.css.map
#	src/web/assets/cp/dist/js/Craft.js
#	src/web/assets/cp/dist/js/Craft.min.js
#	src/web/assets/cp/dist/js/Craft.min.js.map
#	src/web/assets/cp/src/css/_main.scss
#	src/web/assets/cp/src/js/LivePreview.js
#	src/web/assets/matrixsettings/dist/MatrixConfigurator.min.js
#	src/web/assets/matrixsettings/dist/MatrixConfigurator.min.js.map
# Conflicts:
#	src/web/assets/cp/dist/css/craft.css.map
#	src/web/assets/cp/dist/js/Craft.min.js
#	src/web/assets/cp/dist/js/Craft.min.js.map
# Conflicts:
#	src/web/assets/cp/dist/css/craft.css.map
# Conflicts:
#	gulpfile.js
#	package.json
#	src/web/assets/cp/dist/css/craft.css
#	src/web/assets/cp/dist/css/craft.css.map
#	src/web/assets/cp/dist/js/Craft.min.js
#	src/web/assets/cp/dist/js/Craft.min.js.map
# Conflicts:
#	src/web/assets/cp/dist/js/Craft.min.js
# Conflicts:
#	package-lock.json
#	package.json
#	src/web/assets/cp/dist/css/cp.css
#	src/web/assets/cp/dist/js/Craft.min.js
#	src/web/assets/craftsupport/dist/CraftSupportWidget.js
#	src/web/assets/dashboard/dist/Dashboard.js
#	src/web/assets/deprecationerrors/dist/deprecator.js
#	src/web/assets/edituser/dist/AccountSettingsForm.js
#	src/web/assets/edituser/dist/profile.js
#	src/web/assets/generalsettings/dist/rebrand.js
#	src/web/assets/graphiql/dist/graphiql.js
#	src/web/assets/installer/dist/install.js
#	src/web/assets/login/dist/login.js
#	src/web/assets/plugins/dist/PluginManager.js
#	src/web/assets/pluginstoreoauth/dist/PluginStoreOauthCallback.js
#	src/web/assets/routes/dist/routes.js
#	src/web/assets/systemmessages/dist/system_messages.js
#	src/web/assets/updater/dist/Updater.js
#	src/web/assets/updates/dist/UpdatesUtility.js
#	src/web/assets/userpermissions/dist/UserPermissions.js
@brandonkelly brandonkelly marked this pull request as ready for review November 27, 2021 02:28
@brandonkelly brandonkelly merged commit 6e9f954 into 4.0 Nov 27, 2021
@brandonkelly brandonkelly deleted the feature/dev-75-condition-builder-framework branch November 27, 2021 02:28
brandonkelly added a commit that referenced this pull request Jan 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants