-
Notifications
You must be signed in to change notification settings - Fork 356
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
Fix show record after generic object custom button dialog run #2745
Changes from 12 commits
25cc68b
0b1585a
539c373
df178d7
113b298
4f95fd8
ea861ef
8ecdff9
cd35178
9371faa
1ed9207
a171d82
53ec477
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 |
---|---|---|
|
@@ -342,23 +342,30 @@ def build_custom_toolbar_class(model, record, toolbar_result) | |
toolbar.button_group(button_group[:name], button_group[:items]) | ||
end | ||
|
||
custom_button_add_related_buttons(model, record, toolbar) | ||
toolbar | ||
end | ||
|
||
def custom_button_add_related_buttons(model, record, toolbar) | ||
# For Service, we include buttons for ServiceTemplate. | ||
# These buttons are added as a single group with multiple buttons | ||
if record.present? | ||
service_buttons = record_to_service_buttons(record) | ||
unless service_buttons.empty? | ||
buttons = service_buttons.collect { |b| create_custom_button(b, model, record) } | ||
toolbar.button_group("custom_buttons_", buttons) | ||
if record.kind_of?(Service) | ||
service_buttons = record_to_service_buttons(record) | ||
unless service_buttons.empty? | ||
buttons = service_buttons.collect { |b| create_custom_button(b, model, record) } | ||
toolbar.button_group("custom_buttons_", buttons) | ||
end | ||
end | ||
|
||
generic_object_buttons = record_to_generic_object_buttons(record) | ||
unless generic_object_buttons.empty? | ||
buttons = generic_object_buttons.collect { |b| create_custom_button(b, model, record) } | ||
toolbar.button_group("custom_buttons_", buttons) | ||
if record.kind_of?(GenericObject) | ||
generic_object_buttons = record_to_generic_object_buttons(record) | ||
unless generic_object_buttons.empty? | ||
buttons = generic_object_buttons.collect { |b| create_custom_button(b, model, record) } | ||
toolbar.button_group("custom_buttons_", buttons) | ||
end | ||
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. it's time to split the this is getting too long and complex please, split it 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. moved adding the related buttons to a separate method: custom_buttons_add_related_buttons |
||
end | ||
end | ||
|
||
toolbar | ||
end | ||
|
||
def button_class_name(model) | ||
|
@@ -374,15 +381,19 @@ def service_template_id(record) | |
end | ||
end | ||
|
||
def create_related_custom_buttons(record, item) | ||
item.custom_buttons.collect { |cb| create_raw_custom_button_hash(cb, record) } | ||
end | ||
|
||
def record_to_service_buttons(record) | ||
return [] unless record.kind_of?(Service) | ||
return [] if record.service_template.nil? | ||
record.service_template.custom_buttons.collect { |cb| create_raw_custom_button_hash(cb, record) } | ||
create_related_custom_buttons(record, record.service_template) | ||
end | ||
|
||
def record_to_generic_object_buttons(record) | ||
return [] unless record.kind_of?(GenericObject) | ||
record.generic_object_definition.custom_buttons.collect { |cb| create_raw_custom_button_hash(cb, record) } | ||
create_related_custom_buttons(record, record.generic_object_definition) | ||
end | ||
|
||
def get_custom_buttons(model, record, toolbar_result) | ||
|
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.
@lgalis do we need this check, i see record being passed in from the caller
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.
yes, record may not always be present