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){
case "itasks.tui.Time":
case "itasks.tui.Username":
case "itasks.tui.Currency":
case "itasks.tui.Password":
case "textarea":
case "numberfield":
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
// Strings with special meanings
:: EmailAddress = EmailAddress String
:: URL = URL String
:: Password = Password String
:: PhoneNr = PhoneNr String
// Plain text notes
......
......@@ -7,8 +7,8 @@ import Text, Time
derive gPrint EmailAddress, Password, Note, Date, Time, DateTime, Currency
derive gParse EmailAddress, Password, Note, Date, Time, DateTime, Currency
derive gVisualize EmailAddress, Password, DateTime
derive gUpdate EmailAddress, Password, Note, DateTime
derive gVisualize EmailAddress, DateTime
derive gUpdate EmailAddress, Note, DateTime
derive gMerge 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
......@@ -16,6 +16,22 @@ derive gLexOrd Currency
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}
= case vizType of
VEditorDefinition = ([TUIFragment (TUIDateControl {TUIBasicControl|name = dp2s currentPath, id = id, value = oldV, fieldLabel = labelAttr useLabels label, optional = optional})]
......@@ -92,6 +108,16 @@ where
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}
# (date,world) = currentDate world
= (date, {USt|ust & world = world})
......
......@@ -4,15 +4,17 @@ import StdEnv, StdMaybe
import StdGeneric
import TSt, Util, StdDebug
derive JSONEncode User
derive JSONDecode User
from Types import :: Password(..)
derive JSONEncode User, Password
derive JSONDecode User, Password
derive bimap (,), Maybe
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 | userName = "root", displayName = "Root", password = "", roles = []}
rootUser = {User | userName = "root", displayName = "Root", password = Password "", roles = []}
getUser :: !UserName !*TSt -> (!User,!*TSt)
getUser (UserName "root" _) tst
......@@ -65,7 +67,7 @@ authenticateUser username password tst
= (Nothing, tst)
| otherwise
# (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)
_ = (Nothing, tst)
......
......@@ -869,7 +869,7 @@ getId (TUIDateControl d) = Just d.TUIBasicControl.id
getId (TUITimeControl d) = Just d.TUIBasicControl.id
getId (TUICurrencyControl d) = Just d.TUICurrencyControl.id
getId (TUIUsernameControl d) = Just d.TUIBasicControl.id
getId (TUIPasswordControl d) = Just d.TUIBasicControl.id
getId (TUILabel) = Nothing
getId (TUIButton d) = Just d.TUIButton.id
......
......@@ -28,6 +28,7 @@ derive JSONEncode TUIDef, TUIUpdate
| TUINoteControl TUIBasicControl
| TUIDateControl TUIBasicControl
| TUITimeControl TUIBasicControl
| TUIPasswordControl TUIBasicControl
| TUICurrencyControl TUICurrencyControl
| TUIUsernameControl TUIBasicControl
| TUIButton TUIButton
......
......@@ -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|} (TUICurrencyControl r) c = addXType "itasks.tui.Currency" (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 xtype [x:xs] = [x,"\"xtype\" : \"",xtype,"\", ":xs]
\ No newline at end of file
......@@ -7,7 +7,7 @@ definition module Types
from TSt import :: TSt
from TaskTree import :: TaskProperties, :: GroupedBehaviour
from Html import :: HtmlTag
from CommonDomain import :: Note
from CommonDomain import :: Note, :: Password
from StdString import class toString
from iTasks import class iTask
......@@ -23,6 +23,7 @@ derive JSONDecode Document
instance toString TaskPriority
instance toString UserName
instance toString Password
class toUserName a :: a -> UserName
instance toUserName String
......@@ -35,16 +36,19 @@ instance fromUserName (String,String)
instance == UserName
instance == User
instance == Password
:: Role :== String
:: UserId :== String
:: DisplayName :== String
:: Password = Password String
:: UserName = UserName !UserId !DisplayName
:: User =
{ userName :: !UserId
, password :: !String
, password :: !Password
, displayName :: !DisplayName
, roles :: ![Role]
}
......
......@@ -27,6 +27,10 @@ where
| disp == "" = id
| otherwise = disp+++" <"+++id+++">"
instance toString Password
where
toString (Password p) = p
class toUserName a :: a -> UserName
instance toUserName String
......@@ -68,6 +72,10 @@ instance == User
where
(==) a b = a.userName == b.userName
instance == Password
where
(==) (Password a) (Password b) = a == b
// Document
emptyDoc :: Document
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