Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate web component to webkit #116

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5a74f99
webcomponents added as submodule
saadnoor Dec 2, 2021
97e94d5
add - successful test implementation of avatar icons.
saadnoor Dec 6, 2021
819fe75
Fix - get library via npm cdn
saadnoor Dec 10, 2021
fc62869
Removed submodule
saadnoor Dec 10, 2021
2b9e0a3
Fix - submodule trace removal
saadnoor Dec 10, 2021
d793389
Add - avatar icon full implementation
saadnoor Dec 10, 2021
828833e
Update - CDN Url for always getting the latest version webcomponent f…
saadnoor Dec 10, 2021
259f142
fix - code review feedback
saadnoor Dec 27, 2021
d260e98
Merge remote-tracking branch 'origin/master' into Integrate-web-compo…
saadnoor Dec 27, 2021
285a135
fix - code cleanup based of review
saadnoor Dec 27, 2021
d095629
Add - native event capture support
saadnoor Jan 10, 2022
41dbc61
Add - showcase for avatar Icons
saadnoor Jan 16, 2022
ee7f5c1
Refactor - Code cleanup on showcase
saadnoor Jan 16, 2022
2da8fe6
Refactor - Improved code of webcomponents (avatar icon)
saadnoor Jan 16, 2022
f7093fa
Fix - Updated icons
saadnoor Jan 16, 2022
d7ca88c
Merge remote-tracking branch 'origin/master' into Integrate-web-compo…
saadnoor Jan 19, 2022
48ca83e
Fix - Added the dialog showcase again
saadnoor Jan 19, 2022
dd08c04
merge conflict resolved
saadnoor Mar 17, 2022
0fe6673
Fix - Updated Id for avatar inital
saadnoor Mar 17, 2022
b536857
Fix - upper case issue with windows OS
saadnoor Mar 17, 2022
564b64e
Fix - syntax error related method end and removed code duplication
saadnoor Mar 19, 2022
a109909
Fix - introduced redraw method for avatar initial based on review
saadnoor Mar 21, 2022
cb68faf
Fix - code cleanup for redraw design in avatar initial
saadnoor Mar 21, 2022
8406c8e
Fix - removed code duplicacy
saadnoor Mar 21, 2022
0ca6ae4
Fix - avatar initial spelling mistake
saadnoor Mar 21, 2022
d1e22f0
Refactor - Updated circular avatar and removed dynamic loader
saadnoor Mar 22, 2022
a56af55
Fix - Updated avatar initial with latest webcomponent changes
saadnoor Mar 27, 2022
82db059
Merge remote-tracking branch 'origin/master' into Integrate-web-compo…
saadnoor Apr 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion demo/Showcase/Showcase.bbj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use ::WebKit/framework/PortalFrame/PortalFrame.bbj::PortalFrame
use ::WebKit/util/ClientUtil.bbj::ClientUtil
use ::WebKit/model/Menu.bbj::Menu
use ::WebKit/model/Menu.bbj::MenuItem
use ::WebKit/widgets/WebComponents/WebComponents.bbj::WebComponents
use ::WebKit/widgets/WebComponents/AvatarIcon/AvatarIcon.bbj::AvatarIcon
use ::WebKit/demo/Showcase/components/ShowCaseFrame.bbj::ShowCaseFrame
use ::WebKit/framework/LoginDialog/SampleAuthProvider.bbj::SampleAuthProvider
use ::WebKit/framework/Favorites/SampleFavoritesProvider.bbj::SampleFavoritesProvider
Expand All @@ -24,7 +26,6 @@ ClientUtil.addLocalCSS("WebKit/css/webkit.css")

bbjutils! = new ::BBUtils.bbj::BBUtils()

REM iconPool$ = STBL("icon-pool", "fa")
iconPool$ = STBL("icon-pool", "tabler")

authProvider! = new SampleAuthProvider()
Expand Down Expand Up @@ -63,6 +64,14 @@ showCaseItem!.setStartType(2)
showCaseItem! = menu!.addMenuItem(showCase!,201,"Direct - Sales - Options","Direct - Sales - Options","table")
showCaseItem!.setStartType(2)

menuItem! = menu!.addMenuItem(menu!.getRoot(),108,"Avatar Inital","Avatar Inital Demo","typography")
menuItem!.setProgram("::WebKit/demo/Showcase/ShowcasePanels/AvatarInital.bbj::AvatarInital")
menuItem!.setStartType(0)

menuItem! = menu!.addMenuItem(menu!.getRoot(),100,"Dialog","Dialog Panel Demo","message-circle")
menuItem!.setProgram("::WebKit/demo/Showcase/ShowcasePanels/DialogShowcase.bbj::DialogShowcase")
menuItem!.setStartType(0)

showCaseSubItem! = menu!.addMenuItem(showCaseItem!,202,"Personal - Sale","Personal - Sale","table")
showCaseSubItem!.setStartType(2)

Expand Down
71 changes: 71 additions & 0 deletions demo/Showcase/ShowcasePanels/AvatarInital.bbj
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
use ::WebKit/demo/Showcase/ShowcaseWidget/ShowcaseWidget.bbj::ShowcaseWidget

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in file name

Copy link

@SebastianAdams SebastianAdams Mar 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code indentation in the whole file is bad

use ::WebKit/widgets/InputField/InputField.bbj::InputField
use ::WebKit/framework/DialogPanel/DialogPanel.bbj::DialogPanel
use ::WebKit/util/ClientUtil.bbj::ClientUtil
use ::WebKit/widgets/WebComponents/WebComponents.bbj::WebComponents
use ::WebKit/widgets/WebComponents/AvatarIcon/AvatarIcon.bbj::AvatarIcon

class public AvatarInital extends ShowcaseWidget

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in class name: It should probably say "AvatarInitial" or "AvatarInitials"


field private BBjChildWindow window!
field private BBjHtmlView avatarWnd!
field private InputField avatarWidth!
field private InputField avatarHeight!
field private InputField AvatarName!
field private BBjCheckBox CbModal!
field private BBjCheckBox CbCloseIcon!
field private BBjCheckBox CbCloseOutside!
field private BBjChildWindow panel!

method public AvatarInital(BBjWindow wnd!)
#super!(wnd!)

#setTitle("Avatar Initail Demo")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: It should probably say "Avatar Initial Demo"

#setIntro("This demo shows the Avatar initail stuff")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo + We should refrain from writing "stuff" as this seems unprofessional

methodend
method public void redraw(Boolean init!)
#super!.redraw(init!)

if init! then

#panel! = #getContentWindow()
#panel!.setStyle("display","flex")
#panel!.setStyle("flex-direction","column")
#panel!.setStyle("row-gap","10px")

#AvatarName! = new InputField(#panel!)
#AvatarName!.setLabel("Avatar Name")
#AvatarName!.setInput("Stephan Wald")

#avatarHeight! = new InputField(#panel!)
#avatarHeight!.setLabel("Height")
#avatarHeight!.setInput("50")

#avatarWidth! = new InputField(#panel!)
#avatarWidth!.setLabel("Width")
#avatarWidth!.setInput("50")

BtnShow! = #panel!.addButton(#panel!.getAvailableControlID(),0,0,0,0,"Create Avatar")
BtnShow!.setStyle("display","flex")
BtnShow!.setStyle("justify-content","flex-end")
BtnShow!.setAttribute("theme","primary")
BtnShow!.setAttribute("expanse","l")
BtnShow!.setCallback(BBjAPI().ON_BUTTON_PUSH,#this!,"onShowDialog")

endif
methodend

method public void onShowDialog(BBjButtonPushEvent ev!)

if #avatarWnd! <> null() then
#avatarWnd!.destroy()
endif

webComponents! = new AvatarIcon()
#avatarWnd! = CAST(BBjHtmlView, webComponents!.drawAvatarIcon(#panel!, #avatarHeight!.getInput(), #avatarWidth!.getInput(), #AvatarName!.getInput() ))

#avatarWnd!.setStyle("margin","auto")

methodend

classend
4 changes: 2 additions & 2 deletions widgets/Drawer/components/DrawerFooter/DrawerFooter.bbj
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ class public DrawerFooter extends BBjWidget
declare CircularAvatar avatar!
declare BBjChildWindow wrapper!
declare BBjStaticText icon!

if init! then
avatar! = new CircularAvatar(#window!, #drawerDataModel!.getAvatarSize(),#drawerDataModel!.getAvatarUrl())
avatar! = new CircularAvatar(#window!, #drawerDataModel!.getAvatarSize(),#drawerDataModel!.getAvatarUrl(), #title!)

wrapper! = #window!.addChildWindow(#window!.getAvailableControlID(),0,0,0,0,"",$00108800$,BBjAPI().getSysGui().getAvailableContext())
wrapper!.addPanelStyle("drawerFooterWrapperWindowClosed")
wrapper!.addPanelStyle("drawerFooterWrapperWindowSmall")
Expand Down
46 changes: 46 additions & 0 deletions widgets/WebComponents/AvatarIcon/AvatarIcon.bbj
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
use ::WebKit/widgets/WebComponents/WebComponents.bbj::WebComponents
use ::WebKit/util/ClientUtil.bbj::ClientUtil

class public AvatarIcon extends WebComponents

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class should follow the BBjWidget pattern and not use some custom methods to use the widget (drawAvatarIcon)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class is missing some setters to update the avatar values - See BBjWidget pattern

field private static BBjTopLevelWindow Wnd!
field public static BBjNumber ON_AVATAR_INITIAL_CLICK = 1234

method public AvatarIcon()

methodend

method public BBjHtmlView drawAvatarIcon(BBjWindow wnd!,BBjInt height%, BBjInt width%, BBjString name$)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, it's not duplicate, one function takes integer and other take string (width and height)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need two methods performing the exact same task and executing basically the same thing. The method with the int parameters converts the ints into strings and executes the exact same code as the method with the string parameters, making it duplicate code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah you're right. Got it. Fixing now. Thanks.

htmlView! = wnd!.addHtmlView(wnd!.getAvailableControlID(),0,0,300,300,"<avatar-initial height="""+str(height%)+""" width="""+str(width%)+""" name="""+name$+"""></avatar-initial>")
htmlView! = #configureAvatarView(htmlView!)
methodret htmlView!
methodend

method public BBjHtmlView drawAvatarIcon(BBjWindow wnd!,BBjString height$, BBjString width$, BBjString name$)
htmlView! = wnd!.addHtmlView(wnd!.getAvailableControlID(),0,0,300,300,"<avatar-initial height="""+height$+""" width="""+width$+""" name="""+name$+"""></avatar-initial>")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate code

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The properties should not be passed using inline css

htmlView! = #configureAvatarView(htmlView!)
methodret htmlView!
methodend

method public BBjHtmlView drawAvatarIcon(BBjString height$, BBjString width$, BBjString name$)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class should be a widget meaning that the BBjHtmlView should not be returned. The class might use the BBjHtmlView internally but for external usage it should always be treated as BBjWidget

sg! = BBjAPI().openSysGui("X0")
#Wnd! =sg!.addWindow(95501,0,0,0,0,"",$01101083$)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id 95501 ?

sg!.setContext(sg!.getAvailableContext())
htmlView! = #Wnd!.addHtmlView(wnd!.getAvailableControlID(),0,0,300,300,"<avatar-initial height="""+height$+""" width="""+width$+""" name="""+name$+"""></avatar-initial>")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate code

htmlView! = #configureAvatarView(htmlView!)
methodret htmlView!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Syntax Error: missing methodend


method private BBjHtmlView configureAvatarView(BBjHtmlView htmlView!)
htmlView!.setCallback(BBjAPI.ON_NATIVE_JAVASCRIPT, #this!,"onClickAvatarInitial")
htmlView!.setStyle("border","none")
htmlView!.executeScript(#script$)
methodret htmlView!
methodend

method public void onClickAvatarInitial(BBjNativeJavaScriptEvent ev!)
ClientUtil.consoleLog("catched the webcomponent event from BBj :)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this log

#fireEvent(#ON_AVATAR_INITIAL_CLICK, ev!)
methodend

methodend
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this methodend


classend
23 changes: 23 additions & 0 deletions widgets/WebComponents/WebComponents.bbj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use ::BBjWidget/BBjWidget.bbj::BBjWidget

class public WebComponents extends BBjWidget

field public BBjString script$

method public WebComponents()

webComponentLibaryURL$ = STBL("web-component-library-url", err=*next)
if webComponentLibaryURL$ = "" THEN
webComponentLibaryURL$ = "https://cdn.jsdelivr.net/npm/webkit-web-components@latest/dist/web-component/web-component.esm.js"
endif

#script$ = "var script = document.createElement(""script"");"

#script$ = #script$ + "script.setAttribute(""src"",""" + webComponentLibaryURL$ + """);"

#script$ = #script$ + "script.setAttribute(""type"",""module"");"

#script$ = #script$ + "document.head.appendChild(script)"
methodend

classend
25 changes: 23 additions & 2 deletions widgets/common/CircularAvatar/CircularAvatar.bbj
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use ::BBjWidget/BBjWidget.bbj::BBjWidget
use ::WebKit/util/DynamicLoader.bbj::DynamicLoader

use ::WebKit/util/ClientUtil.bbj::ClientUtil
use ::WebKit/widgets/WebComponents/WebComponents.bbj::WebComponents
use ::WebKit/widgets/WebComponents/AvatarIcon/AvatarIcon.bbj::AvatarIcon
class public CircularAvatar extends BBjWidget

field private BBjChildWindow window!

field private BBjString imagePath!

method public CircularAvatar(BBjWindow parent!, BBjString radius!, BBjString imagePath!)
Expand All @@ -18,6 +19,26 @@ class public CircularAvatar extends BBjWidget
#setCanvas(#window!)
#redraw(1)
methodend

method public CircularAvatar(BBjWindow parent!, BBjString radius!, BBjString imagePath!, BBjString title!)
DynamicLoader.addLocalCSS("WebKit/widgets/common/CircularAvatar/CircularAvatar.css")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DynamicLoader is deprecated, use the ClientUtil instead


#window! = parent!.addChildWindow(parent!.getAvailableControlID(),0,0,0,0,"",$00108800$,BBjAPI().getSysGui().getAvailableContext())

if imagePath! = "" THEN
webComponents! = new AvatarIcon()
webComponents!.drawAvatarIcon(#window!, radius!, radius!, title! )
else
#window!.addPanelStyle("circularAvatarPanelStyle")
#window!.setPanelStyle("width", radius!)
#window!.setPanelStyle("height", radius!)
#imagePath! = imagePath!
#setCanvas(#window!)
#redraw(1)
fi

methodend



method public void redraw(Boolean init!)
Expand Down