mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	zerver/lib/events.py: Add FIELD_TYPE_CHOICES_DICT to page_params.
This commit add FIELD_TYPE_CHOICES_DICT to page_params and replace FIELD_TYPE_CHOICES. FIELD_TYPE_CHOICES_DICT includes all field types with keyword, id and display name. Using this field-type-dict, we can access field type information by it's keyword, and remove all static use of field-type'a name or id in frontend. This commit also modifies functions in js where this page_params field-types is used.
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							621a5cdc35
						
					
				
				
					commit
					6e65235a6d
				
			@@ -178,16 +178,17 @@ function show_user_profile(element, user) {
 | 
			
		||||
 | 
			
		||||
    var profile_data = {};
 | 
			
		||||
    var localFormat = moment.localeData().longDateFormat('L');
 | 
			
		||||
    var field_types = page_params.custom_profile_field_types;
 | 
			
		||||
 | 
			
		||||
    page_params.custom_profile_fields.forEach(function (field) {
 | 
			
		||||
        var field_value = people.get_custom_profile_data(user.user_id, field.id);
 | 
			
		||||
        var field_type = settings_profile_fields.field_type_id_to_string(field.type);
 | 
			
		||||
        var field_type = field.type;
 | 
			
		||||
        if (field_value) {
 | 
			
		||||
            if (field_type === "Date") {
 | 
			
		||||
            if (field_type === field_types.DATE.id) {
 | 
			
		||||
                profile_data[field.name] = moment(field_value).format(localFormat);
 | 
			
		||||
            } else if (field_type === "User") {
 | 
			
		||||
            } else if (field_type === field_types.USER.id) {
 | 
			
		||||
                profile_data[field.name] = people.safe_full_names(field_value);
 | 
			
		||||
            } else if (field_type === "Choice") {
 | 
			
		||||
            } else if (field_type === field_types.CHOICE.id) {
 | 
			
		||||
                var field_choice_dict = JSON.parse(field.field_data);
 | 
			
		||||
                profile_data[field.name] = field_choice_dict[field_value].text;
 | 
			
		||||
            } else {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user