×

Master object

If you want to wallpaper or paint a room, you should prepare it and make a minimal calculation of the square meters.

Tables for the datastructure:

  • tpprojects: table of you projects
  • tpareas: table of the areas like walls or ceiling
  • tpsurfaces: table of the surface sizes you need to add or substract

So we have a structure with 2 nested areas:

  • projects[]
    • projectID
    • ...
    • qm (squaremeters)
    • areas[]
      • areaID
      • ...
      • qm (squaremeters)
      • surfaces[]
        • surfaceID
        • ...
        • qm (squaremeters)

Developer

Data structure

Tables for the datastructure:

  • tpprojects: table of you projects
  • tpareas: table of the areas like walls or ceiling
  • tpsurfaces: table of the surface sizes you need to add or substract

datastructure in JavaScript:

Datadefinition

for the form

  • k8form
    • fields[]
      • ...
      • "fieldwraptemplate":"{{area_container}}"
    • html{}
      • area_container="<HTML>"
        file: tpprojects_masterobject_container_record.html
  • js_rec_record
    • areas
      file: tpprojects_masterobject_areas_record.html
    • surfaces
      file: tpprojects_masterobject_surfaces_record.html

kitsamples/tpprojects/tpprojects.json

HTML

kitsamples/tpprojects/tpprojects_masterobject_area_container.html

kitsamples/tpprojects/tpprojects_masterobject_areas_record.html

index_areas is automatically replaced by the index

kitsamples/tpprojects/tpprojects_masterobject_surfaces_record.html

JavaScript

kitsamples/tpprojects/tpprojects.js

Call back functions

The call back functions are:

  • cbnewRecord(...)
  • cbChange(...)

cbnewRecord

Each time a new record or sub record is added the call back function "cbnewRecord" is called. A new record is appended by this events:

  • new, initform
  • after click in the list by displaying the object
  • after click of new for a new array element
  • by by focus in the last field
This is the function with parameters:

Example:

  • <input name="areas[0][surfaces][0][surfaceID]">

Example for namestr:

  • areas[0][surfaces][0]

example for indexarray:

  • [0,"surfaces",0]

functions for the object

If somewhere in the datastructure a button is pressed, the position can be identified by the "indexarray".