1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12 GUI
6 &Scoped-define WINDOW-NAME CURRENT-WINDOW
7 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS V-table-Win
8 /*------------------------------------------------------------------------
12 Description
: from VIEWER.W
- Template for SmartViewer Objects
20 ------------------------------------------------------------------------*/
24 /* *************************** Definitions
************************** */
26 DEF VAR mode
AS CHAR NO-UNDO.
28 /* _UIB-CODE-BLOCK-END
*/
32 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
34 /* ******************** Preprocessor Definitions
******************** */
36 &Scoped-define PROCEDURE-TYPE SmartViewer
38 &Scoped-define ADM-SUPPORTED-LINKS Record-Source,Record-Target,TableIO-Target
40 /* Name of first Frame and
/or Browse and
/or first Query
*/
41 &Scoped-define FRAME-NAME F-Main
44 &Scoped-define EXTERNAL-TABLES FlowTaskType
45 &Scoped-define FIRST-EXTERNAL-TABLE FlowTaskType
48 /* Need to scope the external tables to this procedure
*/
49 DEFINE QUERY external_tables
FOR FlowTaskType.
50 /* Standard List Definitions
*/
51 &Scoped-Define ENABLED-FIELDS FlowTaskType.FlowTaskType ~
52 FlowTaskType.Description FlowTaskType.InitialStep
53 &Scoped-define FIELD-PAIRS~
54 ~
{&FP1}FlowTaskType ~{&FP2}FlowTaskType ~{&FP3}~
55 ~
{&FP1}Description ~{&FP2}Description ~{&FP3}~
56 ~
{&FP1}InitialStep ~{&FP2}InitialStep ~{&FP3}
57 &Scoped-define ENABLED-TABLES FlowTaskType
58 &Scoped-define FIRST-ENABLED-TABLE FlowTaskType
59 &Scoped-Define ENABLED-OBJECTS RECT-29
60 &Scoped-Define DISPLAYED-FIELDS FlowTaskType.FlowTaskType ~
61 FlowTaskType.Description FlowTaskType.InitialStep
63 /* Custom List Definitions
*/
64 /* ADM-CREATE-FIELDS
,ADM-ASSIGN-FIELDS
,List-3
,List-4
,List-5
,List-6
*/
66 /* _UIB-PREPROCESSOR-BLOCK-END
*/
70 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Foreign Keys" V-table-Win _INLINE
71 /* Actions
: ? adm
/support
/keyedit.w ? ? ?
*/
77 FlowTaskType|y|y|TTPL.FlowTaskType.FlowTaskType
80 **************************
81 * Set attributes related to FOREIGN
KEYS
83 RUN set-attribute-list
(
84 'Keys-Accepted
= "FlowTaskType",
85 Keys-Supplied
= "FlowTaskType"'
:U
).
86 /**************************
88 /* _UIB-CODE-BLOCK-END
*/
92 /* *********************** Control Definitions
********************** */
95 /* Definitions of the field level widgets
*/
96 DEFINE RECTANGLE RECT-29
97 EDGE-PIXELS 2 GRAPHIC-EDGE NO-FILL
101 /* ************************ Frame Definitions
*********************** */
104 FlowTaskType.FlowTaskType
AT ROW 1.2 COL 4.72 COLON-ALIGNED
108 FlowTaskType.Description
AT ROW 3 COL 9.86 COLON-ALIGNED
111 FlowTaskType.InitialStep
AT ROW 4.2 COL 9.86 COLON-ALIGNED
114 RECT-29
AT ROW 1 COL 1
115 WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
116 SIDE-LABELS NO-UNDERLINE THREE-D
117 AT COL 1 ROW 1 SCROLLABLE
121 /* *********************** Procedure Settings
************************ */
123 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
124 /* Settings for
THIS-PROCEDURE
126 External Tables
: TTPL.FlowTaskType
127 Allow
: Basic
,DB-Fields
129 Add Fields to
: EXTERNAL-TABLES
130 Other Settings
: PERSISTENT-ONLY
COMPILE
133 /* This procedure should always be
RUN PERSISTENT. Report the error
, */
134 /* then cleanup and return.
*/
135 IF NOT THIS-PROCEDURE:PERSISTENT THEN DO:
136 MESSAGE "{&FILE-NAME} should only be RUN PERSISTENT."
137 VIEW-AS ALERT-BOX ERROR BUTTONS OK.
141 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
143 /* ************************* Create Window
************************** */
145 &ANALYZE-SUSPEND _CREATE-WINDOW
146 /* DESIGN Window definition
(used by the UIB
)
147 CREATE WINDOW V-table-Win
ASSIGN
150 /* END WINDOW DEFINITION
*/
155 /* *************** Runtime Attributes and UIB Settings
************** */
157 &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
158 /* SETTINGS
FOR WINDOW V-table-Win
159 VISIBLE,,RUN-PERSISTENT
*/
160 /* SETTINGS
FOR FRAME F-Main
161 NOT-VISIBLE Size-to-Fit
*/
163 FRAME F-Main
:SCROLLABLE = FALSE
164 FRAME F-Main
:HIDDEN = TRUE.
166 /* SETTINGS
FOR FILL-IN FlowTaskType.FlowTaskType
IN FRAME F-Main
168 /* _RUN-TIME-ATTRIBUTES-END
*/
172 /* Setting information for Queries and Browse Widgets fields
*/
174 &ANALYZE-SUSPEND _QUERY-BLOCK FRAME F-Main
175 /* Query rebuild information for
FRAME F-Main
178 */ /* FRAME F-Main
*/
184 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB V-table-Win
185 /* ************************* Included-Libraries
*********************** */
187 {src
/adm
/method
/viewer.i
}
188 {inc
/method
/m-mntvwr.i
}
190 /* _UIB-CODE-BLOCK-END
*/
195 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK V-table-Win
198 /* *************************** Main Block
*************************** */
200 /* _UIB-CODE-BLOCK-END
*/
204 /* ********************** Internal Procedures
*********************** */
206 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-find-using-key V-table-Win adm/support/_key-fnd.p
207 PROCEDURE adm-find-using-key
:
208 /*------------------------------------------------------------------------------
209 Purpose
: Finds the current record using the contents of
210 the 'Key-Name' and 'Key-Value' attributes.
212 ------------------------------------------------------------------------------*/
213 DEF VAR key-value
AS CHAR NO-UNDO.
214 DEF VAR row-avail-enabled
AS LOGICAL NO-UNDO.
216 /* LOCK status on the find depends on FIELDS-ENABLED.
*/
217 RUN get-attribute
('FIELDS-ENABLED'
:U
).
218 row-avail-enabled
= (RETURN-VALUE eq 'yes'
:U
).
219 /* Look up the current key-value.
*/
220 RUN get-attribute
('Key-Value'
:U
).
221 key-value
= RETURN-VALUE.
223 /* Find the current record using the current Key-Name.
*/
224 RUN get-attribute
('Key-Name'
:U
).
226 WHEN 'FlowTaskType'
:U
THEN
227 {src
/adm
/template
/find-tbl.i
228 &TABLE = FlowTaskType
229 &WHERE = "WHERE FlowTaskType.FlowTaskType eq key-value"
235 /* _UIB-CODE-BLOCK-END
*/
239 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-row-available V-table-Win _ADM-ROW-AVAILABLE
240 PROCEDURE adm-row-available
:
241 /*------------------------------------------------------------------------------
242 Purpose
: Dispatched to this procedure when the Record-
243 Source has a new row available. This procedure
244 tries to get the new row
(or foriegn keys
) from
245 the Record-Source and process it.
247 ------------------------------------------------------------------------------*/
249 /* Define variables needed by this internal procedure.
*/
250 {src
/adm
/template
/row-head.i
}
252 /* Create a list of all the tables that we need to get.
*/
253 {src
/adm
/template
/row-list.i
"FlowTaskType"}
255 /* Get the record
ROWID's from the RECORD-SOURCE.
*/
256 {src
/adm
/template
/row-get.i
}
258 /* FIND each record specified by the RECORD-SOURCE.
*/
259 {src
/adm
/template
/row-find.i
"FlowTaskType"}
261 /* Process the newly available records
(i.e. display fields
,
262 open queries
, and
/or pass records on to any RECORD-TARGETS
).
*/
263 {src
/adm
/template
/row-end.i
}
267 /* _UIB-CODE-BLOCK-END
*/
271 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE cancel-changes V-table-Win
272 PROCEDURE cancel-changes
:
273 /*------------------------------------------------------------------------------
274 Purpose
: Quit without applying any changes
275 ------------------------------------------------------------------------------*/
276 IF mode
= "Add" THEN DO TRANSACTION:
277 FIND CURRENT FlowTaskType
NO-ERROR.
278 IF AVAILABLE(FlowTaskType
) THEN DO:
279 FOR EACH FlowStepType
OF FlowTaskType
:
280 FOR EACH FlowRule
OF FlowStepType
:
289 RUN check-modified
( 'clear'
:U
).
291 RUN dispatch
( 'exit'
:U
).
295 /* _UIB-CODE-BLOCK-END
*/
299 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE confirm-changes V-table-Win
300 PROCEDURE confirm-changes
:
301 /*------------------------------------------------------------------------------
303 ------------------------------------------------------------------------------*/
304 RUN verify-flow-task.
305 IF RETURN-VALUE <> "" THEN RETURN.
307 RUN dispatch
( 'update-record'
:U
).
309 FIND CURRENT FlowTaskType
EXCLUSIVE-LOCK.
310 RUN create-default-step
( FlowTaskType.FlowTaskType
,
311 INPUT-OUTPUT FlowTaskType.InitialStep
).
312 FIND CURRENT FlowTaskType
NO-LOCK.
314 IF mode
= "add" THEN RUN notify
( 'open-query
,record-source'
:U
).
315 RUN dispatch
( 'exit'
:U
).
319 /* _UIB-CODE-BLOCK-END
*/
323 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE create-default-step V-table-Win
324 PROCEDURE create-default-step
:
325 /*------------------------------------------------------------------------------
327 ------------------------------------------------------------------------------*/
328 DEF INPUT PARAMETER task-type
AS CHAR NO-UNDO.
329 DEF INPUT-OUTPUT PARAMETER step-type
AS CHAR NO-UNDO.
331 FIND FIRST FlowStepType
WHERE FlowStepType.FlowTaskType
= task-type
NO-LOCK NO-ERROR.
332 IF AVAILABLE(FlowStepType
) THEN DO:
333 step-type
= FlowStepType.FlowStepType.
337 FIND FlowStepType
WHERE FlowStepType.FlowTaskType
= task-type
338 AND FlowStepType.FlowStepType
= step-type
NO-LOCK NO-ERROR.
339 IF NOT AVAILABLE(FlowStepType
) THEN DO:
341 ASSIGN FlowStepType.FlowTaskType
= task-type
342 FlowStepType.FlowStepType
= step-type
343 FlowStepType.Description
= "Perform Task"
344 FlowStepType.InitialStatus
= "TODO".
347 FIND FIRST FlowRule
OF FlowStepType
NO-LOCK NO-ERROR.
348 IF AVAILABLE(FlowRule
) THEN RETURN.
351 ASSIGN FlowRule.FlowTaskType
= task-type
352 FlowRule.FlowStepType
= step-type
353 FlowRule.FlowRuleCode
= "FINISH"
354 FlowRule.Description
= "Mark task as completed"
355 FlowRule.Priority
= 9
356 FlowRule.FlowRuleType
= "MANUAL"
357 FlowRule.ConditionProgram
= "workflow/rules/always.p"
358 FlowRule.ConditionProgramParam
= "test"
359 FlowRule.ActionProgram
= "workflow/rules/always.p"
360 FlowRule.ActionProgramParam
= "action" .
364 /* _UIB-CODE-BLOCK-END
*/
368 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI V-table-Win _DEFAULT-DISABLE
369 PROCEDURE disable_UI
:
370 /*------------------------------------------------------------------------------
371 Purpose
: DISABLE the User Interface
373 Notes
: Here we clean-up the user-interface by deleting
374 dynamic widgets we have created and
/or hide
375 frames. This procedure is usually called when
376 we are ready to
"clean-up" after running.
377 ------------------------------------------------------------------------------*/
378 /* Hide all frames.
*/
380 IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
383 /* _UIB-CODE-BLOCK-END
*/
387 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-initialize V-table-Win
388 PROCEDURE inst-initialize
:
389 /*------------------------------------------------------------------------------
391 ------------------------------------------------------------------------------*/
393 IF mode
= 'Add'
THEN DO:
395 CURRENT-WINDOW:TITLE = "Adding a New Workflow Task".
396 RUN dispatch
( 'add-record'
:U
).
398 ELSE IF mode
= "Maintain" THEN
399 RUN dispatch
( 'enable-fields'
:U
).
401 RUN dispatch
( 'disable-fields'
:U
).
405 /* _UIB-CODE-BLOCK-END
*/
409 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE override-add-record V-table-Win
410 PROCEDURE override-add-record
:
411 /*------------------------------------------------------------------------------
413 ------------------------------------------------------------------------------*/
414 DO WITH FRAME {&FRAME-NAME}:
416 FIND FlowTaskType
WHERE FlowTaskType.FlowTaskType
= ?
NO-LOCK NO-ERROR.
417 IF NOT AVAILABLE(FlowTaskType
) THEN CREATE FlowTaskType.
419 ASSIGN FlowTaskType.FlowTaskType
= ?
420 FlowTaskType.InitialStep
= "TASK" .
422 CURRENT-WINDOW:TITLE = "Adding a New Workflow Task".
423 RUN dispatch
( 'display-fields'
:U
).
424 RUN dispatch
( 'enable-fields'
:U
).
430 /* _UIB-CODE-BLOCK-END
*/
434 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE pre-destroy V-table-Win
435 PROCEDURE pre-destroy
:
436 /*------------------------------------------------------------------------------
438 ------------------------------------------------------------------------------*/
439 IF LAST-EVENT:FUNCTION = "WINDOW-CLOSE" THEN RUN cancel-changes.
442 /* _UIB-CODE-BLOCK-END
*/
446 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-key V-table-Win adm/support/_key-snd.p
448 /*------------------------------------------------------------------------------
449 Purpose
: Sends a requested
KEY value back to the calling
451 Parameters
: <see adm
/template
/sndkytop.i
>
452 ------------------------------------------------------------------------------*/
454 /* Define variables needed by this internal procedure.
*/
455 {src
/adm
/template
/sndkytop.i
}
457 /* Return the key value associated with each key case.
*/
458 {src
/adm
/template
/sndkycas.i
"FlowTaskType" "FlowTaskType" "FlowTaskType"}
460 /* Close the
CASE statement and end the procedure.
*/
461 {src
/adm
/template
/sndkyend.i
}
465 /* _UIB-CODE-BLOCK-END
*/
469 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-records V-table-Win _ADM-SEND-RECORDS
470 PROCEDURE send-records
:
471 /*------------------------------------------------------------------------------
472 Purpose
: Send record
ROWID's for all tables used by
474 Parameters
: see template
/snd-head.i
475 ------------------------------------------------------------------------------*/
477 /* Define variables needed by this internal procedure.
*/
478 {src
/adm
/template
/snd-head.i
}
480 /* For each requested table
, put it's
ROWID in the output list.
*/
481 {src
/adm
/template
/snd-list.i
"FlowTaskType"}
483 /* Deal with any unexpected table requests before closing.
*/
484 {src
/adm
/template
/snd-end.i
}
488 /* _UIB-CODE-BLOCK-END
*/
492 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE state-changed V-table-Win
493 PROCEDURE state-changed
:
494 /* -----------------------------------------------------------
498 -------------------------------------------------------------*/
499 DEFINE INPUT PARAMETER p-issuer-hdl
AS HANDLE NO-UNDO.
500 DEFINE INPUT PARAMETER p-state
AS CHARACTER NO-UNDO.
503 /* Object instance CASEs can go here to replace standard behavior
505 {src
/adm
/template
/vstates.i
}
509 /* _UIB-CODE-BLOCK-END
*/
513 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE use-Mode V-table-Win
515 /*------------------------------------------------------------------------------
517 ------------------------------------------------------------------------------*/
518 DEF INPUT PARAMETER new-mode
AS CHAR NO-UNDO.
522 /* _UIB-CODE-BLOCK-END
*/
526 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE verify-flow-task V-table-Win
527 PROCEDURE verify-flow-task
:
528 /*------------------------------------------------------------------------------
530 ------------------------------------------------------------------------------*/
532 DO WITH FRAME {&FRAME-NAME}:
534 IF INPUT FlowTaskType.FlowTaskType
= ?
OR TRIM(INPUT FlowTaskType.FlowTaskType
) = "" THEN DO:
535 MESSAGE "You must choose a unique Flow Task code."
536 VIEW-AS ALERT-BOX ERROR TITLE "Unassigned Flow Task Code".
537 APPLY '
ENTRY'
:U
TO FlowTaskType.FlowTaskType.
541 IF INPUT FlowTaskType.FlowTaskType
<> FlowTaskType.FlowTaskType
AND
542 CAN-FIND( FlowTaskType
WHERE FlowTaskType.FlowTaskType
= INPUT FlowTaskType.FlowTaskType
) THEN DO:
543 MESSAGE "A Flow Task already exists with the code" INPUT FlowTaskType.FlowTaskType
"!" SKIP
544 "You must choose a unique FlowTaskType code."
545 VIEW-AS ALERT-BOX ERROR TITLE "Duplicate Flow Task Code".
546 APPLY '
ENTRY'
:U
TO FlowTaskType.FlowTaskType.
550 IF TRIM(INPUT FlowTaskType.Description
) = "" THEN DO:
551 MESSAGE "You must supply a description for the Flow Task!"
552 VIEW-AS ALERT-BOX ERROR TITLE "Incomplete Name".
553 APPLY '
ENTRY'
:U
TO FlowTaskType.Description.
561 /* _UIB-CODE-BLOCK-END
*/