Skip to content

Commit

Permalink
Toolbar cleanup
Browse files Browse the repository at this point in the history
- 5 distinct toolbars for 4 kinds of nodes -
root, god, actions, buttongroup, button

- Other unrequired toolbars have been deleted

- Only the required button toolbar classes have been kept

- Removed `kindof?` usage from those classes

- Fixed toolbar spec
  • Loading branch information
AparnaKarve committed Nov 8, 2017
1 parent 1f419b0 commit b41a559
Show file tree
Hide file tree
Showing 15 changed files with 171 additions and 223 deletions.
34 changes: 19 additions & 15 deletions app/controllers/generic_object_definition_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def self.model

def index
self.x_node = 'root'
redirect_to :action => "show_list"
redirect_to(:action => "show_list")
end

def show_list
Expand All @@ -33,7 +33,7 @@ def show
super
else
@breadcrumbs = []
redirect_to :action => "show_list"
redirect_to(:action => "show_list")
end
end

Expand Down Expand Up @@ -170,23 +170,27 @@ def node_info(node)

def root_node_info
@root_node = true
@center_toolbar = 'generic_object_definitions'
@right_cell_text = _("All %{models}") % {:models => _("Generic Object Classes")}
end

def god_node_info(node)
@god_node = true
@center_toolbar = 'generic_object_definition_node'
@record = GenericObjectDefinition.find(from_cid(node.split('-').last))
@right_cell_text = _("Generic Object Class %{record_name}") % {:record_name => @record.name}
end

def actions_node_info(node)
@actions_node = true
@center_toolbar = 'generic_object_definition_actions_node'
@record = GenericObjectDefinition.find(from_cid(node.split('-').last))
@right_cell_text = _("Actions for %{model}") % {:model => _("Generic Object Class")}
end

def custom_button_group_node_info(node)
@custom_button_group_node = true
@center_toolbar = 'generic_object_definition_button_group'
@record = CustomButtonSet.find(from_cid(node.split("-").last))
@right_cell_text = _("Custom Button Set %{record_name}") % {:record_name => @record.name}
rescue StandardError => _err
Expand All @@ -195,6 +199,7 @@ def custom_button_group_node_info(node)

def custom_button_node_info(node)
@custom_button_node = true
@center_toolbar = 'generic_object_definition_button'
@record = CustomButton.find(from_cid(node.split("-").last))
@right_cell_text = _("Custom Button %{record_name}") % {:record_name => @record.name}
rescue StandardError => _err
Expand All @@ -219,35 +224,35 @@ def process_root_node(presenter)
process_show_list
presenter.replace(:main_div, r[:partial => 'list'])
presenter.show(:paging_div)
build_toolbar("x_gtl_view_tb")
[build_toolbar("x_gtl_view_tb"), build_toolbar("generic_object_definitions_center_tb")]
end

def process_god_node(presenter, node)
god_node_info(node)
presenter.replace(:main_div, r[:partial => 'show_god'])
presenter.hide(:paging_div)
build_toolbar("x_summary_view_tb")
[build_toolbar("x_summary_view_tb"), build_toolbar("generic_object_definition_node_center_tb")]
end

def process_actions_node(presenter, node)
actions_node_info(node)
presenter.replace(:main_div, r[:partial => 'show_actions'])
presenter.hide(:paging_div)
build_toolbar("x_summary_view_tb")
[build_toolbar("x_summary_view_tb"), build_toolbar("generic_object_definition_actions_node_center_tb")]
end

def process_custom_button_group_node(presenter, node)
custom_button_group_node_info(node)
presenter.replace(:main_div, r[:partial => 'show_custom_button_group'])
presenter.hide(:paging_div)
build_toolbar("x_summary_view_tb")
[build_toolbar("x_summary_view_tb"), build_toolbar("generic_object_definition_button_group_center_tb")]
end

def process_custom_button_node(presenter, node)
custom_button_node_info(node)
presenter.replace(:main_div, r[:partial => 'show_custom_button'])
presenter.hide(:paging_div)
build_toolbar("x_summary_view_tb")
[build_toolbar("x_summary_view_tb"), build_toolbar("generic_object_definition_button_center_tb")]
end

def replace_right_cell
Expand All @@ -256,15 +261,14 @@ def replace_right_cell

node = x_node || params[:id]

v_tb = case node_type(node)
when :root then process_root_node(presenter)
when :god then process_god_node(presenter, node)
when :actions then process_actions_node(presenter, node)
when :button_group then process_custom_button_group_node(presenter, node)
when :button then process_custom_button_node(presenter, node)
end
v_tb, c_tb = case node_type(node)
when :root then process_root_node(presenter)
when :god then process_god_node(presenter, node)
when :actions then process_actions_node(presenter, node)
when :button_group then process_custom_button_group_node(presenter, node)
when :button then process_custom_button_node(presenter, node)
end

c_tb = build_toolbar(center_toolbar_filename)
h_tb = build_toolbar("x_history_tb")

presenter.reload_toolbars(:history => h_tb, :center => c_tb, :view => v_tb)
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
class ApplicationHelper::Button::GenericObjectDefinitionButtonButtonGroupDelete < ApplicationHelper::Button::Basic
def visible?
@record.kind_of?(CustomButtonSet)
end

def disabled?
!@record.kind_of?(CustomButtonSet) || (@record.kind_of?(CustomButtonSet) && !@record.custom_buttons.count.zero?)
!@record.custom_buttons.count.zero?
end
end

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class ApplicationHelper::Button::GenericObjectDefinitionButtonDelete < ApplicationHelper::Button::Basic
def visible?
@record.kind_of?(GenericObjectDefinition) && @display != 'generic_objects'
@display != 'generic_objects'
end

def disabled?
@record.kind_of?(GenericObjectDefinition) && !@record.generic_objects.count.zero?
!@record.generic_objects.count.zero?
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class ApplicationHelper::Toolbar::GenericObjectDefinitionActionsNodeCenter < ApplicationHelper::Toolbar::Basic
button_group('generic_object_definition', [
select(
:generic_object_definition_configuration,
'fa fa-cog fa-lg',
title = N_('Configuration'),
title,
:items => [
button(
:ab_group_new,
'pficon pficon-add-circle-o fa-lg',
t = N_('Add a new Button Group'),
t,
:url => 'custom_button_group_new',
),
button(
:ab_button_new,
'pficon pficon-add-circle-o fa-lg',
t = N_('Add a new Button'),
t,
:url => 'custom_button_new',
),
]
)
])
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
class ApplicationHelper::Toolbar::GenericObjectDefinitionButtonCenter < ApplicationHelper::Toolbar::Basic
button_group('generic_object_definition', [
select(
:generic_object_definition_configuration,
'fa fa-cog fa-lg',
title = N_('Configuration'),
title,
:items => [
button(
:ab_group_edit,
'pficon pficon-add-circle-o fa-lg',
t = N_('Edit this Button'),
t,
:url => 'custom_button_edit',
),
button(
:ab_button_delete,
'pficon pficon-delete fa-lg',
t = N_('Remove this Button from Inventory'),
t,
:data => {'function' => 'sendDataWithRx',
'function-data' => '{"type": "delete_custom_button", "controller": "genericObjectDefinitionToolbarController", "entity": "Button"}'},
:confirm => N_("Warning: This Button will be permanently removed!"),
)
]
)
])
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
class ApplicationHelper::Toolbar::GenericObjectDefinitionButtonGroupCenter < ApplicationHelper::Toolbar::Basic
button_group('generic_object_definition', [
select(
:generic_object_definition_configuration,
'fa fa-cog fa-lg',
title = N_('Configuration'),
title,
:items => [
button(
:ab_group_edit,
'pficon pficon-add-circle-o fa-lg',
t = N_('Edit this Button Group'),
t,
:url => 'custom_button_group_edit',
),
button(
:ab_button_new,
'pficon pficon-add-circle-o fa-lg',
t = N_('Add a new Button'),
t,
:url => 'custom_button_new',
),
button(
:ab_button_delete,
'pficon pficon-delete fa-lg',
t = N_('Remove this Button Group from Inventory'),
t,
:data => {'function' => 'sendDataWithRx',
'function-data' => '{"type": "delete_custom_button_set", "controller": "genericObjectDefinitionToolbarController", "entity": "Button Group"}'},
:klass => ApplicationHelper::Button::GenericObjectDefinitionButtonButtonGroupDelete,
:confirm => N_("Warning: This Button Group will be permanently removed!"),
),
]
)
])
end

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
class ApplicationHelper::Toolbar::GenericObjectDefinitionNodeCenter < ApplicationHelper::Toolbar::Basic
button_group('generic_object_definition', [
select(
:generic_object_definition_configuration,
'fa fa-cog fa-lg',
title = N_('Configuration'),
title,
:items => [
button(
:generic_object_definition_edit,
'pficon pficon-edit fa-lg',
t = N_('Edit this Generic Object Class'),
t,
),
button(
:ab_group_new,
'pficon pficon-add-circle-o fa-lg',
t = N_('Add a new Button Group'),
t,
:url => 'custom_button_group_new',
),
button(
:ab_button_new,
'pficon pficon-add-circle-o fa-lg',
t = N_('Add a new Button'),
t,
:url => 'custom_button_new',
),
button(
:generic_object_definition_delete,
'pficon pficon-delete fa-lg',
t = N_('Remove this Generic Object Classes from Inventory'),
t,
:data => {'function' => 'sendDataWithRx',
'function-data' => '{"type": "delete", "controller": "genericObjectDefinitionToolbarController"}'},
:klass => ApplicationHelper::Button::GenericObjectDefinitionButtonDelete,
:confirm => N_("Warning: This Generic Object Class will be permanently removed!"),
),
]
)
])
end
Loading

0 comments on commit b41a559

Please sign in to comment.