Skip to content
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

Make created filters in Datastores visible and fix commiting filters #13140

Closed

Conversation

hstastna
Copy link

@hstastna hstastna commented Dec 13, 2016

fixing
https://bugzilla.redhat.com/show_bug.cgi?id=1398748
https://bugzilla.redhat.com/show_bug.cgi?id=1382768

Make created filters (not global) in Compute -> Infrastructure -> Datastores
visible under My Filters in accordion, no need to refresh the page
after creating a new filter.
Fix commiting a new filter which is related to its creating and saving.

Commiting filters was broken by
#12998

Before:
datastores2
datastores4

After:
datastores1
datastores3

No need to refresh the page after creating a new filter:
datastores5

@hstastna hstastna changed the title [WIP] Make created filters in Datastores visible and fix commiting filters Make created filters in Datastores visible and fix commiting filters Dec 13, 2016
when "global" # Global filters
objects.visible_to_all
when "my" # My filters
objects.where(:search_type => "user", :search_key => User.current_user.userid)
Copy link
Contributor

@lpichler lpichler Dec 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about to move this to model a method (app/models/miq_search.rb) ?

return count_only ? 0 : [] if object[:id] != "global"
objects = MiqSearch.where(:db => options[:leaf]).visible_to_all
objects = MiqSearch.where(:db => options[:leaf])
objects = case object[:id]
Copy link
Contributor

@lpichler lpichler Dec 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and you can use
objects = object[:id] == 'global' ? objects.visible_to_all : objects.your_new_method_from_comment_below

what do you think ?

Copy link
Author

@hstastna hstastna Dec 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed app/presenters/tree_builder_storage.rb like that because it needs the same functionality as in https://github.com/ManageIQ/manageiq/blob/master/app/presenters/tree_builder_vms_filter.rb#L28
which works well and it is well understandable what's going on there.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, then you can move this code to method in app/models/miq_search.rb to avoid duplicating code.

and you can do it in follow up PR for tree_builder_vms_filter.rb

  objects = MiqSearch.where(:db => options[:leaf])
    objects = case object[:id]
              when "global" # Global filters
                objects.visible_to_all
              when "my"     # My filters
                objects.where(:search_type => "user", :search_key => User.current_user.userid)
   end

what do you think ?

@lpichler
Copy link
Contributor

@miq-bot add_label ui, bug
@miq-bot assign @mzazrivec

@@ -307,11 +307,11 @@ def adv_search_button
{:model => ui_lookup(:model => @edit[@expkey][:exp_model]),
:name => @edit[:new_search_name]})
@edit[@expkey].select_filter(s)
@edit[:new_search_name] = @edit[:adv_search_name] = @edit[@expkey][:exp_last_loaded][:description]
@edit[:new_search_name] = @edit[@expkey][:exp_model] != "Storage" ? @edit[:adv_search_name] = @edit[@expkey][:exp_last_loaded][:description] : @edit[:new_search_name]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in else leg you are assigning same variable (@edit[:new_search_name]) ?

@edit[:new_search_name] = @edit[:adv_search_name] = @edit[@expkey][:exp_last_loaded][:description] unless @edit[@expkey][:exp_model] == "Storage"

does it cover you intention ?

Copy link
Author

@hstastna hstastna Dec 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this can be solved by some other (and hopefully better) solutions. If you look at the original line and test it, the result will be that @edit[:new_search_name] will be nil which is not good. I decided to do it like that to leave it as it was for other cases (I mean if the condition is true) because hopefully it was a reason for how it was like that for so long.
For our case @edit[:new_search_name] shouldn't be changed there. Maybe somebody could test it if it could be changed generally (I mean not just for Datastores). I didn't want to break functionality in other places with this. Any ideas how to make it better?

Fix a little typo in adv_search_button method regarding a proper
saving of a new created filter using advanced search panel.
@hstastna hstastna force-pushed the Filters_in_datastores_page_refreshed branch 2 times, most recently from b2bb1ea to 4d61385 Compare December 15, 2016 12:45
fixing
https://bugzilla.redhat.com/show_bug.cgi?id=1398748
https://bugzilla.redhat.com/show_bug.cgi?id=1382768

Make created filters (not global) in Compute -> Infrastructure ->
-> Datastores visible under My Filters in accordion.
@hstastna hstastna force-pushed the Filters_in_datastores_page_refreshed branch from 4d61385 to 3aaad73 Compare December 15, 2016 12:59
Hilda Stastna added 2 commits December 15, 2016 14:00
fixing
https://bugzilla.redhat.com/show_bug.cgi?id=1398748
https://bugzilla.redhat.com/show_bug.cgi?id=1382768

Display a new filter (not global) in Compute -> Infrastructure ->
-> Datastores in My Filters in accordion right after creating it,
no need to refresh the page to see the new filter there.
Fix commiting a new filter in advanced search panel which is
related to its creating and saving because it did not work,
button to 'Commit expression element changes' did not work properly.
Also make button for discarding expression element changes work.
@hstastna hstastna force-pushed the Filters_in_datastores_page_refreshed branch from 3aaad73 to 6e190df Compare December 15, 2016 13:01
@miq-bot
Copy link
Member

miq-bot commented Dec 15, 2016

Checked commits hstastna/manageiq@46e28bf~...6e190df with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1
3 files checked, 4 offenses detected

app/controllers/application_controller/filter.rb

app/views/layouts/exp_atom/_editor.html.haml

  • ⚠️ - Line 27 - Missing curly braces around a hash parameter.
  • ⚠️ - Line 36 - Missing curly braces around a hash parameter.

hstastna pushed a commit to hstastna/manageiq that referenced this pull request Dec 15, 2016
depends on ManageIQ#13140

Refactoring code of x_get_tree_custom_kids method as the
same code needs to be in the method in tree_builder_vms_filter.rb
and in tree_builder_storage.rb;
moving the code to new methods in miq_search.rb.
@h-kataria
Copy link
Contributor

@hstastna after i saved a filter in Datastores accordion that worked and refreshed the tree to show the newly added filter in it, but when i tried to add a new filter Datastore Clusters accordion, after i save the filter it blanks out the whole tree in the left accordion, see screenshot below:
screenshot from 2016-12-15 12-48-27
I think advanced search should not be available on the Datastore Clusters accordion, this should only have regular search box, and advanced search should only be available on Datastores accordion that displays filters in tree.

"data-method" => :post,
:title => t)

- t = _('Commit expression element changes')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@epwinchell can you review this change

Copy link
Contributor

@epwinchell epwinchell Dec 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hstastna Can you replace the link_to(image_tag for each as I have below? That will give us the styling we need.

%button
..%i.fa.fa-check

%button
.. %i.pficon.pficon-close

Copy link
Author

@hstastna hstastna Jan 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@epwinchell could you please test it and give me an exact and working example?
Because I probably don't know how you mean it.
I mean, wit the code around, not just with "..."
It just does not work as simply as you mentioned. I tried it in many ways, without success. Some of my colleagues tried it, too, and also without success.

Originally, the problem was button element.
I know that styling is important, but as I think, more important is if the button works properly.
So I removed the button element and it worked perfectly. Adding some classes was not a problem, it was possible to add them very easily to my original solution.I know that you would like to see nicer solution but my solution worked comparing to the "styling we need". This all makes me to ask: is really button element required to use there? Why? We survived to these days without it.. (I mean, without working buttons there..) If yes, how would you put there all the options to make it work properly and using button element?

Copy link
Contributor

@epwinchell epwinchell Jan 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hstastna Here's a working example. If you get stuck with these in the future, please ping me or @h-kataria for help.

%button.btn.btn-default{:title => t,
"data-miq_sparkle_on" => true,
:remote               => true,
"data-method"         => :post,
:onclick => "miqAjaxButton('#{url_for(:action => 'exp_button', :pressed => 'commit')}');"}
  %i.fa.fa-lg.fa-check
- t = _("Discard expression element changes")
%button.btn.btn-default{:title => t,
"data-miq_sparkle_on" => true,
:remote               => true,
"data-method"         => :post,
:onclick => "miqAjaxButton('#{url_for(:action => 'exp_button', :pressed => 'discard')}');"}
  %i.fa-lg.pficon.pficon-close

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much!

Copy link
Member

@isimluk isimluk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 For fixing broken buttons!!!

@isimluk
Copy link
Member

isimluk commented Dec 19, 2016

This pr fixes broken commit and discart buttons.

However, the and, or, and not buttons are still borked.

I vote for merging this pr early, so we have at least something working.

@miq-bot
Copy link
Member

miq-bot commented Dec 22, 2016

<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush.

@chessbyte chessbyte added wip and removed wip labels Jan 3, 2017
@hstastna
Copy link
Author

hstastna commented Jan 9, 2017

This PR has conflicts because of UI split, I am closing this PR and creating the new one and better: ManageIQ/manageiq-ui-classic#98

@hstastna hstastna closed this Jan 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants