Skip to content
This repository has been archived by the owner on Oct 18, 2022. It is now read-only.

Commit

Permalink
Fixes issue with AND conditionals not working as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
mmikkel committed Nov 19, 2016
1 parent c6e340a commit 3f1f3aa
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 22 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Reasons v. 1.0.7 for Craft CMS ![Craft 2.5](https://img.shields.io/badge/craft-2.5-red.svg?style=flat-square)
# Reasons v. 1.0.8 for Craft CMS ![Craft 2.5](https://img.shields.io/badge/craft-2.5-red.svg?style=flat-square)

_Supercharge your field layouts with conditionals._

Expand All @@ -10,7 +10,7 @@ _Big props to [Benjamin Fleming](https://github.com/benjamminf) for some good id

## Recent updates
* Support for [Button Box](http://plugins.supercooldesign.co.uk/plugin/button-box) custom FieldTypes as toggle fields
* Support for all native relational fields (Entries, Assets, Categories, Tags and Users) as toggle fields
* Support for all native relational fields (Entries, Assets, Categories, Tags and Users) as toggle fields
* Support for [Solspace Calendar](https://solspace.com/craft/calendar)

## Requirements
Expand Down Expand Up @@ -58,7 +58,7 @@ The following custom FieldTypes are also supported:

### Where does it work?

Reasons currently works for
Reasons currently works for

* Entries
* Categories
Expand Down Expand Up @@ -110,6 +110,10 @@ Please report any bugs, feature requests or other issues [here](https://github.c

### Changelog

#### 1.0.8 (19.11.2016)

* [Fixed] Fixes issue with AND conditionals not working as expected

#### 1.0.7 (10.01.2016)

* [Fixed] Fixes minor JavaScript bug (thanks @benf!)
Expand Down
4 changes: 2 additions & 2 deletions reasons/ReasonsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class ReasonsPlugin extends BasePlugin
{

protected $_version = '1.0.7';
protected $_version = '1.0.8';
protected $_schemaVersion = '1.1';
protected $_developer = 'Mats Mikkel Rummelhoff';
protected $_developerUrl = 'http://mmikkel.no';
Expand Down Expand Up @@ -359,7 +359,7 @@ protected function getConditionals()
// $productTypes = craft()->commerce_productTypes->getAllProductTypes();
// if ($productTypes) {
// foreach ($productTypes as $productType) {
// $sources['commerceProductType:'.$productType->id] =
// $sources['commerceProductType:'.$productType->id] =
// }
// }
// }
Expand Down

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions reasons/resources/rev-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"javascripts/reasons.js": "javascripts/reasons-77b7190892588775dd7e.js",
"stylesheets/reasons.css": "stylesheets/reasons-38f07b2161.css"
"javascripts/reasons.js": "javascripts/reasons-a08bbfa4180502815a4e.js",
"stylesheets/reasons.css": "stylesheets/reasons-8f9624f667.css"
}
8 changes: 8 additions & 0 deletions releases.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
[
{
"version": "1.0.8",
"downloadUrl": "https://github.com/mmikkel/Reasons-Craft/archive/master.zip",
"date": "2016-11-19T10:00:00-08:00",
"notes": [
"[Fixed] Fixes issue with AND conditionals not working as expected"
]
},
{
"version": "1.0.7",
"downloadUrl": "https://github.com/mmikkel/Reasons-Craft/archive/master.zip",
Expand Down
18 changes: 11 additions & 7 deletions source/javascripts/modules/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module.exports = class {
.on('click', this.settings.fieldsSelector + '[data-toggle="1"]', this.onInputWrapperClick.bind(this))
.on('change keyup', this.settings.fieldsSelector + '[data-toggle="1"] *:input, '+this.settings.fieldsSelector + '[data-toggle="1"] '+this.settings.lightswitchContainerSelector, this.onFieldInputChange.bind(this))
.on('click', 'a[data-buttonbox-value]', this.onFieldInputChange.bind(this));

// Init element selects
var self = this,
elementSelectClassnames = ['elementselect', 'categoriesfield'],
Expand Down Expand Up @@ -72,12 +72,12 @@ module.exports = class {

removeEventListeners()
{

Garnish.$doc
.off('click', this.settings.fieldsSelector + '[data-toggle="1"]', this.onInputWrapperClick.bind(this))
.off('change keyup', this.settings.fieldsSelector + '[data-toggle="1"] *:input, '+this.settings.fieldsSelector + '[data-toggle="1"] '+this.settings.lightswitchContainerSelector, this.onFieldInputChange.bind(this))
.off('click', 'a[data-buttonbox-value]', this.onFieldInputChange.bind(this));

var self = this,
elementSelect;

Expand Down Expand Up @@ -169,10 +169,14 @@ module.exports = class {
}

// Get toggle field IDs
var fieldIds = Object.keys(this.conditionals);
var toggleFieldIds = [];
for (fieldId in this.conditionals) {
for (var i = 0; i < this.conditionals[fieldId].length; ++i){
toggleFieldIds.push(this.conditionals[fieldId][i][0].fieldId);
var statements;

for (var i = 0; i < fieldIds.length; ++i) {
statements = this.conditionals[fieldIds[i]][0];
for (var j = 0; j < statements.length; ++j) {
toggleFieldIds.push(statements[j].fieldId);
}
}

Expand Down Expand Up @@ -368,4 +372,4 @@ module.exports = class {
Garnish.requestAnimationFrame(this.evaluateConditionals.bind(this));
}

}
}
14 changes: 7 additions & 7 deletions source/javascripts/reasons.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
LAYOUT_DESIGNER_CONTEXT : 'fld',
FIELD_DESIGNER_CONTEXT : 'field',


/*
* Initialize Reasons
*
Expand Down Expand Up @@ -81,7 +81,7 @@
{

var conditionals = this.getConditionals(conditionalsKey);

if (!conditionals) {
return false;
}
Expand Down Expand Up @@ -238,7 +238,7 @@
idInputSelector = $entryType.length ? 'select#entryType, input[type="hidden"][name="entryTypeId"], input[type="hidden"][name="typeId"], #' + namespace + 'entryType' : 'input[type="hidden"][name="sectionId"], #' + namespace + 'section';
break;

case this.ENTRY_TYPE_ACTION :
case this.ENTRY_TYPE_ACTION :
type = this.ENTRY_TYPE_HANDLE;
idInputSelector = 'input[type="hidden"][name="entryTypeId"]';
break;
Expand Down Expand Up @@ -280,7 +280,7 @@
type : type,
id : idInputSelector ? ($form.find(idInputSelector).val() | 0) : false
};

},

getFormContext : function ($form)
Expand All @@ -306,7 +306,7 @@
case this.ASSET_SOURCE_ACTION :
case this.CATEGORY_GROUP_ACTION :
case this.GLOBAL_SET_ACTION :
case this.ENTRY_TYPE_ACTION :
case this.ENTRY_TYPE_ACTION :
case this.TAG_GROUP_ACTION :
case this.USERS_FIELDS_ACTION :
case this.SOLSPACE_CALENDAR_SETTINGS_ACTION :
Expand All @@ -315,7 +315,7 @@

case this.FIELDS_ACTION :
return this.FIELD_DESIGNER_CONTEXT;

}

return false;
Expand Down Expand Up @@ -344,4 +344,4 @@ if (window.jQuery) {
return false;
};
})( jQuery );
}
}

0 comments on commit 3f1f3aa

Please sign in to comment.