Commit c2b35d31 authored by Marc Egger's avatar Marc Egger
Browse files

Refs #10120 creating Form/FormElement added

parent 3ba5f4fe
Pipeline #3611 failed with stages
in 43 seconds
...@@ -7,7 +7,7 @@ use IMATHUZH\Qfq\Core\Database\Database; ...@@ -7,7 +7,7 @@ use IMATHUZH\Qfq\Core\Database\Database;
use IMATHUZH\Qfq\Core\Helper\HelperFile; use IMATHUZH\Qfq\Core\Helper\HelperFile;
use IMATHUZH\Qfq\Core\Helper\SqlQuery; use IMATHUZH\Qfq\Core\Helper\SqlQuery;
// TODO: test deleteing of Form and FormElement <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< // TODO: test creating form and formElement
// TODO: ensure that form file is imported if Form is loaded via Rest API // TODO: ensure that form file is imported if Form is loaded via Rest API
// TODO: gibt es UPDATE/INSERT/DELETE statements die an Form/FormElement arbeiten koennen, die nicht nur durch doForm aufgerufen werden? // TODO: gibt es UPDATE/INSERT/DELETE statements die an Form/FormElement arbeiten koennen, die nicht nur durch doForm aufgerufen werden?
// TODO: Testen: Dies sollte schon erfuellt sein, testen: bevor ein form/formelement im form editor gespeichert wird, soll es vom file geladen werden (Save.php). Falls das file importiert wurde, gibt es eine fehlermeldung. // TODO: Testen: Dies sollte schon erfuellt sein, testen: bevor ein form/formelement im form editor gespeichert wird, soll es vom file geladen werden (Save.php). Falls das file importiert wurde, gibt es eine fehlermeldung.
......
...@@ -425,6 +425,17 @@ class QuickFormQuery { ...@@ -425,6 +425,17 @@ class QuickFormQuery {
// Make sure form file is writable (before DB changes are made) // Make sure form file is writable (before DB changes are made)
// Note: This can't be done earlier because $formModeNew might be changed in the lines above. // Note: This can't be done earlier because $formModeNew might be changed in the lines above.
$recordFormName = FormAsFile::formNameFromFormRelatedRecord($recordId, $this->formSpec[F_TABLE_NAME], $this->dbArray[$this->dbIndexQfq]); $recordFormName = FormAsFile::formNameFromFormRelatedRecord($recordId, $this->formSpec[F_TABLE_NAME], $this->dbArray[$this->dbIndexQfq]);
if (FORM_SAVE === $formModeNew && intval($recordId) === 0) {
switch ($this->formSpec[F_TABLE_NAME]) {
case TABLE_NAME_FORM: // New Form is being created
$recordFormName = $this->store->getVar(F_NAME, STORE_FORM);
break;
case TABLE_NAME_FORM_ELEMENT: // New FormElement is being created
$formId = $this->store->getVar(FE_FORM_ID, STORE_FORM);
$recordFormName = FormAsFile::formNameFromFormRelatedRecord($formId, TABLE_NAME_FORM, $this->dbArray[$this->dbIndexQfq]);
break;
}
}
if ($recordFormName !== null && in_array($formModeNew, [FORM_SAVE, FORM_DRAG_AND_DROP, FORM_DELETE])) { if ($recordFormName !== null && in_array($formModeNew, [FORM_SAVE, FORM_DRAG_AND_DROP, FORM_DELETE])) {
FormAsFile::enforceFormFileWritable($recordFormName); FormAsFile::enforceFormFileWritable($recordFormName);
} }
...@@ -628,7 +639,7 @@ class QuickFormQuery { ...@@ -628,7 +639,7 @@ class QuickFormQuery {
} }
// export Form to file, if loaded record is a Form/FormElement // export Form to file, if loaded record is a Form/FormElement
if ($recordFormName !== false) { if ($recordFormName !== null) {
switch ($formModeNew) { switch ($formModeNew) {
case FORM_SAVE: case FORM_SAVE:
case FORM_DRAG_AND_DROP: case FORM_DRAG_AND_DROP:
...@@ -640,6 +651,7 @@ class QuickFormQuery { ...@@ -640,6 +651,7 @@ class QuickFormQuery {
} else { } else {
FormAsFile::deleteFormFile($recordFormName); FormAsFile::deleteFormFile($recordFormName);
} }
break;
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment