[prev in list] [next in list] [prev in thread] [next in thread] 

List:       helix-server-cvs
Subject:    [Server-cvs] admin/web/build/server uasproplist.js,NONE,1.1
From:       athakwani () helixcommunity ! org
Date:       2007-09-28 7:48:27
Message-ID: 200709280748.l8S7mY3r018956 () mailer ! progressive-comp ! com
[Download RAW message or body]

Update of /cvsroot/server/admin/web/build/server
In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv25195

Added Files:
	uasproplist.js 
Log Message:
Synopsis
========
ERA Admin Page - Inheritance Resolution, Input Control Graying & Reload on apply. 

Branches: SERVER_CURRENT_RN
Suggested Reviewer: Darrick

Description
===========

Implements the design proposed in the ERA spec:

http://systems.dev.prognet.com/Products/Server/Projects/marion/features/Rate
Adaptation/specifications-1/enhanced-rate-adaptation-specification-6.doc/vie
w

Incorporated changes suggested by Darrick, derived UASPropList from PropList and \
UASPropObj from PropObj. In addition added the reload functionality after user click \
on *apply*, because if user changes the base profile values then it should be \
reflected in derived profiles. 

Note - There are many bugs on the page right now, because of which I am keeping this \
CR as Interim CR.

Files Affected:
===============
server/admin/web/src/srvprxy/config_mduap.html.wasm
server/admin/web/src/inc/textLib.pm
server/admin/web/src/js/uasproplist.js.wasm - [new]


Testing Performed
=================
Following testing was done.
1. Tested that textbox's background color for values from base was gray.
2. When modified the background color got changes to white.
3. Made changes to base profile and check that it got reflected in derived profiles.

Platforms tested: win32-i386-vc7
Browsers tested: IE-7, FireFox-2 

QA Hints
========
Will update this section on final CR.

Thanks,
Ashish






--- NEW FILE: uasproplist.js ---

//<SCRIPT>

//The only purpose of deriving this class is to have a flag in object which \
differentiates  //that this PropObjs value is initially from base profile.
function UASPropObj 
(
    name,       // required, property name, usually the rightmost property in a \
property path  defValue,   // optional, default value for the property, default = ""
    readOnly,   // optional, readonly, value cannot be edited, default == false 
    required,   // optional, does the property require a value (i.e. value != "")
    min,        // optional, the minimum value for the property (for numeric \
properties only), default == null  max,        // optional, the maximum value for the \
property (for numeric properties only), default == null  rule,       // optional, \
name of rule to use to validate the property's value before submittal  label,      // \
optional, a more friendly name then the name attribute  restart     // optional, does \
the server require a restart when this property is changed? )
{
    this.base = PropObj;
    this.base(name,	defValue, readOnly,	required, min, max, rule, label, restart);
    
    //This flag when set means that this propObj is basically not containing any \
value, but its value if from base profile.  this.baseDefault = false; 
}

UASPropObj.prototype = new PropObj;

//This Method is called while resolving the inheritance of profile, so as to mark \
this propObj as base default,  //which means that its value is from base profile.
UASPropObj.prototype.setBaseDefaultValue = function (val)
{
    //Not marking it dirty so that while commiting it should not go in derived \
profile.  if (val != this.value)
    {
        this.value = val;
        this.baseDefault = true;
    }
}

//After user click apply, all profile inheritance should be resolved again, 
//for that all baseDefault flags should be reset and values be blank.
//This methos is provided for that purpose.
UASPropObj.prototype.resetBaseDefault = function ()
{
        this.value = "";
        this.baseDefault = false;
}

UASPropObj.prototype.isBaseDefault = function ()
{
    return this.baseDefault;
}

//Need to override this method because we need UASPropObj not PropObj.
UASPropObj.prototype.copy = function ()
{
    var pObj = new UASPropObj
    ( 
        this.name,
        this.defValue,
        this.readOnly,
        this.required,
        this.min,
        this.max,
        this.rule,
        this.label,
        this.bRestart
    );

    if (this.m_configName) pObj.m_configName = this.m_configName ;
    pObj.dirty = this.dirty ;
    pObj.ctrlValue = this.ctrlValue ;
    pObj.value = this.value ;

    return pObj ;

}

//EventHandler for changing textbox colors.
UASPropObj.prototype.setColorDefault = function()
{
    this.style.backgroundColor = "#FFFFFF";
}

//EventHandler for changing textbox colors.
UASPropObj.prototype.setColorAppropriate = function()
{
    if (isCtrlDirty(this))
    {   
        this.style.backgroundColor = "#FFFFFF";
    }
    else
    {
        this.style.backgroundColor = "#dcdcdc";
    }
}

//When Default Profile Values are selected, 
//the control get values programmatically and events are not triggered
//So overriding this to trigger event explicitly.
UASPropObj.prototype.setValue = function (val)
{
    if (val != this.value)
    {
        this.ctrlValue = val ;
        this.dirty = true ;

        if (this.baseDefault)
        {
            this.getCtrl(theForm).onblur();
        }
    }
}

function UASPropList (name, initVals, propSet, propSetSubLists)
{
    this.base = PropList;
    this.base(name, initVals, propSet, propSetSubLists);
}

//The purpose of deriving this class is to set proper color for controls while \
filling the form. UASPropList.prototype = new PropList;

//We need UASPropList object not PropList.
UASPropList.prototype.initSubLists = function (initVals, propSet)
{
    var oThis = this;
    function enumFunc (a, prop, curDepth)
    { 
    if (curDepth > 0) return ;
        if (typeof(a[prop]) == "object")
        {
            if (!oThis.subList(prop))
            {
                oThis.addSubList(new UASPropList(prop, a[prop], propSet));
            }
        }
    }

    this.m_propSetSubLists = propSet ;

    if (initVals)
        enumPropArray(initVals, enumFunc, 1);

}   // UASPropList.prototype.initSubLists ()

//We need UASPropList object not PropList.
UASPropList.prototype.createNew = function (newName, fCopy)
{
    if (isBlank(newName)) 
        newName = this.m_name ; 

    var newList = new UASPropList(newName);
    if (fCopy)
        this.copy(newList);

    return newList;

}   // UASPropList.prototype.createNew

//While filling the form if we encounter an UASPropObj which has baseDefault set i.e \
the value is from base profile,  //then me need to set its color as gray and have \
some event handlers set. UASPropList.prototype.fillForm = function (form)
{
    var value, ctrl, prop ;
    for (var name in this.m_props)
    {
        prop = this.m_props[name];
        ctrl = prop ? prop.getCtrl(form) : null ;
        if (ctrl)
        {
            if (prop.isBaseDefault())
            {
                if (!prop.isDirty())
                {
                    ctrl.style.backgroundColor = "#dcdcdc";
                }
                else
                {
                    ctrl.style.backgroundColor = "#FFFFFF";
                }
                
                ctrl.onblur   = prop.setColorAppropriate;
                ctrl.onfocus  = prop.setColorDefault;
            }
            else
            {
                ctrl.style.backgroundColor = "#FFFFFF";
                ctrl.onblur  = null;
                ctrl.onfocus = null;
            }

            value = (prop.isDirty() || 
                    (isBlank(prop.value) && (!isBlank(prop.ctrlValue))) ? 
                prop.ctrlValue : prop.value);
            if ((value == null) || (typeof(value) == "undefined"))
                value = "" ;

            setCtrlValue(ctrl, value, true);
        }
    }

}   // UASPropList.prototype.fillForm ()    

//</SCRIPT>


_______________________________________________
Server-cvs mailing list
Server-cvs@helixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/server-cvs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic