visual_condition_builder 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f82b832c1d6f0be7ab2ad7a6c4d025ba89b27a2c
4
- data.tar.gz: a14f601b2bf2d7fef39b8e2382c0ec25f28ec738
3
+ metadata.gz: 8f5efbc1e1e60c13d256b4fec51886eb21f209c1
4
+ data.tar.gz: b4c2d18b2e3ede0ae1a0c48ad86fd36de2b409c8
5
5
  SHA512:
6
- metadata.gz: c88f8576de543bcd9a27caabaf5f70e472045d11711bae5d7cd56e0cc17631b9b4a1b1bfce8acef2af470bf1acf53ab51697bf489a267e796838754649b72d74
7
- data.tar.gz: 8433a51f5b221621c0b8f0adadf85966010d04d67a16e0885ed214eac8dd79176a3205cec6b65440b7d1d4792adee5dfc803d2365d8384c487e29d2a38d4a4b0
6
+ metadata.gz: 07cbfd797610edb9b85ee44c05da413c496bc28888aea3563c11d6b013e000067df56f05d7d2c8aec0507a2dc3abb33eeb04269222866c6b0c6fedc101f70949
7
+ data.tar.gz: 83b5ec6de8d1f239908e932a7f33c7bcfef7cf3ecae69637230f8b3968d74865817bf04118b31fde339727ae8cbcb61adaa40a92f6500cec38e938efea35e1dc
data/README.md CHANGED
@@ -2,10 +2,6 @@
2
2
 
3
3
  A great and easy condition builder to your rails project
4
4
 
5
- **BOOTSTRAP 3** : Version 0. ~ 1.
6
-
7
- **BOOTSTRAP 4** : Version 2. +
8
-
9
5
  ## How to install
10
6
 
11
7
  Add it to your **Gemfile**:
@@ -52,11 +52,11 @@
52
52
  field_label = Object.values(fieldObj.group)[0] + ' : ' + field_label;
53
53
  }
54
54
  block.append('<input id="field_'+new_id+'" data-group-id="'+new_id+'" type="hidden" class="field form-control" value="' + fieldObj.field + '" data-type="' + fieldObj.type + '" />');
55
- block.append('<span id="field_name_'+new_id+'" data-group-id="'+new_id+'" class="field_name tag tag-info">' + field_label + ' <a href="" id="remove_condition_'+new_id+'" data-group-id="'+new_id+'" class="remove-condition">&#10006;</a></span>');
56
- block.append('<select id="operators_'+new_id+'" data-group-id="'+new_id+'" class="operators form-control" style="display: none"></select>');
57
- block.append('<span id="fixed_operator_'+new_id+'" data-group-id="'+new_id+'" class="fixed_operator form-control" style="display: none"></span>');
58
- block.append('<select id="values_'+new_id+'" data-group-id="'+new_id+'" class="values form-control" style="display: none"></select>');
59
- block.append('<input id="fixed_value_'+new_id+'" data-group-id="'+new_id+'" class="fixed_value form-control" style="display: none" />');
55
+ block.append('<span id="field_name_'+new_id+'" data-group-id="'+new_id+'" class="field_name label label-info">' + field_label + ' <a href="" id="remove_condition_'+new_id+'" data-group-id="'+new_id+'" class="remove-condition">&#10006;</a></span>');
56
+ block.append('<select id="operators_'+new_id+'" data-group-id="'+new_id+'" class="operators hide form-control"></select>');
57
+ block.append('<span id="fixed_operator_'+new_id+'" data-group-id="'+new_id+'" class="fixed_operator hide form-control"></span>');
58
+ block.append('<select id="values_'+new_id+'" data-group-id="'+new_id+'" class="values hide form-control"></select>');
59
+ block.append('<input id="fixed_value_'+new_id+'" data-group-id="'+new_id+'" class="fixed_value hide form-control" />');
60
60
  if (plugin.parameters.debug == true) {
61
61
  block.append('<p class="expression help-block"></p>');
62
62
  }
@@ -96,10 +96,10 @@
96
96
  var operators = field.operators;
97
97
 
98
98
  remove_plugins_elements(groupConditionId);
99
- $operators.html('').hide();
100
- $fixedOperator.val('').hide();
101
- $values.html('').hide();
102
- $fixedValue.val('').hide();
99
+ $operators.html('').addClass('hide');
100
+ $fixedOperator.val('').addClass('hide');
101
+ $values.html('').addClass('hide');
102
+ $fixedValue.val('').addClass('hide');
103
103
 
104
104
  operators = normalize_operators(operators);
105
105
  $.each(operators, function (op_i, op_el) {
@@ -107,9 +107,9 @@
107
107
  $operators.append(op_option);
108
108
  });
109
109
  if (operators != undefined && operators.length == 1) {
110
- $fixedOperator.html(getLabel(operators[0])).show();
110
+ $fixedOperator.html(getLabel(operators[0])).removeClass('hide');
111
111
  } else {
112
- $operators.show();
112
+ $operators.removeClass('hide');
113
113
  }
114
114
  $operators.trigger('change');
115
115
  };
@@ -243,7 +243,7 @@
243
243
 
244
244
  var getValueElement = function (groupConditions) {
245
245
  var element = $(groupConditions).find('.values');
246
- if (element.is(":hidden")) {
246
+ if (element.hasClass('hide')) {
247
247
  element = $(groupConditions).find('.fixed_value');
248
248
  }
249
249
  return element;
@@ -321,10 +321,8 @@
321
321
  $.each(plugin.parameters.values, function (i, data) {
322
322
  var field = data[0];
323
323
  var groupConditions = plugin.add_condition(field);
324
- if (!is_blank(groupConditions)) {
325
- var groupConditionId = groupConditions.attr('data-id');
326
- plugin.fill_condition(groupConditionId, data);
327
- }
324
+ var groupConditionId = groupConditions.attr('data-id');
325
+ plugin.fill_condition(groupConditionId, data);
328
326
  });
329
327
  }
330
328
  };
@@ -336,8 +334,8 @@
336
334
  var $fixedValue = $groupConditions.find('.fixed_value');
337
335
  var multiple = op_el.attr('data-multiple');
338
336
  multiple = (multiple == 'true' ? 'true' : 'false');
339
- $values.html('').removeAttr('data-ajax-values').hide();
340
- $fixedValue.removeAttr('data-ajax-values').hide();
337
+ $values.html('').removeAttr('data-ajax-values').addClass('hide');
338
+ $fixedValue.removeAttr('data-ajax-values').addClass('hide');
341
339
 
342
340
  if (typeof values === 'string') {
343
341
  $values.attr('data-ajax-values', values);
@@ -362,14 +360,14 @@
362
360
  }
363
361
  $values.append('<option data-index="' + val_i + '" value="' + _id + '">' + _label + '</option>');
364
362
  });
365
- $values.show();
363
+ $values.removeClass('hide');
366
364
  $values.trigger('change');
367
365
  } else {
368
366
  if (multiple == 'true') {
369
- $values.show();
367
+ $values.removeClass('hide');
370
368
  $values.trigger('change');
371
369
  } else {
372
- $fixedValue.show();
370
+ $fixedValue.removeClass('hide');
373
371
  $fixedValue.trigger('change');
374
372
  }
375
373
  }
@@ -393,7 +391,7 @@
393
391
  if (!isNaN(multiple)) {
394
392
  for (var i = 1; i < parseInt(multiple); i++) {
395
393
  var $valueElClone = $valueEl.clone();
396
- $valueElClone.addClass('clone').show();
394
+ $valueElClone.addClass('clone').removeClass('hide');
397
395
  $valueElClone.insertAfter($valueEl);
398
396
  }
399
397
  } else {
@@ -469,7 +467,7 @@
469
467
  console.log(field_name, uTypeField);
470
468
  $el.parent().append('<i class="type_field" style="font-size: 10px; color: #ccc;"><br>' + uTypeField + '</i>');
471
469
  }
472
- if (($el.hasClass('values') && $el.is(":visible"))) {
470
+ if (($el.hasClass('values') && !$el.hasClass('hide'))) {
473
471
  // build_select2_element($el, (!list_with_item && multiple == 'true'));
474
472
  build_select2_element($el);
475
473
  }
@@ -17,6 +17,10 @@
17
17
  vertical-align: middle;
18
18
  }
19
19
 
20
+ .condition-builder .hide {
21
+ display: none !important;
22
+ }
23
+
20
24
  .add-condition {
21
25
  display: inline-block;
22
26
  }
@@ -27,6 +31,16 @@
27
31
  overflow-x: hidden;
28
32
  }
29
33
 
34
+ .add-condition-menu > li > a {
35
+ display: block;
36
+ padding: 3px 20px;
37
+ clear: both;
38
+ font-weight: 400;
39
+ line-height: 1.42857143;
40
+ color: #333;
41
+ white-space: nowrap;
42
+ }
43
+
30
44
  .condition-builder .remove-condition {
31
45
  margin-left: 5px;
32
46
  font-size: 16px;
@@ -34,7 +34,7 @@ txtjs
34
34
  concat(I18n.t(:dropdown, default: ['Fields'], scope: [:condition_builder]))
35
35
  concat(content_tag(:span, nil, class:'caret'))
36
36
  end)
37
- concat(content_tag(:div, class: 'dropdown-menu add-condition-menu') do
37
+ concat(content_tag(:ul, class: 'dropdown-menu add-condition-menu') do
38
38
  create_conditions_fields_item(dictionary_klass.fields(get_dictionary_context(dictionary)))
39
39
  end)
40
40
  end
@@ -46,10 +46,10 @@ txtjs
46
46
  fields.each do |field, attrs|
47
47
  if field.is_a?(Hash) #GROUP
48
48
  group_label = field.values.first
49
- concat(content_tag(:h6, group_label, class: 'dropdown-header'))
49
+ concat(content_tag(:li, group_label, class: 'dropdown-header'))
50
50
  create_conditions_fields_item(attrs)
51
51
  else
52
- concat(link_to(attrs[:label], 'javascript:void(0)', class: 'dropdown-item add-condition-field', data: {field: field}))
52
+ concat(content_tag(:li, link_to(attrs[:label], '#', class: 'add-condition-field', data: {field: field})))
53
53
  end
54
54
  end
55
55
  end
@@ -1,7 +1,7 @@
1
- class Railtie < ::Rails::Railtie
2
- initializer 'activeservice.autoload', :before => :set_autoload_paths do |app|
3
- app.config.autoload_paths << "#{Rails.application.config.root}/app/condition_dictionaries"
4
- end
5
- end
6
-
1
+ # class Railtie < ::Rails::Railtie
2
+ # initializer 'activeservice.autoload', :before => :set_autoload_paths do |app|
3
+ # app.config.autoload_paths << "#{Rails.application.config.root}/app/condition_dictionaries"
4
+ # end
5
+ # end
6
+ #
7
7
 
@@ -1,4 +1,4 @@
1
- # require 'haml'
1
+ require 'haml'
2
2
  require 'visual_condition_builder/engine'
3
3
  require 'visual_condition_builder/helper'
4
4
  require 'visual_condition_builder/converter'
@@ -1,7 +1,7 @@
1
1
  module VisualConditionBuilder
2
2
  module Helper
3
3
  def dictionary_values(id_field, label_field)
4
- self.map{|r| {id: r[id_field], label: r[label_field]} }
4
+ self.map {|r| {id: r[id_field], label: r[label_field]}}
5
5
  end
6
6
  end
7
7
  end
@@ -12,8 +12,19 @@ class Array
12
12
  end
13
13
 
14
14
  #INJETANDO METODO para_* em um conjunto de registros ActiveRecord::Relation
15
- module ActiveRecord
16
- class Relation
17
- include VisualConditionBuilder::Helper
15
+ if defined?(ActiveRecord)
16
+ module ActiveRecord
17
+ class Relation
18
+ include VisualConditionBuilder::Helper
19
+ end
20
+ end
21
+ end
22
+
23
+ #INJETANDO METODO para_* em um conjunto de registros Mongoid::Criteria
24
+ if defined?(Mongoid)
25
+ module Mongoid
26
+ class Criteria
27
+ include VisualConditionBuilder::Helper
28
+ end
18
29
  end
19
30
  end
@@ -1,3 +1,3 @@
1
1
  module VisualConditionBuilder
2
- VERSION = "2.0.0"
2
+ VERSION = "2.1.0"
3
3
  end
metadata CHANGED
@@ -1,15 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: visual_condition_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bruno Porto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-30 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2017-08-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '6'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '3'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '6'
13
33
  description: A great and easy visual condition builder to your rails project
14
34
  email:
15
35
  - brunotporto@gmail.com
@@ -19,7 +39,6 @@ extra_rdoc_files: []
19
39
  files:
20
40
  - MIT-LICENSE
21
41
  - README.md
22
- - Rakefile
23
42
  - app/assets/javascripts/visual_condition_builder.js
24
43
  - app/assets/javascripts/visual_condition_builder/Sortable.js
25
44
  - app/assets/javascripts/visual_condition_builder/autoNumeric-2.0-BETA.js
@@ -96,7 +115,8 @@ files:
96
115
  homepage: https://github.com/brunoporto/visual_condition_builder
97
116
  licenses:
98
117
  - MIT
99
- metadata: {}
118
+ metadata:
119
+ allowed_push_host: https://rubygems.org
100
120
  post_install_message:
101
121
  rdoc_options: []
102
122
  require_paths:
@@ -113,8 +133,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
133
  version: '0'
114
134
  requirements: []
115
135
  rubyforge_project:
116
- rubygems_version: 2.5.1
136
+ rubygems_version: 2.6.12
117
137
  signing_key:
118
138
  specification_version: 4
119
- summary: A great and easy visual condition builder to your rails project
139
+ summary: Visual Condition Builder to your rails project
120
140
  test_files: []
data/Rakefile DELETED
@@ -1,34 +0,0 @@
1
- begin
2
- require 'bundler/setup'
3
- rescue LoadError
4
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
- end
6
-
7
- # require 'rdoc/task'
8
- # RDoc::Task.new(:rdoc) do |rdoc|
9
- # rdoc.rdoc_dir = 'rdoc'
10
- # rdoc.title = 'VisualConditionBuilder'
11
- # rdoc.options << '--line-numbers'
12
- # rdoc.rdoc_files.include('README.rdoc')
13
- # rdoc.rdoc_files.include('lib/**/*.rb')
14
- # end
15
-
16
- APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
17
- load 'rails/tasks/engine.rake'
18
-
19
-
20
- load 'rails/tasks/statistics.rake'
21
-
22
- Bundler::GemHelper.install_tasks
23
-
24
- # require 'rake/testtask'
25
- #
26
- # Rake::TestTask.new(:test) do |t|
27
- # t.libs << 'lib'
28
- # t.libs << 'test'
29
- # t.pattern = 'test/**/*_test.rb'
30
- # t.verbose = false
31
- # end
32
- #
33
- #
34
- # task default: :test