|
definition: |
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: |
argument 2 |
|
deterministic: |
deterministic operation |
|
failfree: |
<FAILING> |
|
indeterministic: |
referentially transparent operation |
|
infix: |
no fixity defined |
|
iotype: |
{(_,{Entity},_,_) |-> _}
|
|
name: |
toDetailsView |
|
precedence: |
no precedence defined |
|
result-values: |
_ |
|
signature: |
String -> Database.ERD.Entity -> [Database.ERD.Relationship] -> [Database.ERD.Entity] -> AbstractCurry.Types.CFuncDecl |
|
solution-complete: |
operation might suspend on free variables |
|
terminating: |
possibly non-terminating |
|
totally-defined: |
possibly non-reducible on same data term |