custom profile field: Minor tweaks in field-table in admin settings.

This commit add minor changes in profile field table in
admin settings:
 - Hide table header if there is no field
 - Fix width of table column
This commit is contained in:
Yashashvi Dave
2018-08-15 17:07:40 +05:30
committed by Tim Abbott
parent 66c2b6d2a6
commit 03f5422ce8
3 changed files with 21 additions and 0 deletions

View File

@@ -8,6 +8,8 @@ set_global('Sortable', {create: () => {}});
const SHORT_TEXT_ID = 1; const SHORT_TEXT_ID = 1;
const CHOICE_ID = 3; const CHOICE_ID = 3;
page_params.custom_profile_fields = {};
page_params.custom_profile_field_types = { page_params.custom_profile_field_types = {
SHORT_TEXT: { SHORT_TEXT: {
id: SHORT_TEXT_ID, id: SHORT_TEXT_ID,

View File

@@ -33,6 +33,17 @@ exports.field_type_id_to_string = function (type_id) {
return field_type_str; return field_type_str;
}; };
function update_profile_fields_table_element() {
var profile_fields_table = $("#admin_profile_fields_table").expectOne();
// If there are no custom fields, hide the table headers at the top
if (page_params.custom_profile_fields.length < 1) {
profile_fields_table.hide();
} else {
profile_fields_table.show();
}
}
function delete_profile_field(e) { function delete_profile_field(e) {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
@@ -41,6 +52,7 @@ function delete_profile_field(e) {
channel.del, channel.del,
"/json/realm/profile_fields/" + encodeURIComponent($(this).attr('data-profile-field-id')), "/json/realm/profile_fields/" + encodeURIComponent($(this).attr('data-profile-field-id')),
{}, $('#admin-profile-field-status').expectOne()); {}, $('#admin-profile-field-status').expectOne());
update_profile_fields_table_element();
} }
function read_field_data_from_form(selector) { function read_field_data_from_form(selector) {
@@ -114,6 +126,7 @@ function create_profile_field(e) {
settings_ui.do_settings_change(channel.post, "/json/realm/profile_fields", form_data, settings_ui.do_settings_change(channel.post, "/json/realm/profile_fields", form_data,
$('#admin-profile-field-status').expectOne(), opts); $('#admin-profile-field-status').expectOne(), opts);
update_profile_fields_table_element();
} }
function add_choice_row(e) { function add_choice_row(e) {
@@ -295,6 +308,8 @@ exports.do_populate_profile_fields = function (profile_fields_data) {
onUpdate: update_field_order, onUpdate: update_field_order,
}); });
} }
update_profile_fields_table_element();
loading.destroy_indicator($('#admin_page_profile_fields_loading_indicator')); loading.destroy_indicator($('#admin_page_profile_fields_loading_indicator'));
}; };

View File

@@ -705,6 +705,10 @@ input[type=checkbox].inline-block {
margin: 10px 0px; margin: 10px 0px;
} }
#settings_content .admin-table-wrapper table.admin_profile_fields_table tr td {
width: 28%;
}
.admin_profile_fields_table, .admin_profile_fields_table,
.profile_field_choices_table { .profile_field_choices_table {
.movable-profile-field-row { .movable-profile-field-row {