Switching 'passing' to 'ytd' as requested, though this is weird.
[capital-apms-progress.git] / sec / b-menuitem.w
blobc2358d8741a3d3ffd5ef66492980aa123c6bcbe0
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12 GUI
2 &ANALYZE-RESUME
3 /* Connected Databases
4 ttpl PROGRESS
5 */
6 &Scoped-define WINDOW-NAME CURRENT-WINDOW
7 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS B-table-Win
8 /*------------------------------------------------------------------------
9 File:
10 Description:
11 ------------------------------------------------------------------------*/
13 CREATE WIDGET-POOL.
15 /***************************** Definitions ****************************/
17 DEF VAR main-menu-node AS INT NO-UNDO.
18 DEF VAR key-value AS CHAR NO-UNDO.
20 FIND FIRST LinkNode WHERE LinkNode.NodeType = "MN"
21 AND LinkNode.Description = "Main Menu" NO-LOCK NO-ERROR.
22 main-menu-node = LinkNode.NodeCode.
23 key-value = STRING(LinkNode.NodeCode).
25 /* _UIB-CODE-BLOCK-END */
26 &ANALYZE-RESUME
29 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
31 /* ******************** Preprocessor Definitions ******************** */
33 &Scoped-define PROCEDURE-TYPE SmartBrowser
35 &Scoped-define ADM-SUPPORTED-LINKS Record-Source,Record-Target,TableIO-Target
37 /* Name of first Frame and/or Browse and/or first Query */
38 &Scoped-define FRAME-NAME F-Main
39 &Scoped-define BROWSE-NAME br_table
41 /* Internal Tables (found by Frame, Query & Browse Queries) */
42 &Scoped-define INTERNAL-TABLES LinkNode UsrGroupMenu UsrGroupMenuItem ~
43 ProgramLink
45 /* Define KEY-PHRASE in case it is used by any query. */
46 &Scoped-define KEY-PHRASE TRUE
48 /* Definitions for BROWSE br_table */
49 &Scoped-define FIELDS-IN-QUERY-br_table UsrGroupMenuItem.SequenceCode ~
50 UsrGroupMenuItem.ButtonLabel UsrGroupMenuItem.GroupName
51 &Scoped-define ENABLED-FIELDS-IN-QUERY-br_table ~
52 UsrGroupMenuItem.SequenceCode
53 &Scoped-define FIELD-PAIRS-IN-QUERY-br_table~
54 ~{&FP1}SequenceCode ~{&FP2}SequenceCode ~{&FP3}
55 &Scoped-define ENABLED-TABLES-IN-QUERY-br_table UsrGroupMenuItem
56 &Scoped-define FIRST-ENABLED-TABLE-IN-QUERY-br_table UsrGroupMenuItem
57 &Scoped-define OPEN-QUERY-br_table OPEN QUERY br_table FOR EACH LinkNode WHERE ~{&KEY-PHRASE} NO-LOCK, ~
58 EACH UsrGroupMenu WHERE UsrGroupMenu.NodeCode = LinkNode.NodeCode NO-LOCK, ~
59 EACH UsrGroupMenuItem WHERE UsrGroupMenuItem.GroupName = UsrGroupMenu.GroupName ~
60 AND UsrGroupMenuItem.MenuName = UsrGroupMenu.MenuName NO-LOCK, ~
61 EACH ProgramLink WHERE ProgramLink.LinkCode = UsrGroupMenuItem.LinkCode ~
62 AND ProgramLink.Source = (IF LinkNode.NodeType = "MN" THEN main-menu-node ELSE LinkNode.NodeCode) NO-LOCK ~
63 ~{&SORTBY-PHRASE}.
64 &Scoped-define TABLES-IN-QUERY-br_table LinkNode UsrGroupMenu ~
65 UsrGroupMenuItem ProgramLink
66 &Scoped-define FIRST-TABLE-IN-QUERY-br_table LinkNode
69 /* Definitions for FRAME F-Main */
71 /* Standard List Definitions */
72 &Scoped-Define ENABLED-OBJECTS br_table
74 /* Custom List Definitions */
75 /* List-1,List-2,List-3,List-4,List-5,List-6 */
77 /* _UIB-PREPROCESSOR-BLOCK-END */
78 &ANALYZE-RESUME
81 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Foreign Keys" B-table-Win _INLINE
82 /* Actions: ? adm/support/keyedit.w ? ? ? */
83 /* STRUCTURED-DATA
84 <KEY-OBJECT>
85 &BROWSE-NAME
86 </KEY-OBJECT>
87 <FOREIGN-KEYS>
88 LinkCode||y|TTPL.ProgramLink.Target
89 LinkCode|y||TTPL.LinkNode.NodeCode
90 </FOREIGN-KEYS>
91 <EXECUTING-CODE>
92 **************************
93 * Set attributes related to FOREIGN KEYS
95 RUN set-attribute-list (
96 'Keys-Accepted = "LinkCode",
97 Keys-Supplied = "LinkCode"':U).
99 /* Tell the ADM to use the OPEN-QUERY-CASES. */
100 &Scoped-define OPEN-QUERY-CASES RUN dispatch ('open-query-cases':U).
101 /**************************
102 </EXECUTING-CODE> */
103 /* _UIB-CODE-BLOCK-END */
104 &ANALYZE-RESUME
106 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Advanced Query Options" B-table-Win _INLINE
107 /* Actions: ? adm/support/advqedit.w ? ? ? */
108 /* STRUCTURED-DATA
109 <KEY-OBJECT>
110 &BROWSE-NAME
111 </KEY-OBJECT>
112 <SORTBY-OPTIONS>
113 SequenceCode|y||TTPL.UsrGroupMenuItem.SequenceCode|yes
114 </SORTBY-OPTIONS>
115 <SORTBY-RUN-CODE>
116 ************************
117 * Set attributes related to SORTBY-OPTIONS */
118 RUN set-attribute-list (
119 'SortBy-Options = "SequenceCode",
120 SortBy-Case = SequenceCode':U).
122 /* Tell the ADM to use the OPEN-QUERY-CASES. */
123 &Scoped-define OPEN-QUERY-CASES RUN dispatch ('open-query-cases':U).
125 /************************
126 </SORTBY-RUN-CODE>
127 <FILTER-ATTRIBUTES>
128 </FILTER-ATTRIBUTES> */
130 /* _UIB-CODE-BLOCK-END */
131 &ANALYZE-RESUME
134 /* *********************** Control Definitions ********************** */
137 /* Definitions of the field level widgets */
138 /* Query definitions */
139 &ANALYZE-SUSPEND
140 DEFINE QUERY br_table FOR
141 LinkNode,
142 UsrGroupMenu,
143 UsrGroupMenuItem,
144 ProgramLink SCROLLING.
145 &ANALYZE-RESUME
147 /* Browse definitions */
148 DEFINE BROWSE br_table
149 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _DISPLAY-FIELDS br_table B-table-Win _STRUCTURED
150 QUERY br_table NO-LOCK DISPLAY
151 UsrGroupMenuItem.SequenceCode COLUMN-LABEL "Seq" FORMAT ">>9"
152 UsrGroupMenuItem.ButtonLabel
153 UsrGroupMenuItem.GroupName
154 ENABLE
155 UsrGroupMenuItem.SequenceCode
156 /* _UIB-CODE-BLOCK-END */
157 &ANALYZE-RESUME
158 WITH NO-ASSIGN SEPARATORS SIZE 39.43 BY 20.8
159 FONT 10.
162 /* ************************ Frame Definitions *********************** */
164 DEFINE FRAME F-Main
165 br_table AT ROW 1 COL 1
166 WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
167 SIDE-LABELS NO-UNDERLINE THREE-D
168 AT COL 1 ROW 1 SCROLLABLE
169 BGCOLOR 16 FGCOLOR 0 FONT 10.
172 /* *********************** Procedure Settings ************************ */
174 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
175 /* Settings for THIS-PROCEDURE
176 Type: SmartBrowser
177 Allow: Basic,Browse
178 Frames: 1
179 Add Fields to: EXTERNAL-TABLES
180 Other Settings: PERSISTENT-ONLY COMPILE
183 /* This procedure should always be RUN PERSISTENT. Report the error, */
184 /* then cleanup and return. */
185 IF NOT THIS-PROCEDURE:PERSISTENT THEN DO:
186 MESSAGE "{&FILE-NAME} should only be RUN PERSISTENT."
187 VIEW-AS ALERT-BOX ERROR BUTTONS OK.
188 RETURN.
189 END.
191 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
193 /* ************************* Create Window ************************** */
195 &ANALYZE-SUSPEND _CREATE-WINDOW
196 /* DESIGN Window definition (used by the UIB)
197 CREATE WINDOW B-table-Win ASSIGN
198 HEIGHT = 22.85
199 WIDTH = 48.14.
200 /* END WINDOW DEFINITION */
202 &ANALYZE-RESUME
205 /* *************** Runtime Attributes and UIB Settings ************** */
207 &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
208 /* SETTINGS FOR WINDOW B-table-Win
209 NOT-VISIBLE,,RUN-PERSISTENT */
210 /* SETTINGS FOR FRAME F-Main
211 NOT-VISIBLE Size-to-Fit */
212 /* BROWSE-TAB br_table 1 F-Main */
213 ASSIGN
214 FRAME F-Main:SCROLLABLE = FALSE
215 FRAME F-Main:HIDDEN = TRUE.
217 /* _RUN-TIME-ATTRIBUTES-END */
218 &ANALYZE-RESUME
221 /* Setting information for Queries and Browse Widgets fields */
223 &ANALYZE-SUSPEND _QUERY-BLOCK BROWSE br_table
224 /* Query rebuild information for BROWSE br_table
225 _TblList = "TTPL.LinkNode,TTPL.UsrGroupMenu WHERE TTPL.LinkNode ...,TTPL.UsrGroupMenuItem WHERE TTPL.UsrGroupMenu ...,TTPL.ProgramLink WHERE TTPL.UsrGroupMenuItem ..."
226 _Options = "NO-LOCK KEY-PHRASE SORTBY-PHRASE"
227 _TblOptList = ",,,"
228 _JoinCode[2] = "UsrGroupMenu.NodeCode = LinkNode.NodeCode"
229 _JoinCode[3] = "UsrGroupMenuItem.GroupName = UsrGroupMenu.GroupName
230 AND UsrGroupMenuItem.MenuName = UsrGroupMenu.MenuName"
231 _JoinCode[4] = "ProgramLink.LinkCode = UsrGroupMenuItem.LinkCode
232 AND ProgramLink.Source = (IF LinkNode.NodeType = ""MN"" THEN main-menu-node ELSE LinkNode.NodeCode)"
233 _FldNameList[1] > TTPL.UsrGroupMenuItem.SequenceCode
234 "UsrGroupMenuItem.SequenceCode" "Seq" ">>9" "integer" ? ? ? ? ? ? yes ?
235 _FldNameList[2] = TTPL.UsrGroupMenuItem.ButtonLabel
236 _FldNameList[3] = TTPL.UsrGroupMenuItem.GroupName
237 _Query is NOT OPENED
238 */ /* BROWSE br_table */
239 &ANALYZE-RESUME
241 &ANALYZE-SUSPEND _QUERY-BLOCK FRAME F-Main
242 /* Query rebuild information for FRAME F-Main
243 _Options = "NO-LOCK"
244 _Query is NOT OPENED
245 */ /* FRAME F-Main */
246 &ANALYZE-RESUME
251 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB B-table-Win
252 /* ************************* Included-Libraries *********************** */
254 {src/adm/method/browser.i}
255 {inc/method/m-drlvwr.i}
257 /* _UIB-CODE-BLOCK-END */
258 &ANALYZE-RESUME
263 /* ************************ Control Triggers ************************ */
265 &Scoped-define BROWSE-NAME br_table
266 &Scoped-define SELF-NAME br_table
267 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL br_table B-table-Win
268 ON ROW-ENTRY OF br_table IN FRAME F-Main
270 /* This code displays initial values for newly added or copied rows. */
271 {src/adm/template/brsentry.i}
272 RUN browse-row-changed.
273 END.
275 /* _UIB-CODE-BLOCK-END */
276 &ANALYZE-RESUME
279 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL br_table B-table-Win
280 ON ROW-LEAVE OF br_table IN FRAME F-Main
282 /* Do not disable this code or no updates will take place except
283 by pressing the Save button on an Update SmartPanel. */
284 {src/adm/template/brsleave.i}
285 END.
287 /* _UIB-CODE-BLOCK-END */
288 &ANALYZE-RESUME
291 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL br_table B-table-Win
292 ON VALUE-CHANGED OF br_table IN FRAME F-Main
294 /* This ADM trigger code must be preserved in order to notify other
295 objects when the browser's current row changes. */
296 {src/adm/template/brschnge.i}
297 END.
299 /* _UIB-CODE-BLOCK-END */
300 &ANALYZE-RESUME
303 &UNDEFINE SELF-NAME
305 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK B-table-Win
308 /* *************************** Main Block *************************** */
310 /* _UIB-CODE-BLOCK-END */
311 &ANALYZE-RESUME
314 /* ********************** Internal Procedures *********************** */
316 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-open-query-cases B-table-Win adm/support/_adm-opn.p
317 PROCEDURE adm-open-query-cases :
318 /*------------------------------------------------------------------------------
319 Purpose: Opens different cases of the query based on attributes
320 such as the 'Key-Name', or 'SortBy-Case'
321 Parameters: <none>
322 ------------------------------------------------------------------------------*/
323 DEF VAR key-value AS CHAR NO-UNDO.
325 /* Look up the current key-value. */
326 RUN get-attribute ('Key-Value':U).
327 key-value = RETURN-VALUE.
329 /* Find the current record using the current Key-Name. */
330 RUN get-attribute ('Key-Name':U).
331 CASE RETURN-VALUE:
332 WHEN 'LinkCode':U THEN DO:
333 &Scope KEY-PHRASE LinkNode.NodeCode eq INTEGER(key-value)
334 RUN get-attribute ('SortBy-Case':U).
335 CASE RETURN-VALUE:
336 WHEN 'SequenceCode':U THEN DO:
337 &Scope SORTBY-PHRASE BY UsrGroupMenuItem.SequenceCode
338 {&OPEN-QUERY-{&BROWSE-NAME}}
339 END.
340 OTHERWISE DO:
341 &Undefine SORTBY-PHRASE
342 {&OPEN-QUERY-{&BROWSE-NAME}}
343 END. /* OTHERWISE...*/
344 END CASE.
345 END. /* LinkCode */
346 OTHERWISE DO:
347 &Scope KEY-PHRASE TRUE
348 RUN get-attribute ('SortBy-Case':U).
349 CASE RETURN-VALUE:
350 WHEN 'SequenceCode':U THEN DO:
351 &Scope SORTBY-PHRASE BY UsrGroupMenuItem.SequenceCode
352 {&OPEN-QUERY-{&BROWSE-NAME}}
353 END.
354 OTHERWISE DO:
355 &Undefine SORTBY-PHRASE
356 {&OPEN-QUERY-{&BROWSE-NAME}}
357 END. /* OTHERWISE...*/
358 END CASE.
359 END. /* OTHERWISE...*/
360 END CASE.
362 END PROCEDURE.
364 /* _UIB-CODE-BLOCK-END */
365 &ANALYZE-RESUME
368 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-row-available B-table-Win _ADM-ROW-AVAILABLE
369 PROCEDURE adm-row-available :
370 /*------------------------------------------------------------------------------
371 Purpose: Dispatched to this procedure when the Record-
372 Source has a new row available. This procedure
373 tries to get the new row (or foriegn keys) from
374 the Record-Source and process it.
375 Parameters: <none>
376 ------------------------------------------------------------------------------*/
378 /* Define variables needed by this internal procedure. */
379 {src/adm/template/row-head.i}
381 /* Process the newly available records (i.e. display fields,
382 open queries, and/or pass records on to any RECORD-TARGETS). */
383 {src/adm/template/row-end.i}
385 END PROCEDURE.
387 /* _UIB-CODE-BLOCK-END */
388 &ANALYZE-RESUME
391 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE browse-row-changed B-table-Win
392 PROCEDURE browse-row-changed :
393 /*------------------------------------------------------------------------------
394 Purpose:
395 ------------------------------------------------------------------------------*/
397 RUN set-link-attributes IN sys-mgr(
398 THIS-PROCEDURE, "Menu Items",
399 "SENSITIVE = " + IF AVAILABLE ProgramLink AND ProgramLink.LinkType <> "MSG" THEN
400 "Yes" ELSE "No" ).
402 END PROCEDURE.
404 /* _UIB-CODE-BLOCK-END */
405 &ANALYZE-RESUME
408 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE current-row-changed B-table-Win
409 PROCEDURE current-row-changed :
410 /*------------------------------------------------------------------------------
411 Purpose:
412 ------------------------------------------------------------------------------*/
414 END PROCEDURE.
416 /* _UIB-CODE-BLOCK-END */
417 &ANALYZE-RESUME
420 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI B-table-Win _DEFAULT-DISABLE
421 PROCEDURE disable_UI :
422 /*------------------------------------------------------------------------------
423 Purpose: DISABLE the User Interface
424 Parameters: <none>
425 Notes: Here we clean-up the user-interface by deleting
426 dynamic widgets we have created and/or hide
427 frames. This procedure is usually called when
428 we are ready to "clean-up" after running.
429 ------------------------------------------------------------------------------*/
430 /* Hide all frames. */
431 HIDE FRAME F-Main.
432 IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
433 END PROCEDURE.
435 /* _UIB-CODE-BLOCK-END */
436 &ANALYZE-RESUME
439 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE local-open-query-cases B-table-Win
440 PROCEDURE local-open-query-cases :
441 /*------------------------------------------------------------------------------
442 Purpose: Override standard ADM method
443 Notes:
444 ------------------------------------------------------------------------------*/
446 /* Code placed here will execute PRIOR to standard behavior. */
448 /* Dispatch standard ADM method. */
449 RUN dispatch IN THIS-PROCEDURE ( INPUT 'open-query-cases':U ) .
451 /* Code placed here will execute AFTER standard behavior. */
452 IF AVAILABLE(UsrGroupMenu) THEN
453 {&WINDOW-NAME}:TITLE = "Menu Options - " + UsrGroupMenu.MenuName.
455 END PROCEDURE.
457 /* _UIB-CODE-BLOCK-END */
458 &ANALYZE-RESUME
461 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-key B-table-Win adm/support/_key-snd.p
462 PROCEDURE send-key :
463 /*------------------------------------------------------------------------------
464 Purpose: Sends a requested KEY value back to the calling
465 SmartObject.
466 Parameters: <see adm/template/sndkytop.i>
467 ------------------------------------------------------------------------------*/
469 /* Define variables needed by this internal procedure. */
470 {src/adm/template/sndkytop.i}
472 /* Return the key value associated with each key case. */
473 {src/adm/template/sndkycas.i "LinkCode" "ProgramLink" "Target"}
475 /* Close the CASE statement and end the procedure. */
476 {src/adm/template/sndkyend.i}
478 END PROCEDURE.
480 /* _UIB-CODE-BLOCK-END */
481 &ANALYZE-RESUME
484 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-records B-table-Win _ADM-SEND-RECORDS
485 PROCEDURE send-records :
486 /*------------------------------------------------------------------------------
487 Purpose: Send record ROWID's for all tables used by
488 this file.
489 Parameters: see template/snd-head.i
490 ------------------------------------------------------------------------------*/
492 /* Define variables needed by this internal procedure. */
493 {src/adm/template/snd-head.i}
495 /* For each requested table, put it's ROWID in the output list. */
496 {src/adm/template/snd-list.i "LinkNode"}
497 {src/adm/template/snd-list.i "UsrGroupMenu"}
498 {src/adm/template/snd-list.i "UsrGroupMenuItem"}
499 {src/adm/template/snd-list.i "ProgramLink"}
501 /* Deal with any unexpected table requests before closing. */
502 {src/adm/template/snd-end.i}
504 END PROCEDURE.
506 /* _UIB-CODE-BLOCK-END */
507 &ANALYZE-RESUME
510 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE state-changed B-table-Win
511 PROCEDURE state-changed :
512 /* -----------------------------------------------------------
513 Purpose:
514 Parameters: <none>
515 Notes:
516 -------------------------------------------------------------*/
517 DEFINE INPUT PARAMETER p-issuer-hdl AS HANDLE NO-UNDO.
518 DEFINE INPUT PARAMETER p-state AS CHARACTER NO-UNDO.
520 CASE p-state:
521 /* Object instance CASEs can go here to replace standard behavior
522 or add new cases. */
523 {src/adm/template/bstates.i}
524 END CASE.
525 END PROCEDURE.
527 /* _UIB-CODE-BLOCK-END */
528 &ANALYZE-RESUME
531 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE use-Key-Value B-table-Win
532 PROCEDURE use-Key-Value :
533 /*------------------------------------------------------------------------------
534 Purpose:
535 ------------------------------------------------------------------------------*/
536 DEF INPUT PARAMETER new-key-value AS CHAR NO-UNDO.
538 key-value = new-key-value.
540 END PROCEDURE.
542 /* _UIB-CODE-BLOCK-END */
543 &ANALYZE-RESUME