From 828ca69bb452bd863b4d7834fb7f3711e33f058d Mon Sep 17 00:00:00 2001 From: JDGrimes Date: Tue, 13 Sep 2016 11:14:22 -0400 Subject: [PATCH 1/3] Hide legacy periods on non-legacy reactions Fixes #507 --- .../js/hooks/reactors/points.manifested.js | 24 ++++++++++++++----- .../points/reaction/periods/update.cept.php | 1 + .../js/hooks/reactors/points.manifest.js | 24 ++++++++++++++----- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/components/points/admin/assets/js/hooks/reactors/points.manifested.js b/src/components/points/admin/assets/js/hooks/reactors/points.manifested.js index 8b0454bc..878e2e07 100644 --- a/src/components/points/admin/assets/js/hooks/reactors/points.manifested.js +++ b/src/components/points/admin/assets/js/hooks/reactors/points.manifested.js @@ -94,15 +94,27 @@ hooks.on( 'init', function () { hooks.Reactors.add( new hooks.reactor.Points( data.points_legacy ) ); } - // Register the legacy periods extension. - hooks.Extensions.add( - new hooks.extension.Periods( { slug: 'points_legacy_periods' } ) - ); - - // Don't show regular periods extension when legacy periods are in use. var periods = hooks.Extensions.get( 'periods' ), nativeShowForReaction = periods.showForReaction; + // Legacy periods extension. + var LegacyPeriods = new hooks.extension.Periods( + { slug: 'points_legacy_periods' } + ); + + LegacyPeriods.showForReaction = function ( reaction ) { + + if ( ! reaction.model.get( 'points_legacy_periods' ) ) { + return false; + } + + return nativeShowForReaction( reaction ); + }; + + // Register the legacy periods extension. + hooks.Extensions.add( LegacyPeriods ); + + // Don't show regular periods extension when legacy periods are in use. periods.showForReaction = function ( reaction ) { if ( reaction.model.get( 'points_legacy_periods' ) ) { diff --git a/tests/codeception/acceptance/points/reaction/periods/update.cept.php b/tests/codeception/acceptance/points/reaction/periods/update.cept.php index 87405c5f..f2c3c2f9 100644 --- a/tests/codeception/acceptance/points/reaction/periods/update.cept.php +++ b/tests/codeception/acceptance/points/reaction/periods/update.cept.php @@ -16,6 +16,7 @@ $I->waitForElement( '#points-user_visit .wordpoints-hook-reaction' ); $I->click( 'Edit', '#points-user_visit .wordpoints-hook-reaction' ); $I->see( 'Rate Limit', '#points-user_visit .wordpoints-hook-reaction' ); +$I->cantSeeElement( '#points-user_visit .wordpoints-hook-reaction [name="points_legacy_periods[fire][0][length]"]' ); $I->canSeeOptionIsSelected( '#points-user_visit .wordpoints-hook-reaction [name="periods[fire][0][length]"]' , 'Minute' diff --git a/unbuilt/components/points/admin/assets/js/hooks/reactors/points.manifest.js b/unbuilt/components/points/admin/assets/js/hooks/reactors/points.manifest.js index 1f8d46be..0ce0f677 100644 --- a/unbuilt/components/points/admin/assets/js/hooks/reactors/points.manifest.js +++ b/unbuilt/components/points/admin/assets/js/hooks/reactors/points.manifest.js @@ -9,15 +9,27 @@ hooks.on( 'init', function () { hooks.Reactors.add( new hooks.reactor.Points( data.points_legacy ) ); } - // Register the legacy periods extension. - hooks.Extensions.add( - new hooks.extension.Periods( { slug: 'points_legacy_periods' } ) - ); - - // Don't show regular periods extension when legacy periods are in use. var periods = hooks.Extensions.get( 'periods' ), nativeShowForReaction = periods.showForReaction; + // Legacy periods extension. + var LegacyPeriods = new hooks.extension.Periods( + { slug: 'points_legacy_periods' } + ); + + LegacyPeriods.showForReaction = function ( reaction ) { + + if ( ! reaction.model.get( 'points_legacy_periods' ) ) { + return false; + } + + return nativeShowForReaction( reaction ); + }; + + // Register the legacy periods extension. + hooks.Extensions.add( LegacyPeriods ); + + // Don't show regular periods extension when legacy periods are in use. periods.showForReaction = function ( reaction ) { if ( reaction.model.get( 'points_legacy_periods' ) ) { From 3d5f0cf6e7e6953d384073e9942141d12e0b4846 Mon Sep 17 00:00:00 2001 From: JDGrimes Date: Sat, 10 Sep 2016 17:18:24 -0400 Subject: [PATCH 2/3] Don't modify field name arrays Fixes #504 --- src/admin/assets/js/hooks/views.manifested.js | 2 ++ unbuilt/admin/assets/js/hooks/controllers/fields.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/admin/assets/js/hooks/views.manifested.js b/src/admin/assets/js/hooks/views.manifested.js index 89e02bed..34943d32 100644 --- a/src/admin/assets/js/hooks/views.manifested.js +++ b/src/admin/assets/js/hooks/views.manifested.js @@ -643,6 +643,8 @@ Fields = Backbone.Model.extend({ if ( _.isArray( field ) ) { + field = _.clone( field ); + if ( 1 === field.length ) { field = field.shift(); } else { diff --git a/unbuilt/admin/assets/js/hooks/controllers/fields.js b/unbuilt/admin/assets/js/hooks/controllers/fields.js index 2e3a6384..e1e131d6 100644 --- a/unbuilt/admin/assets/js/hooks/controllers/fields.js +++ b/unbuilt/admin/assets/js/hooks/controllers/fields.js @@ -114,6 +114,8 @@ Fields = Backbone.Model.extend({ if ( _.isArray( field ) ) { + field = _.clone( field ); + if ( 1 === field.length ) { field = field.shift(); } else { From bc0ae917aab41e4bfb075bf9e20c03332d736c1c Mon Sep 17 00:00:00 2001 From: JDGrimes Date: Tue, 13 Sep 2016 11:43:15 -0400 Subject: [PATCH 3/3] 2.1.2 --- package.json | 2 +- src/includes/constants.php | 2 +- src/languages/wordpoints-es_ES.mo | Bin 27577 -> 27577 bytes src/languages/wordpoints-es_ES.po | 4 ++-- src/languages/wordpoints-lt.mo | Bin 7653 -> 7653 bytes src/languages/wordpoints-lt.po | 4 ++-- src/languages/wordpoints-pt_BR.mo | Bin 28112 -> 28112 bytes src/languages/wordpoints-pt_BR.po | 4 ++-- src/languages/wordpoints.pot | 6 +++--- src/readme.txt | 13 ++++++++++++- src/wordpoints.php | 4 ++-- 11 files changed, 25 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 8afd01fe..fd75fbd4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wordpoints", - "version": "2.1.1", + "version": "2.1.2", "description": "Gamify your WordPress site with points.", "repository": { "type": "git", diff --git a/src/includes/constants.php b/src/includes/constants.php index cb5ece73..95aa7976 100644 --- a/src/includes/constants.php +++ b/src/includes/constants.php @@ -22,7 +22,7 @@ * * @const WORDPOINTS_VERSION */ -define( 'WORDPOINTS_VERSION', '2.1.1' ); +define( 'WORDPOINTS_VERSION', '2.1.2' ); /** * The full path to the plugin's main directory. diff --git a/src/languages/wordpoints-es_ES.mo b/src/languages/wordpoints-es_ES.mo index 66c559fa67835a5816e755dce9c251deee31ecac..c2228641a42b6ce6bc581997fce2a82fe23acb66 100755 GIT binary patch delta 25 gcmdmaopI-N#trfIT*eB9rdB2fRwibfGwlO(0DG$lO#lD@ delta 25 gcmdmaopI-N#trfITt*6pmR6<~Rt6TEGwlO(0DKMzR{#J2 diff --git a/src/languages/wordpoints-es_ES.po b/src/languages/wordpoints-es_ES.po index abf6c910..5a71daf7 100644 --- a/src/languages/wordpoints-es_ES.po +++ b/src/languages/wordpoints-es_ES.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: WordPoints 1.5.0\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wordpoints\n" -"POT-Creation-Date: 2016-09-12 19:58:08+00:00\n" +"POT-Creation-Date: 2016-09-13 15:40:46+00:00\n" "PO-Revision-Date: 2015-02-24 19:20+0200\n" "Last-Translator: Gonzalo Exequiel Pedone \n" "Language-Team: Spanish \n" "Language-Team: Lithuanian xQrDHO|47}tW3-{e|Ea71ptl63Mc>o delta 25 hcmca`oAJVJ#tko>xQrAGEv-x~tPCtRe|Ea71ptmK3Nioy diff --git a/src/languages/wordpoints-pt_BR.po b/src/languages/wordpoints-pt_BR.po index d02816d3..7fb7396e 100644 --- a/src/languages/wordpoints-pt_BR.po +++ b/src/languages/wordpoints-pt_BR.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: WordPoints_pt_BR\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wordpoints\n" -"POT-Creation-Date: 2016-09-12 19:58:08+00:00\n" +"POT-Creation-Date: 2016-09-13 15:40:46+00:00\n" "PO-Revision-Date: 2015-08-27 23:54+0200\n" "Last-Translator: Leonardo Faria \n" "Language-Team: Portuguese (Brazil) - * @version 2.1.1 * @license http://opensource.org/licenses/gpl-license.php GPL, version 2 or later. + * @version 2.1.2 * @copyright 2013-2015 J.D. Grimes */