Author: ashish
Date: Thu Nov 5 10:08:35 2009 New Revision: 833026 URL: http://svn.apache.org/viewvc?rev=833026&view=rev Log: Applied patch from jira issue OFBIZ-3159 - Move geoAutoCompleter.js from ecommerce to ordermgr. geoAutoCompleter.js currently resides in specialpurpose/ecommerce component. But now it is also used in OrderViewScreen.xml#OrderHeaderView screen. First of all we can't have dependency of ordermgr on ecommerce component. Secondly, if I am developing a custom ecommerce application with mount point /ecommerce, thus overriding specialpurpose/ecommerce webapp, and copying the geoAutoCompleter.js to my custom application (to customize) in a directory structure other than that of specialpurpose/ecommerce, then the JS file is not loaded in OrderHeaderView screen due to change of location. The only reason is the dependency stated above. Hence this change is vital. While doing this change, all the references to geoAutoCompleter.js will need to be updated too. Thanks Arpit for the contribution. Special thanks to Mridul for providing notes for the implementation. Added: ofbiz/trunk/applications/order/webapp/ordermgr/images/js/geoAutoCompleter.js (with props) Removed: ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/images/geoAutoCompleter.js Modified: ofbiz/trunk/applications/order/widget/ordermgr/OrderViewScreens.xml ofbiz/trunk/specialpurpose/ecommerce/widget/CustomerScreens.xml ofbiz/trunk/specialpurpose/ecommerce/widget/OrderScreens.xml Added: ofbiz/trunk/applications/order/webapp/ordermgr/images/js/geoAutoCompleter.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/images/js/geoAutoCompleter.js?rev=833026&view=auto ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/images/js/geoAutoCompleter.js (added) +++ ofbiz/trunk/applications/order/webapp/ordermgr/images/js/geoAutoCompleter.js Thu Nov 5 10:08:35 2009 @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +Event.observe(window, 'load', function() { + // Autocompleter for shipping panel + // Preventing getCountryList() from calling and not removed all autocompleter functions so that we can reuse in future. + //getCountryList(); +}); + +function getCountryList() { + countryTargetField = $('shipToCountryGeo'); + countryDivToPopulate = $('shipToCountries'); + countryHiddenTarget = $('shipToCountryGeoId'); + new Ajax.Request("getCountryList", { + asynchronous: false, + onSuccess: callCountryAutocompleter + }); +} + +function callCountryAutocompleter(transport) { + var geos = new Hash(); + var data = transport.responseText.evalJSON(true); + countryList = data.countryList; + countryList.each(function(country) { + var countryName = country.split(': '); + geos.set(countryName[1], countryName[0]); + }); + new Autocompleter.Local(countryTargetField, countryDivToPopulate, $H(geos), { partialSearch: false, afterUpdateElement: setKeyAsParameterAndGetStateList}); +} + +function setKeyAsParameterAndGetStateList(text, li) { + countryHiddenTarget.value = li.id; + getAssociatedStateListForAutoComplete(); +} + +function getAssociatedStateListForAutoComplete() { + stateTargetField = $('shipToStateProvinceGeo'); + stateDivToPopulate = $('shipToStates'); + stateHiddenTarget = $('shipToStateProvinceGeoId'); + new Ajax.Request("getAssociatedStateList", { + asynchronous: false, + parameters: $('shippingForm').serialize(), + onSuccess: callStateAutocompleter + }); +} + +function callStateAutocompleter(transport) { + var geos = new Hash(); + var data = transport.responseText.evalJSON(true); + stateList = data.stateList; + stateList.each(function(state) { + var stateName = state.split(': '); + geos.set(stateName[1], stateName[0]); + }); + if (stateList.size() <= 1) { + $('shipToStateProvinceGeo').value = "No States/Provinces exists"; + $('shipToStateProvinceGeoId').value = "_NA_"; + Effect.Fade('shipStates', {duration: 0.0}); + Effect.Fade('advice-required-shipToStateProvinceGeo', {duration: 0.0}); + Event.stopObserving($('shipToStateProvinceGeo'), 'blur'); + } else { + $('shipToStateProvinceGeo').value = ""; + $('shipToStateProvinceGeoId').value = ""; + Effect.Appear('shipStates', {duration: 0.0}); + Event.observe($('shipToStateProvinceGeo'), 'blur', function() { + if ($('shipToStateProvinceGeo').value == "") { + Effect.Appear('advice-required-shipToStateProvinceGeo', {duration: 0.0}); + } + }); + } + new Autocompleter.Local(stateTargetField, stateDivToPopulate, $H(geos), { partialSearch: false, afterUpdateElement: setKeyAsParameter }); +} + +function setKeyAsParameter(text, li) { + stateHiddenTarget.value = li.id; +} + +//Generic function for fetching country's associated state list. +function getAssociatedStateList(countryId, stateId, errorId, divId) { + var optionList = []; + var requestToSend = "getAssociatedStateList"; + if ($('orderViewed')) { + requestToSend = "/ordermgr/control/getAssociatedStateList" + } + new Ajax.Request(requestToSend, { + asynchronous: false, + parameters: {countryGeoId:$F(countryId)}, + onSuccess: function(transport) { + var data = transport.responseText.evalJSON(true); + stateList = data.stateList; + stateList.each(function(state) { + geoValues = state.split(': '); + optionList.push("<option value = "+geoValues[1]+" >"+geoValues[0]+"</option>"); + }); + $(stateId).update(optionList); + if (stateList.size() <= 1) { + if ($(divId).visible() || $(errorId).visible()) { + Effect.Fade(divId, {duration: 0.0}); + Effect.Fade(errorId, {duration: 0.0}); + Event.stopObserving(stateId, 'blur'); + } + } else { + Effect.Appear(divId, {duration: 0.0}); + Event.observe(stateId, 'blur', function() { + if ($F(stateId) == "") { + Effect.Appear(errorId, {duration: 0.0}); + } + }); + } + } + }); +} \ No newline at end of file Propchange: ofbiz/trunk/applications/order/webapp/ordermgr/images/js/geoAutoCompleter.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/applications/order/webapp/ordermgr/images/js/geoAutoCompleter.js ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/applications/order/webapp/ordermgr/images/js/geoAutoCompleter.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: ofbiz/trunk/applications/order/widget/ordermgr/OrderViewScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/widget/ordermgr/OrderViewScreens.xml?rev=833026&r1=833025&r2=833026&view=diff ============================================================================== --- ofbiz/trunk/applications/order/widget/ordermgr/OrderViewScreens.xml (original) +++ ofbiz/trunk/applications/order/widget/ordermgr/OrderViewScreens.xml Thu Nov 5 10:08:35 2009 @@ -74,7 +74,7 @@ <set field="layoutSettings.javaScripts[+0]" value="/images/prototypejs/validation.js" global="true"/> <set field="layoutSettings.javaScripts[]" value="/ordermgr/images/js/order.js" global="true"/> <set field="layoutSettings.javaScripts[]" value="/ordermgr/images/js/OrderShippingInfo.js" global="true"/> - <set field="layoutSettings.javaScripts[]" value="/ecommerce/images/geoAutoCompleter.js" global="true"/> + <set field="layoutSettings.javaScripts[]" value="/ordermgr/images/js/geoAutoCompleter.js" global="true"/> <script location="component://order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy"/> <script location="component://order/webapp/ordermgr/WEB-INF/actions/order/OrderViewWebSecure.groovy"/> </actions> Modified: ofbiz/trunk/specialpurpose/ecommerce/widget/CustomerScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/widget/CustomerScreens.xml?rev=833026&r1=833025&r2=833026&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ecommerce/widget/CustomerScreens.xml (original) +++ ofbiz/trunk/specialpurpose/ecommerce/widget/CustomerScreens.xml Thu Nov 5 10:08:35 2009 @@ -522,7 +522,7 @@ <property-map resource="SecurityextUiLabels" map-name="uiLabelMap" global="true"/> <set field="titleProperty" value="PageTitleNewCustomer"/> <set field="layoutSettings.javaScripts[]" value="/ecommerce/images/profile.js" global="true"/> - <set field="layoutSettings.javaScripts[]" value="/ecommerce/images/geoAutoCompleter.js" global="true"/> + <set field="layoutSettings.javaScripts[]" value="/ordermgr/images/js/geoAutoCompleter.js" global="true"/> </actions> <widgets> <decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}"> @@ -587,7 +587,7 @@ <set field="layoutSettings.javaScripts[+0]" value="/images/prototypejs/controls.js" global="true"/> <set field="layoutSettings.javaScripts[]" value="/ecommerce/images/profile.js" global="true"/> - <set field="layoutSettings.javaScripts[]" value="/ecommerce/images/geoAutoCompleter.js" global="true"/> + <set field="layoutSettings.javaScripts[]" value="/ordermgr/images/js/geoAutoCompleter.js" global="true"/> <script location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/customer/EditShippingAddress.groovy"/> <script location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/customer/EditBillingAddress.groovy"/> <script location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/customer/ViewProfile.groovy"/> Modified: ofbiz/trunk/specialpurpose/ecommerce/widget/OrderScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/widget/OrderScreens.xml?rev=833026&r1=833025&r2=833026&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ecommerce/widget/OrderScreens.xml (original) +++ ofbiz/trunk/specialpurpose/ecommerce/widget/OrderScreens.xml Thu Nov 5 10:08:35 2009 @@ -618,7 +618,7 @@ <set field="layoutSettings.javaScripts[+0]" value="/images/prototypejs/effects.js" global="true"/> <set field="layoutSettings.javaScripts[]" value="/images/prototypejs/controls.js" global="true"/> <set field="layoutSettings.javaScripts[]" value="/ecommerce/images/checkoutProcess.js" global="true"/> - <set field="layoutSettings.javaScripts[]" value="/ecommerce/images/geoAutoCompleter.js" global="true"/> + <set field="layoutSettings.javaScripts[]" value="/ordermgr/images/js/geoAutoCompleter.js" global="true"/> <script location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/cart/ShowCart.groovy"/> <script location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/customer/EditShippingAddress.groovy"/> <script location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/customer/EditBillingAddress.groovy"/> |
Free forum by Nabble | Edit this page |