From 54310ff095206f545e489d6606a2927e37898da8 Mon Sep 17 00:00:00 2001 From: Carsten Rose <carsten.rose@math.uzh.ch> Date: Sun, 1 May 2016 00:35:08 +0200 Subject: [PATCH] Work on UsersManual. FormEditor: Subrecords colorized, 'ord' values will be automatially computed. index.rst: updated - '&' is the new symbol to indicate constants. QuickFormQuery.php: changed the defaults for Bootstrap forms again - look nicer on UZH CD Layout. *.sql: Colorized subrecords for FormElements, ord will automatically computed, work on example forms (not finished) --- extension/Documentation/UsersManual/Index.rst | 84 +++++++++++--- extension/qfq/qfq/QuickFormQuery.php | 4 +- extension/qfq/sql/formEditor.sql | 108 ++++++------------ extension/qfq/sql/testtables.sql | 77 ++++++++++--- .../qfq/tests/phpunit/fixtures/Generic.sql | 5 - 5 files changed, 167 insertions(+), 111 deletions(-) diff --git a/extension/Documentation/UsersManual/Index.rst b/extension/Documentation/UsersManual/Index.rst index f3e5300bb..295c01473 100644 --- a/extension/Documentation/UsersManual/Index.rst +++ b/extension/Documentation/UsersManual/Index.rst @@ -779,30 +779,27 @@ Type: select Type: subrecord ^^^^^^^^^^^^^^^ -'subrecord' will be rendered as HTML table. - -* *parameter* - - * *detail*: e.g. *detail=id:gr_id,#{{a}}:p_id,#12:x_id* - * *form*: Target form, e.g. *form=person* - * *page*: Target page with detail form. If none specified, use the current page - * *title*: Title displayed over the table. +'subrecord' present a list of records (called secondary records), typically to edit, delete or add such records. The list + is defined as a SQL query. The number of records shown is not limited. These formelement will be rendered inside the + form as a HTML table. * *sql1*: SQL query to select records. E.g.:: - {{!SELECT a.id AS id, CONCAT(a.street, a.streetnumber) AS a, a.city AS b, a.zip AS c FROM adresse AS a}} + {{!SELECT a.id AS id, CONCAT(a.street, a.streetnumber) AS a, a.city AS b, a.zip AS c FROM Address AS a}} # Notice the **exclamation mark** after '{{' - this is necessary to return an array of elements, instead of a single string. - * Exactly one column 'id' has to exist; it specifies the primary record for the target form. If the column 'id' should - not be shown to the user, it's ok to hide the columen by name it '_id'. + * Exactly one column 'id' has to exist; it specifies the primary record for the target form. + In case the id should no be visible to the user, it has to be named *'_id'*. - * Columnname: *<title>[|<number>][|width=<number>][|nostrip][|icon][|url][|mailto]* + * Columnname: *<title>[|<number>][|width=<number>][|nostrip][|icon][|url][|mailto|_rowClass]* * *<number>*: any 'digit only' will be treated as '''width'''. * *width=<number>*: max. number of chars displayed per cell in the column. - * *nostrip*: by default, html tags will be stripped off the cell content before rendering. This protects the table layout. 'nostrip' deactivates the cleaning to make links, images, ... possible. - * *icon*: the cell value contains the name of an icon in *typo3conf/ext/qfq/Resources/Public/icons*. Empty cell values will omit an html image tag (=nothing renderd in the cell). + * *nostrip*: by default, html tags will be stripped off the cell content before rendering. This protects the table + layout. 'nostrip' deactivates the cleaning to make links, images, ... possible. + * *icon*: the cell value contains the name of an icon in *typo3conf/ext/qfq/Resources/Public/icons*. Empty cell values + will omit an html image tag (=nothing renderd in the cell). * *mailto*: value will be rendered as a mailto link. * *url*: value will be rendered as a link. * *title=<text>* or '<none of the above>': column '''title'''. @@ -812,13 +809,37 @@ Type: subrecord SELECT note1 AS 'Comment', note2 AS 'Comment\|50' , note3 AS 'title=Comment\|width=100\|nostrip', note4 AS '50\|Comment', 'checked.png' AS 'Status\|icon', email AS 'mailto', CONCAT(homepage, '\|Homepage') AS 'url' ... - * Special column name: *_rowClass* + * *_rowClass* + + * The value is a CSS class name(s) which will be rendered in the *<tr class="<_rowClass>">* of the subrecord table. + * The column itself is hidden to the user. + * By using Bootstrap, the following predefined classes are available: + + * Text color: *text-muted|text-primary|text-success|text-info|text-warning|text-danger* (http://getbootstrap.com/css/#helper-classes) + * Row background: *active|success|info|warning|danger* (http://getbootstrap.com/css/#tables-contextual-classes) + +* *parameter* + + * *form*: Target form, e.g. *form=person* + * *page*: Target page with detail form. If none specified, use the current page. + * *title*: Title displayed over the table in the current form. + * *detail*: Mapping of values from the primary form to the target form (defined via `form=...`). + + * Syntax:: - * Define CSS class name(s) which will be rendered in the *<tr class="<_rowClass>">* of the subrecord table. - * By using Bootstrap, the following predefined classes are available: + <source table column name 1|&constant 1>:<target column name 1>[,<source table column name 2|&constant 2>:<target column name 2>][...] + + * Example: *detail=id:personId,&12:xId,&{{a}}:personId* + * By default, the given value will overwrite values on the target record. In most situations, this is the wished behaviour. + * Exceptions of the default behaviour have to be defined on the target form in the corresponding formelement in the + field *value*. E.g. `{{<columnname>:RS0}}` - For existing records, the store `R` will provide a value. For new + records, store `R` is empty and store S will be searched for a value: the value defined in `detail` will be choosen. At + last the store '0' is defined as a fallback. + * *source table column name*: E.g. A person form is opened with person.id=5 (r=5). The definition `detail=id:personId` and `form=address` + maps person.id to address.personId. On the target record, the column personId becomes '5'. + * *Constant '&'*: Indicate a 'constant' value. E.g. `&12:xId` or `{{...}}` (all possibilities, incl. further SELECT + statements) might be used. - * Text color: *text-muted|text-primary|text-success|text-info|text-warning|text-danger* (http://getbootstrap.com/css/#helper-classes) - * Row background: *active|success|info|warning|danger* (http://getbootstrap.com/css/#tables-contextual-classes) Type: string ^^^^^^^^^^^^ @@ -2243,3 +2264,28 @@ QFQ content record:: fend = </td> } + +Secondary records: compute next free 'ord' automatically +-------------------------------------------------------- + +Requirement: new records should automatically get the highest number plus 10 for their 'ord' value. Existing records +should not be altered. + +Version 1 +^^^^^^^^^ + +Compute the next 'ord' in advance in the subrecord field of the primary form. Submit that value to the new record +via SIP parameter to the secondary form. + +On the secondary form: for 'new' records choose the computed value, for existing records leave the value +unchanged. + +* Primary form, `subrecord` formelement, field `parameter`: set `detail=id:formId,{{SELECT '&', IFNULL(fe.ord,0)+10 FROM Form AS f LEFT JOIN FormElement AS fe ON fe.formId=f.id WHERE f.id={{r:S0}} ORDER BY fe.ord DESC LIMIT 1}}:ord +* Secondary form, `ord` formelement, field `value`: set `{{RS0}}`. + +Version 2 +^^^^^^^^^ + +Compute the next 'ord' as default value direct inside the secondary form. No change is needed for the primary form. + +* Secondary form, `ord` formelement, field `value`: set `{{SELECT IF({{ord:R0}}=0, MAX(IFNULL(fe.ord,0))+10,{{ord:R0}}) FROM (SELECT 1) AS a LEFT JOIN FormElement AS fe ON fe.formId={{formId:S0}} GROUP BY fe.formId}}`. diff --git a/extension/qfq/qfq/QuickFormQuery.php b/extension/qfq/qfq/QuickFormQuery.php index a37085a41..38f81fc0a 100644 --- a/extension/qfq/qfq/QuickFormQuery.php +++ b/extension/qfq/qfq/QuickFormQuery.php @@ -295,8 +295,8 @@ class QuickFormQuery { # Set defaults: Support::setIfNotSet($this->formSpec, 'class', ''); - Support::setIfNotSet($this->formSpec, F_BS_LABEL_COLUMNS, 2, ''); - Support::setIfNotSet($this->formSpec, F_BS_INPUT_COLUMNS, 9, ''); + Support::setIfNotSet($this->formSpec, F_BS_LABEL_COLUMNS, 3, ''); + Support::setIfNotSet($this->formSpec, F_BS_INPUT_COLUMNS, 8, ''); Support::setIfNotSet($this->formSpec, F_BS_NOTE_COLUMNS, 1, ''); // Clear diff --git a/extension/qfq/sql/formEditor.sql b/extension/qfq/sql/formEditor.sql index 84ce8f3aa..c737fcf7f 100644 --- a/extension/qfq/sql/formEditor.sql +++ b/extension/qfq/sql/formEditor.sql @@ -167,7 +167,7 @@ VALUES '', '', 4, ''), (1, '', 'FormElements', 'show', 'subrecord', 'all', 'native', 500, 0, 0, '', '', '', - '{{!SELECT IF(enabled="yes", "", "text-muted") AS _rowClass, id, feIdContainer, name, label, mode, class, type, ord, size, sql1, parameter FROM FormElement WHERE formId={{id:R0}} ORDER BY ord, id}}', + '{{!SELECT IF(enabled="yes", IF(class="container","info", IF(class="action","success","")), "text-muted") AS _rowClass, id, feIdContainer, name, label, mode, class, type, ord, size, sql1, parameter FROM FormElement WHERE formId={{id:R0}} ORDER BY ord, id}}', '', 'form=formElement\ndetail=id:formId', 5, 'new,edit,delete'); # @@ -179,7 +179,8 @@ INSERT INTO Form (name, title, noteInternal, tableName, permitNew, permitEdit, r 'FormElement', 'always', 'always', 'bootstrap', '', 'maxVisiblePill=5'); # FormEditor: FormElements -INSERT INTO FormElement (id, formId, name, label, mode, type, checkType, class, ord, size, maxLength, note, clientJs, value, sql1, sql2, parameter, feIdContainer, subrecordOption) +INSERT INTO FormElement (id, formId, name, label, mode, type, checkType, class, ord, size, maxLength, note, clientJs, value, + sql1, sql2, parameter, feIdContainer, subrecordOption) VALUES (100, 2, 'basic', 'Basic', 'show', 'pill', 'all', 'container', 10, 0, 0, '', '', '', '', '', '', 0, ''), @@ -188,80 +189,45 @@ VALUES (103, 2, 'value', 'Value', 'show', 'pill', 'all', 'container', 20, 0, 0, '', '', '', '', '', '', 0, ''), (104, 2, 'info', 'Info', 'show', 'pill', 'all', 'container', 20, 0, 0, '', '', '', '', '', '', 0, ''); -INSERT INTO FormElement (formId, name, label, mode, type, checkType, class, ord, size, maxLength, note, clientJs, value, sql1, sql2, parameter, feIdContainer, subrecordOption, dynamicUpdate) +INSERT INTO FormElement (formId, name, label, mode, type, checkType, class, ord, size, maxLength, note, clientJs, value, sql1, sql2, parameter, feIdContainer, subrecordOption, dynamicUpdate, bsLabelColumns, bsInputColumns, bsNoteColumns) VALUES - (2, 'id', 'id', 'readonly', 'text', 'all', 'native', 100, 0, 11, '', '', '', '', '', '', 100, '', 'no'), - (2, 'formId', 'formId', 'readonly', 'text', 'all', 'native', 110, 0, 255, '', '', '', '', '', '', 100, '', 'no'), + (2, 'id', 'id', 'readonly', 'text', 'all', 'native', 100, 0, 11, '', '', '', '', '', '', 100, '', 'no', '', '', ''), + (2, 'formId', 'formId', 'readonly', 'text', 'all', 'native', 110, 0, 255, '', '', '', '', '', '', 100, '', 'no', '', '', ''), (2, 'feIdContainer', 'Container', 'show', 'select', 'all', 'native', 120, 0, 0, '', '', '', '{{!SELECT fe.id, CONCAT(fe.class, " / ", fe.label) FROM FormElement As fe WHERE fe.formId={{formId}} AND fe.class="container" ORDER BY fe.ord }}', - '', 'emptyItemAtStart', 100, '', 'no'), - (2, 'enabled', 'Enabled', 'show', 'checkbox', 'all', 'native', 130, 0, 0, '', '', '', '', '', '', 100, '', 'no'), - (2, 'dynamicUpdate', 'Dynamic Update', 'show', 'checkbox', 'all', 'native', 135, 0, 0, 'This element will be updated on change and trigger other.', '', '', '', '', '', 100, '', 'no'), - (2, 'name', 'Name', 'required', 'text', 'all', 'native', 140, 0, 255, '', '', '', '', '', '', 100, '', 'no'), - (2, 'label', 'Label', 'show', 'text', 'all', 'native', 150, 0, 255, '', '', '', '', '', '', 100, '', 'no'), - (2, 'mode', 'Mode', 'show', 'select', 'all', 'native', 160, 0, 255, '', '', '', '', '', '', 100, '', 'no'), - (2, 'class', 'Class', 'show', 'select', 'all', 'native', 170, 0, 255, '', '', '{{class:FSRD0:alnumx}}', '', '', '', 100, '', 'yes'), + '', 'emptyItemAtStart', 100, '', 'no', '', '', ''), + (2, 'enabled', 'Enabled', 'show', 'checkbox', 'all', 'native', 130, 0, 0, '', '', '', '', '', '', 100, '', 'no', '', '', ''), + (2, 'dynamicUpdate', 'Dynamic Update', 'show', 'checkbox', 'all', 'native', 135, 0, 0, 'This element will be updated on change and trigger other.', '', '', '', '', '', 100, '', 'no', '3', '2', '7'), + (2, 'name', 'Name', 'show', 'text', 'all', 'native', 140, 0, 255, '', '', '', '', '', '', 100, '', 'no', '', '', ''), + (2, 'label', 'Label', 'show', 'text', 'all', 'native', 150, 0, 255, '', '', '', '', '', '', 100, '', 'no', '', '', ''), + (2, 'mode', 'Mode', 'show', 'select', 'all', 'native', 160, 0, 255, '', '', '', '', '', '', 100, '', 'no', '', '', ''), + (2, 'class', 'Class', 'show', 'select', 'all', 'native', 170, 0, 255, '', '', '{{class:FSRD0:alnumx}}', '', '', '', 100, '', 'yes', '', '', ''), (2, 'type', 'Type', 'show', 'select', 'all', 'native', 180, 0, 255, '', '', '', '', '', 'itemList={{SELECT IF( "{{class:FRD0:alnumx}}"="native","checkbox,date,time,datetime,dateJQW,datetimeJQW,gridJQW,hidden,text,note,password,radio,select,subrecord,upload", IF("{{class:FRD0:alnumx}}"="action","before_load,before_save,before_insert,before_update,before_delete,after_load,after_save,after_insert,after_update,after_delete,feGroup,sendmail", "fieldset,pill") ) }}', - 100, '', 'yes'), - (2, 'subrecordOption', 'Subrecord Option', 'show', 'checkbox', 'all', 'native', 190, 0, 0, '', '', '', '', '', '', 100, '', 'no'), - (2, 'checkType', 'Check Type', 'show', 'select', 'all', 'native', 200, 0, 255, '', '', '', '', '', '', 101, '', 'no'), - (2, 'checkPattern', 'Check Pattern', 'show', 'text', 'all', 'native', 210, 0, 255, '', '', '', '', '', '', 101, '', 'no'), - (2, 'onChange', 'JS onChange', 'show', 'text', 'all', 'native', 220, 0, 255, '', '', '', '', '', '', 101, '', 'no'), - (2, 'ord', 'Order', 'show', 'text', 'all', 'native', 230, 0, 255, '', '', '', '', '', '', 101, '', 'no'), - (2, 'tabindex', 'tabindex', 'show', 'text', 'all', 'native', 240, 0, 255, '', '', '', '', '', '', 101, '', 'no'), - (2, 'size', 'Size', 'show', 'text', 'all', 'native', 250, 0, 255, '', '', '', '', '', '', 102, '', 'no'), - (2, 'bsLabelColumns', 'BS Label Columns', 'show', 'text', 'all', 'native', 260, 0, 255, '', '', '', '', '', '', 102, '', 'no'), - (2, 'bsInputColumns', 'BS Input Columns', 'show', 'text', 'all', 'native', 270, 0, 255, '', '', '', '', '', '', 102, '', 'no'), - (2, 'bsNoteColumns', 'BS Note Columns', 'show', 'text', 'all', 'native', 280, 0, 255, '', '', '', '', '', '', 102, '', 'no'), - (2, 'maxLength', 'Maxlength', 'show', 'text', 'all', 'native', 290, 0, 255, '', '', '', '', '', '', 102, '', 'no'), - (2, 'note', 'note', 'show', 'text', 'all', 'native', 300, 0, 255, '', '', '', '', '', '', 102, '', 'no'), - (2, 'tooltip', 'Tooltip', 'show', 'text', 'all', 'native', 310, 0, 255, '', '', '', '', '', '', 102, '', 'no'), - (2, 'placeholder', 'Placeholder', 'show', 'text', 'all', 'native', 320, 0, 255, '', '', '', '', '', '', 102, '', 'no'), - (2, 'value', 'value', 'show', 'text', 'all', 'native', 330, 0, 255, '', '', '', '', '', '', 103, '', 'no'), - (2, 'sql1', 'sql1', 'show', 'text', 'all', 'native', 340, '70,5', 255, '', '', '', '', '', '', 103, '', 'no'), + 100, '', 'yes', '', '', ''), + (2, 'subrecordOption', 'Subrecord Option', 'show', 'checkbox', 'all', 'native', 190, 0, 0, '', '', '', '', '', '', 100, '', 'no', '', '', ''), + (2, 'checkType', 'Check Type', 'show', 'select', 'all', 'native', 200, 0, 255, '', '', '', '', '', '', 101, '', 'no', '', '', ''), + (2, 'checkPattern', 'Check Pattern', 'show', 'text', 'all', 'native', 210, 0, 255, '', '', '', '', '', '', 101, '', 'no', '', '', ''), + (2, 'onChange', 'JS onChange', 'show', 'text', 'all', 'native', 220, 0, 255, '', '', '', '', '', '', 101, '', 'no', '', '', ''), + (2, 'ord', 'Order', 'show', 'text', 'all', 'native', 230, 0, 255, '', '', '{{SELECT IF({{ord:R0}}=0, MAX(IFNULL(fe.ord,0))+10,{{ord:R0}}) FROM (SELECT 1) AS a LEFT JOIN FormElement AS fe ON fe.formId={{formId:S0}} GROUP BY fe.formId}}', '', '', '', 101, '', 'no', '', '', ''), + (2, 'tabindex', 'tabindex', 'show', 'text', 'all', 'native', 240, 0, 255, '', '', '', '', '', '', 101, '', 'no', '', '', ''), + (2, 'size', 'Size', 'show', 'text', 'all', 'native', 250, 0, 255, '', '', '', '', '', '', 102, '', 'no', '', '', ''), + (2, 'bsLabelColumns', 'BS Label Columns', 'show', 'text', 'all', 'native', 260, 0, 255, '', '', '', '', '', '', 102, '', 'no', '', '', ''), + (2, 'bsInputColumns', 'BS Input Columns', 'show', 'text', 'all', 'native', 270, 0, 255, '', '', '', '', '', '', 102, '', 'no', '', '', ''), + (2, 'bsNoteColumns', 'BS Note Columns', 'show', 'text', 'all', 'native', 280, 0, 255, '', '', '', '', '', '', 102, '', 'no', '', '', ''), + (2, 'maxLength', 'Maxlength', 'show', 'text', 'all', 'native', 290, 0, 255, '', '', '', '', '', '', 102, '', 'no', '', '', ''), + (2, 'note', 'note', 'show', 'text', 'all', 'native', 300, 0, 255, '', '', '', '', '', '', 102, '', 'no', '', '', ''), + (2, 'tooltip', 'Tooltip', 'show', 'text', 'all', 'native', 310, 0, 255, '', '', '', '', '', '', 102, '', 'no', '', '', ''), + (2, 'placeholder', 'Placeholder', 'show', 'text', 'all', 'native', 320, 0, 255, '', '', '', '', '', '', 102, '', 'no', '', '', ''), + (2, 'value', 'value', 'show', 'text', 'all', 'native', 330, 0, 255, '', '', '', '', '', '', 103, '', 'no', '', '', ''), + (2, 'sql1', 'sql1', 'show', 'text', 'all', 'native', 340, '70,5', 255, '', '', '', '', '', '', 103, '', 'no', '', '', ''), (2, 'parameter', 'Parameter', 'show', 'text', 'all', 'native', 350, '40,4', 255, '', '', '', '', '', '', 103, '', - 'no'), - (2, 'clientJs', 'ClientJS', 'show', 'text', 'all', 'native', 360, 0, 255, '', '', '', '', '', '', 103, '', 'no'), - (2, 'feGroup', 'feGroup', 'show', 'text', 'all', 'native', 370, 0, 255, '', '', '', '', '', '', 104, '', 'no'), - (2, 'deleted', 'Deleted', 'show', 'checkbox', 'all', 'native', 380, 0, 0, '', '', '', '', '', '', 104, '', 'no'), - (2, 'modified', 'Modified', 'readonly', 'text', 'all', 'native', 390, 0, 20, '', '', '', '', '', '', 104, '', 'no'), - (2, 'created', 'Created', 'readonly', 'text', 'all', 'native', 400, 0, 20, '', '', '', '', '', '', 104, '', 'no'); - -# FormEditor: Small -INSERT INTO Form (name, title, noteInternal, tableName, permitNew, permitEdit, render, multiSql, parameter) VALUES - ('person', 'Person {{SELECT ": ", firstName, " ", name, " (", id, ")" FROM Person WHERE id = {{r:S0}}}}', - 'Please secure the form', - 'Person', 'always', 'always', 'bootstrap', '', ''); - -# FormEditor: FormElements -INSERT INTO FormElement (id, formId, name, label, mode, type, checkType, class, ord, size, maxLength, note, clientJs, value, sql1, sql2, parameter, feIdContainer, subrecordOption) -VALUES + 'no', '', '', ''), + (2, 'clientJs', 'ClientJS', 'show', 'text', 'all', 'native', 360, 0, 255, '', '', '', '', '', '', 103, '', 'no', '', '', ''), + (2, 'feGroup', 'feGroup', 'show', 'text', 'all', 'native', 370, 0, 255, '', '', '', '', '', '', 104, '', 'no', '', '', ''), + (2, 'deleted', 'Deleted', 'show', 'checkbox', 'all', 'native', 380, 0, 0, '', '', '', '', '', '', 104, '', 'no', '', '', ''), + (2, 'modified', 'Modified', 'readonly', 'text', 'all', 'native', 390, 0, 20, '', '', '', '', '', '', 104, '', 'no', '', '', ''), + (2, 'created', 'Created', 'readonly', 'text', 'all', 'native', 400, 0, 20, '', '', '', '', '', '', 104, '', 'no', '', + '', ''); - (200, 3, 'name', 'Name', 'show', 'text', 'all', 'native', 10, 0, 255, '', '', '', '', '', '', 0, ''), - (201, 3, 'firstname', 'Firstname', 'show', 'text', 'all', 'native', 20, 0, 255, '', '', '', '', '', '', 0, ''), - (202, 3, 'birthday', 'Birthday', 'show', 'date', 'all', 'native', 30, 0, 255, '', '', '', '', '', '', 0, ''); - -# ---------------------------------------------------------------------- -# - -# Form: plain -INSERT INTO Form (name, title, noteInternal, tableName, permitNew, permitEdit, render, multiSql, parameter) VALUES - ('formplain', 'Form: Plain', '', 'Form', 'always', 'always', 'plain', '', ''); - -# FormEditor: FormElements -INSERT INTO FormElement (id, formId, name, label, mode, type, checkType, class, ord, size, maxLength, note, clientJs, value, sql1, sql2, parameter, feIdContainer, subrecordOption) -VALUES - (300, 4, 'id', 'id', 'readonly', 'text', 'all', 'native', 100, 0, 11, '', '', '', '', '', '', 0, ''), - (310, 4, 'name', 'Name', 'show', 'text', 'all', 'native', 120, 0, 255, '', '', '', '', '', '', 0, ''); - -# Form: table -INSERT INTO Form (name, title, noteInternal, tableName, permitNew, permitEdit, render, multiSql, parameter) VALUES - ('formtable', 'Form: Table', '', 'Form', 'always', 'always', 'table', '', ''); - -# FormEditor: FormElements -INSERT INTO FormElement (id, formId, name, label, mode, type, checkType, class, ord, size, maxLength, note, clientJs, value, sql1, sql2, parameter, feIdContainer, subrecordOption) -VALUES - (400, 5, 'id', 'id', 'readonly', 'text', 'all', 'native', 100, 0, 11, '', '', '', '', '', '', 0, ''), - (410, 5, 'name', 'Name', 'show', 'text', 'all', 'native', 120, 0, 255, '', '', '', '', '', '', 0, ''); diff --git a/extension/qfq/sql/testtables.sql b/extension/qfq/sql/testtables.sql index 9ee45f952..5d8c224b8 100644 --- a/extension/qfq/sql/testtables.sql +++ b/extension/qfq/sql/testtables.sql @@ -1,11 +1,11 @@ DROP TABLE IF EXISTS Person; CREATE TABLE Person ( - id BIGINT AUTO_INCREMENT PRIMARY KEY, + id BIGINT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(128), firstname VARCHAR(128), - gender ENUM('', 'male', 'female') NOT NULL DEFAULT 'male', - groups SET('', 'a', 'b', 'c') NOT NULL DEFAULT '', - birthday DATE NOT NULL DEFAULT '0000-00-00' + gender ENUM('', 'male', 'female') NOT NULL DEFAULT 'male', + groups SET('', 'a', 'b', 'c') NOT NULL DEFAULT '', + birthday DATE NOT NULL DEFAULT '0000-00-00' ); # @@ -15,24 +15,73 @@ INSERT INTO Person (id, name, firstname, gender, groups) VALUES (NULL, 'Smith', 'Jane', 'female', 'a,c'); +DROP TABLE IF EXISTS PersFunction; +CREATE TABLE PersFunction ( + id BIGINT AUTO_INCREMENT PRIMARY KEY, + personId BIGINT, + type ENUM('Student', 'Assistant', 'Professor', 'Administration'), + start DATE NOT NULL DEFAULT '0000-00-00', + end DATE NOT NULL DEFAULT '0000-00-00', + note VARCHAR(255) +); + +# --------------------------- +# Form: plain +REPLACE INTO Form (id, name, title, noteInternal, tableName, permitNew, permitEdit, render, multiSql, parameter) VALUES + (3, 'formplain', 'Form: Plain', '', 'Form', 'always', 'always', 'plain', '', ''); + +# FormEditor: FormElements +REPLACE INTO FormElement (id, formId, name, label, mode, type, checkType, class, ord, size, maxLength, note, clientJs, value, sql1, sql2, parameter, feIdContainer, subrecordOption) +VALUES + (300, 3, 'id', 'id', 'readonly', 'text', 'all', 'native', 100, 0, 11, '', '', '', '', '', '', 0, ''), + (310, 3, 'name', 'Name', 'show', 'text', 'all', 'native', 120, 0, 255, '', '', '', '', '', '', 0, ''); + +# Form: table +REPLACE INTO Form (id, name, title, noteInternal, tableName, permitNew, permitEdit, render, multiSql, parameter) VALUES + (4, 'formtable', 'Form: Table', '', 'Form', 'always', 'always', 'table', '', ''); + +# FormEditor: FormElements +REPLACE INTO FormElement (id, formId, name, label, mode, type, checkType, class, ord, size, maxLength, note, clientJs, value, sql1, sql2, parameter, feIdContainer, subrecordOption) +VALUES + (400, 4, 'id', 'id', 'readonly', 'text', 'all', 'native', 100, 0, 11, '', '', '', '', '', '', 0, ''), + (410, 4, 'name', 'Name', 'show', 'text', 'all', 'native', 120, 0, 255, '', '', '', '', '', '', 0, ''); + + +# Form: Person +REPLACE INTO Form (id, name, title, noteInternal, tableName, permitNew, permitEdit, render, multiSql, parameter) VALUES + (5, 'person', 'Person {{SELECT ": ", firstName, " ", name, " (", id, ")" FROM Person WHERE id = {{r:S0}}}}', + 'Please secure the form', + 'Person', 'always', 'always', 'bootstrap', '', ''); + +# FormEditor: FormElements +REPLACE INTO FormElement (id, formId, name, label, mode, type, checkType, class, ord, size, maxLength, note, clientJs, value, sql1, sql2, parameter, feIdContainer, subrecordOption) +VALUES + + (500, 5, 'name', 'Name', 'show', 'text', 'all', 'native', 10, 0, 255, '', '', '', '', '', '', 0, ''), + (501, 5, 'firstname', 'Firstname', 'show', 'text', 'all', 'native', 20, 0, 255, '', '', '', '', '', '', 0, ''), + (502, 5, 'birthday', 'Birthday', 'show', 'date', 'all', 'native', 30, 0, 255, '', '', '', '', '', '', 0, ''), + (506, 5, 'gender', 'Sex', 'show', 'select', 'alnumx', 'native', 40, 0, 0, '', '', '', '', '', '', 0, ''), + (503, 5, 'datumZeit', 'Datum & Zeit', 'show', 'datetime', 'alnumx', 'native', 50, 0, 0, '', '', '', '', '', '', 0, + ''), + (504, 5, 'zeit', 'Zeit', 'show', 'time', 'alnumx', 'native', 60, 0, 0, '', '', '', '', '', '', 0, ''), + (505, 5, 'picture', 'Picture', 'show', 'upload', 'allbut', 'native', 70, 0, 0, '', '', '', '', '', '', 0, ''); + +# ---------------------------------------------------------------------- +# DROP TABLE IF EXISTS Address; CREATE TABLE Address ( id BIGINT AUTO_INCREMENT PRIMARY KEY, - person_id BIGINT, + personId BIGINT, street VARCHAR(128), city VARCHAR(128), country ENUM('Switzerland', 'Austria', 'France', 'Germany'), gr_id_typ BIGINT ); -DROP TABLE IF EXISTS Gruppe; -CREATE TABLE Gruppe ( - id BIGINT AUTO_INCREMENT PRIMARY KEY, - name VARCHAR(255), - value VARCHAR(255), - typ VARCHAR(255), - t1 TEXT -); +INSERT INTO Address (personId, street, city) VALUES + (1, 'Side Street', 'Zurich'), + (1, 'Park Street', 'Zurich'), + (1, 'Winter Street', 'Zurich'), + (2, 'Summer Street', 'Zurich'); -# --------------------------- diff --git a/extension/qfq/tests/phpunit/fixtures/Generic.sql b/extension/qfq/tests/phpunit/fixtures/Generic.sql index 8e5dafc56..fb4a96802 100644 --- a/extension/qfq/tests/phpunit/fixtures/Generic.sql +++ b/extension/qfq/tests/phpunit/fixtures/Generic.sql @@ -38,8 +38,3 @@ CREATE TABLE Address ( PRIMARY KEY (`id`) ); -INSERT INTO Address (person_id, street, city) VALUES - (1, 'Side Street', 'Zurich'), - (1, 'Park Street', 'Zurich'), - (1, 'Winter Street', 'Zurich'), - (2, 'Summer Street', 'Zurich'); -- GitLab