Skip to content

Commit

Permalink
Adds support for Tags. Bump to 2.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mmikkel committed Jun 12, 2020
1 parent b6fe213 commit c519bc1
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## 2.1.2 - 2020-06-12
### Added
- Adds support for Tags
### Fixed
- Fixes an issue where Reasons could break element editor modals for Tags

## 2.1.1 - 2020-06-08
### Fixed
- Fixes an issue where Reasons could throw an exception when syncing project config via console
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ These field types can be used as toggle fields:

### Where does it work?

Reasons works for Entries, Global Sets, Categories, Assets and Users. It also works inside Live Preview, in element editor modals and for entry drafts and revisions.
Reasons works for Entries, Global Sets, Categories, Assets, Users and Tags. It also works inside Live Preview, in element editor modals and for entry drafts and revisions.

### A note on required fields

Be careful not to add conditionals to a required field. Even if the required field is hidden, it'll still be _required_ by Craft, potentially making your content impossible to save.

### What Reasons doesn't do - or a disclaimer of sorts

It's important to realize that Reasons is strictly about increasing authoring experienc, by hiding the UI for fields that might be irrelevant based on other fields' current values.
It's important to realize that Reasons is strictly about increasing authoring experience, by hiding the UI for fields that might be irrelevant based on other fields' current values.

Reasons works as a thin layer on top of Craft's Control Panel UI, using JavaScript to show and hide fields as content is being edited. Since the plugin is dependant on undocumented features, markup, CSS and JavaScript in the Control Panel, it's basically a big hack and may stop working at any time if certain aspects of the Control Panel is ever changed or redesigned.

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "mmikkel/reasons",
"description": "Adds conditionals to field layouts.",
"type": "craft-plugin",
"version": "2.1.1",
"version": "2.1.2",
"keywords": [
"craft",
"cms",
Expand Down
2 changes: 1 addition & 1 deletion src/Reasons.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ protected function initAjaxRequest()
break;

case Tag::class:
$conditionalsKey = "tagGroup:{$element->tagId}";
$conditionalsKey = "tagGroup:{$element->groupId}";
break;

case User::class:
Expand Down
11 changes: 11 additions & 0 deletions src/assetbundles/reasons/dist/js/reasons.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
ENTRY_TYPE_ACTION: 'sections/save-entry-type',
USERS_ACTION: 'users/save-user',
USERS_FIELDS_ACTION: 'users/save-field-layout',
TAG_ACTION: 'tags/save-tag',
TAG_GROUP_ACTION: 'tags/save-tag-group',
FIELDS_ACTION: 'fields/save-field',

RENDER_CONTEXT: 'render',
Expand Down Expand Up @@ -122,6 +124,7 @@
}

var formData = this.getElementSourceFromForm($form);

if (!formData) {
return null;
}
Expand Down Expand Up @@ -241,6 +244,12 @@
type = this.USERS_HANDLE;
break;

case this.TAG_ACTION :
case this.TAG_GROUP_ACTION :
type = this.TAG_GROUP_HANDLE;
idInputSelector = 'input[type="hidden"][name="tagGroupId"]';
break;

}

if (!type) {
Expand Down Expand Up @@ -274,13 +283,15 @@
case this.ENTRY_REVISION_ACTION :
case this.CATEGORY_ACTION :
case this.USERS_ACTION :
case this.TAG_ACTION :
return this.RENDER_CONTEXT;

case this.ASSET_SOURCE_ACTION :
case this.CATEGORY_GROUP_ACTION :
case this.GLOBAL_SET_ACTION :
case this.ENTRY_TYPE_ACTION :
case this.USERS_FIELDS_ACTION :
case this.TAG_GROUP_ACTION :
return this.LAYOUT_DESIGNER_CONTEXT;

}
Expand Down

0 comments on commit c519bc1

Please sign in to comment.