diff --git a/assets/javascripts/discourse/lib/wizard-mapper.js.es6 b/assets/javascripts/discourse/lib/wizard-mapper.js.es6 index c398eaf4..9037bec5 100644 --- a/assets/javascripts/discourse/lib/wizard-mapper.js.es6 +++ b/assets/javascripts/discourse/lib/wizard-mapper.js.es6 @@ -35,6 +35,7 @@ function inputTypesContent(options = {}) { const connectors = { pair: [ "equal", + "not_equal", "greater", "less", "greater_or_equal", diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 8a856636..98519335 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -324,6 +324,7 @@ en: then: "then" set: "set" equal: '=' + not_equal: '!=' greater: '>' less: '<' greater_or_equal: '>=' diff --git a/lib/custom_wizard/mapper.rb b/lib/custom_wizard/mapper.rb index 4e18ad01..66a10736 100644 --- a/lib/custom_wizard/mapper.rb +++ b/lib/custom_wizard/mapper.rb @@ -30,6 +30,7 @@ class CustomWizard::Mapper OPERATORS = { equal: '==', + not_equal: "!=", greater: '>', less: '<', greater_or_equal: '>=', diff --git a/plugin.rb b/plugin.rb index 8d5d1a89..b90e0965 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # name: discourse-custom-wizard # about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more. -# version: 2.3.2 +# version: 2.3.3 # authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever # url: https://github.com/paviliondev/discourse-custom-wizard # contact_emails: development@pavilion.tech diff --git a/spec/components/custom_wizard/mapper_spec.rb b/spec/components/custom_wizard/mapper_spec.rb index 510632a9..3e0e6ce6 100644 --- a/spec/components/custom_wizard/mapper_spec.rb +++ b/spec/components/custom_wizard/mapper_spec.rb @@ -291,6 +291,19 @@ describe CustomWizard::Mapper do end end + it "handles not equal pairs" do + expect(CustomWizard::Mapper.new( + inputs: inputs['not_equals_pair'], + data: data, + user: user1 + ).perform).to eq(true) + expect(CustomWizard::Mapper.new( + inputs: inputs['not_equals_pair'], + data: data, + user: user2 + ).perform).to eq(false) + end + it "handles greater than pairs" do expect(CustomWizard::Mapper.new( inputs: inputs['greater_than_pair'], diff --git a/spec/fixtures/mapper/inputs.json b/spec/fixtures/mapper/inputs.json index 3fd406a4..2ef81a28 100644 --- a/spec/fixtures/mapper/inputs.json +++ b/spec/fixtures/mapper/inputs.json @@ -195,6 +195,21 @@ ] } ], + "not_equals_pair": [ + { + "type": "validation", + "pairs": [ + { + "index": 0, + "key": "trust_level", + "key_type": "user_field", + "value": "1", + "value_type": "text", + "connector": "not_equal" + } + ] + } + ], "greater_than_pair": [ { "type": "validation",