From 27092c431520ee107e96f8e3513841f8d0369342 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Tue, 8 Aug 2017 14:32:27 -0400 Subject: [PATCH] Updating the add city button. Now when adding the city it sorts the state list. Also done with mailing address. commenting out a call that was giving an error. Think the geocode thing is done on the map button anyways. --- views/admin/member/memberInfo.html | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/views/admin/member/memberInfo.html b/views/admin/member/memberInfo.html index 9c8808d6..8429b32f 100644 --- a/views/admin/member/memberInfo.html +++ b/views/admin/member/memberInfo.html @@ -509,6 +509,25 @@ $("#newCityDialog").dialog("open"); }); + function sortSelectOptions(selector, skip_first) { + var options = (skip_first) ? $(selector + ' option:not(:first)') : $(selector + ' option'); + var arr = options.map(function(_, o) { return { t: $(o).text().trim(), v: o.value, s: $(o).prop('selected') }; }).get(); + arr.sort(function(o1, o2) { + var t1 = o1.t.toLowerCase(), t2 = o2.t.toLowerCase(); + return t1 > t2 ? 1 : t1 < t2 ? -1 : 0; + }); + options.each(function(i, o) { + o.value = arr[i].v; + $(o).text(arr[i].t); + if (arr[i].s) { + $(o).attr('selected', 'selected').prop('selected', true); + } else { + $(o).removeAttr('selected'); + $(o).prop('selected', false); + } + }); + } + // Submit new city var newCityAdded = false; $('#newCitySubmit').click( function() { @@ -538,6 +557,7 @@ // Add the new city name to the city picklist $('#city').append(''); $('#city').val(-1); + sortSelectOptions( '#city', true ); $('#newCityNameTD').append(''); newCityAdded = true; @@ -548,10 +568,12 @@ $("#newCityDialog").dialog("close"); - glmGeocode(); + // This was giving an error. + //glmGeocode(); }); + /* * New Mailing City Dialog */ @@ -600,6 +622,7 @@ // Add the new city name to the city picklist $('#mailing_city').append(''); $('#mailing_city').val(-1); + sortSelectOptions( '#mailing_city', true ); $('#newMailingCityNameTD').append(''); newMailingCityAdded = true; @@ -610,8 +633,6 @@ $("#newMailingCityDialog").dialog("close"); - glmGeocode(); - }); /* -- 2.17.1