Commit 2375f81c authored by Rinus Plasmeijer's avatar Rinus Plasmeijer
Browse files

optie om naar database te schrijven toegevoegd in htmlRefFormLib

read only gedoe weggehaald...
parent 864bed81
......@@ -40,3 +40,7 @@ MyDir :: ServerKind -> String // name of directory in which persistent form
traceHtmlInput :: ServerKind (Maybe String) -> BodyTag // for debugging showing the information received from browser
// low level encoding and decoding
encodeString :: String -> String
decodeString :: String -> *String
......@@ -241,8 +241,8 @@ where
| isJust exception
= ([Txt "Sorry, an exception occurred, something went wrong, you have to try again"],hst)
# (_,hst) = mkEditForm (Set,pFormId uniquename (0,person)) hst // store person info
# (_,hst) = mkEditForm (Set,pFormId uniquepaper (0,paperf.value)) hst // store paper info
# (_,hst) = mkEditForm (Set,storeFormId uniquename (0,person)) hst // store person info
# (_,hst) = mkEditForm (Set,storeFormId uniquepaper (0,paperf.value)) hst // store paper info
# (_,hst) = guestAccountStore (\(_,guest) -> (False,account)) hst // kick out guest
= ([B [] "Paper submitted.",Br, Txt "Use your account to update provided information",Br,
Txt "and stay in touch with us",Br],hst)
......@@ -67,3 +67,10 @@ derefPersons :: [RefPerson] !*HSt -> ([Person],!*HSt)
derefReports :: [RefReport] !*HSt -> ([Maybe Report],!*HSt)
getAllPersons :: !ConfAccounts !*HSt -> ([RefPerson],[Person],!*HSt)
getAllMyReports :: !ConfAccount !ConfAccounts !*HSt -> ([(Int,[(Person, Maybe Report)])],!*HSt)
// global setting to store either in files or in a database
//storageOption :== Persistent // Choose this one to store in files
storageOption :== Database // Choose this one to store in a database
storeFormId :== if (storageOption == Persistent) pFormId dbFormId
......@@ -11,11 +11,11 @@ import StdListExtensions
AccountsDB :: !Init !ConfAccounts *HSt -> (ConfAccounts,!*HSt) // conf management database
AccountsDB init accounts hst
# accounts = setInvariantAccounts accounts // ensure that all links are correct
= universalDB (init,accounts,uniqueDBname) (\s a -> invariantLogAccounts s a + invariantConfAccounts s a) hst
= universalDB (init,storageOption,accounts,uniqueDBname) (\s a -> invariantLogAccounts s a + invariantConfAccounts s a) hst
PaperNrStore :: !(Int -> Int) *HSt -> (Int,!*HSt) // paper counter
PaperNrStore fun hst
# (intf,hst) = mkStoreForm (Init,{pFormId "LastPaperNr" 1 & mode = NoForm}) fun hst
# (intf,hst) = mkStoreForm (Init,{storeFormId "LastPaperNr" 1 & mode = NoForm}) fun hst
= (intf.value,hst)
// utility access functions for dereferencing
......@@ -61,19 +61,19 @@ editorRefPerson :: !(InIDataId RefPerson) !*HSt -> (Form Person,!*HSt)
editorRefPerson (init,formid) hst
# (RefPerson refperson) = formid.ival
# (Ref2 name) = refperson
= universalRefEditor (init,reuseFormId formid refperson) (invariantPerson name) hst
= universalRefEditor storageOption (init,reuseFormId formid refperson) (invariantPerson name) hst
editorRefPaper :: !(InIDataId RefPaper) !*HSt -> (Form Paper,!*HSt)
editorRefPaper (init,formid) hst
# (RefPaper refpaper) = formid.ival
# (Ref2 name) = refpaper
= universalRefEditor (init,reuseFormId formid refpaper) (invariantPaper name) hst
= universalRefEditor storageOption (init,reuseFormId formid refpaper) (invariantPaper name) hst
editorRefReport :: !(InIDataId RefReport) !*HSt -> (Form (Maybe Report),!*HSt)
editorRefReport (init,formid) hst
# (RefReport refreport) = formid.ival
# (Ref2 name) = refreport
= universalRefEditor (init,reuseFormId formid refreport) (invariant name) hst
= universalRefEditor storageOption (init,reuseFormId formid refreport) (invariant name) hst
where
invariant name Nothing = Ok
invariant name (Just report) = invariantReport name report
......@@ -82,7 +82,7 @@ editorRefDiscussion :: !(InIDataId RefDiscussion) !*HSt -> (Form Discussion,!*HS
editorRefDiscussion (init,formid) hst
# (RefDiscussion refdiscus) = formid.ival
# (Ref2 name) = refdiscus
= universalRefEditor (init,reuseFormId formid refdiscus) (const Ok) hst
= universalRefEditor storageOption (init,reuseFormId formid refdiscus) (const Ok) hst
// specialized idata forms
......
......@@ -187,12 +187,12 @@ discussPapersPage account accounts hst
# selectedpaper = allpapernrs!!selected
# mbpaperrefinfo = getPaperInfo selectedpaper accounts
# (RefDiscussion (Ref2 name)) = (fromJust mbpaperrefinfo).discussion
# (disclist,hst) = universalDB (Init,Discussion [],name) (\_ _ -> Ok) hst
# (disclist,hst) = universalDB (Init,storageOption,Discussion [],name) (\_ _ -> Ok) hst
# (time,date,hst) = getTimeAndDate hst
# (newsubmit,newdiscf,hst)
= mkSubStateForm (if pdfun.changed Set Init, nFormId "sh_dpp_adddisc" (TS 80 "")) disclist
(\s -> addItemTextInput (account.login.loginName) time date (toS s)) hst
# (_,hst) = if newsubmit (universalDB (Set,newdiscf.value,name) (\_ _ -> Ok) hst) (undef,hst)
# (_,hst) = if newsubmit (universalDB (Set,storageOption,newdiscf.value,name) (\_ _ -> Ok) hst) (undef,hst)
# (disclistf,hst) = mkEditForm (Set,sdFormId "sh_show_disc" newdiscf.value) hst
# (newsubmit,newdiscf,hst)
= if newsubmit (mkSubStateForm (Set,nFormId "sh_dpp_adddisc" (TS 80 "")) disclist
......
......@@ -14,9 +14,15 @@ derive gParse Record
derive gPrint Record
derive gerda Record
Start world = doHtmlServer MyPage world
Start world = doHtmlServer MyPage5 world
//Start world = doHtmlServer testdb world
MyPage5 hst
# (balancedtree,hst) = mkEditForm (Init,pDFormId "test" [0]) hst
= mkHtml "Balanced Tree"
[ H1 [] "Balanced Tree"
, BodyTag balancedtree.form
] hst
:: Record = {name :: String, address :: String, zipcode :: Int}
......@@ -36,7 +42,7 @@ MyPage4 hst
, BodyTag myrecord.form
] hst
myBalancedTree = dbFormId "BalancedTree" (fromListToBalTree [0])
myBalancedTree = pDFormId "BalancedTree" (fromListToBalTree [0])
mySortedList = nFormId "SortedList" [0]
MyPage hst
......
......@@ -46,7 +46,7 @@ MainModule
NeverMemoryProfile: False
NeverTimeProfile: False
StrictnessAnalysis: True
ListTypes: InferredTypes
ListTypes: NoTypes
ListAttributes: True
Warnings: True
Verbose: True
......@@ -62,11 +62,11 @@ MainModule
DclOpen: False
Icl
WindowPosition
X: 124
Y: 26
SizeX: 932
X: 12
Y: 10
SizeX: 892
SizeY: 556
IclOpen: False
IclOpen: True
LastModified: No 0 0 0 0 0 0
OtherModules
Module
......@@ -671,15 +671,15 @@ OtherModules
Dcl
WindowPosition
X: 77
Y: -17
Y: 0
SizeX: 806
SizeY: 566
DclOpen: False
Icl
WindowPosition
X: 306
Y: 0
SizeX: 779
X: 106
Y: 7
SizeX: 999
SizeY: 574
IclOpen: False
LastModified: No 0 0 0 0 0 0
......@@ -4318,10 +4318,10 @@ OtherModules
DclOpen: False
Icl
WindowPosition
X: -2
Y: 16
SizeX: 897
SizeY: 516
X: -29
Y: 26
SizeX: 932
SizeY: 504
IclOpen: False
LastModified: No 0 0 0 0 0 0
Module
......@@ -4764,29 +4764,28 @@ Static
Path: {Application}\Libraries\StdEnv\Clean System Files\_startup2.o
Path: {Application}\Libraries\StdEnv\Clean System Files\_system.o
Path: {Project}\Clean System Files\balanceTree.o
Path: {Application}\Libraries\htmlGEC\Clean System Files\htmlRefFormlib.o
Path: {Application}\Libraries\htmlGEC\Clean System Files\StdHtml.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdCharList.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdTuple.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdOrdList.o
Path: {Application}\Libraries\StdEnv\Clean System Files\_SystemEnum.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdEnum.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdList.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdFile.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdString.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdReal.o
Path: {Application}\Libraries\StdEnv\Clean System Files\_SystemArray.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdArray.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdClass.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdChar.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdMisc.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdInt.o
Path: {Application}\Libraries\Dynamics\extension\Clean System Files\StdCleanTypes.o
Path: {Application}\Libraries\Dynamics\implementation\windows\Clean System Files\_SystemDynamic.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdOverloaded.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdEnv.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdBool.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdInt.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdMisc.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdChar.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdClass.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdArray.o
Path: {Application}\Libraries\StdEnv\Clean System Files\_SystemArray.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdReal.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdString.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdFile.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdList.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdEnum.o
Path: {Application}\Libraries\StdEnv\Clean System Files\_SystemEnum.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdOrdList.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdTuple.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdCharList.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdFunc.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdEnv.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdOverloaded.o
Path: {Application}\Libraries\Dynamics\implementation\windows\Clean System Files\_SystemDynamic.o
Path: {Application}\Libraries\Dynamics\extension\Clean System Files\StdCleanTypes.o
Path: {Application}\Libraries\htmlGEC\Clean System Files\StdHtml.o
Path: {Application}\Libraries\htmlGEC\Clean System Files\htmlFormData.o
Path: {Application}\Libraries\htmlGEC\Clean System Files\htmlDataDef.o
Path: {Application}\Libraries\htmlGEC\Clean System Files\htmlStyleDef.o
......@@ -4797,9 +4796,9 @@ Static
Path: {Application}\Libraries\StdEnv\Clean System Files\_SystemEnumStrict.o
Path: {Application}\Libraries\Gerda\Clean System Files\Gerda.o
Path: {Application}\Libraries\StdLib\Clean System Files\StdMaybe.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdDebug.o
Path: {Application}\Libraries\Gerda\Clean System Files\odbc.o
Path: {Application}\Libraries\Gerda\Clean System Files\odbccp.o
Path: {Application}\Libraries\StdEnv\Clean System Files\StdDebug.o
Path: {Application}\Libraries\ArgEnvWindows\Clean System Files\ArgEnv.o
Path: {Application}\Libraries\htmlGEC\Clean System Files\htmlStylelib.o
Path: {Application}\Libraries\htmlGEC\Clean System Files\htmlHandler.o
......@@ -4916,6 +4915,7 @@ Static
Path: {Application}\Libraries\StdLib\Clean System Files\StdArrayExtensions.o
Path: {Application}\Libraries\htmlGEC\Clean System Files\htmlButtons.o
Path: {Application}\Libraries\htmlGEC\Clean System Files\htmlFormlib.o
Path: {Application}\Libraries\htmlGEC\Clean System Files\htmlRefFormlib.o
Path: {Application}\Libraries\htmlGEC\Clean System Files\htmlArrow.o
Path: {Application}\Libraries\GEC\GEC Implementation\Clean System Files\StdArrow.o
Path: {Application}\Libraries\Generics\Clean System Files\GenEq.o
......
......@@ -7,6 +7,7 @@ import htmlTask
derive gForm []
derive gUpd []
:: Void = Void
//Start world = doHtmlServer (mkflow CoffeeMachineInf) world
......@@ -15,14 +16,27 @@ derive gUpd []
//Start world = doHtmlServer (mkflow CreateMusic) world
//Start world = doHtmlServer (mkflow (Quotation myQuotation)) world
//Start world = doHtmlServer (mkflow travel) world
Start world = doHtmlServer (mkflow twotasks) world
Start world = doHtmlServer (mkflow twotasks2) world
where
mkflow tasks hst
# (html,hst) = startTask tasks hst
= mkHtml "test" html hst
twotasks2 tst
# ((tboss,tsecr),tst) = mkLTaskRTC2 "name" 25 tst // split name task
= PTasks
[( "employee1", tsecr) // assign name task
,( "boss", STask "ervoor" 0 `bind`
\bi -> tboss (STask "DoIt" bi) `bind`
\si -> STask "erna" si
)
] tst
:: RecForm = {name :: String, number:: Int}
twotasks tst
# ((tbname,tname),tst) = mkLTask "name" (STask "name" "") tst // split name task
# ((tbnumber,tnumber),tst) = mkLTask "number" (STask "number" 0) tst // split number task
......
......@@ -161,6 +161,7 @@ where
instance == Lifespan
where
(==) Database Database = True
(==) Persistent Persistent = True
(==) PersistentRO PersistentRO = True
(==) Session Session = True
......
......@@ -9,12 +9,12 @@ import StdEnv, htmlHandler, htmlButtons
:: Ref2 a = Ref2 String
instance == (Ref2 a)
ref2EditForm :: !(InIDataId a) !(InIDataId (Ref2 a)) !*HSt -> (Form a,!*HSt) | iData, TC a
invokeRefEditor :: (!(InIDataId b) !*HSt -> (Form d,!*HSt)) (InIDataId b) !*HSt -> (Form b,!*HSt)
ref2EditForm :: !(InIDataId a) !(InIDataId (Ref2 a)) !*HSt -> (Form a,!*HSt) | iData, TC a
invokeRefEditor :: (!(InIDataId b) !*HSt -> (Form d,!*HSt)) (InIDataId b) !*HSt -> (Form b,!*HSt)
universalRefEditor :: !(InIDataId (Ref2 a)) !(a -> Judgement) !*HSt -> (Form a,!*HSt) | iData, TC a
universalRefEditor :: !Lifespan !(InIDataId (Ref2 a)) !(a -> Judgement) !*HSt -> (Form a,!*HSt) | iData, TC a
universalDB :: !(!Init,!a,!String) !(String a -> Judgement) !*HSt -> (a,!*HSt) | iData, TC a
universalDB :: !(!Init,!Lifespan,!a,!String) !(String a -> Judgement) !*HSt -> (a,!*HSt) | iData, TC a
// Usefull for exception handling
......
This diff is collapsed.
......@@ -9,6 +9,9 @@ import StdHtml
:: Task a :== St *TSt a // an interactive task
:: IDataFun a :== St *HSt (Form a) // an iData Form
mkLTaskRTC2 :: String a *TSt -> (((Task a) -> (Task a),Task a),*TSt) | iData, TC a
/*
startTask :: lift iData to iTask domain
mkTask :: promote TSt state function to an interactive Task, i.e. task will only be called when it is its turn
......
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment