CurryInfo: spicey-4.2.0 / Spicey.EntitiesToHtmlGeneration.toDetailsView

definition: Info
 
toDetailsView :: ToHtmlGenerator
toDetailsView erdname (Entity entityName attrlist) relationships allEntities =
 let manyToManyEntities = manyToMany allEntities (Entity entityName attrlist)
     manyToOneEntities  = manyToOne (Entity entityName attrlist) relationships
     eName = lowerFirst entityName
     evar  = (1,eName)
  in
 cmtfunc
  ("The detailed view of a " ++ entityName ++ " entity in HTML format.\n" ++
   if null manyToOneEntities && null manyToManyEntities
     then ""
     else "It also takes associated entities for every associated entity type.")
  (thisModuleName erdname, lowerFirst entityName ++ "ToDetailsView")
  2
  Public
  -- function type
  (withHTMLContext $
     foldr CFuncType (listType htmlTVar)
           ([baseType (model erdname, entityName)] ++
            (map ctvar manyToOneEntities) ++ -- defaults for n:1
            (map (\ (name,_) -> listType (ctvar name)) manyToManyEntities)
           )
  )
  [CRule
    ( -- parameters
      [CPVar evar] ++
       map (\ (name, varId) -> CPVar (varId,"related"++name))
            (zip manyToOneEntities [2..]) ++
       map (\ ((ename,erel), i) -> CPVar (i, lowerFirst erel ++ ename ++ "s"))
           (zip manyToManyEntities [(length manyToOneEntities + 2)..])
    )
    (CSimpleRhs
       (list2ac [
          applyF (spiceyModule, "spTable") [
            applyF (pre "map")
            [
              CLambda [tuplePattern [CPVar(2, "label"), CPVar(3, "value")]]
                      (list2ac [cvar "label", cvar "value"]),
              applyF (pre "zip")
                     [constF (thisModuleName erdname, eName++"LabelList"),
                      CVar (2,"detailedView")]
            ]
          ]
        ]
      )
    [CLocalPat (CPVar (2,"detailedView"))
       (CSimpleRhs
         (list2ac
            (map (\a -> list2ac [
                          applyF (attributeToConverter a)
                              [applyF (model erdname, eName ++ attributeName a)
                                      [CVar evar]]])
                 attrlist ++
             map (\ (name,varId) ->
                    list2ac [applyF (html "htxt")
                                    [applyF (thisModuleName erdname,
                                             lowerFirst name ++ "ToShortView")
                                            [CVar (varId,"related"++name)]]])
                 (zip manyToOneEntities [2..]) ++
             map (\ ((ename,erel),varId) ->
                    list2ac
                      [applyF (html "htxt")
                         [applyF (pre "unwords")
                            [applyF (pre "map")
                               [applyF (thisModuleName erdname,
                                        lowerFirst ename ++ "ToShortView") [],
                                CVar (varId, lowerFirst erel ++ ename++"s")]]]])
                 (zip manyToManyEntities [(length manyToOneEntities + 2)..])
            )
        )
        [])
    ])
  ]
demand: Info
 argument 2
deterministic: Info
 deterministic operation
failfree: Info
 <FAILING>
indeterministic: Info
 referentially transparent operation
infix: Info
 no fixity defined
iotype: Info
 {(_,{Entity},_,_) |-> _}
name: Info
 toDetailsView
precedence: Info
 no precedence defined
result-values: Info
 _
signature: Info
 String -> Database.ERD.Entity -> [Database.ERD.Relationship]
-> [Database.ERD.Entity] -> AbstractCurry.Types.CFuncDecl
solution-complete: Info
 operation might suspend on free variables
terminating: Info
 possibly non-terminating
totally-defined: Info
 possibly non-reducible on same data term