-
Notifications
You must be signed in to change notification settings - Fork 88
fixing model with namespace #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,7 +37,7 @@ def editable(object, method, options = {}) | |
| nid = options.delete(:nid) | ||
| nested = options.delete(:nested) | ||
| title = options.delete(:title) do | ||
| klass = nested ? object.class.const_get(nested.to_s.classify) : object.class | ||
| klass = nested ? object.class.const_get(nested.to_s.singularize.capitalize) : object.class | ||
| klass.human_attribute_name(method) | ||
| end | ||
|
|
||
|
|
@@ -72,13 +72,7 @@ def editable(object, method, options = {}) | |
| }) | ||
|
|
||
| content_tag tag, html_options do | ||
| if %w(select checklist).include?(data[:type].to_s) && !source.is_a?(String) | ||
| source = normalize_source(source) | ||
| content = source.detect { |t| output_value == output_value_for(t[0]) } | ||
| content.present? ? content[1] : "" | ||
| else | ||
| safe_join(source_values_for(value, source), tag(:br)) | ||
| end | ||
| safe_join(source_values_for(value, source), tag(:br)) unless %w(select checklist).include? data[:type] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [116/80] |
||
| end | ||
| else | ||
| error || safe_join(source_values_for(value, source), tag(:br)) | ||
|
|
@@ -87,17 +81,6 @@ def editable(object, method, options = {}) | |
|
|
||
| private | ||
|
|
||
| def normalize_source(source) | ||
| return [] unless source | ||
| source.map do |el| | ||
| if el.is_a? Array | ||
| el | ||
| else | ||
| [el[:value], el[:text]] | ||
| end | ||
| end | ||
| end | ||
|
|
||
| def output_value_for(value) | ||
| value = case value | ||
| when TrueClass | ||
|
|
@@ -152,9 +135,11 @@ def format_source(source, value) | |
| if source.is_a?(Array) && source.first.is_a?(String) && source.size == 2 | ||
| { '1' => source[0], '0' => source[1] } | ||
| end | ||
| else | ||
| when String | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indent when as deep as case. |
||
| if source.is_a?(Array) && source.first.is_a?(String) | ||
| source.map { |v| { value: v, text: v } } | ||
| source.inject({}){|hash, key| hash.merge(key => key)} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space missing to the left of {. |
||
| elsif source.is_a?(Hash) | ||
| source | ||
| end | ||
| end | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [104/80]