How can i set the default menus for Rhomobile Application? - rhomobile

Currently on going for menu, it shows some options like sync, close, home.
Since i don't have any such functionality of sync, so i just need to be able to manage them. Or if i could able to add my own custom menu it would be quite well for me.
Please help.

You can handle the default menu on the application.rb file. You can set the required default menu like below,
# default options menu
#default_menu = {
"Home" => :home,
"Refresh" => :refresh,
"Close" => :close
}
Even you can set the custom menu as like this,
# default options menu
#default_menu = {
"Home" => :home,
"Refresh" => :refresh,
"Close" => :close,
"Custom" => '/app/MyModel'
}
Check here http://docs.rhomobile.com/rhodes/ui#application-menu

Related

How can i change confirm message button delete in Active Admin

this my app/admin/author- enter image description here
How can i change delete button in admin/authors (index)
I need change only confirm message
How can i do this?
I try:
actions :all, :except => [:destroy] and then add custom actions default: true and create custon button, and its work i get custom message, but i can't destroy some author, because when i actions :all, :except => [:destroy], this delete route for deleting author
If relying on jquery does not bother you, add this to app/assets/javascripts/active_admin.js
$(document).ready(function () {
$('a.delete_link').data('confirm', 'is this what you really want?');
/* narrow down with selector for specificity */
$('table#index_table_authors a.delete_link').data('confirm', 'must this author really be destroyed?');
});
Or

In Redmine how to add my custom plugin inside Project Menu Bar?

I'm trying to add my Plugin inside a project's menu eg. I want to use my plugin as: https://redmine-site/projects/test-project/my-plugin
Like in this image i want to link my plugin after SPENT TIME in the menu.
You can add link to your custom controller (or any other place) in project menu. use this code in your init.rb
menu :project_menu, :plugin_example, { controller: :example, action: :say_hello}, caption: :label_sample, after: :time_entries, :param => :project_id
You have to add the link to your custom controller and add the permissions otherwise its not shown.
permission :performancedetail, { :performance => [:index, :vote] }, :public => true
menu :project_menu, :performancedetail, { controller: 'performance', action: 'index' }, caption: 'Performance'

How do you add an input search field in an ActiveAdmin menu or header

I am trying to add a search field into the ActiveAdmin header. I would prefer it to be next to the logout button in ActiveAdmin, but I'd settle for it being anywhere in the header. I've tried using admin.build_menu with no luck. I don't want to use sidebars since it would eat into my horizontal space.
It would be great to be able to do something like this:
config.namespace :admin do |admin|
admin.build_menu do |menu|
menu.add :input => 'Search', :url => "/search"
end
end
and have it place a search box in the menu bar
Any help on this would be appreciated. I'd like to do this as cleanly as possible without overriding ActiveAdmin code, but I'm willing to entertain any solution.
The solution I implemented is via jQuery.
Added this line on active_admin.js:
$('#header ul#tabs').append('<li><input id="listing-search" type="text" placeholder="Listing Number"></input></li>');
Then handle the event correspondingly (via JS of course).

Rails - Change boolean value on link click

In my app I have user notifications where the user gets notified for certain actions. These notifications are being shown in a dropdown from the navbar (like Facebook or S.O.). All of the notifications have a boolean attribute called :read and are default set to false. I'm using bootstrap with the dropdowns (in case that helps).
I want to create a method where when the user clicks to open the dropdown, all of their unread notifications become read.
Here is what I have so far for the method.
def read_notifications
PublicActivity::Activity.where(recipient_id: current_user).where(read: false).update_all(:read => true)
end
This updates all of the current user's notifications to :read => true when the method is called. In the view here is what I had so far for the dropdown link.
<%= link_to read_notifications_path, :class => "dropdown-toggle notifications_icon", :'data-toggle' => "dropdown", :controller => "application", :action => "read_notifications", :method => :post do %><% end %>
and the routes.rb I had this.
match "/read" => "application#read_notifications", :as => "read_notifications", via: 'post'
Now I know what I have is wrong, but even so when I click the link it does switch all of the user's notifications to read, it just acts also as a link (duh) and goes to a different page.
As you know, the link on a bootstrap dropdown is "#".
Does anyone know how I can set this up properly where when the user clicks the notification link in the navbar, ALL it does is open the dropdown and change the boolean value to true for all notifications.
I know this is possible, I just haven't been able to figure it out yet.
Thanks for taking a look at it.
EDIT
JS file
$(".notifications_icon").on("click", function(){
$.post("/read", function(data){
$('.notification_badge').text("");
});
});
View
<%= link_to "#", :class => "dropdown-toggle notifications_icon", :'data-toggle' => "dropdown" do %>
<span class="notification_badge"><%= find_unread_notifications_count(current_user) %></span>
<% end %>
This is Posting to the /read to read all of the notifications but it's not updating the count
You want a dash of unobtrusive JS. For example, SO has a class js-inbox-button that, when clicked, triggers updates on unread counts (both client and server). I won't dig into their JS source, but it's fairly simple to build.
You seem to already have a relevant class (notifications_icon), though you might want to use something else. When the link is clicked, use jquery $.post.
$(".notifications_icon").on("click", function(){
$.post("/read", function(data){
// remove unread count
$('.notification_badge').text('');
});
});
Now this is a very basic implementation. Couple of suggestions:
Only make requests when necessary (check for unread count on page first)
Use a data attribute on the link to pass /read path. That way you can still use your path helpers instead of hardcoding a path.
Store the above JS in a separate file (unobtrusive)
AJAX.
By adding remote: true you're starting with AJAX. Now the call goes to your path, and nothing happens! yay!
You want something to happen, though. So in your controller (I wouldn't do it in the application_controller, if I were you... activities_controller.rb maybe?):
controllers/activities_controller.rb
def read_notifications
PublicActivity::Activity.where(recipient_id: current_user).where(read: false).update_all(:read => true)
respond_to do |format|
format.js
end
end
You're on your way to Asynchronous loading! Now you need a js file to match it. So, since you've already moved this action to the activites, in your view, you'll have a new js.erb file to create (notice that it's in the same folder in the views as the controller name, and the file is named after the action):
views/activities/read_notifications.js.erb
$('#your_menu_div').html("<%= j render partial: 'activities/notifications' %>");
Now you create a partial (views/activities/_notifications.html.erb) that gets rendered into your pulldown menu.
Clear as mud?

how to add a new tab in spree admin panel?

I created a controller under Spree::Admin module and also I have mentioned in
routes.rb
match '/admin/new_tab => 'spree/admin/new_controller#index'
but this is working in front end.
How can I move this page to admin panel with new tab?
To make this controller work only if admin is signed in (like the other controllers in Admin namespace), it should inherit from Admin::BaseController.
To make the new tab, you should probably create Deface, something like this:
Deface::Override.new(:virtual_path => "spree/layouts/admin",
:name => "admin_content_admin_tab_parser",
:insert_bottom => "[data-hook='admin_tabs']",
:text => "<%= tab :new_tab, :url => 'admin/new_tab', :icon => 'icon-th-large' %>",
:disabled => false)

Resources