Adding icons to menu items in odoo - odoo

I try to set an icon to menuitem, So I find that the attribute icon is supported, but No change happen when I change its value.
I want to know if it is still supported by menuitem in odoo v7/8. If not, how to add an icon to a menu item?
Edit:
I try to customize the view of the menu in odoo. So I override the template that render the menu in "webClient_templates.xml" from web module like this:
<template id="my_menu_link" inherit_id="web.menu_link">
<span position="replace">
<span class="oe_menu_text">
<i class="fa fa-check"></i>
<t t-esc="menu['name']"/>
</span>
</span>
</template>
Likely, all the menu items will have the same icon (i.e. fa-check) from font-awesome lib.
Now, I try to add a specific icon for each menu item, that I can define it somehow in the xml description of menuitem as a kind of attribute or anything else, and retrieve it like this:
<i t-attrs-class="menu['icon']"></i>
I tried to use icon attribute of menuitem, even if it's deprecated, but menu['icon'] is not recognized in the template level.
Please any suggestions ?

AFAIK displaying icons in menu items is deprecated and does not work on the web client. Probably the to achieve you would need to create a module for the web client extending it with that capability.

I'm using odoo v12 now, and there is also an unused field for icons on ir.ui.menu model.
I managed to show icons on backend's menus, here are the difference with your code:
The icon field is named web_icon, it may be specific to v10+ , I don't have a v8 to verify this.
The templating syntax to set attributes is t-att-<name> and not t-attrs-<name>
And most important: the menus in backend are generated using javascript, so the templates to modify are to find in web/static/src/xml/menu.xml
There are 3 places to add an <i> markup in 2 templates:
<t t-name="Menu.link">
Line 47: <span><i t-att-class="menu.web_icon"></i> <t t-esc="menu.name"/></span>
Line 59: <span><i t-att-class="menu.web_icon"></i> <t t-esc="menu.name"/></span>
<t t-name="Menu.sections">
Line 81: <i t-att-class="second_level_menu.web_icon"></i> <t t-esc="second_level_menu.name"/>
The data to set in menu's icon field is the whole font-awesome CSS classes:
fa fa-check
This is good if you add more icons sets, you won't need to modify again the templates.
But if you want to force the usage of font-awesome, or want to use another icon set like font-awesome solid (using fas class), you can use this markup in templates:
<i t-attf-class="fas fa-#{menu.web_icon}"></i>
(note t-attf-<name> to use "attribute function")
And so the data in the field will be only check...
And finally, the best should be to create a module to inherit the templates and make this modification against modifying it directly as I did...
And also add some more CSS styling to align icon and text correctly (here icons are not the same sized).

Related

How to style Buefy buttons to look like text links

I'm trying to style a Buefy button to look like a simple text-link.
For example, it is possible to use:
<b-button
tag="a"
type="is-text"
href="https://www.example.com"
>
Click here
</b-button>
This produces near the result I'm looking for, except I want to achieve a type such as is-text-red and is-text-blue to make the button appear as text of particular colours.
I could solve this by simply using:
Click here
Click here
But I want to use <b-button type="is-text-red"> to make an inline link.
Can anyone point me in a direction that involves Bulma CSS and/or Buefy CSS modifications that would achieve this?
I'm looking at the node_modules BButton component, and it looks like the type prop is passed through, so it looks possible to create a custom type somewhere that would be analogous to is-info and is-warning.
I would like to have text-only versions such as is-text-info and is-text-warning so I can use the button component to place inline anchor tags.
Stated concisely, how does a person add another type to <b-button> that provides arbitrary styling?
Check this link(https://buefy.org/documentation/customization/). You might need to define your own css overrides.

Using cypress with vuetify

I have a Vue.js project (Nuxt.js) and as UI I use the Vuetify.
For e2e testing I use the Cypress.
Below is my scenarios of test in Cypress:
I have a problem while creating test for page where I use v-autocomplete component.
The problem is that I can't use Vuetify native classes to get the element I want to test.
below is an example with data-cy selector
<v-autocomplete
v-model="model"
:items="items"
item-text="Description"
item-value="API"
label="Public APIs"
placeholder="Start typing to Search"
data-cy="autocomplete"
></v-autocomplete>
I type some text into search input.
Then in v-autocomplete have been found search results.
And example of one of there is below:
...
<div>
<a class="v-list__tile v-list__tile--link theme--light">
<div class="v-list__tile__content">
<div class="v-list__tile__title">Result item
<span class="v-list__tile__mask">result item</span>
</div>
</div>
</a>
</div>
...
Then I want select one of search items by clicking to one of found results.
And for that I should to use native classes of Vuetify, but it is not have stability (.v-list__tile--link class сan be renamed by developers).
How I can add data-cy selector into result search html item?
Maybe who know any another way to resolve this problem?
I don't think v-list__tile--link can be changed by developers, it seems to be added at runtime DOM by the Vuetify library (unless you mean Vuetify developers, then sure it can change between versions).
In any case, if you want to be more content-oriented in your selectors, use Cypress .parent() selector
For example,
cy.contains('div', 'itemTextToSelect').parent('a').click()
If posssible make sure 'itemTextToSelect' is really distinctive (if you can set it in the test fixture).
BTW, before the user starts typing the autocomplete list is display: none, so you will need to either .type('something') into the input, or .click({force: true}) the item.

typo3 bootstrap accordion - collapse the initial element

This is related to Typo3 with the bootstrap theme only please.
I'd like to have ALL elements of the accordion closed at page startup. Currently the top element is open like here
In do understand that it's only related to the in in the class of this statement
<div id="panel-425-0" class="panel-collapse collapse in">
but changing this in the source would have side effects to other locations which I'like to avoid.
So I'm looking for a solution to do the closure with CSS or javascript.
Any guidance welcome.
Here try this
So basically you get element by its Id and re-set its class attribute without the 'in' class.
<script>
document.getElementById('panel-425-0').setAttribute('class','panel-collapse collapse');
</script>
Just for completenes, my own reminder and to whom it might help the full TS to be put into the setup section of a template
# get some javascript into
# for hiding the first accordion element
page.jsFooterInline.20 = TEXT
page.jsFooterInline.20.value = document.getElementById('accordion-....').setAttribute('class','panel-collapse collapse');

how to link backend custom fields of product to product specification tab in bigcommerce

Under the "Product Specification" tab, i want to link this to the "Custom Fields" on the back-end(by "Back-end" I mean the control panel where you login and can modify the product) of the website. If you go to each product on the back-end, each product has a "Custom Field" tab that has the product specifications set up. I want the "Custom Field" contents in the back-end for each product to show under the "Product Specification" tab of the product's page.
Not sure if you're developing on Stencil or Blueprint, so I will explain both.
Stencil
In Stencil, first navigate to the templates/components/products/product-view.html file. Locate the custom fields code, and move it to the Product Details tab. Using handlebars, we will add the class name to the custom-field <li> and render the fields. If you only have one field, you may want to use a <p> tag instead of <li>.
{{#if product.custom_fields}}
<ul>
{{#each product.custom_fields}}
<li class="custom-field {{name}}"><span>{{name}}:</span> {{{value}}}</li>
{{/each}}
</ul>
{{/if}}
Blueprint
The Custom Fields Snippet, is located inside the ProductOtherDetails.html Panel. Inside this Panel, it calls the %%SNIPPET_ProductCustomFields%% which loops each custom field. Code below.
<div class="DetailRow %%GLOBAL_CustomFieldName%%">
<div class="Label">%%GLOBAL_CustomFieldName%%:</div>
<div class="Value">
%%GLOBAL_CustomFieldValue%%
</div>
</div>
I recommend adding the %%GLOBAL_CustomFieldName%% as a class on the DetailRow as a way to target each custom field using JS/CSS if you have more than one.
If you have more than one custom field and you only want to move the one field to the product description, I recommend using Javascript. Something like:
$('.DetailRow.CUSTOMFIELDNAME').detach().appendTo('.ProductDescription');
If you only have one custom field or you'd like all your custom fields in the product description, you can just move the Panel to the ProductDesription Panel which will render those custom fields in the product description.
Hope this helps.

Custom ListView in Worklight using Dojo

I am working on a Worklight project, and I am trying to use custom listview. I use the Dojo toolkit to implement it, but it's not coming up to my expectations. Regarding design I am confuse. Here is my code:
<div id="bookmarks" data-dojo-type="dojox.mobile.ScrollableView">
<h1 data-dojo-type="dojox/mobile/Heading">Some Heading</h1>
<ul data-dojo-type="dojox.mobile.RoundRectList">
<li data-dojo-type="dojox.mobile.ListItem" data-dojo-props="label:'Item'"><button
data-dojo-type="dojox.mobile.ToggleButton">Label</button></li>
</ul>
</div>
I want this type of listView which include image tag, icon tag and a checkbox in each list item
Check out the Dojo documentation on ListItems for examples of adding built in options like icons.
dojotoolkit.org/reference-guide/1.8/dojox/mobile/ListItem.html#dojox-mobile-listitem
For more complex layout, such as the larger title, small sub-title, and timestamp, you can use span tags and css.