Bootstrap Extra Components 1.1.0 released

patrick:
addMenuItem expects one item and you are giving it an array… So change that to

var item =    {
    itemId: "1",
    displayType: "MENU_ITEM",
    iconName: "fa fa-pencil-square-o",
    onAction: onAction_edit,
    position: "RIGHT",
    text: "Help"

};
elements.navbar.addMenuItem(item)




and try again.

EDITED: onAction wants a Function (reference), not the name of a function... So remove the quotes.

I have copied this and added onAction as a function it is still not creating a menu item ? the code is:

var item =    {
        itemId: "1",
        displayType: "MENU_ITEM",
        iconName: "fa fa-pencil-square-o",
        onAction: onAction,
        position: "RIGHT",
        text: "Help"
   };
elements.navbar.addMenuItem(item)

In addition I am getting a warning about the addMenuItem:

The function addMenuItem(bootstrapextracomponents-navbar.menuItem) is not applicable for the arguments
({itemId:String,displayType:String,iconName:String,onAction:String,position:String,text:String})

Gordon

Hi Gordon,

You Need an annotation in your code. This tell your compiler what item is:

/**@type{bootstrapextracomponents-navbar.menuItem}*/
var item =    {
        itemId: "1",
        displayType: "MENU_ITEM",
        iconName: "fa fa-pencil-square-o",
        onAction: onAction_edit,
        position: "RIGHT",
        text: "Help"
   };
elements.navbar.addMenuItem(item)

I prefer this spelling

[code]
/**@type{bootstrapextracomponents-navbar.menuItem}*/
var item =    new Object() ;
item.itemId =  "1" ;
item.displayType = "MENU_ITEM" ;
item.iconName = "fa fa-pencil-square-o" ;
item.onAction = onAction_edit ;
item.position = "RIGHT" ;
item.text = "Help" ;

elements.navbar.addMenuItem(item)

[/code]

it would be good to add this example or a similar one to the wiki if thats possible as the instructions made little sense to me, I don’t know about others

Hm. Not sure I understand why that isn’t clear. The docs state

Method
addMenuItem	

Parameter (name/type)
menuItem:menuItem		

Description
Adds the given menu item to the bar.

Meaning the method wants a menuItem (even a link to the type definition is available) and not an array of something. That would look like this:

Method
setMenuItems	

Parameter (name/type)
menuItems:menuItem[]

so in this case, it wants an array containing menuItem items (it wants all items).

Examples in the Wiki would be nice, I agree. But they take time that I can’t spend on features :wink: And there is a sample solution that among other things has exactly your case as example.

I have copied this and added onAction as a function it is still not creating a menu item ? the code is:

I have done just that right now. Copied the code (except that I chose an ID not already used and used a different method) and put it in the sample solution on the “Add item” button:

function onAction_addItem(event) {
	/** @type {bootstrapextracomponents-navbar.menuItem} */
	var itemToAdd =    {
        itemId: "1000",
        displayType: "MENU_ITEM",
        iconName: "fa fa-pencil-square-o",
        onAction: onAction_addItem,
        position: "RIGHT",
        text: "Help"
   };
	elements.navbar.addMenuItem(itemToAdd);
}

and I get

[attachment=1]snip_20170322231359.png[/attachment]

When I click that now, I get

[attachment=0]snip_20170322231547.png[/attachment]

So not sure what goes wrong at your place…

snip_20170322231547.png

snip_20170322231359.png

OK. I now added sample code to the wiki for setMenuItems() and addMenuItem()…

HEKUCH:
Hi Gordon,

You Need an annotation in your code. This tell your compiler what item is:

/**@type{bootstrapextracomponents-navbar.menuItem}*/

var item =    {
        itemId: “1”,
        displayType: “MENU_ITEM”,
        iconName: “fa fa-pencil-square-o”,
        onAction: onAction_edit,
        position: “RIGHT”,
        text: “Help”
   };
elements.navbar.addMenuItem(item)




I prefer this spelling 


[code]
/**@type{bootstrapextracomponents-navbar.menuItem}*/
var item =    new Object() ;
item.itemId = “1” ;
item.displayType = “MENU_ITEM” ;
item.iconName = “fa fa-pencil-square-o” ;
item.onAction = onAction_edit ;
item.position = “RIGHT” ;
item.text = “Help” ;

elements.navbar.addMenuItem(item)





[/code]

Talking the need for annotation on board where do you get the correct syntax because I have tried adding this to another component and its throwing a warning “Unknown type servoyextracomponents-sidebar” ie is there a type list anywhere as I have not seen it ?

/** @type {servoyextracomponents-sidebar} */

Hi,
I want to change my solution from setting the navbar brandlogo to a solution media file

elements.navbar.brandLogo = "media:///companylogo.png";

to using an image stored in a table (media datatype)

elements.navbar.brandLogo = plugins.images.getImage(_to_organisation_default.logo) ;

I also tried

elements.navbar.brandLogo = solutionModel.getMedia(_to_organisation_default.logo) ;

but neither are working (and relationship is pointing to correct record & that media does exist)

Please can someone tell me the correct syntax??
Thanks
Rafi

I have to investigate this a bit. It seems that the media type can’t be just set from a byte, maybe because we need a resource on the server (instead of the bytes).

As a workaround you could do

var media = solutionModel.newMedia('mylogo',record.image_media)
elements.navbar.brandLogo = 'media:///mylogo'

Bit strange, but it should work.

patrick:
I have to investigate this a bit. It seems that the media type can’t be just set from a byte, maybe because we need a resource on the server (instead of the bytes).

As a workaround you could do

var media = solutionModel.newMedia('mylogo',record.image_media)

elements.navbar.brandLogo = ‘media:///mylogo’




Bit strange, but it should work.

Hi Patrick,
thanks for looking in to this & I will have to use your ‘strange’ way of doing it for the moment.
Thanks
Rafi

As I thought: the media type does not support byte. I could add a property brandLogoDataprovider, then you could assign a form variable or something like that, but I think that’s a bit over engineered. Your use case of setting a nav bar’s brand logo from a record is maybe not the 90% use case…

patrick:
As I thought: the media type does not support byte. I could add a property brandLogoDataprovider, then you could assign a form variable or something like that, but I think that’s a bit over engineered. Your use case of setting a nav bar’s brand logo from a record is maybe not the 90% use case…

Hi.
My ‘use case’ is that I want a client to be able to associate an image of their choosing that I am now getting them to store along with their organisation details & then in solution, if they change the ‘org’ it changes the logo…
(My client has two parts that I have termed organisations and in the solution someone at a higher level may want to change which org they are dealing with & illustrate by changing logo)
I’d be happy with a new property brandLogoDataprovider…

Thanks
Rafi

But since this logo is rather static, it doesn’t feel wrong to create a media from it, does it?

patrick:
But since this logo is rather static, it doesn’t feel wrong to create a media from it, does it?

Most of them it will be static, but if the client decides to change the logo they use for an org, I don’t want to have to be changing media files on the server and I’m also using that table media on reports, so want it to come from the table …

Also, I’m a bit confused :?
In my onLoad I put

	var media = solutionModel.newMedia('mylogo',_to_organisation_default.logo);
	elements.navbar.brandLogo = 'media:///mylogo';

and that sets the correct image.
I have added a menu to the navbar with the list of organisations and an ‘onDataChange’ method to that menu.
Prior to this, this code changed the brandLogo correctly

	switch (_to_organisation_default.name, 1)) {
	case 'Org2':
		elements.navbar.brandLogo = "media:///Org2Logo.png";
		break
	default:
		elements.navbar.brandLogo = "media:///OrgDefaultLogo.png";
	}

but now using this code, it doesn’t work

	// remove logo if it exists
	var removed = solutionModel.removeMedia('mylogo');
	// set logo to org logo
	var media = solutionModel.newMedia('mylogo',_to_organisation_default.logo);
	elements.navbar.brandLogo = 'media:///mylogo';

(followed by an application.updateUI…)
and the relationship which is based on a global is having it’s global value changed (& if I console output the media column, it changes), as the org name which is setting brandName is changing also based on that relationship??
Not sure what I’m doing wrong or why it isn’t working…

It could be that Servoy does not see the setting of brandLogo = ‘media:///logo’ as a change and therefore doesn’t send anything to the client.

Try something like this instead:

// set logo to org logo
var media = solutionModel.newMedia('logo_' + _to_organisation_default.organisation_id, _to_organisation_default.logo);
elements.navbar.brandLogo = 'media:///logo_' + _to_organisation_default.organisation_id;

This should give each org logo a unique name… (given that the ID of organisation is called “organisation_id”).

Also, with this approach, there is no need to remove any media previously created…

patrick:
It could be that Servoy does not see the setting of brandLogo = ‘media:///logo’ as a change and therefore doesn’t send anything to the client.

I think that must be the case…

patrick:
Try something like this instead:
This should give each org logo a unique name… (given that the ID of organisation is called “organisation_id”).
Also, with this approach, there is no need to remove any media previously created…

as it now works great, thanks for the suggestion.

Hi,
I was just playing with the online demo (demo.servoy.com) & downloaded the bootstrapextracomponents sample from there, imported it & let it auto import the correct web packages, but the current release of Bootstrap Extra Components seems to be missing the ‘badges’ component??
Is there a reason or is it just a mistake?
Thanks
Rafi

[^^BUMP^^]

That is a know little problem and is fixed for the next release. You could also use the git source to fix this.

patrick:
That is a know little problem and is fixed for the next release. You could also use the git source to fix this.

Thanks Patrick…
I can probably wait for next release ;-)