Skip to content

Commit

Permalink
New field layout designer
Browse files Browse the repository at this point in the history
Resolves #806
Resolves #841
Resolves #913
Resolves #1103
Resolves #1138
Resolves #2644
Resolves #3953
Resolves #4647
Resolves #4738
  • Loading branch information
brandonkelly committed Jul 11, 2020
1 parent e7c9431 commit 746eaff
Show file tree
Hide file tree
Showing 91 changed files with 4,412 additions and 1,995 deletions.
44 changes: 43 additions & 1 deletion CHANGELOG-v3.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
### Added
- Added the Project Config utility, which can be used to perform project config actions, and view a dump of the stored project config. ([#4371](https://github.com/craftcms/cms/issues/4371))
- It’s now possible to customize the labels and author instructions for all fields (including Title fields), from within field layout designers. ([#806](https://github.com/craftcms/cms/issues/806), [#841](https://github.com/craftcms/cms/issues/841))
- It’s now possible to set Title fields’ positions within field layout designers. ([#3953](https://github.com/craftcms/cms/issues/3953))
- It’s now possible to set field widths to 25%, 50%, 75%, or 100%, and fields will be positioned next to each other when there’s room. ([#2644](https://github.com/craftcms/cms/issues/2644))
- It’s now possible to add headings, tips, warnings, and horizontal rules to field layouts. ([#1103](https://github.com/craftcms/cms/issues/1103), [#1138](https://github.com/craftcms/cms/issues/1138), [#4738](https://github.com/craftcms/cms/issues/4738))
- It’s now possible to search for fields from within field layout designers. ([#913](https://github.com/craftcms/cms/issues/913))
- Added the “Use shapes to represent statuses” user preference. ([#3293](https://github.com/craftcms/cms/issues/3293))
- Added the “Underline links” user preference. ([#6153](https://github.com/craftcms/cms/issues/6153))
- Added the “Suspend by default” user registration setting. ([#5830](https://github.com/craftcms/cms/issues/5830))
- Added the ability to disable sites on the front end. ([#3005](https://github.com/craftcms/cms/issues/3005))
- Soft-deleted elements now have a “Delete permanently” element action. ([#4420](https://github.com/craftcms/cms/issues/4420))
- Entry types can now specify custom Title field instructions. ([#1518](https://github.com/craftcms/cms/issues/1518))
- Entry types can now change the Title field’s translation method, similar to how custom fields’ translation methods. ([#2856](https://github.com/craftcms/cms/issues/2856))
- Entry draft forms no longer have a primary action, and the <kbd>Ctrl</kbd>/<kbd>Command</kbd> + <kbd>S</kbd> keyboard shortcut now forces a resave of the draft, rather than publishing it. ([#6199](https://github.com/craftcms/cms/issues/6199))
- Edit Entry pages now support a <kbd>Shift</kbd> + <kbd>Ctrl</kbd>/<kbd>Command</kbd> + <kbd>S</kbd> keyboard shortcut for saving the entry and creating a new one. ([#2851](https://github.com/craftcms/cms/issues/2851))
Expand All @@ -34,6 +38,7 @@
- Added the `|diff` Twig filter.
- Added the `|explodeClass` Twig filter, which converts class names into an array.
- Added the `|explodeStyle` Twig filter, which converts CSS styles into an array of property/value pairs.
- Added the `|namespaceAttributes` Twig filter, which namespaces `id`, `for`, and other attributes, but not `name`.
- Added the `|push` Twig filter, which returns a new array with one or more items appended to it.
- Added the `|unshift` Twig filter, which returns a new array with one or more items prepended to it.
- Added the `|where` Twig filter.
Expand All @@ -55,6 +60,8 @@
- Added the “Prettify” and “History” buttons to the GraphiQL IDE.
- Added the Explorer plugin to GraphiQL.
- Added support for external subnav links in the global control panel nav.
- Added the `fieldLayoutDesigner()` and `fieldLayoutDesignerField()` macros to the `_includes/forms.html` control panel template.
- Added the `_includes/forms/fieldLayoutDesigner.html` control panel template.
- Added the `_layouts/components/form-action-menu.twig` control panel template.
- Added the `parseRefs` GraphQL directive. ([#6200](https://github.com/craftcms/cms/issues/6200))
- Added the `prev` and `next` fields for entries, categories and assets when querying elements via GraphQL. ([#5571](https://github.com/craftcms/cms/issues/5571))
Expand Down Expand Up @@ -88,6 +95,8 @@
- Added `craft\base\Field::searchKeywords()`.
- Added `craft\base\FieldInterface::getContentGqlMutationArgumentType()`.
- Added `craft\base\FieldInterface::getContentGqlQueryArgumentType()`.
- Added `craft\base\FieldLayoutElement`.
- Added `craft\base\FieldLayoutElementInterface`.
- Added `craft\base\Model::EVENT_DEFINE_EXTRA_FIELDS`.
- Added `craft\base\Model::EVENT_DEFINE_FIELDS`.
- Added `craft\base\Volume::getFieldLayout()`.
Expand All @@ -98,6 +107,7 @@
- Added `craft\console\controllers\MigrateController::EVENT_REGISTER_MIGRATOR`.
- Added `craft\controllers\AppController::actionBrokenImage()`.
- Added `craft\controllers\BaseEntriesController::enforceSitePermissions()`.
- Added `craft\controllers\FieldsController::actionRenderLayoutElementSelector()`.
- Added `craft\controllers\UtilitiesController::actionProjectConfigPerformAction()`.
- Added `craft\db\MigrationManager::TRACK_CONTENT`.
- Added `craft\db\MigrationManager::TRACK_CRAFT`.
Expand Down Expand Up @@ -131,13 +141,23 @@
- Added `craft\events\DefineAttributeKeywordsEvent`.
- Added `craft\events\DefineFieldHtmlEvent`.
- Added `craft\events\DefineFieldKeywordsEvent`.
- Added `craft\events\DefineFieldLayoutFieldEvent`.
- Added `craft\events\DefineFieldsEvent`.
- Added `craft\events\EagerLoadElementsEvent`.
- Added `craft\events\RegisterElementFieldLayoutsEvent`.
- Added `craft\events\RegisterGqlMutationsEvent`.
- Added `craft\events\RegisterGqlSchemaComponentsEvent`.
- Added `craft\events\RegisterMigratorEvent`.
- Added `craft\events\SetEagerLoadedElementsEvent`.
- Added `craft\fieldlayoutelements\BaseField`.
- Added `craft\fieldlayoutelements\CustomField`.
- Added `craft\fieldlayoutelements\EntryTitleField`.
- Added `craft\fieldlayoutelements\Heading`.
- Added `craft\fieldlayoutelements\HorizontalRule`.
- Added `craft\fieldlayoutelements\StandardField`.
- Added `craft\fieldlayoutelements\StandardTextField`.
- Added `craft\fieldlayoutelements\Tip`.
- Added `craft\fieldlayoutelements\TitleField`.
- Added `craft\fields\BaseOptionsField::getContentGqlMutationArgumentType()`.
- Added `craft\fields\BaseRelationField::getContentGqlMutationArgumentType()`.
- Added `craft\fields\Date::getContentGqlMutationArgumentType()`.
Expand Down Expand Up @@ -209,6 +229,20 @@
- Added `craft\helpers\MailerHelper::settingsReport()`.
- Added `craft\helpers\ProjectConfig::splitConfigIntoComponents()`.
- Added `craft\helpers\Queue`.
- Added `craft\models\FieldLayout::createForm()`.
- Added `craft\models\FieldLayout::EVENT_DEFINE_STANDARD_FIELDS`.
- Added `craft\models\FieldLayout::getAvailableCustomFields()`.
- Added `craft\models\FieldLayout::getAvailableStandardFields()`.
- Added `craft\models\FieldLayout::getAvailableUiElements()`.
- Added `craft\models\FieldLayout::getField()`.
- Added `craft\models\FieldLayout::isFieldIncluded()`.
- Added `craft\models\FieldLayoutForm`.
- Added `craft\models\FieldLayoutFormTab`.
- Added `craft\models\FieldLayoutTab::$elements`.
- Added `craft\models\FieldLayoutTab::createFromConfig()`.
- Added `craft\models\FieldLayoutTab::getConfig()`.
- Added `craft\models\FieldLayoutTab::getElementConfigs()`.
- Added `craft\models\FieldLayoutTab::updateConfig()`.
- Added `craft\models\Section::PROPAGATION_METHOD_CUSTOM`.
- Added `craft\models\Site::$enabled`.
- Added `craft\queue\jobs\PruneRevisions`.
Expand All @@ -228,6 +262,7 @@
- Added `craft\services\Elements::invalidateCachesForElementType()`.
- Added `craft\services\Elements::startCollectingCacheTags()`.
- Added `craft\services\Elements::stopCollectingCacheTags()`.
- Added `craft\services\Fields::createLayoutElement()`.
- Added `craft\services\Fields::getLayoutsByElementType()`.
- Added `craft\services\Gql::getAllSchemaComponents()`.
- Added `craft\services\Images::getSupportsWebP()`. ([#5853](https://github.com/craftcms/cms/issues/5853))
Expand All @@ -251,6 +286,8 @@
- Added the `_includes/forms/password.html` control panel template.
- Added the `_includes/forms/copytext.html` control panel template.
- Added the `copytext` and `copytextField` macros to the `_includes/forms.html` control panel template.
- Added the `Craft.Listbox` JavaScript class.
- Added the `Craft.SlidePicker` JavaScript class.
- Added the `Craft.removeLocalStorage()`, `getCookie()`, `setCookie()`, and `removeCookie()` JavaScript methods.
- Added the `Craft.submitForm()` JavaScript method.
- Added the `Craft.cp.getSiteId()` and `setSiteId()` JavaScript methods.
Expand Down Expand Up @@ -351,6 +388,7 @@
- Deprecated `craft\helpers\Stringy`.
- Deprecated `craft\queue\jobs\DeleteStaleTemplateCaches`.
- Deprecated `craft\services\ElementIndexes::getAvailableTableFields()`. `getSourceTableAttributes()` should be used instead.
- Deprecated `craft\services\Fields::assembleLayout()`.
- Deprecated `craft\services\Gql::getAllPermissions()`. `craft\services\Gql::getAllSchemaComponents()` should be used instead.
- Deprecated `craft\services\TemplateCaches::deleteAllCaches()`. `craft\services\Elements::invalidateAllCaches()` should be used instead.
- Deprecated `craft\services\TemplateCaches::deleteCacheById()`.
Expand All @@ -375,10 +413,13 @@
- Removed the [Interactive Shell Extension for Yii 2](https://github.com/yiisoft/yii2-shell), as it’s now a dev dependency of the `craftcms/craft` project instead. ([#5783](https://github.com/craftcms/cms/issues/5783))
- Removed support for the `import` directive in project config files.
- Removed the `cacheElementQueries` config setting.
- Removed the `entries/_fields.html` control panel template.
- Removed the `entries/_titlefield.html` control panel template.
- Removed `craft\controllers\UtilitiesController::actionDbBackupPerformAction()`.
- Removed `craft\db\MigrationManager::TYPE_APP`.
- Removed `craft\db\MigrationManager::TYPE_CONTENT`.
- Removed `craft\db\MigrationManager::TYPE_PLUGIN`.
- Removed `craft\models\EntryType::$titleLabel`.
- Removed `craft\models\Info::$configMap`.
- Removed `craft\records\Migration`.
- Removed `craft\records\Plugin::getMigrations()`.
Expand All @@ -391,6 +432,7 @@
- Fixed a bug where it was impossible to filter elements using a Lightswitch field using the GraphQL API. ([#5930](https://github.com/craftcms/cms/issues/5930))
- Fixed an error that could occur when saving template caches. ([#2674](https://github.com/craftcms/cms/issues/2674))
- When previewing an image asset on a non-public volume, the image is no longer published to the `cpresources` folder. ([#6093](https://github.com/craftcms/cms/issues/6093)
- Fixed a bug where Entry Edit pages would start showing a tab bar after switching entry types, even if the new entry type only had one content tab.

### Security
- The `_includes/forms/checkbox.html`, `checkboxGroup.html`, and `checkboxSelect.html` control panel templates now HTML-encode checkbox labels by default, preventing possible XSS vulnerabilities. If HTML code was desired, it must be passed through the new `raw()` function first.
Expand Down
44 changes: 44 additions & 0 deletions CHANGELOG-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,65 @@

### Added
- Added the Project Config utility, which can be used to perform project config actions, and view a dump of the stored project config. ([#4371](https://github.com/craftcms/cms/issues/4371))
- It’s now possible to customize the labels and author instructions for all fields (including Title fields), from within field layout designers. ([#806](https://github.com/craftcms/cms/issues/806), [#841](https://github.com/craftcms/cms/issues/841))
- It’s now possible to set Title fields’ positions within field layout designers. ([#3953](https://github.com/craftcms/cms/issues/3953))
- It’s now possible to set field widths to 25%, 50%, 75%, or 100%, and fields will be positioned next to each other when there’s room. ([#2644](https://github.com/craftcms/cms/issues/2644))
- It’s now possible to add headings, tips, warnings, and horizontal rules to field layouts. ([#1103](https://github.com/craftcms/cms/issues/1103), [#1138](https://github.com/craftcms/cms/issues/1138), [#4738](https://github.com/craftcms/cms/issues/4738))
- It’s now possible to search for fields from within field layout designers. ([#913](https://github.com/craftcms/cms/issues/913))
- Entry types can now specify custom Title field instructions. ([#1518](https://github.com/craftcms/cms/issues/1518))
- Entry types can now change the Title field’s translation method, similar to how custom fields’ translation methods. ([#2856](https://github.com/craftcms/cms/issues/2856))
- User groups can now have descriptions. ([#4893](https://github.com/craftcms/cms/issues/4893))
- Added support for GraphQL query batching. ([#5677](https://github.com/craftcms/cms/issues/5677))
- Added the `parseRefs` GraphQL directive. ([#6200](https://github.com/craftcms/cms/issues/6200))
- Added the `prev` and `next` fields for entries, categories and assets when querying elements via GraphQL. ([#5571](https://github.com/craftcms/cms/issues/5571))
- Added the `imageEditorRatios` config setting, making it possible to customize the list of available aspect ratios in the image editor. ([#6201](https://github.com/craftcms/cms/issues/6201))
- Added the `|namespaceAttributes` Twig filter, which namespaces `id`, `for`, and other attributes, but not `name`.
- Added the `fieldLayoutDesigner()` and `fieldLayoutDesignerField()` macros to the `_includes/forms.html` control panel template.
- Added the `_includes/forms/fieldLayoutDesigner.html` control panel template.
- Added `craft\base\ElementInterface::getIsTitleTranslatable()`.
- Added `craft\base\ElementInterface::getTitleTranslationDescription()`.
- Added `craft\base\ElementInterface::getTitleTranslationKey()`.
- Added `craft\base\ElementInterface::isFieldEmpty()`.
- Added `craft\base\FieldLayoutElement`.
- Added `craft\base\FieldLayoutElementInterface`.
- Added `craft\base\Model::EVENT_DEFINE_EXTRA_FIELDS`.
- Added `craft\base\Model::EVENT_DEFINE_FIELDS`.
- Added `craft\controllers\FieldsController::actionRenderLayoutElementSelector()`.
- Added `craft\controllers\UtilitiesController::actionProjectConfigPerformAction()`.
- Added `craft\elements\Asset::getVolumeId()`.
- Added `craft\elements\Asset::setVolumeId()`.
- Added `craft\events\DefineFieldLayoutFieldEvent`.
- Added `craft\events\DefineFieldsEvent`.
- Added `craft\fieldlayoutelements\BaseField`.
- Added `craft\fieldlayoutelements\CustomField`.
- Added `craft\fieldlayoutelements\EntryTitleField`.
- Added `craft\fieldlayoutelements\Heading`.
- Added `craft\fieldlayoutelements\HorizontalRule`.
- Added `craft\fieldlayoutelements\StandardField`.
- Added `craft\fieldlayoutelements\StandardTextField`.
- Added `craft\fieldlayoutelements\Tip`.
- Added `craft\fieldlayoutelements\TitleField`.
- Added `craft\gql\base\InterfaceType::resolveElementTypeName()`.
- Added `craft\gql\GqlEntityRegistry::prefixTypeName()`.
- Added `craft\helpers\App::dbMutexConfig()`.
- Added `craft\helpers\ElementHelper::translationDescription()`.
- Added `craft\helpers\ElementHelper::translationKey()`.
- Added `craft\helpers\ProjectConfig::splitConfigIntoComponents()`.
- Added `craft\models\FieldLayout::createForm()`.
- Added `craft\models\FieldLayout::EVENT_DEFINE_STANDARD_FIELDS`.
- Added `craft\models\FieldLayout::getAvailableCustomFields()`.
- Added `craft\models\FieldLayout::getAvailableStandardFields()`.
- Added `craft\models\FieldLayout::getAvailableUiElements()`.
- Added `craft\models\FieldLayout::getField()`.
- Added `craft\models\FieldLayout::isFieldIncluded()`.
- Added `craft\models\FieldLayoutForm`.
- Added `craft\models\FieldLayoutFormTab`.
- Added `craft\models\FieldLayoutTab::$elements`.
- Added `craft\models\FieldLayoutTab::createFromConfig()`.
- Added `craft\models\FieldLayoutTab::getConfig()`.
- Added `craft\models\FieldLayoutTab::getElementConfigs()`.
- Added `craft\models\FieldLayoutTab::updateConfig()`.
- Added `craft\services\Fields::createLayoutElement()`.
- Added `craft\services\Path::getProjectConfigPath()`.
- Added `craft\services\ProjectConfig::$folderName`. ([#5982](https://github.com/craftcms/cms/issues/5982))
- Added `craft\web\Controller::setFailFlash()`.
Expand All @@ -35,6 +71,8 @@
- Added `craft\web\Request::getIsJson()`.
- Added `craft\web\Request::getMimeType()`.
- Added `craft\web\View::$allowEval()`, which determines whether calling `evaluateDynamicContent()` should be allowed. ([#6185](https://github.com/craftcms/cms/pull/6185))
- Added the `Craft.Listbox` JavaScript class.
- Added the `Craft.SlidePicker` JavaScript class.

### Changed
- Craft now stores project config files in a new `config/project/` folder, regardless of whether the (deprecated) `useProjectConfigFile` config setting is enabled, and syncing new project config file changes is now optional.
Expand All @@ -55,11 +93,15 @@
- Deprecated `craft\elements\db\ElementQuery::$enabledForSite`.
- Deprecated `craft\elements\db\ElementQuery::enabledForSite()`.
- Deprecated `craft\helpers\App::mutexConfig()`.
- Deprecated `craft\services\Fields::assembleLayout()`.

### Removed
- Removed support for the `import` directive in project config files.
- Removed the `entries/_fields.html` control panel template.
- Removed the `entries/_titlefield.html` control panel template.
- Removed `craft\models\Info::$configMap`.
- Removed `craft\services\ProjectConfig::$filename`.
- Removed `craft\models\EntryType::$titleLabel`.

### Fixed
- Fixed an error that occurred when using the `gqlTypePrefix` config setting.
Expand All @@ -69,6 +111,8 @@
- Fixed a 403 Forbidden error that occurred when clicking on the GraphQL nav item, if the `allowAdminChanges` config setting was disabled. ([#6242](https://github.com/craftcms/cms/issues/6242))
- Fixed a bug where `data-params` and `data-param` attributes on `.formsubmit` elements weren’t being respected.
- Fix a bug where it was impossible to upload an asset using GraphQL mutations. ([#6322](https://github.com/craftcms/cms/pull/6322))
- Fixed a bug where Entry Edit pages would start showing a tab bar after switching entry types, even if the new entry type only had one content tab.
- Fixed a bug where some fields were growing wider than they were supposed to within element editor HUDs.

### Security
- `craft\web\View::evaluateDynamicContent()` can no longer be called by default. ([#6185](https://github.com/craftcms/cms/pull/6185))
Expand Down
31 changes: 31 additions & 0 deletions src/base/ApplicationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,22 @@
use craft\db\MigrationManager;
use craft\db\Query;
use craft\db\Table;
use craft\elements\Asset;
use craft\elements\Category;
use craft\elements\Entry;
use craft\errors\DbConnectException;
use craft\errors\SiteNotFoundException;
use craft\errors\WrongEditionException;
use craft\events\DefineFieldLayoutFieldsEvent;
use craft\events\EditionChangeEvent;
use craft\fieldlayoutelements\EntryTitleField;
use craft\fieldlayoutelements\TitleField;
use craft\helpers\App;
use craft\helpers\Db;
use craft\i18n\Formatter;
use craft\i18n\I18N;
use craft\i18n\Locale;
use craft\models\FieldLayout;
use craft\models\Info;
use craft\queue\Queue;
use craft\queue\QueueInterface;
Expand Down Expand Up @@ -1386,6 +1393,9 @@ private function _preInit()
*/
private function _postInit()
{
// Register field layout listeners
$this->_registerFieldLayoutListener();

// Register all the listeners for config items
$this->_registerConfigListeners();

Expand Down Expand Up @@ -1481,6 +1491,27 @@ private function _getFallbackLanguage(): string
return $this->sourceLanguage;
}

/**
* Register event listeners for field layouts.
*/
private function _registerFieldLayoutListener()
{
Event::on(FieldLayout::class, FieldLayout::EVENT_DEFINE_STANDARD_FIELDS, function(DefineFieldLayoutFieldsEvent $event) {
/** @var FieldLayout $fieldLayout */
$fieldLayout = $event->sender;

switch ($fieldLayout->type) {
case Asset::class:
case Category::class:
$event->fields[] = new TitleField();
break;
case Entry::class:
$event->fields[] = new EntryTitleField();
break;
}
});
}

/**
* Register event listeners for config changes.
*/
Expand Down
Loading

0 comments on commit 746eaff

Please sign in to comment.