Project

General

Profile

Actions

Feature #10120

closed

Form als File

Added by Marc Egger about 4 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Marc Egger
Target version:
Start date:
13.02.2020
Due date:
% Done:

0%

Estimated time:
Discuss:
Prio Planung:
Vote:

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.

Files

toml-format.html toml-format.html 8.88 KB Marc Egger, 18.06.2020 11:35
toml-format.html.pdf View toml-format.html.pdf 67.6 KB Marc Egger, 18.06.2020 11:40
Actions #1

Updated by Marc Egger about 4 years ago

  • Description updated (diff)
Actions #2

Updated by Marc Egger about 4 years ago

  • Status changed from New to Priorize
Actions #3

Updated by Marc Egger almost 4 years ago

  • Status changed from Priorize to Some day maybe
Actions #4

Updated by Marc Egger almost 4 years 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'
"..." = '...'
Actions #5

Updated by Marc Egger almost 4 years ago

  • Status changed from Some day maybe to Priorize
Actions #6

Updated by Marc Egger almost 4 years ago

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

Updated by Marc Egger almost 4 years ago

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

Updated by Marc Egger almost 4 years ago

  • Status changed from Priorize to In Progress
Actions #9

Updated by Marc Egger almost 4 years ago

  • Description updated (diff)
Actions #10

Updated by Marc Egger almost 4 years ago

  • Description updated (diff)
Actions #11

Updated by Marc Egger almost 4 years 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)

Actions #12

Updated by Marc Egger almost 4 years ago

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

Actions #13

Updated by Marc Egger over 3 years 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

Actions #14

Updated by Marc Egger over 3 years ago

  • Status changed from In Progress to Priorize
Actions #15

Updated by Marc Egger over 3 years ago

  • Priority changed from High to Normal
Actions #16

Updated by Marc Egger over 3 years ago

  • Status changed from Priorize to In Progress
Actions #17

Updated by Carsten Rose about 3 years ago

  • Description updated (diff)
Actions #18

Updated by Marc Egger about 3 years ago

  • Status changed from In Progress to Closed
Actions #19

Updated by Carsten Rose almost 3 years ago

  • Target version changed from next5 to 21.3.1
Actions

Also available in: Atom PDF