discerner 2.0.14 → 2.0.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 26ea81aeac59525239c0078e08c14647c1900dd6
4
- data.tar.gz: 9b84a30a0b9f8fc95e61bacb664f841246817c2f
3
+ metadata.gz: 49628dbdcf63e05933a54b84e4d6f0162c322f78
4
+ data.tar.gz: ca6cc17e8d4f66c9484508e195d7f6ddead236d3
5
5
  SHA512:
6
- metadata.gz: 469b864ff203219f141ad24a874f0f731ab3d9d449a5fe5f38b4f56ef7cc7bf3face4088e162eff306e9b4b816ea82fc6cc6abcaf2aee385ff44d95bc2058037
7
- data.tar.gz: ce3e880a330bddd8616b67d0fd14a6c930d89b0671b9e4576ba4000d1e09a5c543bc0304a8a6aeb3e91ba2d5ecbaedb38b15a23c0731972e474a3e7876561510
6
+ metadata.gz: 6f8194a039eba254752279fe88b6aa848c7cd8085f88df29358b4ea6d5d9a9885825188560fa5af22829197826b404233707dfe90430af1022e6edd26af44bc0
7
+ data.tar.gz: e7306ba0e1dcc68816bf0b516440e20d8e843209c05f7182a8b9f8686e8c1e2a53609210bafe17077e7e22e74fa0c52de2227c4d5ea5b193d7794d79f3d28464
@@ -22,26 +22,26 @@ Discerner.SearchParameter.UI = function (config) {
22
22
  }
23
23
  });
24
24
  $.each($('select.parameters_combobox_autocompleter option'), function(){
25
- if (!($(this).hasClass(dictionary_class) || $(this).val() == '')) {
25
+ if (!($(this).hasClass(dictionary_class) || $(this).val() === '')) {
26
26
  $(this).remove();
27
27
  }
28
28
  });
29
- };
29
+ }
30
30
  $(".parameters_combobox_autocompleter").combobox({watermark:'a criteria'});
31
31
 
32
32
  // get max display order
33
33
  $.each(display_orders, function(){
34
- var val = parseInt($(this).val());
35
- if (val >= i) { i = val }
34
+ var val = parseInt($(this).val(), 10);
35
+ if (val >= i) { i = val; }
36
36
  });
37
37
 
38
38
  // assign display order to search predicates without it
39
39
  $.each(display_orders, function(){
40
- if ($(this).val().length == 0) {
41
- i = i + 1
40
+ if ($(this).val().length === 0) {
41
+ i = i + 1;
42
42
  $(this).val(i);
43
43
  }
44
- })
44
+ });
45
45
  },
46
46
  searchParametersNestedAttributesForm = new NestedAttributes({
47
47
  container: $('.search_parameters'),
@@ -57,7 +57,7 @@ Discerner.SearchParameter.UI = function (config) {
57
57
  select = $(this).siblings('select').first(),
58
58
  // get all the "sibling" dropdowns
59
59
  sibling_selects = $('select.' + select.attr('class')).filter(function(){
60
- return $(this).closest('tr').find('td.remove input[name$="[_destroy]"]:not([name*="[search_parameter_values_attributes]"])').filter(function() { return this.value === '1'; }).length == 0 // exclude rows marked for destroy
60
+ return $(this).closest('tr').find('td.remove input[name$="[_destroy]"]:not([name*="[search_parameter_values_attributes]"])').filter(function() { return this.value === '1'; }).length === 0; // exclude rows marked for destroy
61
61
  }),
62
62
  // get all selected parameter options from sibling selects
63
63
  matching_selected_options = sibling_selects.find('option.exclusive:selected');
@@ -67,7 +67,7 @@ Discerner.SearchParameter.UI = function (config) {
67
67
  $.each(matching_selected_options, function(){
68
68
  option = select.find('option[value=' + $(this).val() + ']');
69
69
  popup.find('.parameter_category .criteria a.categorized_autocompleter_item_link[rel="' + $(option).attr('id') + '"]').addClass('selection_disabled');
70
- })
70
+ });
71
71
  toggleCategorizedAutocompleterPopup(this);
72
72
  toggleCategorizedAutocompleterPopup($(this).closest('.search_parameter').find('.parameter_value a.expanded_categorized_autocompleter_link'));
73
73
  });
@@ -105,10 +105,9 @@ Discerner.SearchParameter.UI = function (config) {
105
105
  add_button = $(predicate).find('a.add_search_parameter_values');
106
106
 
107
107
  $(predicate).find('.nested_records_search_parameter_values .search_parameter_value .delete_search_parameter_values').click();
108
- if ($(selected_option).length == 0 || $(selected_option).val() == ''){
108
+ if ($(selected_option).length === 0 || $(selected_option).val() === ''){
109
109
  $(add_button).hide();
110
- }
111
- else if ($(selected_option).hasClass('list')){
110
+ } else if ($(selected_option).hasClass('list')) {
112
111
  $($(predicate).find('.tmp_link')).remove();
113
112
  $.get(parametersUrl.sub({ question_id: this.value }), function (data) {
114
113
  $.each(data.parameter_values, function() {
@@ -119,12 +118,29 @@ Discerner.SearchParameter.UI = function (config) {
119
118
  $(add_button).hide();
120
119
  });
121
120
  });
121
+ } else if ($(selected_option).hasClass('exclusive_list')) {
122
+ $($(predicate).find('.tmp_link')).remove();
123
+ $.get(parametersUrl.sub({ question_id: this.value }), function (data) {
124
+ $(add_button).click();
125
+ var row = $(predicate).find('.nested_records_search_parameter_values .search_parameter_value .parameter_value').filter(':last');
126
+ $.each(data.parameter_values, function() {
127
+ var value_id_element = row.find('.parameter_value_id'),
128
+ radio_id = value_id_element.attr('id') + '_' + this.parameter_value_id,
129
+ value_item_div = $('<div>').addClass('parameter_value_item');
130
+
131
+ radio_button = $('<input>').attr('type', 'radio').attr('name', value_id_element.attr('name')).attr('id',radio_id).val(this.parameter_value_id);
132
+ radio_button_text = $('<label>').attr('for', radio_id).text(this.name);
133
+ value_item_div.append(radio_button);
134
+ value_item_div.append(radio_button_text);
135
+ row.append(value_item_div);
136
+ $(add_button).hide();
137
+ });
138
+ });
122
139
  } else {
123
140
  $(add_button).show();
124
141
  $(add_button).click();
125
142
  }
126
143
  });
127
-
128
144
  setupParameters();
129
145
  };
130
146
 
@@ -33,7 +33,7 @@ Discerner.SearchParameterValue.UI = function (config) {
33
33
  hideValue($(row).find('.additional_value').show());
34
34
  row.find('.parameter_values_boolean_operator').show();
35
35
 
36
- if ($(selectedParameter).hasClass('list')) { // list parameters
36
+ if ($(selectedParameter).hasClass('list')){ // list parameters
37
37
  row.find('.chosen, .parameter_value').show();
38
38
  $(config.container).find('a.add_search_parameter_values').hide();
39
39
  $(config.container).find('.additional_value').hide();
@@ -57,6 +57,10 @@ Discerner.SearchParameterValue.UI = function (config) {
57
57
  }
58
58
  $(config.container).find('.parameter_value, .remove').show();
59
59
  $(config.container).find('a.add_search_parameter_values').show();
60
+ } else if ($(selectedParameter).hasClass('exclusive_list')) { // exclusive parameter values list
61
+ $(config.container).find('a.add_search_parameter_values').hide();
62
+ $(config.container).find('.additional_value', '.chosen').hide();
63
+ $(config.container).find('.parameter_value').show();
60
64
  } else { // date, text and numeric parameters
61
65
  var parameter_classes = ['date', 'numeric', 'text', 'string'];
62
66
  for (var i in parameter_classes) {
@@ -164,7 +168,7 @@ Discerner.SearchParameterValue.UI = function (config) {
164
168
  $(this).closest('.categorized-parameter-values, .uncategorized-parameter-values').find('.category-items').show();
165
169
  $(this).addClass('hide-category-items');
166
170
  $(this).removeClass('show-category-items');
167
- $(this).html('less')
171
+ $(this).html('less');
168
172
  });
169
173
 
170
174
  $(document).on('click', '.hide-category-items', function(e) {
@@ -172,6 +176,6 @@ Discerner.SearchParameterValue.UI = function (config) {
172
176
  $(this).closest('.categorized-parameter-values, .uncategorized-parameter-values').find('.category-items').hide();
173
177
  $(this).addClass('show-category-items');
174
178
  $(this).removeClass('hide-category-items');
175
- $(this).html('more')
179
+ $(this).html('more');
176
180
  });
177
181
  };
@@ -137,6 +137,9 @@
137
137
  :width 28em
138
138
  .column
139
139
  :width 12em
140
+ input[type="radio"]
141
+ :margin 0.3em 0.7em 0.3em 0.5em
142
+
140
143
 
141
144
  .parameter, .combined_search, .parameter_value
142
145
  .categorized_autocompleter, .combined_search_combobox
@@ -47,6 +47,14 @@
47
47
  %td.remove
48
48
  = discerner_link_to_remove_fields 'Remove', f, :search_parameter_values
49
49
 
50
+ - when 'exclusive_list'
51
+ %td.parameter_value
52
+ - parameter.parameter_values.each do |parameter_value|
53
+ .parameter_value_item
54
+ = f.radio_button :parameter_value_id, parameter_value.id, class: 'parameter_value_id'
55
+ = f.label :parameter_value_id, parameter_value.name
56
+ %td{class: "remove", class: "invisible"}
57
+ = discerner_link_to_remove_fields 'Remove', f, :search_parameter_values
50
58
  - else
51
59
  %td.operator
52
60
  - selected = f.object.operator.blank? ? nil : f.object.operator.id
@@ -0,0 +1,29 @@
1
+ module Discerner
2
+ module Enum
3
+ DISCERNER_PARAMETER_TYPE_NUMERIC = 'numeric'
4
+ DISCERNER_PARAMETER_TYPE_DATE = 'numeric'
5
+ DISCERNER_PARAMETER_TYPES = ['numeric', 'date', 'list', 'combobox', 'text', 'string', 'search', 'exclusive_list'].freeze
6
+
7
+ ABSTRACTION_OTHER_VALUE_TYPE_NOT_APPLICABLE = 'not applicable'
8
+ ABSTRACTION_OTHER_VALUE_TYPES = [ABSTRACTION_OTHER_VALUE_TYPE_UNKNOWN, ABSTRACTION_OTHER_VALUE_TYPE_NOT_APPLICABLE]
9
+
10
+ ABSTRACTION_STATUS_NEEDS_REVIEW = 'needs review'
11
+ ABSTRACTION_STATUS_REVIEWED = 'reviewed'
12
+ ABSTRACTION_STATUS_ACTUALLY_ANSWERED = 'actually answered'
13
+ ABSTRACTION_STATUSES = [ABSTRACTION_STATUS_NEEDS_REVIEW, ABSTRACTION_STATUS_REVIEWED, ABSTRACTION_STATUS_ACTUALLY_ANSWERED]
14
+
15
+ ABSTRACTION_SUGGESTION_TYPE_UNKNOWN = 'unknown'
16
+ ABSTRACTION_SUGGESTION_TYPE_SUGGESTED = 'suggested'
17
+ ABSTRACTION_SUGGESTION_TYPES = [ABSTRACTION_SUGGESTION_TYPE_UNKNOWN, ABSTRACTION_SUGGESTION_TYPE_SUGGESTED]
18
+
19
+ ABSTRACTOR_SECTION_TYPE_CUSTOM = 'custom'
20
+ ABSTRACTOR_SECTION_TYPE_NAME_VALUE = 'name/value'
21
+ ABSTRACTOR_SECTION_TYPES = [ABSTRACTOR_SECTION_TYPE_CUSTOM, ABSTRACTOR_SECTION_TYPE_NAME_VALUE]
22
+
23
+ ABSTRACTOR_SUGGESTION_STATUS_NEEDS_REVIEW = 'Needs review'
24
+ ABSTRACTOR_SUGGESTION_STATUS_ACCEPTED = 'Accepted'
25
+ ABSTRACTOR_SUGGESTION_STATUS_REJECTED = 'Rejected'
26
+ ABSTRACTOR_SUGGESTION_STATUSES = [ABSTRACTOR_SUGGESTION_STATUS_NEEDS_REVIEW, ABSTRACTOR_SUGGESTION_STATUS_ACCEPTED, ABSTRACTOR_SUGGESTION_STATUS_REJECTED]
27
+ ABSTRACTOR_GROUP_SENTINENTAL_SUBTYPE = 'sentinental'
28
+ end
29
+ end
@@ -90,7 +90,7 @@ module Discerner
90
90
  parameter_categories_used = search.export_parameters.map{ |ep| ep.parameter.parameter_category }.flatten
91
91
  parameter_categories = parameter_categories_available | parameter_categories_used
92
92
  end
93
- parameter_categories.sort{|a,b| a.parameters.length <=> b.parameters.length}
93
+ parameter_categories
94
94
  end
95
95
 
96
96
  def exportable_parameters(search, category)
@@ -21,7 +21,7 @@ module Discerner
21
21
 
22
22
  def name_supported?
23
23
  return if self.name.blank?
24
- supported_types = ['numeric', 'date', 'list', 'combobox', 'text', 'string', 'search']
24
+ supported_types = ['numeric', 'date', 'list', 'combobox', 'text', 'string', 'search', 'exclusive_list']
25
25
  errors.add(:base,"Parameter type '#{self.name}' is not supported, please use one of the following types: #{supported_types.join(', ')}") unless supported_types.include?(self.name)
26
26
  end
27
27
  end
@@ -52,6 +52,9 @@ module Discerner
52
52
  when 'combobox'
53
53
  values = [search_parameter_values.map { |spv| spv.parameter_value.search_value unless spv.parameter_value.nil? }.compact]
54
54
  predicate = "#{parameter.search_method} in (?)" unless values.blank?
55
+ when 'exclusive_list'
56
+ values = [search_parameter_values.map { |spv| spv.parameter_value.search_value unless spv.parameter_value.nil? }.compact.first]
57
+ predicate = "#{parameter.search_method} = ?" unless values.blank?
55
58
  else # 'numeric','date', 'text', 'string
56
59
  spvs = []
57
60
  values = []
@@ -75,7 +75,7 @@ module Discerner
75
75
  warnings.add(:base, "Provided date is not valid")
76
76
  return true
77
77
  end
78
- if parameter_value.blank? && search_parameter.parameter.parameter_type.name == 'combobox'
78
+ if parameter_value.blank? && ['combobox', 'exclusive_list'].include?(search_parameter.parameter.parameter_type.name)
79
79
  warnings.add(:base, "Parameter value has to be selected")
80
80
  return true
81
81
  end
@@ -116,7 +116,7 @@ module Discerner
116
116
  end
117
117
 
118
118
  def validate_operator
119
- if search_parameter && search_parameter.parameter && search_parameter.parameter.parameter_type && ['list', 'combobox'].include?(search_parameter.parameter.parameter_type.name)
119
+ if search_parameter && search_parameter.parameter && search_parameter.parameter.parameter_type && ['list', 'combobox', 'exclusive_list'].include?(search_parameter.parameter.parameter_type.name)
120
120
  self.operator = nil
121
121
  else
122
122
  errors.add(:base, "Operator has to be selected for parameter values that do not belong to list or combobox") if operator.blank?
@@ -1,3 +1,3 @@
1
1
  module Discerner
2
- VERSION = "2.0.14"
2
+ VERSION = "2.0.15"
3
3
  end
@@ -1,36 +1,36 @@
1
1
  # ---- General structure:
2
2
  # :dictionaries:
3
- # - :name: string # has to be unique within not-deleted dictionaries
3
+ # - :name: string # has to be unique within not-deleted dictionaries
4
4
  # :parameter_categories:
5
- # - :name: string # has to be unique within the dictionary
5
+ # - :name: string # has to be unique within the dictionary
6
6
  # :parameters:
7
- # - :name: string # used for display
8
- # :unique_identifier: # has to be unique within the dictionary
7
+ # - :name: string # used for display
8
+ # :unique_identifier: # has to be unique within the dictionary
9
9
  # :export:
10
- # :model: string # name of the model to be used for exporting
11
- # :method: string # name of the model method to be used for exporting
12
- # :hidden: boolean # default: false. If set to true, parameter will be hidden from list of exportable parameters
13
- # :search: # parameter search model and method combination has to be unique within the category
14
- # :model: string # name of the model to be used for searching
15
- # :method: string # name of the model method to be used for searching
16
- # :hidden: boolean # default: false. If set to true, parameter will be hidden from list of searchable parameters
17
- # :parameter_type: numeric/date/list/combobox/text/string # used to define applicable operators/display options. does not have to be restricted to the given list, but additional parameters will require adding operators to match
18
- # :parameter_value_categories_source: # used to define parameter value categories
19
- # :model: string # source model to be used to load parameter value categiories
20
- # :method: string # method in the source model that returns parameter_value_categories in a form of [{name: 'string, unique_identifier: 'adventure', display_order: 1, collapse: true}]
21
- # :parameter_value_categories: # used to define parameter value categories
10
+ # :model: string # name of the model to be used for exporting
11
+ # :method: string # name of the model method to be used for exporting
12
+ # :hidden: boolean # default: false. If set to true, parameter will be hidden from list of exportable parameters
13
+ # :search: # parameter search model and method combination has to be unique within the category
14
+ # :model: string # name of the model to be used for searching
15
+ # :method: string # name of the model method to be used for searching
16
+ # :hidden: boolean # default: false. If set to true, parameter will be hidden from list of searchable parameters
17
+ # :parameter_type: numeric/date/list/combobox/text/string/exclusive_list # used to define applicable operators/display options. does not have to be restricted to the given list, but additional parameters will require adding operators to match
18
+ # :parameter_value_categories_source: # used to define parameter value categories
19
+ # :model: string # source model to be used to load parameter value categiories
20
+ # :method: string # method in the source model that returns parameter_value_categories in a form of [{name: 'string, unique_identifier: 'adventure', display_order: 1, collapse: true}]
21
+ # :parameter_value_categories: # used to define parameter value categories
22
22
  # - :name: string
23
- # :unique_identifier: string # has to be unique within parameter
24
- # :collapse: boolean # used to define if parameter category should be collapsed in the list and its values hidden from the view
23
+ # :unique_identifier: string # has to be unique within parameter
24
+ # :collapse: boolean # used to define if parameter category should be collapsed in the list and its values hidden from the view
25
25
  # :display_order: integer
26
- # :allow_empty_values: boolean # default: true. If set to true, "none" value will be added to the list ov values
27
- # :parameter_values: # needs to be defined for list/combobox parameters unless parameter values come from the model, see ':source'
28
- # - :name: string # used for display, if not provided, 'search_value' will be used instead
29
- # :search_value: string # has to be unique within parameter, intendend to be used as a database value while searching
30
- # :parameter_value_category: string # used to define category for parameter value, should match one of parameter_value_categories unique_identifiers listed above
26
+ # :allow_empty_values: boolean # default: true. If set to true, "none" value will be added to the list ov values
27
+ # :parameter_values: # needs to be defined for list/combobox parameters unless parameter values come from the model, see ':source'
28
+ # - :name: string # used for display, if not provided, 'search_value' will be used instead
29
+ # :search_value: string # has to be unique within parameter, intendend to be used as a database value while searching
30
+ # :parameter_value_category: string # used to define category for parameter value, should match one of parameter_value_categories unique_identifiers listed above
31
31
  # :source:
32
- # :model: string # source model to be used to load parameter values
33
- # :method: string # method/method in the source model to be used to load parameter values
32
+ # :model: string # source model to be used to load parameter values
33
+ # :method: string # method/method in the source model to be used to load parameter values
34
34
 
35
35
  ---
36
36
  :dictionaries:
@@ -270,3 +270,13 @@
270
270
  :method: text
271
271
  :hidden: true
272
272
 
273
+ - :name: "Bestseller"
274
+ :unique_identifier: bestseller
275
+ :search:
276
+ :model: Book
277
+ :method: text
278
+ :parameter_type: exclusive_list
279
+ :parameter_values:
280
+ - :search_value: yes
281
+ - :search_value: no
282
+
@@ -8,6 +8,7 @@
8
8
  - numeric
9
9
  - date
10
10
  - string
11
+ - exclusive_list
11
12
  - :unique_identifier: is_not_equal_to
12
13
  :type: comparison
13
14
  :symbol: '!='
@@ -16,6 +17,7 @@
16
17
  - numeric
17
18
  - date
18
19
  - string
20
+ - exclusive_list
19
21
  - :unique_identifier: is_less_than
20
22
  :type: comparison
21
23
  :symbol: '<'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: discerner
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.14
4
+ version: 2.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Gurley, Yulia Bushmanova
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-21 00:00:00.000000000 Z
11
+ date: 2015-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -436,6 +436,7 @@ files:
436
436
  - db/seeds.rb
437
437
  - lib/discerner.rb
438
438
  - lib/discerner/engine.rb
439
+ - lib/discerner/enum.rb
439
440
  - lib/discerner/methods/controllers/export_parameters_controller.rb
440
441
  - lib/discerner/methods/controllers/parameters_controller.rb
441
442
  - lib/discerner/methods/controllers/searches_controller.rb