Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
781 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,5 @@ tmp/**/* | |
.idea/*.xml | ||
.sass-cache | ||
nbproject | ||
/.DS_Store | ||
*/**/.DS_Store |
36 changes: 36 additions & 0 deletions
36
app/assets/javascripts/rails_admin/filter-box-components/association_filter_component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
(function (components) { | ||
|
||
var helpers = components.helpers; | ||
|
||
components.has_many_association_filter_component = function (options) { | ||
var component = {}; | ||
if (options.check_boxes) { | ||
component.control = options.checkbox_values.map(function (value) { | ||
return helpers.new_checkbox(value, options); | ||
}).join('\n'); | ||
} else { | ||
component.control = '<select style="display:' + helpers.select_input_display(options) + 'class="select-single input-sm form-control">' + | ||
'<option value="_discard">...</option>' + | ||
'<option ' + helpers.present_operator_selected(options) + RailsAdmin.I18n.t("is_present") + '</option>' + | ||
'<option ' + helpers.blank_operator_selected(options) + ' value="_blank">' + RailsAdmin.I18n.t("is_blank") + '</option>' + | ||
'<option disabled="disabled">---------</option>' + | ||
options.select_options + | ||
'</select>' + | ||
'<a href="#" class="switch-select"><i class="icon-' + helpers.plus_or_minus_icon(options.multi_select) + '"></i></a>'; | ||
} | ||
return component; | ||
}; | ||
|
||
components.has_and_belongs_to_many_association_filter_component = function (options) { | ||
return this.has_many_association_filter_component(options); | ||
}; | ||
|
||
components.belongs_to_association_filter_component = function (options) { | ||
var select_options = options['select_options']; | ||
if (select_options.length > 0) { | ||
return this.has_many_association_filter_component(options); | ||
} | ||
return this.string_filter_component(options); | ||
}; | ||
|
||
}(FilterBoxComponents)); |
19 changes: 19 additions & 0 deletions
19
app/assets/javascripts/rails_admin/filter-box-components/boolean_filter_component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
(function (components) { | ||
|
||
var helpers = components.helpers; | ||
|
||
components.boolean_filter_component = function (options) { | ||
var component = {}; | ||
component.control = '<select class="input-sm form-control" name="' + options.value_name + '">' + | ||
'<option value="_discard">...</option>' + | ||
'<option value="true"' + true_operator_selected(options) + '>' + RailsAdmin.I18n.t("true") + '</option>' + | ||
'<option value="false"' + false_operator_selected(options) + '>' + RailsAdmin.I18n.t("false") + '</option>' + | ||
'<option disabled="disabled">---------</option>' + | ||
'<option ' + helpers.present_operator_selected(options) + ' value="_present">' + RailsAdmin.I18n.t("is_present") + '</option>' + | ||
'<option ' + helpers.blank_operator_selected(options) + ' value="_blank" >' + RailsAdmin.I18n.t("is_blank") + '</option>' + | ||
'</select>'; | ||
return component; | ||
}; | ||
|
||
}(FilterBoxComponents)); |
38 changes: 38 additions & 0 deletions
38
app/assets/javascripts/rails_admin/filter-box-components/date_filter_component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
(function (components) { | ||
|
||
var helpers = components.helpers; | ||
var shared_elements = components.shared_elements; | ||
|
||
|
||
components.datetime_filter_component = function (options) { | ||
var component = {}; | ||
component.control = '<select class="switch-additionnal-fieldsets input-sm form-control" name="' + options.operator_name + '">' + | ||
shared_elements.between_and_default_options() + | ||
'<option ' + helpers.today_filter_selected(options) + ' value="today">' + RailsAdmin.I18n.t("today") + '</option>' + | ||
'<option ' + helpers.yesterday_operator_selected(options) + ' value="yesterday">' + RailsAdmin.I18n.t("yesterday") + '</option>' + | ||
'<option ' + helpers.this_week_operator_selected(options) + ' value="this_week">' + RailsAdmin.I18n.t("this_week") + '</option>' + | ||
'<option ' + helpers.last_week_operator_selected(options) + ' value="last_week">' + RailsAdmin.I18n.t("last_week") + '</option>' + | ||
'<option disabled="disabled">---------</option>' + | ||
'<option ' + helpers.not_null_operator_selected(options) + ' value="_not_null">' + RailsAdmin.I18n.t("is_present") + '</option>' + | ||
'<option ' + helpers.null_operator_selected(options) + ' value="_null" >' + RailsAdmin.I18n.t("is_blank") + '</option>' + | ||
'</select>'; | ||
component.additional_control = '<input size="25" class="datetime additional-fieldset default input-sm form-control" style="display:' + helpers.default_filter_display(options) + ';" type="text" name="' + options.value_name + '[]" value="' + (options.field_value[0] || '') + '" /> ' + | ||
'<input size="25" placeholder="-∞" class="datetime additional-fieldset between input-sm form-control" style="display:' + helpers.between_operator_display(options) + ';" type="text" name="' + options.value_name + '[]" value="' + (options.field_value[1] || '') + '" /> ' + | ||
'<input size="25" placeholder="∞" class="datetime additional-fieldset between input-sm form-control" style="display:' + helpers.between_operator_display(options) + ';" type="text" name="' + options.value_name + '[]" value="' + (options.field_value[2] || '') + '" />'; | ||
return component; | ||
}; | ||
|
||
components.date_filter_component = function (options) { | ||
var component = {}; | ||
component.control = this.datetime_filter_component(options).control; | ||
component.additional_control = '<input size="20" class="date additional-fieldset default input-sm form-control" style="display:' + ((!options.field_operator || options.field_operator === "default") ? 'inline-block' : 'none') + ';" type="text" name="' + options.value_name + '[]" value="' + (options.field_value[0] || '') + '" /> ' + | ||
'<input size="20" placeholder="-∞" class="date additional-fieldset between input-sm form-control" style="display:' + helpers.between_operator_display(options) + ';" type="text" name="' + options.value_name + '[]" value="' + (options.field_value[1] || '') + '" /> ' + | ||
'<input size="20" placeholder="∞" class="date additional-fieldset between input-sm form-control" style="display:' + helpers.between_operator_display(options) + ';" type="text" name="' + options.value_name + '[]" value="' + (options.field_value[2] || '') + '" />'; | ||
return component; | ||
}; | ||
|
||
components.timestamp_filter_component = function (options) { | ||
return this.datetime_filter_component(options); | ||
}; | ||
|
||
}(FilterBoxComponents)); |
7 changes: 7 additions & 0 deletions
7
app/assets/javascripts/rails_admin/filter-box-components/default_filter_component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(function (components) { | ||
|
||
components.default_filter_component = function (options) { | ||
return {control: '<input type="text" class="input-sm form-control" name="' + options.value_name + '" value="' + options.field_value + '"/>' } | ||
} | ||
|
||
}(FilterBoxComponents)); |
23 changes: 23 additions & 0 deletions
23
app/assets/javascripts/rails_admin/filter-box-components/enum_filter_component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
(function (components) { | ||
|
||
var helpers = components.helpers; | ||
|
||
components.enum_filter_component = function (options) { | ||
var component = {}; | ||
var multiple_values = (options.field_value instanceof Array); | ||
component.control = '<select style="display:' + (multiple_values ? 'none' : 'inline-block') + '" ' + (multiple_values ? '' : 'name="' + options.value_name + '"') + ' data-name="' + options.value_name + '" class="select-single input-sm form-control">' + | ||
'<option value="_discard">...</option>' + | ||
'<option ' + helpers.present_operator_selected(options) + ' value="_present">' + RailsAdmin.I18n.t("is_present") + '</option>' + | ||
'<option ' + helpers.blank_operator_selected(options) + ' value="_blank">' + RailsAdmin.I18n.t("is_blank") + '</option>' + | ||
'<option disabled="disabled">---------</option>' + | ||
options.select_options + | ||
'</select>' + | ||
'<select multiple="multiple" style="display:' + helpers.multiple_values_display(multiple_values, options) + ' data-name="' + options.value_name + '[]" class="select-multiple input-sm form-control">' + | ||
options.select_options + | ||
'</select> ' + | ||
'<a href="#" class="switch-select"><i class="icon-' + helpers.plus_or_minus_icon(multiple_values) + '"></i></a>'; | ||
return component; | ||
} | ||
|
||
}(FilterBoxComponents)); |
93 changes: 93 additions & 0 deletions
93
app/assets/javascripts/rails_admin/filter-box-components/filter-box-helpers.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
(function (helpers) { | ||
|
||
var selected_state = 'selected="selected"'; | ||
|
||
helpers.like_operator_selected = function (options) { | ||
return (options.field_operator === "like" ? selected_state : ''); | ||
}; | ||
|
||
helpers.is_operator_selected = function (options) { | ||
return (options.field_operator === "is" ? selected_state : ''); | ||
}; | ||
|
||
helpers.starts_with_operstor_selected = function (options) { | ||
return (options.field_operator === "starts_with" ? selected_state : ''); | ||
}; | ||
|
||
helpers.ends_with_operator_selected = function (options) { | ||
return (options.field_operator === "ends_with" ? selected_state : ''); | ||
}; | ||
|
||
helpers.default_operator_selected = function (options) { | ||
return (options.field_operator === "default" ? selected_state : ''); | ||
}; | ||
|
||
helpers.between_operator_selected = function (options) { | ||
return (options.field_operator === "between" ? selected_state : ''); | ||
}; | ||
|
||
helpers.not_null_operator_selected = function (options) { | ||
return (options.field_operator === "_not_null" ? selected_state : ''); | ||
}; | ||
|
||
helpers.null_operator_selected = function (options) { | ||
return (options.field_operator === "_null" ? selected_state : ''); | ||
}; | ||
|
||
helpers.today_operator_selected = function (options) { | ||
return (options.field_operator === "today" ? selected_state : '') | ||
}; | ||
helpers.yesterday_operator_selected = function (options) { | ||
return (options.field_operator === "yesterday" ? selected_state : '') | ||
}; | ||
helpers.last_week_operator_selected = function (options) { | ||
return (options.field_operator === "last_week" ? selected_state : '') | ||
}; | ||
helpers.this_week_operator_selected = function (options) { | ||
return (options.field_operator === "this_week" ? selected_state : '') | ||
}; | ||
helpers.true_operator_selected = function (options) { | ||
return (options.field_value === "true" ? selected_state : ''); | ||
}; | ||
helpers.false_operator_selected = function (options) { | ||
return (options.field_value === "false" ? selected_state : ''); | ||
}; | ||
|
||
helpers.default_filter_display = function (options) { | ||
return ((!options.field_operator || options.field_operator === "default") ? 'inline-block' : 'none'); | ||
}; | ||
|
||
helpers.between_operator_display = function (options) { | ||
return ((options.field_operator === "between") ? 'inline-block' : 'none'); | ||
}; | ||
|
||
helpers.checked = function (value, applied_filters) { | ||
return $.inArray(value[1], applied_filters) !== -1 ? 'checked="checked"' : ''; | ||
}; | ||
|
||
helpers.new_checkbox = function (value, options) { | ||
return '<label class="checkbox-inline" for="' + options.value_name + '[]">' + | ||
'<input style="display:inline-block" name="' + options.value_name + '[]" data-name="' + options.value_name + '[]" class="checkbox input-sm form-control" type="checkbox" value="' + value[1] + '" ' + helpers.checked(value, options.applied_filters) + ' />' + | ||
'' + value[0] + | ||
'</label>'; | ||
}; | ||
|
||
helpers.select_input_display = function (options) { | ||
return (options.multi_select ? 'none' : 'inline-block') + '" ' + (options.multi_select ? '' : 'name="' + options.value_name + '"') + ' data-name="' + options.value_name + ' '; | ||
}; | ||
|
||
helpers.present_operator_selected = function (options) { | ||
return (options.field_value === "_present" ? 'selected="selected"' : '') + ' value="_present">'; | ||
}; | ||
helpers.blank_operator_selected = function (options) { | ||
return (options.field_value === "_blank" ? 'selected="selected"' : ''); | ||
}; | ||
helpers.plus_or_minus_icon = function (multi) { | ||
return (multi ? 'minus' : 'plus'); | ||
}; | ||
|
||
helpers.multiple_values_display = function (multiple_values, options) { | ||
return (multiple_values ? 'inline-block' : 'none') + '" ' + (multiple_values ? 'name="' + options.value_name + '[]"' : ''); | ||
}; | ||
|
||
}(FilterBoxComponents.helpers)); |
33 changes: 33 additions & 0 deletions
33
app/assets/javascripts/rails_admin/filter-box-components/number_filter_component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
(function (components) { | ||
|
||
var helpers = components.helpers; | ||
var shared_elements = components.shared_elements; | ||
|
||
components.number_filter_component = function (options) { | ||
var component = {}; | ||
component.control = '<select class="switch-additionnal-fieldsets input-sm form-control" name="' + options.operator_name + '">' + | ||
shared_elements.between_and_default_options(options) + | ||
'<option disabled="disabled">---------</option>' + | ||
'<option ' + helpers.not_null_operator_selected(options) + ' value="_not_null">' + RailsAdmin.I18n.t("is_present") + '</option>' + | ||
'<option ' + helpers.null_operator_selected(options) + ' value="_null" >' + RailsAdmin.I18n.t("is_blank") + '</option>' + | ||
'</select>'; | ||
component.additional_control = | ||
'<input class="additional-fieldset default input-sm form-control" style="display:' + helpers.default_filter_display(options) + ';" type="' + options.field_type + '" name="' + options.value_name + '[]" value="' + (options.field_value[0] || '') + '" /> ' + | ||
'<input placeholder="-∞" class="additional-fieldset between input-sm form-control" style="display:' + helpers.between_operator_display(options) + ';" type="' + options.field_type + '" name="' + options.value_name + '[]" value="' + (options.field_value[1] || '') + '" /> ' + | ||
'<input placeholder="∞" class="additional-fieldset between input-sm form-control" style="display:' + helpers.between_operator_display(options) + ';" type="' + options.field_type + '" name="' + options.value_name + '[]" value="' + (options.field_value[2] || '') + '" />'; | ||
return component; | ||
}; | ||
|
||
components.integer_filter_component = function (options) { | ||
return this.number_filter_component(options); | ||
}; | ||
|
||
components.decimal_filter_component = function (options) { | ||
return this.number_filter_component(options); | ||
}; | ||
|
||
components.float_filter_component = function (options) { | ||
return this.number_filter_component(options); | ||
}; | ||
|
||
}(FilterBoxComponents)); |
11 changes: 11 additions & 0 deletions
11
app/assets/javascripts/rails_admin/filter-box-components/shared_elements.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
(function(components){ | ||
|
||
var shared_elements = components.shared_elements; | ||
var helpers = components.helpers; | ||
|
||
shared_elements.between_and_default_options = function (options) { | ||
return '<option ' + helpers.default_operator_selected(options) + ' data-additional-fieldset="default" value="default">' + RailsAdmin.I18n.t("number") + '</option>' + | ||
'<option ' + helpers.between_operator_selected(options) + ' data-additional-fieldset="between" value="between">' + RailsAdmin.I18n.t("between_and_") + '</option>'; | ||
} | ||
|
||
}(FilterBoxComponents)); |
25 changes: 25 additions & 0 deletions
25
app/assets/javascripts/rails_admin/filter-box-components/string_filter_component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
(function (components) { | ||
var helpers = components.helpers; | ||
|
||
components.string_filter_component = function (options) { | ||
var control; | ||
var component = {}; | ||
component.control = '<select class="switch-additionnal-fieldsets input-sm form-control" value="' + options.field_operator + '" name="' + options.operator_name + '">' + | ||
'<option data-additional-fieldset="additional-fieldset"' + helpers.like_operator_selected(options) + ' value="like">' + RailsAdmin.I18n.t("contains") + '</option>' + | ||
'<option data-additional-fieldset="additional-fieldset"' + helpers.is_operator_selected(options) + ' value="is">' + RailsAdmin.I18n.t("is_exactly") + '</option>' + | ||
'<option data-additional-fieldset="additional-fieldset"' + helpers.starts_with_operstor_selected(options) + ' value="starts_with">' + RailsAdmin.I18n.t("starts_with") + '</option>' + | ||
'<option data-additional-fieldset="additional-fieldset"' + helpers.ends_with_operator_selected(options) + ' value="ends_with">' + RailsAdmin.I18n.t("ends_with") + '</option>' + | ||
'<option disabled="disabled">---------</option>' + | ||
'<option ' + helpers.not_null_operator_selected(options) + ' value="_not_null">' + RailsAdmin.I18n.t("is_present") + '</option>' + | ||
'<option ' + helpers.null_operator_selected(options) + ' value="_null">' + RailsAdmin.I18n.t("is_blank") + '</option>' + | ||
'</select>'; | ||
component.additional_control = '<input class="additional-fieldset input-sm form-control" style="display:' + (options.field_operator === "_blank" || options.field_operator === "_present" ? 'none' : 'inline-block') + ';" type="text" name="' + options.value_name + '" value="' + options.field_value + '" />'; | ||
return component; | ||
}; | ||
|
||
components.text_filter_component = function (options) { | ||
return this.string_filter_component(options) | ||
}; | ||
|
||
}(FilterBoxComponents)); |
13 changes: 13 additions & 0 deletions
13
app/assets/javascripts/rails_admin/ra.filter-box-components.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
var FilterBoxComponents = { | ||
helpers: {}, | ||
shared_elements: {}, | ||
create: function(options){ | ||
var fieldFactoryName = options.field_type + '_filter_component'; | ||
try { | ||
return this[fieldFactoryName](options); | ||
} catch (e) { | ||
throw('FilterComponent.createError: ' + e + '. The most likely fix is to create a function in "FilterComponents" named "' + fieldFactoryName + '(options)" that returns a filter component HTML.') | ||
} | ||
} | ||
}; |
Oops, something went wrong.