Remove navigation menu item for model without removing ability to manage in RailsAdmin and CanCan? - cancan

So I have a model (Image) that belongs to another model (Product), and I want to allow a user to manage both of these two types of models, but I don't want to list the model in the navigation menu in RailsAdmin.
Basically of these two I only want Product to be visible in the navigation menu, while allowing the user to still crud their images within the edit/add form of a Product.
Is this possible with CanCan? Or do I need to use CSS to hide these navigation items?

config.model Team do
visible false
end

According to this issue, and this issue your only valid approach would be the CSS approach

I had the same issue, and unfortunately I haven't found any proper solution. The only workaround was to hack Rails Admin using javascript.
So, to hide the model Image from the navigation menu I added this code in 'app/assets/javascripts/rails_admin/custom/ui.js':
$(document).on('rails_admin.dom_ready', function() {
$('ul.nav-pills li[data-model="image"]').hide();
});

I had same issue. fixed using this css
li[data-model="event_date"] {
display:none !important;
}

in your model:
rails_admin do
visible false
end
no need to edit your rails_admin.rb file.

Related

SAPUI5 - Basic info - how to manage UI elements in view.js?

experts,
These are two very basic connected questions.
I'm studying SAPUI5 and I cannot find means to position my UI elements on the screen.
In my view.js file I create, let's say, a button, a datepicker and a text field.
If I do something like:
aControls=[];
<Define the button - oButton>
aControls.push(oButton);
<Define the datepicker - oDatePicker>
aControls.push(oDatePicker);
<Define the text field - oText>
aControls.push(oText);
return aControls;
then I get all three elements positioned in a row one right after another.
I cannot use css, because I pass all those objects in one array and all of them are placed into a common div on index.html.
How do I position these? A link to any good tutorial/examples is very welcome.
Also, how do I refresh UI elements?
For example, I have situation, when on button press I make a call to the server, get response and put it into a using something like:
response.placeAt('some-id');
The button is created in the view.js and the call is processed in controller.js.
The response is added every time I press the button and I have no idea how to replace the old response with the new one.
A good link is very welcome.
Thanks.
There are a lot of layout controls of SAPUI5 you can use: Grid, HorizontalLayout, VerticalLayout, MatrixLayout,etc. You can check the examples and see how you need to layout your views.
You are currently doing UI5 JS view which implements createContent method to define views, this is one approach. Another common approach is to use XML views, it is declarative and more straightforward, also needs less code. See this simple example in JSBin of defining XML view and controller to refresh UI.
SAP UI5 is all about Model(JSONModel/ODataModel)-View(JSView/XMLView)-Controller. You are highly recommend to read this MVC example, though it is based on SAP UI5 mobile, the content is relevant to SAP UI5 desktop as well.
Hope you will get some hints.

GWT Editors for readonly and edit mode

GWT's Editor framework is really handy and it can not only be used for editing POJOs but also for read-only display.
However I am not entirely sure what the best practice is for doing inline edits.
Let's assume I have a PersonProxy and I have one Presenter-View pair for displaying and editing the PersonProxy. This Presenter-View should by default display the PersonProxy in read-only mode and if the user presses on a edit button it should allow the user to edit the PersonProxy object.
The solution I came up with was to create two Editors (PersonEditEditor and PersonDisplayEditor) that both added via UiBinder to the View. The PersonEditEditor contains
ValueBoxEditorDecorators and the PersonDisplayEditor contains normal Labels.
Initially I display the PersonDisplayEditor and hide PersonEditEditor.
In the View I create two RequestFactoryEditorDriver for each Editor and make it accessable from the Presenter via the View interface. I also define a setState() method in the View interface.
When the Presenter is displayed for the first time I call PersonDisplayDriver.display() and setState(DISPLAYING).
When the user clicks on the Edit button I call PersonEditDriver.edit() and setState(EDITING) from my Presenter.
setState(EDITING) will hide the PersonDisplayEditor and make the PersonEditEditor visible.
I am not sure if this is the best approach. If not what's the recommended approach for doing inline edits? What's the best way to do unit-testing on the Editors?
If you can afford developing 2 distinct views, then go with it, it gives you the most flexibility.
What we did in our app, where we couldn't afford the cost of developing and maintaining two views, was to bake the two states down into our editors, e.g. a custom component that can be either a label or a text box (in most cases, we simply set the text box to read-only and applied some styling to hide the box borders).
To detect which mode we're in, because we use RequestFactoryEditorDriver (like you do), we have our editors implement HasRequestContext: receiving a null value here means the driver's display() method was used, so we're in read-only mode. An alternative would be to use an EditorVisitor along with some HasReadOnly interface (which BTW is exactly what RequestFactoryEditorDriver does to pass the RequestContext down to HasRequestContext editors).
Yes,Presenter-View pair should be. But Here two ways to achieve this feature if you like to go with:
1) Integrate Edit/View code design in one ui.xml i.e.Edit code in EDitHorizonatlPanel and View code in ViewHorizontalPanel.The panel has different id. By using id, show/hide panel with display method. if getView().setState() ==Displaying then show ViewHorizontalPanel and if getView().setState()==Editing then show EditHorizontalPanel.
2) Instead of using labels, Use textboxes only. set Enable property is false when you need it in view mode otherwise true
You have created two Presenter/view but I think if Edit/View function has similar code so no need to rewrite similar code again and again for view purpose.
If a big project has so many Edit/View function and you will create such type of multiple View/Presenter than your project size become so huge unnecessary.
I think that whatever I have suggest that might be not good approach but a way should be find out which help to avoid code replication.

Zend Framework: Hide navigation item in menu by show in breadcrumbs

i am using Zend_Navigation i want to show the nav item in the breadcrumbs but hide it in my menu, how can i do that?
There are many choices, e.g.
You may set visible parameter to false (eg. in xml config file), then use setRenderInvisible(true/false) on the navigation helper,
You may use separate containers,
You may modify the container on the fly (getContainer(), getItemBy()…)
When using an XML config file, use an integer instead of a boolean value:
<visible>0</visible>
An issue has already been logged for this problem here.

How do you programatically remove (not disable) a button from TinyMCE?

I can disable the table button using this:
tinyMCE.activeEditor.controlManager.get('divId_table').setDisabled(true)
but what I'm interested in is actually hiding it. Any idea on how to accomplish that?
Thank you!
First, you have to use the advanced theme.
Then, add this option in the TinyMCE init code.
tinyMCE.init({
...
theme_advanced_disable : "bold, justifyleft, justifyright"
});
I hope this might help someone.
source
list of elements' name here
I'm not familiar with TinyMCE myself, but since you appear to have javascript access to the element itself, all you need to do is set it's display property to "none".
document.getElementById("theButton").style.display = "none";
incase ur trying to hide a specific button, use the following code.
$('.mce_cut').hide() //hides cut button
lookup other button titles using firebug in case u wish to hide something specific.
Incase you are looking to hide specific editor's button, modifiy the jquery selector to select correct sibling/descendent.
alternately, try this ..
tinyMCE.activeEditor.controlManager.controls.ctl00_SPWebPartManager1_g_5005db96_e035_4197_a958_75f008b35061_ctl00_tbKeywords_cut.remove()
Note that ctl00_SPWebPartManager1_g_5005db96_e035_4197_a958_75f008b35061_ctl00_tbKeywords is my asp.net control's id. Don't bother about this if ur not using Asp.net serverside textbox control. In case you are.. <% theTextBoxID.ClientID %> gets u that.
Use the following (using jQuery; a non-jQuery approch is easily built):
var elem = $(ed.id+'_'+'divId_table')
elem.addClass('mceButtonDisabled');
elem.removeClass('mceButtonEnabled');

SharePoint Navigation Menu - Multi Level

I'm looking into integrating some Telerik Components into our MOSS Installation. I'd figure I would kill a few birds with one stone and work on the Navigation Menu first.
I'm slightly new to SharePoint, and pulling hair at some of it's oddities.
We have some requirements for our Navigation menu:
Security Trimmed
Multi-Level Navigation
As best as I can tell, there doesn't seem to be a way to get security trimming without using SharePoint's out of the box Navigation Settings. Am I wrong?
Is there a way to get these Navigation Settings to go more than two levels deep?
EDITS
I'm using the Global Navigation, located at / > Site Settings > Modify Navigation
Haven't used the Telerik control.
I suspect you should be able to accomplish this with basic properties, something like StaticDisplayLevels="2" with 2 being the number you want.
The security I believe would be handled on your datasource that the control uses.
Again, I haven't used the telerik control so I'm sure it's a bit different, looking at the product info for this control it appears to be a matter of figuring out what the properties are that you need to adjust. There must be some documentation that came with it?
Savageguy is correct that you modify this on the datasource, an example:
<PublishingNavigation:PortalSiteMapDataSource
ID="MainNavigationDataSource"
runat="server"
EnableViewState="true"
SiteMapProvider="GlobalNavSiteMapProvider"
StartingNodeOffset="0"
ShowStartingNode="false" />
and then you can use any sort of control (databound) to render your menu. I´m using a repeater for my menu:
<asp:Repeater runat="server" ID="MenuRepeater"
DataSourceID="MainNavigationDataSource">
you are not required to use any other components other than SharePoint Menu but you have to add a small piece of script in the body tag:
< body onload="javascript:if (typeof(_spBodyOnLoadWrapper) != 'undefined') _spBodyOnLoadWrapper();">