forked from Coded/SIPRP
				
			
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							74 lines
						
					
					
						
							2.1 KiB
						
					
					
				
			
		
		
	
	
							74 lines
						
					
					
						
							2.1 KiB
						
					
					
				 evoapp.factory('settings', function($rootScope) {
 | 
						|
     
 | 
						|
    var me = this;
 | 
						|
 | 
						|
    me.settings = {
 | 
						|
   
 | 
						|
        //globals.settings.dateFormat: dd-MM-yyyy | yyyy-MM-dd
 | 
						|
        dateFormat: 'yyyy-MM-dd',
 | 
						|
 | 
						|
        //globals.settings.dateTimeFormat
 | 
						|
        dateTimeFormat: 'yyyy-MM-dd HH:mm:ss',
 | 
						|
 | 
						|
        //globals.settings.timeFormat
 | 
						|
        timeFormat: 'H:i',
 | 
						|
 | 
						|
        regex: {
 | 
						|
            Email: /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/,
 | 
						|
 | 
						|
            //YYYY-MM-DD: /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/
 | 
						|
            //DD-MM-YYYY: /^(0?[1-9]|[12][0-9]|3[01])[\/\-](0?[1-9]|1[012])[\/\-]\d{4}$/
 | 
						|
            Date: /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/
 | 
						|
        }
 | 
						|
    };
 | 
						|
 | 
						|
    var apply = function(userSession){
 | 
						|
 | 
						|
        angular.forEach(userSession.Settings, function (setting) {
 | 
						|
            
 | 
						|
            var value = null, settingName = setting.SettingName;
 | 
						|
 | 
						|
            if(setting.IntValue != null)
 | 
						|
            {
 | 
						|
                value = setting.IntValue;
 | 
						|
            }
 | 
						|
            else if(setting.StringValue != null)
 | 
						|
            {
 | 
						|
                value = setting.StringValue;
 | 
						|
            }
 | 
						|
            else if(setting.DateTimeValue != null)
 | 
						|
            {
 | 
						|
                value = moment(setting.DateTimeValue).toDate();
 | 
						|
            }
 | 
						|
            else if(setting.BinaryValue != null)
 | 
						|
            {
 | 
						|
                value = setting.BinaryValue;
 | 
						|
            }
 | 
						|
            else if(setting.BoolValue != null)
 | 
						|
            {
 | 
						|
                value = setting.BoolValue;
 | 
						|
            }
 | 
						|
 | 
						|
            var properties = settingName.split('.');
 | 
						|
 | 
						|
            if(properties.length > 1)
 | 
						|
            {
 | 
						|
                if(!me.settings.hasOwnProperty(properties[0])){
 | 
						|
                    me.settings[properties[0]] = {};
 | 
						|
                }
 | 
						|
 | 
						|
                me.settings[properties[0]][properties[1]] = value;
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                me.settings[settingName] = value;
 | 
						|
            }
 | 
						|
        });
 | 
						|
    };
 | 
						|
    
 | 
						|
    return {
 | 
						|
        apply: apply,
 | 
						|
        settings: me.settings
 | 
						|
    };
 | 
						|
});
 |