Commit 3237fbe0 authored by Rinus Plasmeijer's avatar Rinus Plasmeijer
Browse files

gForm can now also deal with a Set

parent 52e2527c
......@@ -18,7 +18,7 @@ mainEntrance hst
loginhandling :: *HSt -> ([BodyTag],*HSt)
loginhandling hst
# (accounts,hst) = editAccounts Display Init [initManagerAccount initManagerLogin] hst
# (accounts,hst) = AccountsDB Display Init [initManagerAccount initManagerLogin] hst
// read out all accounts read only
# (mblogin,loginBody,hst) = loginPage accounts.value hst // set up a login page
= case mblogin of // check result of login procedure
......@@ -54,8 +54,7 @@ doConfPortal account accounts hst
# (navButtons,hst) = navigationButtons account.state hst // setup proper set of navigation buttons
# (_,hst) = ReportStore (\_ -> OK) hst // set global store to "all is fine"
# (currPage,hst) = currPageStore (homePage account.state) navButtons.value hst // determine which current page to display
# ((_,_),navBody,hst)
= handleCurrPage currPage.value account accounts hst // and handle the corresponding page
# (navBody,hst) = handleCurrPage currPage.value account accounts hst // and handle the corresponding page
# ((ok,message),hst)= ReportStore id hst // see if an error has occured somewhere
= ( [ mkSTable2 [ [EmptyBody,B [] "Conference" <.||.> B [] "Manager ",Oeps ok message currPage.value]
, [mkColForm navButtons.form, EmptyBody, BodyTag navBody]
......@@ -101,27 +100,23 @@ where
currPageStore :: !CurrPage !(CurrPage -> CurrPage) *HSt -> (!Form CurrPage,!*HSt) // current page to display
currPageStore currpage cbf hst = mkStoreForm (Init, sFormId "cf_currPage" currpage) cbf hst
handleCurrPage :: CurrPage ConfAccount ConfAccounts *HSt
-> ((ConfAccount,ConfAccounts),[BodyTag],*HSt)
handleCurrPage :: CurrPage ConfAccount ConfAccounts *HSt -> ([BodyTag],*HSt)
handleCurrPage currPage account accounts hst
//# (papersform,hst) = papersStore [initPaper i (toString i) \\ i <- [0..3]] id hst
//# papers = papersform.value
= case currPage of
RootHomePage -> (account,accounts) <~ rootHomePage hst
RootHomePage -> rootHomePage hst
ModifyStates -> modifyStatesPage account accounts hst
// AssignPapers -> assignPapersPage papers states hst
// AssignConflict -> assignConflictsPage papers states hst
ChangePassword -> changePasswrdPage account accounts hst
ChangeInfo -> (account,accounts) <~ changeInfo account hst
// ListPapers -> (state,states) <~ showPapersPage papers loginState states hst
ChangeInfo -> changeInfo account hst
ListPapers -> showPapersPage account accounts hst
// RefereeForm -> refereeStatusPage papers loginState states hst
MemberHomePage -> (account,accounts) <~ memberHomePage hst
_ -> (account,accounts) <~ ([],hst)
where
(<~) infix
(<~) states (body,hst) = (states,body,hst)
MemberHomePage -> memberHomePage hst
_ -> ([],hst)
// the different pages the super user can choose from
......@@ -140,7 +135,7 @@ memberHomePage hst =
changePasswrdPage account accounts hst
# (mbaccount,body,hst) = changePasswordPage account hst
= case mbaccount of
Nothing -> ((account, accounts), body, hst)
Nothing -> (body, hst)
Just naccount -> handleCurrPage (homePage account.state)
naccount (changePassword naccount.login.password account accounts) hst
......
......@@ -30,25 +30,14 @@ derive gParse
// Naming convention of shared persistent information
uniqueDBname :== "conferenceDBS"
uniquePerson name :== Refto (name +++ ".person")
uniqueReport name :== Refto (name +++ ".report")
uniquePaper name :== Refto (name +++ ".paper")
uniqueDBname :== "conferenceDBS"
uniquePerson name :== name +++ ".person"
uniqueReport int name :== name +++ ".report" +++ "." +++ toString int
uniquePaper int name :== name +++ ".paper" +++ "." +++ toString int
// The used persistent global i-Data editors and stores
editAccounts :: !Mode !Init !ConfAccounts *HSt -> (Form ConfAccounts,!*HSt)
editPerson :: !Mode !Init !(Refto Person) *HSt -> (Form Person,!*HSt)
//getPerson :: !RefPerson *HSt -> (!Person,!*HSt)
//editReport :: (!Mode,!Init,(!RefReport,!Mode,!Init)) *HSt -> (Form RefReport,Form Report,!*HSt)
//getReport :: !RefReport *HSt -> (!Report,!*HSt)
//editPaper :: (!Mode,!Init,(!RefPaper,!Mode,!Init)) *HSt -> (Form RefPaper,Form Paper,!*HSt)
//getPaper :: !RefPaper *HSt -> (!Paper,!*HSt)
AccountsDB :: !Mode !Init !ConfAccounts *HSt -> (Form ConfAccounts,!*HSt)
......@@ -6,17 +6,14 @@ import loginAdmin, loginAdminIData
// global editors and stores
editAccounts :: !Mode !Init !ConfAccounts *HSt -> (Form ConfAccounts,!*HSt) // login administration database
editAccounts mode Init accounts hst
= mkEditForm (Init,
{pFormId uniqueDBname accounts
& mode = mode, lifespan = ifEdit mode Persistent PersistentRO}) hst
editAccounts mode Set accounts hst
= mkEditForm (Set,
{pFormId uniqueDBname accounts
& mode = mode, lifespan = ifEdit mode Persistent PersistentRO}) hst
// editor for shared structures...
AccountsDB :: !Mode !Init !ConfAccounts *HSt -> (Form ConfAccounts,!*HSt) // login administration database
AccountsDB mode init accounts hst
= mkEditForm (init,
{sFormId uniqueDBname accounts
& lifespan = ifEdit mode Persistent PersistentRO}
) hst
// general deRefto approach
editRefto :: (!Mode,!Init,(!(!Refto a,!a),!!Mode,!Init)) *HSt ->
(Form (Refto a),Form a,!*HSt) | gForm{|*|}, gUpd{|*|}, gPrint{|*|}, gParse{|*|}, TC a
......@@ -24,128 +21,121 @@ editRefto (rmode,rinit,((Refto s,a),pmode,pinit)) hst
= reftoEditForm rmode rinit (pinit,
{nFormId ("Refto_" +++ s) (Refto s, a) & mode = pmode}) hst
// reference to Persons
getPerson :: !(Refto Person) *HSt -> (!Person,!*HSt)
getPerson refperson hst
# (_,personf,hst) = editRefto (Display,Init,((refperson,createDefault),Display,Init)) hst
= (personf.value,hst)
setPerson :: !(Refto Person) !Person *HSt -> (!Person,!*HSt)
setPerson refperson person hst
# (_,personf,hst) = editRefto (Edit,Set,((refperson,person),Display,Init)) hst
= (personf.value,hst)
editPerson :: !Mode !Init !(Refto Person) *HSt -> (Form Person,!*HSt)
editPerson mode init (Refto person) hst
# (personv,hst) = getPerson (Refto person) hst // read out file
# (personf,hst) = mkEditForm (init,{sFormId person personv & mode = mode}) hst // make an editor
# (ok,msg) = invariantPerson personf.value // check invariants
# (_,hst) = ReportStore (addJudgement (ok,msg)) hst // report them
# (_,_,hst) = if (ok && mode == Edit) // store
(editRefto (Edit,Set,((Refto person,personf.value),Display,Init)) hst)
universalRefEditor :: !Mode !(a -> Judgement) !(Refto a) *HSt -> (Form a,!*HSt) | gForm{|*|}, gUpd{|*|}, gPrint{|*|}, gParse{|*|}, TC a
universalRefEditor mode invariant (Refto filename) hst
# (_,filef,hst) = editRefto (Display,Init,((Refto filename,createDefault),Display,Init)) hst // read out file
# (copyf,hst) = mkEditForm (Init,{sFormId filename filef.value & mode = mode}) hst // make an editor
# (ok,msg) = invariant copyf.value // check invariants
# (_,hst) = if (filename <> "") (ReportStore (addJudgement (ok,msg)) hst) (undef,hst) // report them
# (_,_,hst) = if (ok && mode == Edit) // write to file if ok
(editRefto (Edit,Set,((Refto filename,copyf.value),Display,Init)) hst)
(undef,undef,hst)
= (personf,hst)
editReport :: (!Mode,!Init,(!Refto Report,!Mode,!Init)) *HSt -> (Form (Refto Report),Form Report,!*HSt)
editReport (rmode,rinit,(Refto report,pmode,pinit)) hst
= editRefto (rmode,rinit,((Refto report,initReport),pmode,pinit)) hst
= (copyf,hst)
getReport :: !RefReport *HSt -> (!Report,!*HSt)
getReport (RefReport refreport) hst
# (refreportf,reportf,hst) = editReport (Display,Init,(refreport,Display,Init)) hst
= (reportf.value,hst)
// exported forms
editPaper :: (!Mode,!Init,(!Refto Paper,!Mode,!Init)) *HSt -> (Form (Refto Paper),Form Paper,!*HSt)
editPaper (rmode,rinit,(Refto paper,pmode,pinit)) hst
= editRefto (rmode,rinit,((Refto paper,initPaper paper),pmode,pinit)) hst
getPaper :: !RefPaper *HSt -> (!Paper,!*HSt)
getPaper (RefPaper refpaper) hst
# (refpaperf,paperf,hst) = editPaper (Display,Init,(refpaper,Display,Init)) hst
= (paperf.value,hst)
// specialized forms
gForm {|RefPerson|} (init,formid) hst = specialize myeditor (init,formid) hst
where
myeditor (init,formid) hst
# (RefPerson refperson) = formid.ival
# (personf,hst) = universalRefEditor Edit invariantPerson refperson hst
= ({personf & value = RefPerson refperson},hst)
// special idata
gForm {|[]|} gHa formid hst
= case formid.ival of
[x:xs]
# (x,hst) = gHa (subFormId formid (toString (length xs)) x) hst
# (xs,hst) = gForm {|*->*|} gHa (reuseFormId formid xs) hst
= ({changed = x.changed||xs.changed,form = x.form ++ xs.form,value = [x.value:xs.value]},hst)
[]
= ({changed = False,form = [],value = []},hst)
gForm {|Maybe|} ga formid hst
# elem = formid.ival
= case elem of
Nothing = ({value=Nothing,changed =False,form=[toHtml "Not yet done",Br]},hst)
Just val
# (valform,hst) = ga (reuseFormId formid val) hst
= ({value=Just valform.value,changed =valform.changed,form=valform.form},hst)
gForm {|RefReport|} (init,formid) hst = specialize myeditor (init,formid) hst
where
myeditor (init,formid) hst
# (RefReport refreport) = formid.ival
# (reportf,hst) = universalRefEditor Edit (\_ -> OK) refreport hst
= ({reportf & value = RefReport refreport},hst)
gForm {|RefPerson|} formid hst
# (RefPerson refperson) = formid.ival
# (personf,hst) = editPerson Edit Init refperson hst
= ({value = RefPerson refperson, form = personf.form,changed = personf.changed},hst)
gForm {|Reports|} informid hst = specialize myeditor informid hst
where
myeditor (init,formid) hst
# (Reports papernrs) = formid.ival
# (papersf,hst) = vertlistFormButs 5 (init,subsFormId formid "report" papernrs) hst
= ({papersf & value = Reports papersf.value},hst)
gForm {|RefPaper|} formid hst
# (RefPaper refpaper) = formid.ival
# (refpaperf,paperf,hst) = editPaper (Edit,Init,(refpaper,Edit,Init)) hst
= ({value = RefPaper refpaperf.value, form = paperf.form,changed = paperf.changed},hst)
gForm {|RefPaper|} (init,formid) hst = specialize myeditor (init,formid) hst
where
myeditor (init,formid) hst
# (RefPaper refpaper) = formid.ival
# (reportf,hst) = universalRefEditor formid.mode (\_ -> OK) refpaper hst
= ({reportf & value = RefPaper refpaper},hst)
gForm {|RefReport|} formid hst
# (RefReport refreport) = formid.ival
# (refreportf,reportf,hst) = editReport (Edit,Init,(refreport,Edit,Init)) hst
= ({value = RefReport refreportf.value, form = reportf.form,changed = reportf.changed},hst)
gForm {|Conflicts|} informid hst = specialize myeditor informid hst
where
myeditor (init,formid) hst
# (Conflicts papernrs) = formid.ival
# (papersf,hst) = vertlistFormButs 5 (init,subsFormId formid "conflict" papernrs) hst
= ({papersf & value = Conflicts papersf.value},hst)
gForm {|Conflicts|} formid hst = specialize myeditor (Init,formid) hst
gForm {|Co_authors|} informid hst = specialize myeditor informid hst
where
myeditor (Init,formid) hst
# (Conflicts papernrs) = formid.ival
# (papersf,hst) = vertlistFormButs 5 (Init,subsFormId formid "conflicts" papernrs) hst
= ({value = Conflicts papersf.value, form = papersf.form,changed = papersf.changed},hst)
myeditor (init,formid) hst
# (Co_authors authors) = formid.ival
# (authorsf,hst) = vertlistFormButs 5 (init,subsFormId formid "authors" authors) hst
= ({authorsf & value = Co_authors authorsf.value},hst)
// general forms display settings
derive gForm [], Maybe
derive gUpd [], Maybe
derive gPrint Maybe
derive gParse Maybe
derive gForm
Login, Account, Member, ManagerInfo, RefereeInfo, /* Conflicts, */
Login, Account, Member, ManagerInfo, RefereeInfo, /*Conflicts, */
/*RefPerson, */Person,
Reports, /*RefReport, */Report, Recommendation, Familiarity,
/*Reports, *//*RefReport, */ Report, Recommendation, Familiarity,
/*RefPaper, */Paper, PaperInfo
derive gUpd
Login, Account, Member, ManagerInfo, RefereeInfo, Conflicts,
RefPerson, Person,
Reports, RefReport, Report, Recommendation, Familiarity,
RefPaper, Paper, PaperInfo
RefPaper, Paper, PaperInfo, Co_authors
derive gPrint
Login, Account, Member, ManagerInfo, RefereeInfo, Conflicts,
RefPerson, Person,
Reports, RefReport, Report, Recommendation, Familiarity,
RefPaper, Paper, PaperInfo
RefPaper, Paper, PaperInfo, Co_authors
derive gParse
Login, Account, Member, ManagerInfo, RefereeInfo, Conflicts,
RefPerson, Person,
Reports, RefReport, Report, Recommendation, Familiarity,
RefPaper, Paper, PaperInfo
RefPaper, Paper, PaperInfo, Co_authors
/*
editPerson :: (!Mode,!Init,(!Refto Person,!Mode,!Init)) *HSt -> (Form (Refto Person),Form Person,!*HSt)
editPerson (rmode,rinit,(Refto person,pmode,pinit)) hst
# (personv,hst) = getPerson (Refto person)
//# (refpersonf,personf,hst) = editRefto (rmode,rinit,((Refto person,initPerson person),pmode,pinit)) hst
# (personf,hst) = mkEdit (rinit,sFormId person peronv)
# (ok,msg) = invariantPerson personf.value
# (_,hst) = ReportStore (addJudgement (ok,msg)) hst
# (_,hst) = if ok
(editRefto (rmode,rinit,((Refto person,initPerson person),pmode,pinit)) hst)
= (refpersonf,personf,hst)
*/
\ No newline at end of file
PersonDB :: !Mode !Init !(Refto Person) *HSt -> (Form Person,!*HSt)
PersonDB mode init refperson hst = universalRefEditor Edit invariantPerson refperson hst
gForm {|[]|} gHa formid hst
= case formid.ival of
[x:xs]
# (x,hst) = gHa (subFormId formid (toString (length xs)) x) hst
# (xs,hst) = gForm {|*->*|} gHa (reuseFormId formid xs) hst
= ({changed = x.changed||xs.changed,form = x.form ++ xs.form,value = [x.value:xs.value]},hst)
[]
= ({changed = False,form = [],value = []},hst)
gForm {|Maybe|} ga formid hst
# elem = formid.ival
= case elem of
Nothing = ({value=Nothing,changed =False,form=[toHtml "Not yet done",Br]},hst)
Just val
# (valform,hst) = ga (reuseFormId formid val) hst
= ({value=Just valform.value,changed =valform.changed,form=valform.form},hst)
uniqueKey :: *HSt -> (Form Int,!*HSt)
uniqueKey hst = mkStoreForm (Init,pFormId "key" 1) inc hst
mkUniqueKey prefix "" hst
# (intf,hst) = uniqueKey hst
= (prefix +++ toString intf.value,hst)
mkUniqueKey prefix key hst
= (key,hst)
*/
\ No newline at end of file
......@@ -10,7 +10,6 @@ instance == Login
where
(==) login1 login2 = login1.loginName == login2.loginName
instance < (Account s)
where
(<) login1 login2 = login1.login.loginName < login2.login.loginName
......
......@@ -24,9 +24,9 @@ import loginAdmin, htmlFormlib
, nr :: PaperNr
, paper :: RefPaper
}
:: RefereeInfo = { person :: RefPerson
:: RefereeInfo = { person :: RefPerson
, conflicts :: Conflicts
, reports :: Reports
, reports :: Reports
}
:: PaperNr :== Int
:: Conflicts = Conflicts [PaperNr]
......@@ -49,8 +49,8 @@ import loginAdmin, htmlFormlib
:: Familiarity = Expert
| Knowledgeable
| Low
:: CommCommittee:== TextArea
:: CommAuthors :== TextArea
:: CommCommittee:== String // TextArea
:: CommAuthors :== String // TextArea
// Information maintained by the Conference Manager *or* a Referee *or* an Author
......@@ -63,33 +63,38 @@ import loginAdmin, htmlFormlib
// Information submitted by an author
:: Paper = { title :: String
, first_author :: RefPerson
, co_authors :: [RefPerson]
, first_author :: Person
, co_authors :: Co_authors
, abstract :: String
, pdf :: String
}
:: Co_authors = Co_authors [Person]
// access functions on these data structures:
initManagerLogin :: Login
initManagerAccount :: Login -> ConfAccount
initRefereeAccount :: Login -> ConfAccount
initAuthorsAccount :: Login Int -> ConfAccount
initReport :: Report
initPaper :: String -> Paper
isConfManager :: ConfAccount -> Bool
isConfManager :: ConfAccount -> Bool
getRefPerson :: Member -> (Refto Person)
getRefPerson :: Member -> RefPerson
getRefPapers :: ConfAccounts -> [(Int,RefPaper)]
// invariants testing and setting
invariantPerson :: Person -> Judgement
setInvariantAccounts:: ConfAccounts -> ConfAccounts
invariantPerson :: Person -> Judgement
setInvariantAccounts :: ConfAccounts -> ConfAccounts
/*
initRefereeAccount :: Login -> ConfAccount
initAuthorsAccount :: Login Int -> ConfAccount
initReport :: Report
initPaper :: String -> Paper
setInvariantAccounts:: ConfAccounts -> ConfAccounts
findReports :: Int [ConfAccount] -> [(Person,Maybe Report)]
findReport :: Int ConfAccount -> (Maybe Report)
......
......@@ -10,39 +10,7 @@ initManagerLogin
initManagerAccount :: Login -> ConfAccount
initManagerAccount login
= mkAccount login (ConfManager {ManagerInfo | person = RefPerson (uniquePerson login.loginName)})
initRefereeAccount :: Login -> ConfAccount
initRefereeAccount login
= mkAccount login (Referee { person = RefPerson (uniquePerson login.loginName)
, conflicts = Conflicts []
, reports = Reports []
})
initAuthorsAccount :: Login Int -> ConfAccount
initAuthorsAccount login i
= mkAccount login (Authors { nr = i
, paper = RefPaper (uniquePaper login.loginName)
, person = RefPerson (uniquePerson login.loginName)
})
initPaper :: String -> Paper
initPaper name
= { title = "paper of " +++ name
, first_author = RefPerson (uniquePerson name)
, co_authors = []
, abstract = "type in abstract here"
, pdf = "download pdf here"
}
initReport :: Report
initReport
= { recommendation = StrongReject
, familiarity = Low
, commCommittee = TextArea 4 70 ""
, commAuthors = TextArea 10 70 "Please enter your report"
}
= mkAccount login (ConfManager {ManagerInfo | person = RefPerson (Refto "")})
isConfManager :: ConfAccount -> Bool
isConfManager account
......@@ -50,12 +18,16 @@ isConfManager account
ConfManager _ -> True
_ -> False
getRefPerson :: Member -> (Refto Person)
getRefPerson (ConfManager managerInfo) = deRefPerson managerInfo.ManagerInfo.person
getRefPerson (Referee refereeInfo) = deRefPerson refereeInfo.RefereeInfo.person
getRefPerson (Authors paperInfo) = deRefPerson paperInfo.PaperInfo.person
getRefPerson :: Member -> RefPerson
getRefPerson (ConfManager managerInfo) = managerInfo.ManagerInfo.person
getRefPerson (Referee refereeInfo) = refereeInfo.RefereeInfo.person
getRefPerson (Authors paperInfo) = paperInfo.PaperInfo.person
getRefPapers :: ConfAccounts -> [(Int,RefPaper)]
getRefPapers accounts = [(nr,refpapers)
\\ {state = Authors {nr,paper = refpapers}} <- accounts]
deRefPerson (RefPerson refto) = refto
invariantPerson :: Person -> Judgement
invariantPerson {firstName,lastName,affiliation,emailAddress}
......@@ -68,19 +40,37 @@ invariantPerson {firstName,lastName,affiliation,emailAddress}
setInvariantAccounts :: ConfAccounts -> ConfAccounts
setInvariantAccounts confaccounts
= map setInvariantAccount confaccounts
where
setInvariantAccount :: ConfAccount -> ConfAccount
setInvariantAccount account
= case account.state of
(ConfManager managerInfo) ->
{account & state = ConfManager {managerInfo
& ManagerInfo.person = RefPerson (Refto uniquename)}}
(Referee refereeInfo) ->
{account & state = Referee {refereeInfo
& RefereeInfo.person = RefPerson (Refto uniquename)
, RefereeInfo.reports = setInvariantReports refereeInfo.reports}}
(Authors paperInfo) ->
{account & state = Authors {paperInfo
& PaperInfo.person = RefPerson (Refto uniquename)
, PaperInfo.paper = RefPaper(Refto (uniquePaper paperInfo.nr uniquename))}}
where
uniquename = uniquePerson account.login.loginName
setInvariantReports (Reports reports) = Reports (setInvariantReport reports)
setInvariantReport :: [(PaperNr, Maybe RefReport)] -> [(PaperNr, Maybe RefReport)]
setInvariantReport [] = []
setInvariantReport [(nr, Just (RefReport (Refto _))):reports]
= [(nr, Just (RefReport (Refto (uniqueReport nr uniquename)))):setInvariantReport reports]
setInvariantReport [report:reports]
= [report:setInvariantReport reports]
setInvariantAccount :: ConfAccount -> ConfAccount
setInvariantAccount account
= case account.state of
(ConfManager managerInfo) ->
{account & state = ConfManager {managerInfo & ManagerInfo.person = RefPerson (uniquePerson account.login.loginName)}}
(Referee refereeInfo) ->
{account & state = Referee {refereeInfo & RefereeInfo.person = RefPerson (uniquePerson account.login.loginName)}}
(Authors paperInfo) ->
{account & state = Authors {paperInfo & PaperInfo.person = RefPerson (uniquePerson account.login.loginName)}}
/*
/*
FetchReports :: Int ConfAccounts -> ([(Person,Maybe Report)],*Hst)
FetchReports papernr accounts hst
= [ (state.person,report) \\ {state = Referee info} <- accounts
......@@ -89,6 +79,20 @@ FetchReports papernr accounts hst
*/
/*
initRefereeAccount :: Login -> ConfAccount
initRefereeAccount login
= mkAccount login (Referee { person = RefPerson (Refto "")
, conflicts = Conflicts []
, reports = Reports []
})
initAuthorsAccount :: Login Int -> ConfAccount
initAuthorsAccount login i
= mkAccount login (Authors { nr = i