change text of active admin has_many_remove button? - ruby-on-rails

How do I change the text on the Remove (the one assigned class 'has_many_remove') button on an active admin f.has_many stanza from 'Remove' to 'Hide'? Only for the current page/model and not site-wide.

I confirmed this feature is missing from Active Admin, see the discussion in the issues section of the Active Admin github repo: https://github.com/activeadmin/activeadmin/issues/5283

For application-wide change, you just need to add the following inside config/locales/en.yml:
en:
active_admin:
has_many_remove: "Hide"
But for page-specific change, you need some help from JS.
p.s. I can update the answer with js solution if you can provide your specific needs.

Related

customized symfony 3 form template

I tried to create a customized theme form symfony_3 form.
path: app/Resources/views/form
And I set the form as current theme
$view['form']->setTheme($form, array('app/Resources/views/form'));?>
But that does not work and the system calls the default symfony form theme. How can I fix that?
you could try define the form theming globaly in your config.yml as explained in this doc or locally like this other doc:
Hope it helps

Automatically add current url before print instruction in Joomla article

I want to manually add a [Print] icon in the position of my choosing in a Joomla 3.6 article. This article will be used as a 'master' which will be copied and renamed on a weekly basis so I would like the reference to the article in the URL to be automatic. Something like this:
<div class="btn-group">Print Preview</div>
I tried using # to reference the current page etc but this meant that the entire content of the page was (all modules, headers, footers, etc) were displayed in the print preview as well as the current article.
Thank you.
p.s. BTW, "Joomla3.6" isn't a valid tag yet so I couldn't add it with my reputation of just 1!
Not sure about your goal to "Manually add a [print] icon".
The normal way:
In the joomla /adminstrator , in the menu under Content->article, in the options on the right, there is a "Show print icon" - option. This will show the print icon for all articles. You might need to style it to suit your need. This can also be configured on a per-menu - basis.
Optionally:
You could override the default output of the article template (More on output overrides here) and add the print icon wherever you need it:
Copy the file /components/com_content/views/article/tmpl/default.php to /templates/yourtemplate/html/com_content/article/default.php
Add the print icon somewhere: <div class="btn-group"><a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language)); ?>" ... >Print Preview</a></div>
But, you can probably use the first method. Or perhaps just move the current output of the print icon in default.php, using the override method described above.

Remove bloggers automatic 'add URL' feature to menu items

My Blogger template (klarity) automatically adds my domain name infront of any link I want to add to my menu. For example: I want to create a link to my page 'about'. All I need to do is create a list item with a link pointing towards /about.html.
This is a problem when I want to link a menu item with an external domain. So if I want to create a link between the menu item 'shop' and www.myshop.com I cannot simply change the href of the link to www.myshop.com because blogger adds my domain name infront of it, making it look like: www.mydomain.com/www.myshop.com.
From what I understand Blogger does this through the following code: data:post.url or similar. I have looked for that kind of code and tried cutting it out but so far I have not managed to get rid of www.mydomain.com infront of every list item.
How can I remove www.mydomain.com from my menu items? This is the only solution I could think of, if there are any others please do suggest them!
So I actually figured out the problem, it was really easy:
Just change the link so that it looks like this:
My domain
Make sure you don't forget the http, otherwise you are going to get errors (thats's the mistake I made)

Active Admin Customization in Ruby On Rails

I'm using active admin gem. In one table i want admins page to have some extra fields apart from the default functionalities.
Is it possible to have a default active admin page + a provision to render some html.
I want something like this in picture
The extra feature that i was talking was about push notification and message and that text area part
If you want a page with your own content, you could register a page: http://www.activeadmin.info/docs/10-custom-pages.html
But if you want to customise the default html strucure of the index page, you have to re-open the ActiveAdmin::Views::Pages module and override the build_page_content method. You can do this inside your app, for example create a new file in app/lib folder and override the method.
https://github.com/gregbell/active_admin/blob/master/lib/active_admin/views/pages/base.rb#L62
or if you want to customise the index table:
https://github.com/gregbell/active_admin/blob/master/lib/active_admin/views/pages/index.rb
Not a nice solution, but it's work. :/
Unfortunately, it seems index doesn't support custom rendering:
https://github.com/gregbell/active_admin/issues/813#issuecomment-3059957
However, you might have luck using panel, except in my experience that renders above the table ActiveAdmin generates.

ASP.NET MVC 5 Customise Bootstrap navbar based on User Role

I'm using the ASP.NET MVC 5 built in authentication methods. I would like to show and hide links (in the menu navbar) based on the role the user is in.
Has anyone acheived this?
Where would be a starting point?
Just wrap your links in:
#if (User.IsInRole("SomeRole"))
{
...
}
You can use MvcSiteMap for this. It has a feature called SecurityTrimming which uses the [Authorize] attribute on your action methods to decide whether or not to display the menu item.
I know it's frowned upon to post a links in answers but I found this blog post very useful.
In addition to the role-based menu visibility, I added custom attributes to the MvcSiteMapNodes to determine visibility of links that were accessible to users but I didn't want shown in the menu (e.g. Edit pages), and I also added icon attributes which allowed me to use the bootstrap menu icons e.g:
<mvcSiteMapNode title="Till" controller="Home" action="Index" area="Till" iconClass="icon-home" visibility="true">
I went a bit off-topic there, but I just wanted to highlight how flexible MvcSiteMap is.
Two things I do. Either
User.IsInRole(admin)
{link somewhere}
Or what I personally do is because I use areas I have a viewstart in area admin which links to admin shared viewmodel then in admin shared view that links to the public view.
In the admin shared view. I set up a section. Inside this section I define extra nav details what that specific role will see and add them in a list tag
Then inside public shared view I then use (on phone can't remember exact name something like)
Html.IsSectionDefined
I personally like the second method using areas and sections both would work fine but with the second I find it much cleaner and you can be so much more specific and much simpler

Resources