[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/designer/templates/forms FormBuilder.py
From: |
Jason Cater |
Subject: |
gnue/designer/templates/forms FormBuilder.py |
Date: |
Thu, 28 Feb 2002 11:44:23 -0500 |
CVSROOT: /home/cvs
Module name: gnue
Changes by: Jason Cater <address@hidden> 02/02/28 11:44:23
Modified files:
designer/templates/forms: FormBuilder.py
Log message:
iteration logic in the multipurpose form builder
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/designer/templates/forms/FormBuilder.py.diff?cvsroot=OldCVS&tr1=1.1&tr2=1.2&r1=text&r2=text
Patches:
Index: gnue/designer/templates/forms/FormBuilder.py
diff -c gnue/designer/templates/forms/FormBuilder.py:1.1
gnue/designer/templates/forms/FormBuilder.py:1.2
*** gnue/designer/templates/forms/FormBuilder.py:1.1 Thu Feb 28 00:37:37 2002
--- gnue/designer/templates/forms/FormBuilder.py Thu Feb 28 11:44:23 2002
***************
*** 32,37 ****
--- 32,50 ----
from gnue.designer.TemplateBase import *
import string
+ #
+ # Steps
+ #
+ # 0. Get Title Goto step 1
+ # 1. Select Connection Goto step 2
+ # 2. Select Table Goto step 3
+ # 3. Select Fields Goto step 4 or 7
+ # 4. Select Master Goto step 5
+ # 5. Select Master Keys Goto step 6
+ # 6. Select Detail Keys Goto step 7
+ # 7. Add another? Goto step 1,2, or 8
+ # 8. Complete.
+ #
class FormBuilderTemplate(FormTemplate):
***************
*** 50,70 ****
def Start(self, form):
self.form = form
###############
#
# Return the markup for a specific page
#
def GetStep(self, stepCode):
! step = string.split(stepCode,':')[0]
! print "Step! ", step, "-", stepCode
#
# Step #0 / Get Title, et al
#
if step == '0':
- # Wipe the settings in memory
- self.variables['total_children'] = 1
- self.variables['current_child'] = 1
return { 'title': 'Basic Form Information',
'content': (WizardText('Welcome to the sample form wizard.'),
--- 63,115 ----
def Start(self, form):
self.form = form
+ # The first table can never have a master
+ self.variables['hasmaster0'] = '0'
+
+
###############
#
# Return the markup for a specific page
#
def GetStep(self, stepCode):
! try:
! step, iteration = string.split(stepCode,':')
! iteration = int(iteration)
! except ValueError:
! step = stepCode
!
! # Add another? loop logic
! if step == '1or8':
!
! # If continue is set to 1, then go to step 1; otherwise, step 8
! if self.variables['continue'] == '1':
!
! step = '1'
!
! # If we are reusing the same connection, record that now and skip a
step
! if self.variables['singleconnection'] == '1':
! self.variables['connection%s' % iteration] =
self.variables['connection0']
! step = '2'
!
! else:
! # We are done... record the total number of children
! self.variables['iterations'] = iteration
! step = '8'
!
!
! # Has Master? loop logic
! if step == '4or7':
! if self.variables['hasmaster%s' % iteration] == '1':
! step = '4'
! else:
! step = '7'
!
!
#
# Step #0 / Get Title, et al
#
if step == '0':
return { 'title': 'Basic Form Information',
'content': (WizardText('Welcome to the sample form wizard.'),
***************
*** 75,99 ****
size=40),
),
'prev': None,
! 'next': '1:%s' % self.variables['current_child'] }
#
# Step #1 / Get Connection
#
! if step == '1' or (step == '5' and self.variables['continue']=='1'):
! if step == '5':
! self.variables['total_children'] += 1
! self.variables['current_child'] += 1
!
! return { 'title': 'Connection Information',
! 'content': (WizardText('What connection contains the table
you wish to\nthe form?'),
! WizardInput('connection',label='Connection:',
required=1,
! set=self.GetAvailableConnections()),
! WizardText('You may be asked to login to this
connection.'),
! ),
! 'prev': self.variables['current_child'] > 1 and '5:%s' or
'0', # Loop back
! 'next': '2:%s' % self.variables['current_child'] }
#
--- 120,158 ----
size=40),
),
'prev': None,
! 'next': '1:0' }
#
# Step #1 / Get Connection
#
! if step == '1':
! if iteration == 0:
! # first time through ask about reusing same connection
! return { 'title': 'Connection Information',
! 'content': (WizardText('What connection contains the
table you wish to\nthe form?'),
!
WizardInput('connection%s'%iteration,label='Connection:', required=1,
!
set=self.GetAvailableConnections()),
! WizardInput('singleconnection',
! label='Reuse this connection for all
tables?',
! required=1,set=(('1','Yes'),
! ('0','No')
! )),
! WizardText('You may be asked to login to this
connection.'),
! ),
! 'prev': '0', # Loop back
! 'next': '2:%s' % iteration }
!
! else:
!
! return { 'title': 'Connection Information',
! 'content': (WizardText('What connection contains the
table you wish to\nthe form?'),
!
WizardInput('connection%s'%iteration,label='Connection:', required=1,
!
set=self.GetAvailableConnections()),
! WizardText('You may be asked to login to this
connection.'),
! ),
! 'prev': '7:%s' % (iteration - 1), # Loop back
! 'next': '2:%s' % iteration }
#
***************
*** 101,199 ****
#
elif step == '2':
! # TODO: If the connection changed between steps,
! # TODO: variables['table'] and variables['fields']
! # TODO: should be cleared.
!
! return { 'title': 'Select Table/Source',
! 'content': (WizardText('Now, please select a table for your
form.'),
! WizardInput('table%s' %
self.variables['current_child'],
! label='Table:', required=1, lines=5,
!
set=self.GetAvailableSources(self.variables['connection'])), ),
! 'prev': '1:%s' % self.variables['current_child'],
! 'next': '3:%s' % self.variables['current_child'] }
elif step == '3':
- # TODO: If the table changed between steps,
- # TODO: variables['fields'] should be cleared.
return { 'title': 'Select Fields to Include',
! 'content': (WizardText('Which master-level fields shall I
include in your form as entries?'),
! WizardInput('tablefields%s' %
self.variables['current_child'],
label='Columns:', required=1,
maxSelections=-1, orderable=1,
set=self.GetAvailableFields( \
! self.variables['connection'],
! self.variables['table%s' %
self.variables['current_child']])),
! WizardInput('tablearrangement%s' %
self.variables['current_child'],
label='Arrangement Method:',
required=1,
set=(('left','Single Record with
Labels to Left'),
('above','Single Record with
Labels Above'),
('grid','Grid Format')))),
! 'prev': '2:%s' % self.variables['current_child'],
! 'next': '4:%s' % self.variables['current_child'] }
-
- #
#
! # Step #3 / Get Master Columns to Include
#
elif step == '4':
! # TODO: If the table changed between steps,
! # TODO: variables['fields'] should be cleared.
! return { 'title': 'Add Another Table?',
! 'content': (WizardInput('continue', label='Add Another
Table?',
! required=1,set=(('1','Yes'),
! ('0','No')
! )),),
! 'prev': '2:%s' % self.variables['current_child'],
! 'next': '5:%s' % self.variables['current_child'] }
! # Step #4 / Get Base Detail Table
! #
! elif step == '3':
!
! # TODO: If the connection changed between steps,
! # TODO: variables['table'] and variables['fields']
! # TODO: should be cleared.
!
! return { 'title': 'Select Base Table/Source',
! 'content': (WizardText('Now, please select the detail table
for the master table %s.' % self.variables['mastertable']),
! WizardInput('detailtable', label='Detail
Table:', required=1, lines=5,
!
set=self.GetAvailableSources(self.variables['connection'])), ),
! 'prev': '2',
! 'next': '4' }
- #
- # Step #3 / Get Detail Columns to Include
- #
- elif step == '4':
- # TODO: If the table changed between steps,
- # TODO: variables['fields'] should be cleared.
! return { 'title': 'Select Detail Fields to Include',
! 'content': (WizardText('Which detail-level fields shall I
include in your form as entries?'),
! WizardInput('detailfields', label='Columns:',
required=1,
! maxSelections=-1, orderable=1,
! set=self.GetAvailableFields( \
! self.variables['connection'],
!
self.variables['detailtable'])),
! WizardInput('detailarrangement',
label='Arrangement Method:',
! required=1,
! set=(('left','Single Record with
Labels to Left'),
! ('above','Single Record with
Labels Above'),
! ('grid','Grid Format')))),
! 'prev': '3',
! 'next': '5' }
#
--- 160,256 ----
#
elif step == '2':
! # If using the same connection for all tables, skip question on Prev
! if iteration and self.variables['singleconnection'] == '1':
! prev = '1'
! elif iteration:
! prev = '7'
! else:
! prev = '0'
!
! # Do not ask about master/detail if we're iteration #1
! if iteration:
! return { 'title': 'Select Table/Source',
! 'content': (WizardText('Now, please select a table for
your form.'),
! WizardInput('table%s' % iteration,
! label='Table:', required=1,
lines=5,
!
set=self.GetAvailableSources(self.variables['connection%s'%iteration])),
! WizardInput('hasmaster%s' % iteration,
! label='Will this table have a
master?',
! required=1,set=(('0','No'),
! ('1','Yes'),
! )),
! ),
! 'prev': '%s:%s' % (prev,iteration),
! 'next': '3:%s' % iteration }
!
! else:
! return { 'title': 'Select Table/Source',
! 'content': (WizardText('Now, please select a table for
your form.'),
! WizardInput('table%s' % iteration,
! label='Table:', required=1,
lines=5,
!
set=self.GetAvailableSources(self.variables['connection%s'%iteration])),
! ),
! 'prev': '%s:%s' % (prev,iteration),
! 'next': '3:%s' % iteration }
+ #
+ # Step #3 / Select fields to include
+ #
elif step == '3':
return { 'title': 'Select Fields to Include',
! 'content': (WizardText('Which fields shall I include in your
form as entries?'),
! WizardInput('tablefields%s' % iteration,
label='Columns:', required=1,
maxSelections=-1, orderable=1,
set=self.GetAvailableFields( \
!
self.variables['connection%s'%iteration],
! self.variables['table%s' %
iteration])),
! WizardInput('tablearrangement%s' % iteration,
label='Arrangement Method:',
required=1,
set=(('left','Single Record with
Labels to Left'),
('above','Single Record with
Labels Above'),
('grid','Grid Format')))),
! 'prev': '2:%s' % iteration,
! 'next': '4or7:%s' % iteration }
#
! # Step #4 / Select Master Table
#
elif step == '4':
! set = []
! tables = {}
! for i in range(iteration):
! table = self.variables['table%s' % i]
! # Append a "#2" to the table name if multiple sources use same table
! if tables.has_key(table):
! tables[table] += 1
! table += ' #%s' % tables[table]
! else:
! tables[table] = 1
+ set.append( (i, table ) )
! # NOTE: mastertable# will be set to a NUMBER corresponding to the
datasource to
! # use. It is NOT set to an actual name! (i.e., the table to use
is
! # self.variables['table%s' % mastertable#]
+ return { 'title': 'Link to Master Table',
+ 'content': (WizardText('Now, please select the table to be
the master of %s.' % self.variables['table%s'%iteration]),
+ WizardInput('mastertable%s'%iteration,
label='Master Table:', required=1, lines=5,
+ set=set), ),
+ 'prev': '3:%s' % iteration,
+ 'next': '5:%s' % iteration }
#
***************
*** 201,218 ****
#
elif step == '5':
- # TODO: If the table changed between steps,
- # TODO: variables['fields'] should be cleared.
return { 'title': 'Master key fields',
'content': (WizardText('Which master-level fields are the
primary keys?'),
! WizardInput('masterkeys', label='Columns:',
required=1,
maxSelections=-1, orderable=1,
set=self.GetAvailableFields( \
! self.variables['connection'],
!
self.variables['mastertable']))),
! 'prev': '4',
! 'next': '6' }
#
--- 258,273 ----
#
elif step == '5':
return { 'title': 'Master key fields',
'content': (WizardText('Which master-level fields are the
primary keys?'),
! WizardInput('masterkeys%s' % iteration,
label='Columns:', required=1,
maxSelections=-1, orderable=1,
set=self.GetAvailableFields( \
! self.variables['connection%s'
% self.variables['mastertable%s' % iteration]],
! self.variables['table%s' %
self.variables['mastertable%s' % iteration]]))),
! 'prev': '4:%s' % iteration,
! 'next': '6:%s' % iteration }
#
***************
*** 228,236 ****
WizardInput('detailkeys', label='Columns:',
required=1,
maxSelections=-1, orderable=1,
set=self.GetAvailableFields( \
! self.variables['connection'],
!
self.variables['detailtable']))),
! 'prev': '5',
'next': None }
--- 283,322 ----
WizardInput('detailkeys', label='Columns:',
required=1,
maxSelections=-1, orderable=1,
set=self.GetAvailableFields( \
! self.variables['connection%s'
% iteration],
! self.variables['table%s' %
iteration]))),
! 'prev': '5:%s' % iteration,
! 'next': '7:%s' % iteration }
!
! #
! #
! # Step #7 / Get Master Columns to Include
! #
! elif step == '7':
!
! # If current table has no master, then skip the master/detail stuff
! if self.variables['hasmaster%s' % iteration] == '0':
! prev = '3'
! else:
! prev = '6'
!
!
! # TODO: If the table changed between steps,
! # TODO: variables['fields'] should be cleared.
!
! return { 'title': 'Add Another Table?',
! 'content': (WizardInput('continue', label='Add Another
Table?',
! required=1,set=(('1','Yes'),
! ('0','No')
! )),),
! 'prev': '%s:%s' % (prev,iteration),
! 'next': '1or8:%s' % (iteration+1) }
!
! elif step == '8':
!
! return { 'title': "That's it!",
! 'content': (WizardText('Click finish to create your
form?'),),
! 'prev': '7:%s' % (iteration-1),
'next': None }