@@ -6,18 +6,20 @@ import "@servicenow/now-collapse";
66import "@servicenow/now-dropdown" ;
77import "@servicenow/now-input" ;
88import "./menu-editor" ;
9+ import iconlist from "../icons" ;
910
1011// File description: This is where to configure all the details about a menu item, such as its name, link, or delete
1112
1213const view = (
1314 {
14- properties : { id, choice, label, type, page, sysId, href, expandParent } ,
15+ properties : { id, choice, label, type, page, sysId, href, expandParent, rightIcon } ,
1516 labelInput,
1617 typeInput,
1718 pageInput,
1819 sysIdInput,
1920 hrefInput,
2021 editMode,
22+ iconInput
2123 } ,
2224 { dispatch }
2325) => {
@@ -31,6 +33,7 @@ const view = (
3133 const pageValue = pageInput || page ;
3234 const sysIdValue = sysIdInput || sysId ;
3335 const hrefValue = hrefInput || href ;
36+ const iconValue = iconInput || rightIcon ;
3437
3538 // This is constructing the JSON output that the chrome_menu UX Page Property expects for this specific menu item
3639
@@ -54,6 +57,11 @@ const view = (
5457 } ,
5558 } ;
5659
60+ // adding rightIcon property to JSON
61+ if ( iconValue ) {
62+ actionJSON . value . rightIcon = iconValue
63+ }
64+
5765 if ( typeValue ) {
5866 actionJSON . value . type = typeValue ;
5967 actionJSON . value . value = typeValue === "route" ? routeJSON : externalJSON ;
@@ -88,6 +96,32 @@ const view = (
8896 name = "labelInput"
8997 readonly = { ! editMode }
9098 > </ now-input >
99+ {
100+ iconValue && < now-button
101+ variant = "primary"
102+ size = "md"
103+ icon = { iconValue }
104+ > </ now-button >
105+ }
106+ < now-dropdown
107+ // mapping iconlist for required data in now-dropdown
108+ // adding no-icon as a no selection
109+ items = { [ { id : null , label : "no-icon" } , ...iconlist . map ( e => ( { id : e , label : e } ) ) ] }
110+ selectedItems = { [ iconValue ] }
111+ name = "iconInput"
112+ select = "single"
113+ placeholder = ""
114+ icon = ""
115+ variant = "secondary"
116+ size = "md"
117+ bare = { true }
118+ tooltip-content = "Select right icon"
119+ panel-fit-props = { { } }
120+ show-padding = { true }
121+ config-aria = { { } }
122+ disabled = { ! editMode }
123+ search = "true"
124+ > </ now-dropdown >
91125 < now-dropdown
92126 items = { [
93127 { id : "external" , label : "External Link" } ,
@@ -203,6 +237,9 @@ createCustomElement("menu-item", {
203237 } ,
204238 expandParent : {
205239 default : undefined
240+ } ,
241+ rightIcon : {
242+ default : null
206243 }
207244 } ,
208245 // Keeps track of any changes made during editing
@@ -212,6 +249,7 @@ createCustomElement("menu-item", {
212249 pageInput : undefined ,
213250 sysIdInput : undefined ,
214251 hrefInput : undefined ,
252+ iconInput : undefined ,
215253 editMode : false ,
216254 } ,
217255 actionHandlers : {
@@ -229,6 +267,7 @@ createCustomElement("menu-item", {
229267 updateState ( { typeInput : payload . item . id } ) ;
230268 break ;
231269 default :
270+ updateState ( { iconInput : payload . item . id } ) ; // action on icon selection
232271 }
233272 } ,
234273 // Text input field has changed (someone typed in the field or cleared value for example)
0 commit comments