From: Thomas Heck Date: Mon, 1 Jul 2013 12:42:29 +0000 (+0200) Subject: Karten-Icon nur anzeigen, wenn eine Adresse angegeben ist X-Git-Tag: release-3.1.0beta1~161^2^2~23 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=3bb283ad739b95704f8df9a55c1ed0b86f617f23;p=kivitendo-erp.git Karten-Icon nur anzeigen, wenn eine Adresse angegeben ist --- diff --git a/js/kivi.CustomerVendor.js b/js/kivi.CustomerVendor.js index 371434c21..134efb492 100644 --- a/js/kivi.CustomerVendor.js +++ b/js/kivi.CustomerVendor.js @@ -1,6 +1,8 @@ -namespace('kivi.CustomerVendor', function() { +namespace('kivi.CustomerVendor', function(ns) { - this.selectShipto = function() { + var kivi = namespace('kivi'); + + this.selectShipto = function(params) { var shiptoId = $('#shipto_shipto_id').val(); if( shiptoId ) { @@ -11,12 +13,18 @@ namespace('kivi.CustomerVendor', function() { $(document.getElementById('shipto_'+ key)).val(data[key]); $('#action_delete_shipto').show(); + + if( params.onFormSet ) + params.onFormSet(); }); } else { $('#shipto :input').not(':button, :submit, :reset, :hidden').val(''); $('#action_delete_shipto').hide(); + + if( params.onFormSet ) + params.onFormSet(); } }; @@ -35,7 +43,7 @@ namespace('kivi.CustomerVendor', function() { } }; - this.selectContact = function() { + this.selectContact = function(params) { var contactId = $('#contact_cp_id').val(); if( contactId ) { @@ -44,40 +52,99 @@ namespace('kivi.CustomerVendor', function() { $.getJSON(url, function(data) { var contact = data.contact; for(var key in contact) - $(document.getElementById('contact_'+ key)).val(contact[key]); + $(document.getElementById('contact_'+ key)).val(contact[key]) var cvars = data.contact_cvars; for(var key in cvars) $(document.getElementById('contact_cvar_'+ key)).val(cvars[key]); $('#action_delete_contact').show(); + + if( params.onFormSet ) + params.onFormSet(); }); } else { $('#contacts :input').not(':button, :submit, :reset, :hidden').val('').removeAttr('checked').removeAttr('selected'); $('#action_delete_contact').hide(); + + if( params.onFormSet ) + params.onFormSet(); } $('#contact_cp_title_select, #contact_cp_abteilung_select').val(''); }; + var mapSearchStmts = [ + '#street', + ', ', + '#zipcode', + ' ', + '#city', + ', ', + '#country' + ]; + + this.showMapWidget = function(prefix, widgetWrapper) { + var result = { + }; + + $(function(){ + + widgetWrapper = $(widgetWrapper); + + var mapSearchElements = []; + for(var i in mapSearchStmts) { + var stmt = mapSearchStmts[i]; + if( stmt.charAt(0) == '#' ) { + var elem = $('#'+ prefix + stmt.substring(1)); + if( elem ) + mapSearchElements.push(elem); + } + } + + var isNotEmpty = function() { + for(var i in mapSearchElements) + if( mapSearchElements[i].val() == '' ) + return false; + return true; + }; - this.showMap = function(prefix) { - var searchStmts = [ - '#street', - ', ', - '#zipcode', - ' ', - '#city', - ', ', - '#country' - ]; + widgetWrapper + .html(''+ kivi.t8(') + .click(function(){ + ns.showMap(prefix); + }); + var testInputs = function() { + if( isNotEmpty() ) + widgetWrapper.show(); + else + widgetWrapper.hide(); + }; + + result.testInputs = testInputs; + + $(mapSearchElements) + .map(function() { + return this.toArray(); + }) + .keyup(testInputs) + + if( !isNotEmpty() ) + widgetWrapper.hide(); + + }); + + return result; + }; + + this.showMap = function(prefix) { var searchString = ""; - for(var i in searchStmts) { - var stmt = searchStmts[i]; + for(var i in mapSearchStmts) { + var stmt = mapSearchStmts[i]; if( stmt.charAt(0) == '#' ) { var val = $('#'+ prefix + stmt.substring(1)).val(); if( val ) diff --git a/js/locale/de.js b/js/locale/de.js index 0d45d3094..883ac6b60 100644 --- a/js/locale/de.js +++ b/js/locale/de.js @@ -1,5 +1,6 @@ namespace("kivi").setupLocale({ "Are you sure?":"Sind Sie sicher?", +"Map":"Karte", "The description is missing.":"Die Beschreibung fehlt.", "The name is missing.":"Der Name fehlt.", "The name must only consist of letters, numbers and underscores and start with a letter.":"Der Name darf nur aus Buchstaben (keine Umlaute), Ziffern und Unterstrichen bestehen und muss mit einem Buchstaben beginnen.", diff --git a/templates/webpages/customer_vendor/tabs/billing.html b/templates/webpages/customer_vendor/tabs/billing.html index f666b5a9c..d2b422573 100644 --- a/templates/webpages/customer_vendor/tabs/billing.html +++ b/templates/webpages/customer_vendor/tabs/billing.html @@ -87,9 +87,10 @@ [% L.input_tag('cv.street', SELF.cv.street) %] - - [% 'Map' | $T8 %] - + + diff --git a/templates/webpages/customer_vendor/tabs/contacts.html b/templates/webpages/customer_vendor/tabs/contacts.html index 1238a4dc3..398f60c88 100644 --- a/templates/webpages/customer_vendor/tabs/contacts.html +++ b/templates/webpages/customer_vendor/tabs/contacts.html @@ -18,7 +18,8 @@ empty_title = LxERP.t8('New contact'), value_key = 'cp_id', title_key = 'full_name', - onchange = "namespace('kivi.CustomerVendor').selectContact();") + onchange = "namespace('kivi.CustomerVendor').selectContact({onFormSet: function(){contactsMapWidget.testInputs();}});", + ) %] @@ -156,10 +157,10 @@ [% L.input_tag('contact.cp_street', SELF.contact.cp_street, size = 40, maxlength = 75) %] - - - [% 'Map' | $T8 %] - + + diff --git a/templates/webpages/customer_vendor/tabs/shipto.html b/templates/webpages/customer_vendor/tabs/shipto.html index ef20e7fe1..5080802c8 100644 --- a/templates/webpages/customer_vendor/tabs/shipto.html +++ b/templates/webpages/customer_vendor/tabs/shipto.html @@ -16,7 +16,7 @@ title_key = 'displayable_id', with_empty = 1, empty_title = LxERP.t8('New shipto'), - onchange = "namespace('kivi.CustomerVendor').selectShipto();" + onchange = "namespace('kivi.CustomerVendor').selectShipto({onFormSet: function(){shiptoMapWidget.testInputs();}});", ) %] @@ -45,9 +45,10 @@ [% L.input_tag('shipto.shiptostreet', SELF.shipto.shiptostreet, size = 35, maxlength = 75) %] - - [% 'Map' | $T8 %] - + +