visual_condition_builder 0.1.6 → 2.0.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: 9ea07253b9dc8b055f7fc38fd0fa0d0e966d37b3
4
- data.tar.gz: e59b36b297760866d4a3e4a87565432ec8ef7af5
3
+ metadata.gz: f82b832c1d6f0be7ab2ad7a6c4d025ba89b27a2c
4
+ data.tar.gz: a14f601b2bf2d7fef39b8e2382c0ec25f28ec738
5
5
  SHA512:
6
- metadata.gz: 1c6d56f57ece6ebdf922c2030ab94dbe9b0c067df49650c3b68a707d91d487a53c3242612477eaeca1463c762e6b1aed21e252c170b6b930deaac020c3ac7aac
7
- data.tar.gz: 300c167f4e732e991143da6462bc151652d38ff4b665e6ea240cdf3f615fc15e5743d12e092fe2b98019b2ee4f16c2e8addbae0388ecafb3588ed326e9d01a60
6
+ metadata.gz: c88f8576de543bcd9a27caabaf5f70e472045d11711bae5d7cd56e0cc17631b9b4a1b1bfce8acef2af470bf1acf53ab51697bf489a267e796838754649b72d74
7
+ data.tar.gz: 8433a51f5b221621c0b8f0adadf85966010d04d67a16e0885ed214eac8dd79176a3205cec6b65440b7d1d4792adee5dfc803d2365d8384c487e29d2a38d4a4b0
data/README.md CHANGED
@@ -2,6 +2,10 @@
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
+
5
9
  ## How to install
6
10
 
7
11
  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 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" />');
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" />');
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('').addClass('hide');
100
- $fixedOperator.val('').addClass('hide');
101
- $values.html('').addClass('hide');
102
- $fixedValue.val('').addClass('hide');
99
+ $operators.html('').hide();
100
+ $fixedOperator.val('').hide();
101
+ $values.html('').hide();
102
+ $fixedValue.val('').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])).removeClass('hide');
110
+ $fixedOperator.html(getLabel(operators[0])).show();
111
111
  } else {
112
- $operators.removeClass('hide');
112
+ $operators.show();
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.hasClass('hide')) {
246
+ if (element.is(":hidden")) {
247
247
  element = $(groupConditions).find('.fixed_value');
248
248
  }
249
249
  return element;
@@ -321,8 +321,10 @@
321
321
  $.each(plugin.parameters.values, function (i, data) {
322
322
  var field = data[0];
323
323
  var groupConditions = plugin.add_condition(field);
324
- var groupConditionId = groupConditions.attr('data-id');
325
- plugin.fill_condition(groupConditionId, data);
324
+ if (!is_blank(groupConditions)) {
325
+ var groupConditionId = groupConditions.attr('data-id');
326
+ plugin.fill_condition(groupConditionId, data);
327
+ }
326
328
  });
327
329
  }
328
330
  };
@@ -334,8 +336,8 @@
334
336
  var $fixedValue = $groupConditions.find('.fixed_value');
335
337
  var multiple = op_el.attr('data-multiple');
336
338
  multiple = (multiple == 'true' ? 'true' : 'false');
337
- $values.html('').removeAttr('data-ajax-values').addClass('hide');
338
- $fixedValue.removeAttr('data-ajax-values').addClass('hide');
339
+ $values.html('').removeAttr('data-ajax-values').hide();
340
+ $fixedValue.removeAttr('data-ajax-values').hide();
339
341
 
340
342
  if (typeof values === 'string') {
341
343
  $values.attr('data-ajax-values', values);
@@ -360,14 +362,14 @@
360
362
  }
361
363
  $values.append('<option data-index="' + val_i + '" value="' + _id + '">' + _label + '</option>');
362
364
  });
363
- $values.removeClass('hide');
365
+ $values.show();
364
366
  $values.trigger('change');
365
367
  } else {
366
368
  if (multiple == 'true') {
367
- $values.removeClass('hide');
369
+ $values.show();
368
370
  $values.trigger('change');
369
371
  } else {
370
- $fixedValue.removeClass('hide');
372
+ $fixedValue.show();
371
373
  $fixedValue.trigger('change');
372
374
  }
373
375
  }
@@ -391,7 +393,7 @@
391
393
  if (!isNaN(multiple)) {
392
394
  for (var i = 1; i < parseInt(multiple); i++) {
393
395
  var $valueElClone = $valueEl.clone();
394
- $valueElClone.addClass('clone').removeClass('hide');
396
+ $valueElClone.addClass('clone').show();
395
397
  $valueElClone.insertAfter($valueEl);
396
398
  }
397
399
  } else {
@@ -467,7 +469,7 @@
467
469
  console.log(field_name, uTypeField);
468
470
  $el.parent().append('<i class="type_field" style="font-size: 10px; color: #ccc;"><br>' + uTypeField + '</i>');
469
471
  }
470
- if (($el.hasClass('values') && !$el.hasClass('hide'))) {
472
+ if (($el.hasClass('values') && $el.is(":visible"))) {
471
473
  // build_select2_element($el, (!list_with_item && multiple == 'true'));
472
474
  build_select2_element($el);
473
475
  }
@@ -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(:ul, class: 'dropdown-menu add-condition-menu') do
37
+ concat(content_tag(:div, 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(:li, group_label, class: 'dropdown-header'))
49
+ concat(content_tag(:h6, group_label, class: 'dropdown-header'))
50
50
  create_conditions_fields_item(attrs)
51
51
  else
52
- concat(content_tag(:li, link_to(attrs[:label], '#', class: 'add-condition-field', data: {field: field}), class: 'dropdown-item'))
52
+ concat(link_to(attrs[:label], 'javascript:void(0)', class: 'dropdown-item add-condition-field', data: {field: field}))
53
53
  end
54
54
  end
55
55
  end
@@ -1,3 +1,3 @@
1
1
  module VisualConditionBuilder
2
- VERSION = "0.1.6"
2
+ VERSION = "2.0.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: visual_condition_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bruno Porto