add view details panel; clean up other panels
This commit is contained in:
parent
f7a2ca070f
commit
ab9b3c208a
@ -108,6 +108,7 @@
|
|||||||
Say 'NO CONTACT FOUND'
|
Say 'NO CONTACT FOUND'
|
||||||
return
|
return
|
||||||
END
|
END
|
||||||
|
|
||||||
return contacts[1] /* Rexx is 1-indexed */
|
return contacts[1] /* Rexx is 1-indexed */
|
||||||
|
|
||||||
/***************************
|
/***************************
|
||||||
@ -135,6 +136,46 @@
|
|||||||
END
|
END
|
||||||
return contacts
|
return contacts
|
||||||
|
|
||||||
|
/***********************
|
||||||
|
* Get Contact Details *
|
||||||
|
***********************/
|
||||||
|
::METHOD getContactDetails
|
||||||
|
expose db
|
||||||
|
use arg contactID
|
||||||
|
|
||||||
|
contact = self~getContact(contactId)
|
||||||
|
if contact \= .nil then do
|
||||||
|
/* Get Phone Numbers */
|
||||||
|
psql = "SELECT * FROM phone_numbers WHERE contact_id = "contact["ID"]
|
||||||
|
phones = db~exec(psql,.true,.ooSQLite~OO_ARRAY_OF_DIRECTORIES)
|
||||||
|
phone = phones[1] /* just grab the first phone */
|
||||||
|
contact["PHONE_NUMBER"] = phone["NUMBER"]
|
||||||
|
contact["PHONE_TYPE"] = phone["TYPE"]
|
||||||
|
|
||||||
|
/* Now get email addresses */
|
||||||
|
esql = "SELECT * FROM email_addresses WHERE contact_id = "contact["ID"]
|
||||||
|
emails = db~exec(esql,.true,.ooSQLite~OO_ARRAY_OF_DIRECTORIES)
|
||||||
|
email = emails[1]
|
||||||
|
contact["EMAIL_ADDRESS"] = email["EMAIL"]
|
||||||
|
contact["EMAIL_TYPE"] = email["TYPE"]
|
||||||
|
|
||||||
|
/* Now get real physical address */
|
||||||
|
asql = "SELECT * FROM addresses WHERE contact_id = "contact["ID"]
|
||||||
|
addresses = db~exec(asql,.true,.ooSQLite~OO_ARRAY_OF_DIRECTORIES)
|
||||||
|
address = addresses[1]
|
||||||
|
contact["STREET"] = address["STREET"]
|
||||||
|
contact["CITY"] = address["CITY"]
|
||||||
|
contact["STATE"] = address["STATE"]
|
||||||
|
contact["POSTAL_CODE"] = address["POSTAL_CODE"]
|
||||||
|
contact["COUNTRY"] = address["COUNTRY"]
|
||||||
|
|
||||||
|
end /* add contact details */
|
||||||
|
RETURN contact
|
||||||
|
|
||||||
|
|
||||||
|
/***********************
|
||||||
|
* Search All Contacts *
|
||||||
|
***********************/
|
||||||
::METHOD searchContacts
|
::METHOD searchContacts
|
||||||
expose db
|
expose db
|
||||||
use arg searchTerm
|
use arg searchTerm
|
||||||
|
164
app/appui.cls
164
app/appui.cls
@ -77,6 +77,8 @@
|
|||||||
when clrset = 8 then panel~init_pair(9, panel~COLOR_CYAN, panel~COLOR_BLACK)
|
when clrset = 8 then panel~init_pair(9, panel~COLOR_CYAN, panel~COLOR_BLACK)
|
||||||
/* blacken everything to give the appearance of disappearance */
|
/* blacken everything to give the appearance of disappearance */
|
||||||
when clrset = 9 then panel~init_pair(10, panel~COLOR_BLACK, panel~COLOR_BLACK)
|
when clrset = 9 then panel~init_pair(10, panel~COLOR_BLACK, panel~COLOR_BLACK)
|
||||||
|
/* red on black */
|
||||||
|
when clrset = 10 then panel~init_pair(11, panel~COLOR_RED, panel~COLOR_BLACK)
|
||||||
/* Default to white text on black background */
|
/* Default to white text on black background */
|
||||||
OTHERWISE DO
|
OTHERWISE DO
|
||||||
clrset=0
|
clrset=0
|
||||||
@ -97,8 +99,8 @@
|
|||||||
max_y = win~lines
|
max_y = win~lines
|
||||||
max_x = win~cols
|
max_x = win~cols
|
||||||
|
|
||||||
menu_height = 21
|
menu_height = 16
|
||||||
menu_width = 40
|
menu_width = 30
|
||||||
start_y = (max_y - menu_height) % 2
|
start_y = (max_y - menu_height) % 2
|
||||||
start_x = (max_x - menu_width) % 2
|
start_x = (max_x - menu_width) % 2
|
||||||
clrset=1
|
clrset=1
|
||||||
@ -106,8 +108,8 @@
|
|||||||
with_box = .true
|
with_box = .true
|
||||||
|
|
||||||
menuwin = self~DrawSubPanel(menu_height, menu_width, start_y, start_x, clrset, title, with_box)
|
menuwin = self~DrawSubPanel(menu_height, menu_width, start_y, start_x, clrset, title, with_box)
|
||||||
menu_items = .array~of("[A]dd Contact", "[D]elete Contact", "[E]dit Contact", "[S]earch", "[L]ist All", "[Q]uit")
|
menu_items = .array~of("[V]iew Contact", "[A]dd Contact", "[D]elete Contact", "[E]dit Contact", "[S]earch", "[L]ist All", "[Q]uit")
|
||||||
menu_keys = .array~of("a", "d", "e", "s", "l", "q")
|
menu_keys = .array~of("v", "a", "d", "e", "s", "l", "q")
|
||||||
|
|
||||||
.environment~selected = 1
|
.environment~selected = 1
|
||||||
self~DrawMenu(menuwin, menu_items, .environment~selected, win)
|
self~DrawMenu(menuwin, menu_items, .environment~selected, win)
|
||||||
@ -148,7 +150,7 @@
|
|||||||
win~refresh
|
win~refresh
|
||||||
self~setupMainMenu(win)
|
self~setupMainMenu(win)
|
||||||
menuwin~refresh()
|
menuwin~refresh()
|
||||||
RETURN
|
RETURN
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* Add new contact *
|
* Add new contact *
|
||||||
@ -261,7 +263,7 @@
|
|||||||
end
|
end
|
||||||
end /* add contact */
|
end /* add contact */
|
||||||
self~dropWindow(formwin)
|
self~dropWindow(formwin)
|
||||||
return
|
RETURN
|
||||||
|
|
||||||
/****************************
|
/****************************
|
||||||
* Delete Contact Panel *
|
* Delete Contact Panel *
|
||||||
@ -272,21 +274,21 @@
|
|||||||
/* Create a form panel */
|
/* Create a form panel */
|
||||||
max_y = win~lines
|
max_y = win~lines
|
||||||
max_x = win~cols
|
max_x = win~cols
|
||||||
form_height = 14
|
form_height = 12
|
||||||
form_width = 35
|
form_width = 35
|
||||||
start_y = (max_y - form_height) % 2
|
start_y = (max_y - form_height) % 2
|
||||||
start_x = (max_x - form_width) % 2
|
start_x = (max_x - form_width) % 2
|
||||||
delwin = self~DrawSubPanel(form_height, form_width, start_y, start_x, 0, "Delete A Contact", .true)
|
delwin = self~DrawSubPanel(form_height, form_width, start_y, start_x, 10, "Delete A Contact", .true)
|
||||||
|
|
||||||
delwin~mvaddstr(3, 2, "Contact ID: ")
|
delwin~mvaddstr(4, 2, "Contact ID: ")
|
||||||
delwin~mvaddstr(form_height-2, 2, "[Enter] to save, [Esc] to cancel")
|
delwin~mvaddstr(form_height-1, 2, "[Enter] to del, [Esc] to cancel")
|
||||||
delwin~refresh()
|
delwin~refresh()
|
||||||
|
|
||||||
contactId = self~getInputField(delwin, 3, 14, 10)
|
contactId = self~getInputField(delwin, 4, 14, 10)
|
||||||
if contactId = .nil then do
|
if contactId = .nil then do
|
||||||
self~dropWindow(delwin)
|
self~dropWindow(delwin)
|
||||||
RETURN
|
RETURN
|
||||||
END
|
END
|
||||||
|
|
||||||
result = db~deleteContact(contactId)
|
result = db~deleteContact(contactId)
|
||||||
|
|
||||||
@ -303,17 +305,95 @@
|
|||||||
self~dropWindow(delwin)
|
self~dropWindow(delwin)
|
||||||
RETURN
|
RETURN
|
||||||
|
|
||||||
|
/********************************
|
||||||
|
* View Contact Selection Panel *
|
||||||
|
********************************/
|
||||||
|
::METHOD viewContactSelectPanel
|
||||||
|
expose win db menuwin viewselectwin
|
||||||
|
|
||||||
|
/* Create a form panel */
|
||||||
|
max_y = win~lines
|
||||||
|
max_x = win~cols
|
||||||
|
form_height = 12
|
||||||
|
form_width = 35
|
||||||
|
start_y = (max_y - form_height) % 2
|
||||||
|
start_x = (max_x - form_width) % 2
|
||||||
|
viewselectwin = self~DrawSubPanel(form_height, form_width, start_y, start_x, 8, "View A Contact", .true)
|
||||||
|
|
||||||
|
viewselectwin~mvaddstr(4, 2, "Contact ID: ")
|
||||||
|
viewselectwin~mvaddstr(form_height-1, 2, "[Enter] to sel., [Esc] to cancel")
|
||||||
|
viewselectwin~refresh()
|
||||||
|
|
||||||
|
contactId = self~getInputField(viewselectwin, 4, 14, 10)
|
||||||
|
if contactId = .nil then do
|
||||||
|
self~dropWindow(viewselectwin)
|
||||||
|
RETURN
|
||||||
|
END
|
||||||
|
|
||||||
|
result = db~getContact(contactId)
|
||||||
|
|
||||||
|
if result = .nil then do /* should be a result id number */
|
||||||
|
viewselectwin~mvaddstr(8, 2, "Contact not found.")
|
||||||
|
viewselectwin~refresh()
|
||||||
|
call SysWait 0.5
|
||||||
|
self~dropWindow(viewselectwin)
|
||||||
|
RETURN
|
||||||
|
end
|
||||||
|
|
||||||
|
/* launch a view panel with full contact details */
|
||||||
|
self~dropWindow(viewselectwin)
|
||||||
|
self~viewContactDetailPanel(contactId)
|
||||||
|
RETURN
|
||||||
|
|
||||||
|
/************************
|
||||||
|
* View Contact Details *
|
||||||
|
************************/
|
||||||
|
::METHOD viewContactDetailPanel
|
||||||
|
expose win db menuwin detailwin viewselectwin
|
||||||
|
use arg contactID
|
||||||
|
|
||||||
|
/* Create a form panel */
|
||||||
|
max_y = win~lines
|
||||||
|
max_x = win~cols
|
||||||
|
form_height = 14
|
||||||
|
form_width = 40
|
||||||
|
start_y = (max_y - form_height) % 2
|
||||||
|
start_x = (max_x - form_width) % 2
|
||||||
|
detailwin = self~DrawSubPanel(form_height, form_width, start_y, start_x, 1, "View Contact Details", .true)
|
||||||
|
|
||||||
|
contactDetails = db~getContactDetails(contactId)
|
||||||
|
|
||||||
|
/* Detail fields */
|
||||||
|
detailwin~mvaddstr(4, 3, contactDetails~first_name);
|
||||||
|
detailwin~mvaddstr(4, LENGTH(contactDetails~first_name)+1+3, contactDetails~last_name);
|
||||||
|
detailwin~mvaddstr(5, 3, contactDetails~street)
|
||||||
|
detailwin~mvaddstr(6, 3, contactDetails~city);
|
||||||
|
detailwin~mvaddstr(6, LENGTH(contactDetails~city)+4, contactDetails~state);
|
||||||
|
detailwin~mvaddstr(6, LENGTH(contactDetails~city)+LENGTH(contactDetails~state)+5, contactDetails~postal_code);
|
||||||
|
detailwin~mvaddstr(6, LENGTH(contactDetails~city)+LENGTH(contactDetails~state)+LENGTH(contactDetails~postal_code)+6, contactDetails~country)
|
||||||
|
detailwin~mvaddstr(7, 3, contactDetails~email_address)
|
||||||
|
detailwin~mvaddstr(8, 3, contactDetails~phone_number)
|
||||||
|
|
||||||
|
detailwin~mvaddstr(form_height-1, 2, "[Esc] to cancel")
|
||||||
|
detailwin~refresh()
|
||||||
|
|
||||||
|
detailwin~getch()
|
||||||
|
self~dropWindow(detailwin)
|
||||||
|
RETURN
|
||||||
|
|
||||||
|
RETURN
|
||||||
|
|
||||||
/****************************
|
/****************************
|
||||||
* List all contacts *
|
* List all contacts *
|
||||||
****************************/
|
****************************/
|
||||||
::method listAllContactsPanel
|
::METHOD listAllContactsPanel
|
||||||
expose win db menuwin
|
expose win db menuwin
|
||||||
|
|
||||||
/* Create a list panel */
|
/* Create a list panel */
|
||||||
max_y = win~lines
|
max_y = win~lines
|
||||||
max_x = win~cols
|
max_x = win~cols
|
||||||
list_height = max_y - 5
|
list_height = max_y - 10
|
||||||
list_width = max_x - 23
|
list_width = max_x - 30
|
||||||
start_y = (max_y - list_height) % 2
|
start_y = (max_y - list_height) % 2
|
||||||
start_x = (max_x - list_width) % 2
|
start_x = (max_x - list_width) % 2
|
||||||
|
|
||||||
@ -324,11 +404,11 @@
|
|||||||
/* Display column headers */
|
/* Display column headers */
|
||||||
listwin~attron(listwin~A_BOLD)
|
listwin~attron(listwin~A_BOLD)
|
||||||
listwin~mvaddstr(4, 2, "ID")
|
listwin~mvaddstr(4, 2, "ID")
|
||||||
listwin~mvaddstr(4, 6, "First Name")
|
listwin~mvaddstr(4, 5, "First Name")
|
||||||
listwin~mvaddstr(4, 18, "Last Name")
|
listwin~mvaddstr(4, 17, "Last Name")
|
||||||
listwin~mvaddstr(4, 30, "Phone")
|
listwin~mvaddstr(4, 29, "Phone")
|
||||||
listwin~mvaddstr(4, 50, "Email")
|
listwin~mvaddstr(4, 45, "Email")
|
||||||
listwin~mvaddstr(5, 2, "-- ---------- --------- --------------- -------------------------")
|
listwin~mvaddstr(5, 2, "-- ---------- --------- --------------- -------------------------")
|
||||||
listwin~attroff(listwin~A_BOLD)
|
listwin~attroff(listwin~A_BOLD)
|
||||||
|
|
||||||
contacts = db~getAllContacts()
|
contacts = db~getAllContacts()
|
||||||
@ -338,10 +418,10 @@
|
|||||||
do i = 1 to contacts~items
|
do i = 1 to contacts~items
|
||||||
contact = contacts[i]
|
contact = contacts[i]
|
||||||
listwin~mvaddstr(i+5, 2, contact['ID'])
|
listwin~mvaddstr(i+5, 2, contact['ID'])
|
||||||
listwin~mvaddstr(i+5, 6, contact['FIRST_NAME'])
|
listwin~mvaddstr(i+5, 5, contact['FIRST_NAME'])
|
||||||
listwin~mvaddstr(i+5, 18, contact['LAST_NAME'])
|
listwin~mvaddstr(i+5, 17, contact['LAST_NAME'])
|
||||||
listwin~mvaddstr(i+5, 30, contact['PHONE_NUMBER'])
|
listwin~mvaddstr(i+5, 29, contact['PHONE_NUMBER'])
|
||||||
listwin~mvaddstr(i+5, 50, contact['EMAIL_ADDRESS'])
|
listwin~mvaddstr(i+5, 45, contact['EMAIL_ADDRESS'])
|
||||||
/* Break if we run out of screen space */
|
/* Break if we run out of screen space */
|
||||||
if i > list_height-7 then LEAVE
|
if i > list_height-7 then LEAVE
|
||||||
end
|
end
|
||||||
@ -358,7 +438,7 @@
|
|||||||
/****************************
|
/****************************
|
||||||
* Search for contact *
|
* Search for contact *
|
||||||
****************************/
|
****************************/
|
||||||
::method searchContactPanel
|
::METHOD searchContactPanel
|
||||||
expose win db menuwin menu_items
|
expose win db menuwin menu_items
|
||||||
|
|
||||||
/* Create a search panel */
|
/* Create a search panel */
|
||||||
@ -401,23 +481,23 @@
|
|||||||
/* Create a list panel */
|
/* Create a list panel */
|
||||||
max_y = win~lines
|
max_y = win~lines
|
||||||
max_x = win~cols
|
max_x = win~cols
|
||||||
list_height = max_y - 5
|
list_height = max_y - 15
|
||||||
list_width = max_x - 23
|
list_width = max_x - 30
|
||||||
start_y = (max_y - list_height) % 2
|
start_y = (max_y - list_height) % 2
|
||||||
start_x = (max_x - list_width) % 2
|
start_x = (max_x - list_width) % 2
|
||||||
|
|
||||||
searchoutwin = self~DrawSubPanel(list_height, list_width, start_y, start_x, 1, "All Contacts", .true)
|
searchoutwin = self~DrawSubPanel(list_height, list_width, start_y, start_x, 1, "Search Results", .true)
|
||||||
searchoutwin~scrollok(.true)
|
/* searchoutwin~scrollok(.true)
|
||||||
searchoutwin~Setscrreg(4,18)
|
searchoutwin~Setscrreg(4,18) */
|
||||||
|
|
||||||
/* Display column headers */
|
/* Display column headers */
|
||||||
searchoutwin~attron(searchoutwin~A_BOLD)
|
searchoutwin~attron(searchoutwin~A_BOLD)
|
||||||
searchoutwin~mvaddstr(4, 2, "ID")
|
searchoutwin~mvaddstr(4, 2, "ID")
|
||||||
searchoutwin~mvaddstr(4, 6, "First Name")
|
searchoutwin~mvaddstr(4, 5, "First Name")
|
||||||
searchoutwin~mvaddstr(4, 18, "Last Name")
|
searchoutwin~mvaddstr(4, 17, "Last Name")
|
||||||
searchoutwin~mvaddstr(4, 30, "Phone")
|
searchoutwin~mvaddstr(4, 29, "Phone")
|
||||||
searchoutwin~mvaddstr(4, 50, "Email")
|
searchoutwin~mvaddstr(4, 45, "Email")
|
||||||
searchoutwin~mvaddstr(5, 2, "-- ---------- --------- --------------- -------------------------")
|
searchoutwin~mvaddstr(5, 2, "-- ---------- --------- --------------- -------------------------")
|
||||||
searchoutwin~attroff(searchoutwin~A_BOLD)
|
searchoutwin~attroff(searchoutwin~A_BOLD)
|
||||||
|
|
||||||
contacts = db~searchContacts(term)
|
contacts = db~searchContacts(term)
|
||||||
@ -427,10 +507,10 @@
|
|||||||
do i = 1 to contacts~items
|
do i = 1 to contacts~items
|
||||||
contact = contacts[i]
|
contact = contacts[i]
|
||||||
searchoutwin~mvaddstr(i+5, 2, contact['ID'])
|
searchoutwin~mvaddstr(i+5, 2, contact['ID'])
|
||||||
searchoutwin~mvaddstr(i+5, 6, contact['FIRST_NAME'])
|
searchoutwin~mvaddstr(i+5, 5, contact['FIRST_NAME'])
|
||||||
searchoutwin~mvaddstr(i+5, 18, contact['LAST_NAME'])
|
searchoutwin~mvaddstr(i+5, 17, contact['LAST_NAME'])
|
||||||
searchoutwin~mvaddstr(i+5, 30, contact['PHONE_NUMBER'])
|
searchoutwin~mvaddstr(i+5, 29, contact['PHONE_NUMBER'])
|
||||||
searchoutwin~mvaddstr(i+5, 50, contact['EMAIL_ADDRESS'])
|
searchoutwin~mvaddstr(i+5, 45, contact['EMAIL_ADDRESS'])
|
||||||
/* Break if we run out of screen space */
|
/* Break if we run out of screen space */
|
||||||
if i > list_height-7 then LEAVE
|
if i > list_height-7 then LEAVE
|
||||||
end
|
end
|
||||||
@ -444,7 +524,6 @@
|
|||||||
|
|
||||||
RETURN
|
RETURN
|
||||||
|
|
||||||
|
|
||||||
/************************
|
/************************
|
||||||
* Get Input From Field *
|
* Get Input From Field *
|
||||||
************************/
|
************************/
|
||||||
@ -567,7 +646,7 @@
|
|||||||
self~deleteContactPanel()
|
self~deleteContactPanel()
|
||||||
END
|
END
|
||||||
when key_char = 'e' then do
|
when key_char = 'e' then do
|
||||||
menuwin~mvaddstr(19 - 3, 5, "TODO: Create an Edit Panel ");
|
menuwin~mvaddstr(menuwin~lines-15, 3, "TODO: Create Edit Panel");
|
||||||
menuwin~refresh
|
menuwin~refresh
|
||||||
END
|
END
|
||||||
when key_char = 's' then do
|
when key_char = 's' then do
|
||||||
@ -576,6 +655,9 @@
|
|||||||
when key_char = 'l' then do
|
when key_char = 'l' then do
|
||||||
self~listAllContactsPanel()
|
self~listAllContactsPanel()
|
||||||
END
|
END
|
||||||
|
when key_char = 'v' then do
|
||||||
|
self~viewContactSelectPanel()
|
||||||
|
END
|
||||||
when key_char = 'q' then do
|
when key_char = 'q' then do
|
||||||
menuwin~mvaddstr(19 - 3, 5, "Exiting the application... ")
|
menuwin~mvaddstr(19 - 3, 5, "Exiting the application... ")
|
||||||
menuwin~refresh
|
menuwin~refresh
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user