Project

General

Profile

Feature #10120

Form als File

Added by Marc Egger 7 months ago. Updated about 1 month ago.

Status:
Priorize
Priority:
Normal
Assignee:
Target version:
Start date:
13.02.2020
Due date:
% Done:

0%

Estimated time:
Discuss:

Description

Prio1 für Nicola!

TODO:
- Beispiel mit Multiline String
- Was hat sich von TOML 0.4 auf 1.0 geandert?
- FormElements > FormElement_ (Einzahl)
- script PHP: Form aus Datenbank lesen und in JSON/TOML abspeichern
- SQL SELECTs in Form rendering mit JSON/TOML auslesen ersetzen

FRAGEN:
- Wie ordnen wir FormElements im TOML?
- immer nach ord?
- was wenn ord in file geändert wurde und dann in QFQ geladen? Automatisch FormElemente neu nach ord ordnen und in file speichern?

Mögliche JSON formatierung von einem Form:

{
  "name" : "personFormular",
  "title" : "Person editieren",
  "sqlAfter" : : "{{INSERT ... }}",
  "..." : "...",
  "..." : "...",
  "formElements" : [
    {
      "name" : "vormane",
      "label" : "Vorname",
      "type" : "text",
      "value" : "{{SELECT p.vorname FROM p AS PERSON where ... }}",
      "sqlAfter" : "..." 
      "currentValue" : "Marc" 
      "..." : "...",
      "..." : "...",
    }]
}

Nice to have: Frontend mit VUE
QFQ Frontend das fuer die Formulare verantwortlich is, mit Vue neu schreiben.

  • Die Kommunikation zwischen Vue und Backend sollte auschliesslich ueber API stattfinden. Das Frontend entscheidet sich, ein Formular zu rendern und holt dann die noetigen Daten zu dem Formular via REST vom Backend
  • Pro Formular gibt es eine JSON struktur die sowohl fuer die Beschreibung des Formulars als auch fuer dessen Inhalte genutzt wird. (dies setzt voraus, dass Formulare nicht mehr in der Datenbank sondern in Dateien gespeichert werden)
    • Beispielsweise existiert das Feld "value" wie bisher. Dieses enthaelt weiterhin die SQL query, die von dem Backend interpretiert wird. Zusaetlzlich enthaelt das JSON Formularelement aber auch noch das Attribut "currentValue", dieses enthaelt dann den Inhalt, der tatsaechlich im Formularelement steht und dem Benutzer angezeigt wird. Beim Submitten eines Formulars wird dann auch das "currentValue" in der gleichen JSON Struktur uebergeben.
  • der name von Formular und Formularelementen dient als eindeutige referenz, bzw. als eindeutige ID. Die namen muessen also weiterhin eindeutig bleiben.
  • das Backend sendet nur die JSON felder mit, die das Frontend benoetigt. Beispielsweise sendet das Backend das "value" feld nicht mit, aber das "currentValue" berechnet er und sendet es in dieser Struktur mit.
  • das Absenden eines Formulars wird wahrscheinlich auch gleich per REST api und nicht mehr ueber POST passieren, damit man ueberall mit der JSON struktur arbeiten kann.
  • Das Parameter Feld wird aufgeloest und die moeglichen Parameter werden direkt attribute des Felds
  • Das Vue Frontend enthaelt das Formular als JSON mit den fuer das Frontend relevanten Attributen.
  • Fuer jeden Typen eines Formularelements wird ein Component von Vue gerendert
  • Die JSON daten zu einem Formularelement werden direkt an das Component weitergereicht.
    • So koennen zwischen Backend und Formularelementen "parameter" definiert werden, ohne dass man am rest vom Code etwas anpassen muss.
toml-format.html (8.88 KB) toml-format.html Marc Egger, 18.06.2020 11:35
toml-format.html.pdf (67.6 KB) toml-format.html.pdf Marc Egger, 18.06.2020 11:40

Associated revisions

Revision 1e5f39ff (diff)
Added by Marc Egger 4 months ago

Refs #10120 Teste form zu json

Revision 6c7db184 (diff)
Added by Marc Egger 4 months ago

Refs #10120 get default values for Form table

Revision 4799d6bc (diff)
Added by Marc Egger 3 months ago

Refs #10120 filter non default columns from form and formElements

Revision d3fe1f7e (diff)
Added by Marc Egger 3 months ago

Refs #10120 build toml, current toml parser needs php 7.1!

Revision 1fb238c5 (diff)
Added by Marc Egger 3 months ago

Refs #10120 add git-submodules to "make bootstrap"

Revision bdc1316e (diff)
Added by Marc Egger 3 months ago

Refs #10120 add yosymfony/parser-utils as submodule. now parsing works

Revision 957e2d91 (diff)
Added by Marc Egger 3 months ago

Refs #10120 add git-submodules to "make basic" for deployment

Revision d107a986 (diff)
Added by Marc Egger 3 months ago

Refs #10120 test multiline strings TOML parser

Revision 324207fb (diff)
Added by Marc Egger 3 months ago

Refs #10120 load form from file to database, not finished

Revision d3d05439 (diff)
Added by Marc Egger 3 months ago

Refs #10120 load form from file to database, still not finished

Revision 31920a8c (diff)
Added by Marc Egger 3 months ago

Refs #10120 update and insert form work, todo: FormElements

Revision b72e479b (diff)
Added by Marc Egger 3 months ago

Refs #10120 update and insert formElement work, todo: Delete Form/FormElement

Revision c16c82c7 (diff)
Added by Marc Egger 3 months ago

Refs #10120 remove form update. delete and insert always.

Revision 8a937d21 (diff)
Added by Marc Egger 3 months ago

Refs #10120 almost finished with container referencing in form file

Revision fbf9a433 (diff)
Added by Marc Egger 3 months ago

Refs #10120 containers work & form is deleted from DB if file not readable

Revision 9f351281 (diff)
Added by Marc Egger 3 months ago

Refs #10120 remove unused code: non-default column filtering, update FormElement.

Revision 3557cdb2 (diff)
Added by Marc Egger 3 months ago

Refs #10120 docstrings cleanup

Revision df7ee54e (diff)
Added by Marc Egger 3 months ago

Refs #10120 load form from file if it is opened in Form-Editor

Revision 7d6ca4d0 (diff)
Added by Marc Egger 3 months ago

Refs #10120 Dirty.php: add error hint, FormAsFile.php: fix CWD file path problem when API

Revision 6674f4ae (diff)
Added by Marc Egger 3 months ago

Refs #10120 export form on save works

Revision c5132b1f (diff)
Added by Marc Egger 3 months ago

Refs #10120 all basic functionality implemented. Needs testing.

Revision f416e94d (diff)
Added by Marc Egger 2 months ago

Refs #10120 fix bug: isFormOrFormElement returned "" instead of false since return type was ": string"

Revision a9a26973 (diff)
Added by Marc Egger 2 months ago

Refs #10120 coersion to int not necessary. PHP does it automatically due to type hint.

Revision 79def3bf (diff)
Added by Marc Egger 2 months ago

Refs #10120 add strict_types to make sure the previous bug won't be repeated.

Revision 3ba5f4fe (diff)
Added by Marc Egger 2 months ago

Refs #10120 add return type to function

Revision c2b35d31 (diff)
Added by Marc Egger 2 months ago

Refs #10120 creating Form/FormElement added

Revision 9d966f75 (diff)
Added by Marc Egger 2 months ago

Refs #10120 allow form name change

Revision 2541d843 (diff)
Added by Marc Egger 2 months ago

Refs #10120 update all forms when report operates on Form/FormElement. (unfinished)

Revision 3de494ea (diff)
Added by Marc Egger 2 months ago

Refs #10120 update all forms when report operates on Form/FormElement. (finished)

Revision a0778931 (diff)
Added by Marc Egger 2 months ago

Refs #10120 add docstring

Revision ae0483ab (diff)
Added by Marc Egger 2 months ago

Refs #10120 when form path is created, export all forms from DB

Revision ce1a3871 (diff)
Added by Marc Egger 2 months ago

Refs #10120 add column fileStats to Form Table definition

Revision 802ef88d (diff)
Added by Marc Egger 2 months ago

Refs #10120 export forms after all UPDATE statements which are not called by doForm()

Revision a32a7d3d (diff)
Added by Marc Egger 2 months ago

Refs #10120 finetune export and import forms on Database update

Revision 2e7081ee (diff)
Added by Marc Egger 2 months ago

Refs #10120 finished checking for UPDATE/INSERT/DELETE statements which could operate on Form/FormElement

Revision 97501ec0 (diff)
Added by Marc Egger 2 months ago

Refs #10120 import form on request Dirty & delete stale formElements as a precaution

Revision 0f2659c6 (diff)
Added by Marc Egger 2 months ago

Refs #10120 insertForm(): update filestats at the end instead of with form insert

Revision e8d15ede (diff)
Added by Marc Egger 2 months ago

Refs #10120 fix minor bug + remove Git Submodule (was for TOML parser)

Revision 55949995 (diff)
Added by Marc Egger 2 months ago

Refs #10120 remov return type ?string since ? is not supported by the PHP version on webwork16. very sad.

Revision 7c4b8766 (diff)
Added by Marc Egger 2 months ago

Refs #10120 remove return type ?string since ? is not supported by the PHP version of the gitlab runner. very sad.

Revision 966bace2 (diff)
Added by Marc Egger 2 months ago

Refs #10120 remove return type void since it is not supported by the PHP version of the gitlab runner. very sad.

Revision e6a7f746 (diff)
Added by Marc Egger 2 months ago

Refs #10120 Dirty.php: remove form import since it breaks unittests and it is not important

Revision cf68a1ea (diff)
Added by Marc Egger 2 months ago

Refs #10120 add form path to the QFQ extension settings and move constants to constants.php

Revision d41f0f74 (diff)
Added by Marc Egger 2 months ago

Refs #10120 extract sql queries which are used multiple times

Revision acd786c5 (diff)
Added by Marc Egger 2 months ago

Refs #10120 remove unnecessary log records in Selenium test application

Revision 3a84ac5e (diff)
Added by Marc Egger 2 months ago

Refs #10120 cleanup todo comments

Revision f4cfb74a (diff)
Added by Marc Egger 2 months ago

Refs #10120 add fileStats column to sql update and raise qfq version

Revision 6267461b (diff)
Added by Marc Egger 2 months ago

Refs #10120 DatbaseUpdate.php: Move form as file code before version number update

Revision b5ea4b78 (diff)
Added by Marc Egger about 2 months ago

Refs #10120 cleanup todo comments

History

#1 Updated by Marc Egger 7 months ago

  • Description updated (diff)

#2 Updated by Marc Egger 7 months ago

  • Status changed from New to Priorize

#3 Updated by Marc Egger 5 months ago

  • Status changed from Priorize to Some day maybe

#4 Updated by Marc Egger 4 months ago

Alternativ könnte man das TOML format benutzen um forms zu speichern.
Vorteile: humen-usable, comments, less complex than YAML

Python hat sich entschieden für Konfigurationsfiles auf TOML umzusteigen. Dokumentation zum Entscheidungsprozess:  https://www.python.org/dev/peps/pep-0518/#other-file-formats

Leider existiert kein TOML parser implementiert in PHP für die aktuelle Version von TOML.
Neuste TOML version: v1.0.0-rc.1
Neuste PHP TOML implementation: v0.4.0
Liste der Implementationen: https://github.com/toml-lang/toml/wiki

Ein form in TOML abgebildet wuerde so aussehen:

name = 'personFormular'
title = 'Person editieren'
sqlAfter = '{{INSERT ... }}'
"..." = '...'

[[formElements]]
name = 'vormane'
label = 'Vorname'
type = 'text'
value = '{{SELECT p.vorname FROM p AS PERSON where ... }}'
sqlAfter = '...'
currentValue = 'Marc'
"..." = '...'

[[formElements]]
name = 'Nachname'
label = 'Nachname'
type = 'text'
value = '{{SELECT p.nachname FROM p AS PERSON where ... }}'
sqlAfter = '...'
currentValue = 'Egger'
"..." = '...'

#5 Updated by Marc Egger 4 months ago

  • Status changed from Some day maybe to Priorize

#6 Updated by Marc Egger 4 months ago

  • Subject changed from Form mit Vue to Form als File (eventuel mit Vue)

#7 Updated by Marc Egger 4 months ago

  • Description updated (diff)
  • Priority changed from Normal to High

#8 Updated by Marc Egger 4 months ago

  • Status changed from Priorize to In Progress

#9 Updated by Marc Egger 3 months ago

  • Description updated (diff)

#10 Updated by Marc Egger 3 months ago

  • Description updated (diff)

#11 Updated by Marc Egger 3 months ago

TOML

Tatsächlich scheint Python TOML 0.4 zu benutzen. Denn der Parser vo dem sie sprechen ist nachwievor nur v0.4 kompatiebel ( https://pypi.org/project/pytoml/ ).
Das Review das für die Pzthon Entscheidung geschrieben wurde, wurde zur Zeiten von TOML 0.4 gemacht und schon damals war klar, dass das Fileformat schon sehr stabiel ist: https://gist.github.com/njsmith/78f68204c5d969f8c8bc645ef77d4a8f#toml

Looking at the changelist from v0.4 to v1.0 there are only very few changes between v0.4 and v1.0 which might affect us:

  • dotted Keys are not allowed in v0.4
  • raw tab characters in basic strings and muli-line basic strings are not allowed in v0.4
  • the values of arrays must all be of the same type in v0.4

In the attached document I listed all the changes and categorized them by relevance. 
toml-format.html (Changes by relevance for QFQ)

#12 Updated by Marc Egger 3 months ago

The same Document again but as PDF:  toml-format.html.pdf

#13 Updated by Marc Egger about 1 month ago

  • Subject changed from Form als File (eventuel mit Vue) to Form als File

Fertig implementiert.

TODO:
- Mit Carsten die Notes in FormAsFile.php besprechen
- Selenium tests schreiben

#14 Updated by Marc Egger about 1 month ago

  • Status changed from In Progress to Priorize

#15 Updated by Marc Egger about 1 month ago

  • Priority changed from High to Normal

Also available in: Atom PDF