Bootstrap Extra Components 1.1.0 released

Announcements of the latest WebComponents for NGClient (shipped by the WebPackageManager)

Re: Bootstrap Extra Components 1.1.0 released

Postby tgs » Mon Mar 20, 2017 6:57 pm

Hi Patrick,

when I execute the method to set the INPUT menuItem I will assign the formvariable as dataProvider.
For that I made:
dataProvider: 'my_data_provider'

But the formvariable is always null if I enter any value and execute the onAction_find method.

Why is it doing what I want, if I set the property of the INPUT menuItem in the form/component properties and not by method.
Thomas Schnaus
SAN Developer
yomotec GmbH
User avatar
tgs
 
Posts: 833
Joined: Wed Oct 04, 2006 12:05 pm
Location: Germany

Re: Bootstrap Extra Components 1.1.0 released

Postby patrick » Mon Mar 20, 2017 8:41 pm

Just tested that and there is indeed a small bug that kills databinding for inputs when you have left and right aligned items (with only left aligned items I think it should work). Could you please create a ticket on github then I can fix that?
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3610
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: Bootstrap Extra Components 1.1.0 released

Postby Gordon McLean » Wed Mar 22, 2017 3:22 pm

Hi Patrick

I am trying to set menu items individually depending on the user access rights by adding them one at a time with a loop. The problem addMenuItem does not appear to be working as I have it and I am not understanding the Wiki instructions

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


Instructions are saying:

addMenuItem
Adds the given item to the navbar.
Params
Type Name Description Required
menuItem itemToAdd The item to add Required
Returns void

Can you point me in the right direction please

rgds
Gordon
Gordon McLean
Clickdigital.com
Gordon McLean
 
Posts: 191
Joined: Wed Aug 03, 2005 12:24 pm
Location: UK

Re: Bootstrap Extra Components 1.1.0 released

Postby patrick » Wed Mar 22, 2017 3:43 pm

addMenuItem expects one item and you are giving it an array... So change that to

Code: Select all
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.
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3610
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: Bootstrap Extra Components 1.1.0 released

Postby Gordon McLean » Wed Mar 22, 2017 8:23 pm

Thanks Patrick, 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

Gordon
Gordon McLean
Clickdigital.com
Gordon McLean
 
Posts: 191
Joined: Wed Aug 03, 2005 12:24 pm
Location: UK

Re: Bootstrap Extra Components 1.1.0 released

Postby Gordon McLean » Wed Mar 22, 2017 8:34 pm

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

Code: Select all
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:

Code: Select all
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
Gordon McLean
Clickdigital.com
Gordon McLean
 
Posts: 191
Joined: Wed Aug 03, 2005 12:24 pm
Location: UK

Re: Bootstrap Extra Components 1.1.0 released

Postby HEKUCH » Thu Mar 23, 2017 12:01 am

Hi Gordon,

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

Code: Select all
/**@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: Select all
[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]


Hendrick Kurland

DataBit GmbH
CH-9217 Neukirch an der Thur
HEKUCH
 
Posts: 13
Joined: Thu May 05, 2011 8:02 am

Re: Bootstrap Extra Components 1.1.0 released

Postby patrick » Thu Mar 23, 2017 12:11 am

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

Code: Select all
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:

Code: Select all
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.
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3610
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: Bootstrap Extra Components 1.1.0 released

Postby patrick » Thu Mar 23, 2017 12:17 am

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:

Code: Select all
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

snip_20170322231359.png


When I click that now, I get

snip_20170322231547.png


So not sure what goes wrong at your place...
You do not have the required permissions to view the files attached to this post.
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3610
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: Bootstrap Extra Components 1.1.0 released

Postby patrick » Thu Mar 23, 2017 12:33 am

OK. I now added sample code to the wiki for setMenuItems() and addMenuItem()...
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3610
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: Bootstrap Extra Components 1.1.0 released

Postby Gordon McLean » Wed Apr 12, 2017 4:52 pm

HEKUCH wrote:Hi Gordon,

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

Code: Select all
/**@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: Select all
[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} */
Gordon McLean
Clickdigital.com
Gordon McLean
 
Posts: 191
Joined: Wed Aug 03, 2005 12:24 pm
Location: UK

Setting brandlogo

Postby rafig » Thu Jun 22, 2017 6:12 pm

Hi,
I want to change my solution from setting the navbar brandlogo to a solution media file
Code: Select all
elements.navbar.brandLogo = "media:///companylogo.png";

to using an image stored in a table (media datatype)
Code: Select all
elements.navbar.brandLogo = plugins.images.getImage(_to_organisation_default.logo) ;

I also tried
Code: Select all
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
Servoy Certified Developer
Image
rafig
 
Posts: 481
Joined: Mon Dec 22, 2003 12:58 pm
Location: Watford, UK

Re: Bootstrap Extra Components 1.1.0 released

Postby patrick » Thu Jun 22, 2017 6:58 pm

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

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


Bit strange, but it should work.
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3610
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: Bootstrap Extra Components 1.1.0 released

Postby rafig » Thu Jun 22, 2017 7:55 pm

patrick wrote: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

Code: Select all
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
Servoy Certified Developer
Image
rafig
 
Posts: 481
Joined: Mon Dec 22, 2003 12:58 pm
Location: Watford, UK

Re: Bootstrap Extra Components 1.1.0 released

Postby patrick » Fri Jun 23, 2017 8:44 am

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 Ruhsert
Servoy DACH
patrick
 
Posts: 3610
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

PreviousNext

Return to Web Components

Who is online

Users browsing this forum: No registered users and 1 guest

cron