Making a menu item appear when a certain view is displayed rails - ruby-on-rails-4

Windows 8.1
Rails 4.1
Ruby 2.0
I have the menus for my application defined in views/layout, and one of those is the header where I have the menu items. There are some additional partials rendered form _header.html.erb as well.
I would like to have an additional menu appear ONLY when I render views/pages/index. How do I go about doing this?

I would look in Javascript. Have you tried listening for the specific body class of that page? Each body gets a dynamically generated attribute of class="controller action". If you listen for body.controller.action, you'll have the event that can trigger you to show (or hide) your menu item.
Pseudo code might look like:
I want a new menu to appear for controller1, action1
when any action fires in any controller
if the class of the body element has both class "controller1" and class "action1"
menu.show()
else
menu.hide()

Related

Android navigation component- With Login screens

When dealing with login screens, I am trying to work out the better approach - either execute navigation "action" to go to login fragment on first use (and hide back button to actual app), or start a new login activity (with its own nav graph). For the first approach (just using navigation components), I do not know the way to remove the back button without a hack "hide". I tried using navoptions, setpopupto etc., but it does not work. Code below:
val navOptions = NavOptions.Builder()
.setPopUpTo(R.id.home_fragment, true)
.build()
host?.navController?.navigate(R.id.action_global_signUpFragment_dest, null, navOptions)
Two questions then:
1) How to properly handle login transition with just navigation component?
2) Is starting a new login activity, with separate nav graph, a better idea?
I think the first approach is better.
To hide the 'back' button on your toolbar inside signUpFragment you can use AppBarConfiguration, and customize which destinations are considered top-level destinations.
For example:
val appBarConfiguration = AppBarConfiguration.Builder(setOf(R.id.home_fragment, R.id.signUpFragment_dest)).build()
NavigationUI.setupWithNavController(toolbar, navController, appBarConfiguration)
This way home_fragment and signUpFragment_dest will be considered top-level destinations, and won't have back button on toolbar.
Another option for solving the back button problem is how I did it here. Also, rather than show/hide the bottom nav bar, I have two NavHostFragment, one main full screen one, and one contained within the home fragment (above the bottom nav bar).
When I want to navigate to a full screen view I call this extension function,
fun Fragment.findMainNavController(): NavController =
Navigation.findNavController(activity!!, R.id.nav_host_fragment)
then navigate via the main graph.
This makes sense conceptually to me, to have parent and child nav graphs.

raw_id_fields with pages field does not work

There are several issues if we add "pages" field to raw_id_fields.
When I click on search button, pages dialog opens, and if I select any page, nothing happens (I think that context variable is_popup from render_page_row method in cms/utils/admin.py should additionally check if IS_POPUP_VAR is present in request.META['HTTP_REFERER'])
If problem 1. is fixed, click on page adds page id but also all parent ids all the way to the tree root (I think that propagation of onclick event should be stopped)
It is not possible to open child nodes without selecting parent. When parent node arrow is clicked in order to see and add child node, parent is selected and dialog is closed. Result of adding onclick event handler on cms-tree-node.
Is it possible to add onclick event only for page link and not on the whole element with class cms-tree-node, so we can open node children without selecting page?
Environment
Python version: 2.7
Django version: 1.8
django CMS version: 3.4.4

How to customize Android action bar with search button

I want to create a custom action bar in my app like the Play Store Action bar so I can have some Back to Home and Search buttons. I'm beginner to Android development and don't know how can I do it.
How can I add these buttons and have this action bar remain in all activity layouts?
Also, how can I create a class that universally handles searches and click events from this action bar without hardcoding in each activity?
I found a solution for my problem.
for creating action bar , my solution is creating a layout and disable native action bar in style.xml by this tag
<item name="android:windowNoTitle">true</item>
then use your own layout instead of native layout.
for handle action bar universaly in all activities instead of writing repetitious codes it's better to create a base class that extends from Activity class and use this class as parent class of other activities instead of using Activity as parent. then write methods in parent class for handle action bar like click event and etc...
Best Regards
Ali

AngularJS Master Detail example [ASP.NET application with WEBAPI,AngularJS]

The requirements is like master detail grid, on load the master gets displayed as a table, on every detail row edit button click , need to open the detail edit form in a Modal window. There could be different templates based on detail/productTypes . For example productType1 will display few set of fields(template 1) , so on.
Have WEBAPI with REST support and understand how to build the initial Master table But not sure on how the details part.
Any direction would be helpful.
Does your HTML/CSS Framework provide mechanism for a dialog? If so you would have to create a directive to wrap it around the script to open the dialog.
On the master grid row ng-click will set a flag on the controller. When this flag is set to true, the code in directive will open the dialog. Within that dialog div you can use ng-include that will be bound to the url of the template (controller variable will store that url).
The template is bound to a child object in the controller scope and has the fields for the details. Setting the flag to false will close the dialog and you will have changes your main controller.

How to call IShellFolder::EnumObjects externally in a shell extension

I have created a Windows Shell Extension similar to Google's GDrive. Now I want to add different views to the ListView that inherits from IShellView. A new context menu has been added to to display 3 views (Details, Small Icon, Large Icon). When a view is changed using the context menu, the current window needs to be refreshed/created to display the changed view.
In my IShellFolder::EnumObjects, a new ListView object is created and OnCreate is called automatically. I need to call this method when I change view using the context menu also. I guess there might be some API like SHChangeNotify() that can all the EnumObjects() automatically and a new IShellView window will be created with the changed view.
As i understood from your question, you need the same contents to be viewed in listview but with the new view.
You don't need to recreate the Listview object after the new view mode selection, Just set the ListView's style to LVS_REPORT, LVS_SMALLICON, or LVS_ICON.
SHChangeNotify is used to reflect the change to the tree pane not the ListView.