Commit fb85b646 authored by ecrombag's avatar ecrombag

Added first version of Password Control

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@947 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 99f7c2e2
...@@ -68,6 +68,7 @@ itasks.ttc.common.attachTaskHandlers = function(comp,taskId){ ...@@ -68,6 +68,7 @@ itasks.ttc.common.attachTaskHandlers = function(comp,taskId){
case "itasks.tui.Time": case "itasks.tui.Time":
case "itasks.tui.Username": case "itasks.tui.Username":
case "itasks.tui.Currency": case "itasks.tui.Currency":
case "itasks.tui.Password":
case "textarea": case "textarea":
case "numberfield": case "numberfield":
case "datefield": case "datefield":
......
Ext.ns('itasks.tui');
itasks.tui.PasswordControl = Ext.extend(Ext.form.TextField,{
width: 100,
fieldClass: 'x-form-field',
initComponent: function(){
this.hideLabel = this.fieldLabel == null;
this.fieldLabel = itasks.util.fieldLabel(this.optional,this.fieldLabel);
this.allowBlank = this.optional;
this.inputType = 'password';
if(this.value == "") delete this.value;
itasks.tui.PasswordControl.superclass.initComponent.apply(this,arguments);
}
});
Ext.reg('itasks.tui.Password',itasks.tui.PasswordControl);
\ No newline at end of file
...@@ -11,7 +11,6 @@ from InteractionTasks import class html, generic gMakeSharedCopy, generic gMakeL ...@@ -11,7 +11,6 @@ from InteractionTasks import class html, generic gMakeSharedCopy, generic gMakeL
// Strings with special meanings // Strings with special meanings
:: EmailAddress = EmailAddress String :: EmailAddress = EmailAddress String
:: URL = URL String :: URL = URL String
:: Password = Password String
:: PhoneNr = PhoneNr String :: PhoneNr = PhoneNr String
// Plain text notes // Plain text notes
......
...@@ -7,8 +7,8 @@ import Text, Time ...@@ -7,8 +7,8 @@ import Text, Time
derive gPrint EmailAddress, Password, Note, Date, Time, DateTime, Currency derive gPrint EmailAddress, Password, Note, Date, Time, DateTime, Currency
derive gParse EmailAddress, Password, Note, Date, Time, DateTime, Currency derive gParse EmailAddress, Password, Note, Date, Time, DateTime, Currency
derive gVisualize EmailAddress, Password, DateTime derive gVisualize EmailAddress, DateTime
derive gUpdate EmailAddress, Password, Note, DateTime derive gUpdate EmailAddress, Note, DateTime
derive gMerge EmailAddress, Password, Note, Date, Time, DateTime, Currency derive gMerge EmailAddress, Password, Note, Date, Time, DateTime, Currency
derive gMakeSharedCopy EmailAddress, Password, Note, Date, Time, DateTime, Currency derive gMakeSharedCopy EmailAddress, Password, Note, Date, Time, DateTime, Currency
derive gMakeLocalCopy EmailAddress, Password, Note, Date, Time, DateTime, Currency derive gMakeLocalCopy EmailAddress, Password, Note, Date, Time, DateTime, Currency
...@@ -16,6 +16,22 @@ derive gLexOrd Currency ...@@ -16,6 +16,22 @@ derive gLexOrd Currency
derive bimap Maybe, (,) derive bimap Maybe, (,)
//VValue a DataMask
gVisualize{|Password|} old new vst=:{vizType,label,idPrefix,currentPath,useLabels,optional,valid}
= case vizType of
VEditorDefinition = ([TUIFragment (TUIPasswordControl {TUIBasicControl | name = dp2s currentPath, id = id, value = oldV, fieldLabel = labelAttr useLabels label, optional = optional})]
, 1
, {VSt | vst & currentPath = stepDataPath currentPath, valid = stillValid currentPath old optional valid})
VEditorUpdate
| oldV <> newV = ([TUIUpdate (TUISetValue id newV)]
, 1
, {VSt | vst & currentPath = stepDataPath currentPath, valid = stillValid currentPath new optional valid})
_ = ([TextFragment (foldr (+++) "" (repeatn (size oldV) "*"))],1,{VSt | vst & currentPath = stepDataPath currentPath, valid = stillValid currentPath old optional valid})
where
id = dp2id idPrefix currentPath
oldV = value2s currentPath old
newV = value2s currentPath new
gVisualize{|Date|} old new vst=:{vizType,label,idPrefix,currentPath,useLabels,optional,valid} gVisualize{|Date|} old new vst=:{vizType,label,idPrefix,currentPath,useLabels,optional,valid}
= case vizType of = case vizType of
VEditorDefinition = ([TUIFragment (TUIDateControl {TUIBasicControl|name = dp2s currentPath, id = id, value = oldV, fieldLabel = labelAttr useLabels label, optional = optional})] VEditorDefinition = ([TUIFragment (TUIDateControl {TUIBasicControl|name = dp2s currentPath, id = id, value = oldV, fieldLabel = labelAttr useLabels label, optional = optional})]
...@@ -91,7 +107,17 @@ where ...@@ -91,7 +107,17 @@ where
value dp (VValue v dm) = if (isMasked dp dm) (decFormat (toInt v)) "" value dp (VValue v dm) = if (isMasked dp dm) (decFormat (toInt v)) ""
id = dp2id idPrefix currentPath id = dp2id idPrefix currentPath
gUpdate{|Password|} _ ust=:{USt|mode=UDCreate}
= (Password "", ust)
gUpdate{|Password|} s ust=:{USt|mode=UDSearch,searchPath,currentPath,update}
| currentPath == searchPath
= (Password update, toggleMask {USt | ust & mode = UDDone})
| otherwise
= (s, {USt|ust & currentPath = stepDataPath currentPath})
gUpdate{|Password|} s ust=:{USt|mode=UDMask,currentPath,mask}
= (s, {USt|ust & currentPath = stepDataPath currentPath, mask = appendToMask currentPath mask})
gUpdate{|Date|} _ ust=:{USt|mode=UDCreate,world} gUpdate{|Date|} _ ust=:{USt|mode=UDCreate,world}
# (date,world) = currentDate world # (date,world) = currentDate world
= (date, {USt|ust & world = world}) = (date, {USt|ust & world = world})
......
...@@ -4,15 +4,17 @@ import StdEnv, StdMaybe ...@@ -4,15 +4,17 @@ import StdEnv, StdMaybe
import StdGeneric import StdGeneric
import TSt, Util, StdDebug import TSt, Util, StdDebug
derive JSONEncode User from Types import :: Password(..)
derive JSONDecode User
derive JSONEncode User, Password
derive JSONDecode User, Password
derive bimap (,), Maybe derive bimap (,), Maybe
unknownUser :: User unknownUser :: User
unknownUser = {User | userName = "unknown", displayName = "Unknown user", password = "", roles = []} unknownUser = {User | userName = "unknown", displayName = "Unknown user", password = Password "", roles = []}
rootUser :: User rootUser :: User
rootUser = {User | userName = "root", displayName = "Root", password = "", roles = []} rootUser = {User | userName = "root", displayName = "Root", password = Password "", roles = []}
getUser :: !UserName !*TSt -> (!User,!*TSt) getUser :: !UserName !*TSt -> (!User,!*TSt)
getUser (UserName "root" _) tst getUser (UserName "root" _) tst
...@@ -65,7 +67,7 @@ authenticateUser username password tst ...@@ -65,7 +67,7 @@ authenticateUser username password tst
= (Nothing, tst) = (Nothing, tst)
| otherwise | otherwise
# (users, tst) = userStore id tst # (users, tst) = userStore id tst
= case [u \\ u <- users | u.userName == username && u.password == password] of = case [u \\ u <- users | u.userName == username && u.password == (Password password)] of
[user] = (Just user, tst) [user] = (Just user, tst)
_ = (Nothing, tst) _ = (Nothing, tst)
......
...@@ -869,7 +869,7 @@ getId (TUIDateControl d) = Just d.TUIBasicControl.id ...@@ -869,7 +869,7 @@ getId (TUIDateControl d) = Just d.TUIBasicControl.id
getId (TUITimeControl d) = Just d.TUIBasicControl.id getId (TUITimeControl d) = Just d.TUIBasicControl.id
getId (TUICurrencyControl d) = Just d.TUICurrencyControl.id getId (TUICurrencyControl d) = Just d.TUICurrencyControl.id
getId (TUIUsernameControl d) = Just d.TUIBasicControl.id getId (TUIUsernameControl d) = Just d.TUIBasicControl.id
getId (TUIPasswordControl d) = Just d.TUIBasicControl.id
getId (TUILabel) = Nothing getId (TUILabel) = Nothing
getId (TUIButton d) = Just d.TUIButton.id getId (TUIButton d) = Just d.TUIButton.id
......
...@@ -27,7 +27,8 @@ derive JSONEncode TUIDef, TUIUpdate ...@@ -27,7 +27,8 @@ derive JSONEncode TUIDef, TUIUpdate
| TUIBoolControl TUIBasicControl | TUIBoolControl TUIBasicControl
| TUINoteControl TUIBasicControl | TUINoteControl TUIBasicControl
| TUIDateControl TUIBasicControl | TUIDateControl TUIBasicControl
| TUITimeControl TUIBasicControl | TUITimeControl TUIBasicControl
| TUIPasswordControl TUIBasicControl
| TUICurrencyControl TUICurrencyControl | TUICurrencyControl TUICurrencyControl
| TUIUsernameControl TUIBasicControl | TUIUsernameControl TUIBasicControl
| TUIButton TUIButton | TUIButton TUIButton
......
...@@ -40,7 +40,7 @@ JSONEncode{|TUIDef|} (TUIDateControl r) c = addXType "itasks.tui.Date" (JSONEnco ...@@ -40,7 +40,7 @@ JSONEncode{|TUIDef|} (TUIDateControl r) c = addXType "itasks.tui.Date" (JSONEnco
JSONEncode{|TUIDef|} (TUITimeControl r) c = addXType "itasks.tui.Time" (JSONEncode{|*|} r c) JSONEncode{|TUIDef|} (TUITimeControl r) c = addXType "itasks.tui.Time" (JSONEncode{|*|} r c)
JSONEncode{|TUIDef|} (TUICurrencyControl r) c = addXType "itasks.tui.Currency" (JSONEncode{|*|} r c) JSONEncode{|TUIDef|} (TUICurrencyControl r) c = addXType "itasks.tui.Currency" (JSONEncode{|*|} r c)
JSONEncode{|TUIDef|} (TUIUsernameControl r) c = addXType "itasks.tui.Username" (JSONEncode{|*|} r c) JSONEncode{|TUIDef|} (TUIUsernameControl r) c = addXType "itasks.tui.Username" (JSONEncode{|*|} r c)
JSONEncode{|TUIDef|} (TUIPasswordControl r) c = addXType "itasks.tui.Password" (JSONEncode{|*|} r c)
addXType :: String [String] -> [String] addXType :: String [String] -> [String]
addXType xtype [x:xs] = [x,"\"xtype\" : \"",xtype,"\", ":xs] addXType xtype [x:xs] = [x,"\"xtype\" : \"",xtype,"\", ":xs]
\ No newline at end of file
...@@ -7,7 +7,7 @@ definition module Types ...@@ -7,7 +7,7 @@ definition module Types
from TSt import :: TSt from TSt import :: TSt
from TaskTree import :: TaskProperties, :: GroupedBehaviour from TaskTree import :: TaskProperties, :: GroupedBehaviour
from Html import :: HtmlTag from Html import :: HtmlTag
from CommonDomain import :: Note from CommonDomain import :: Note, :: Password
from StdString import class toString from StdString import class toString
from iTasks import class iTask from iTasks import class iTask
...@@ -23,6 +23,7 @@ derive JSONDecode Document ...@@ -23,6 +23,7 @@ derive JSONDecode Document
instance toString TaskPriority instance toString TaskPriority
instance toString UserName instance toString UserName
instance toString Password
class toUserName a :: a -> UserName class toUserName a :: a -> UserName
instance toUserName String instance toUserName String
...@@ -35,16 +36,19 @@ instance fromUserName (String,String) ...@@ -35,16 +36,19 @@ instance fromUserName (String,String)
instance == UserName instance == UserName
instance == User instance == User
instance == Password
:: Role :== String :: Role :== String
:: UserId :== String :: UserId :== String
:: DisplayName :== String :: DisplayName :== String
:: Password = Password String
:: UserName = UserName !UserId !DisplayName :: UserName = UserName !UserId !DisplayName
:: User = :: User =
{ userName :: !UserId { userName :: !UserId
, password :: !String , password :: !Password
, displayName :: !DisplayName , displayName :: !DisplayName
, roles :: ![Role] , roles :: ![Role]
} }
......
...@@ -27,6 +27,10 @@ where ...@@ -27,6 +27,10 @@ where
| disp == "" = id | disp == "" = id
| otherwise = disp+++" <"+++id+++">" | otherwise = disp+++" <"+++id+++">"
instance toString Password
where
toString (Password p) = p
class toUserName a :: a -> UserName class toUserName a :: a -> UserName
instance toUserName String instance toUserName String
...@@ -68,6 +72,10 @@ instance == User ...@@ -68,6 +72,10 @@ instance == User
where where
(==) a b = a.userName == b.userName (==) a b = a.userName == b.userName
instance == Password
where
(==) (Password a) (Password b) = a == b
// Document // Document
emptyDoc :: Document emptyDoc :: Document
emptyDoc = {type = Local, content = EmptyDocument} emptyDoc = {type = Local, content = EmptyDocument}
......
Markdown is supported
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