Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision bc998bc1

Von Thomas Heck vor mehr als 11 Jahren hinzugefügt

  • ID bc998bc1f290dd5768a15c183953a05ad24c5c7a
  • Vorgänger 60d93ca0
  • Nachfolger 69e7991b

Karten-Icon nur anzeigen, wenn eine Adresse angegeben ist

Unterschiede anzeigen:

js/kivi.CustomerVendor.js
1
namespace('kivi.CustomerVendor', function() {
1
namespace('kivi.CustomerVendor', function(ns) {
2 2

  
3
  this.selectShipto = function() {
3
  var kivi = namespace('kivi');
4

  
5
  this.selectShipto = function(params) {
4 6
    var shiptoId = $('#shipto_shipto_id').val();
5 7

  
6 8
    if( shiptoId ) {
......
11 13
          $(document.getElementById('shipto_'+ key)).val(data[key]);
12 14

  
13 15
        $('#action_delete_shipto').show();
16

  
17
        if( params.onFormSet )
18
          params.onFormSet();
14 19
      });
15 20
    }
16 21
    else {
17 22
      $('#shipto :input').not(':button, :submit, :reset, :hidden').val('');
18 23

  
19 24
      $('#action_delete_shipto').hide();
25

  
26
      if( params.onFormSet )
27
        params.onFormSet();
20 28
    }
21 29
  };
22 30

  
......
35 43
    }
36 44
  };
37 45

  
38
  this.selectContact = function() {
46
  this.selectContact = function(params) {
39 47
    var contactId = $('#contact_cp_id').val();
40 48

  
41 49
    if( contactId ) {
......
44 52
      $.getJSON(url, function(data) {
45 53
        var contact = data.contact;
46 54
        for(var key in contact)
47
          $(document.getElementById('contact_'+ key)).val(contact[key]);
55
          $(document.getElementById('contact_'+ key)).val(contact[key])
48 56

  
49 57
        var cvars = data.contact_cvars;
50 58
        for(var key in cvars)
51 59
          $(document.getElementById('contact_cvar_'+ key)).val(cvars[key]);
52 60

  
53 61
        $('#action_delete_contact').show();
62

  
63
        if( params.onFormSet )
64
          params.onFormSet();
54 65
      });
55 66
    }
56 67
    else {
57 68
      $('#contacts :input').not(':button, :submit, :reset, :hidden').val('').removeAttr('checked').removeAttr('selected');
58 69

  
59 70
      $('#action_delete_contact').hide();
71

  
72
      if( params.onFormSet )
73
        params.onFormSet();
60 74
    }
61 75

  
62 76
    $('#contact_cp_title_select, #contact_cp_abteilung_select').val('');
63 77
  };
64 78

  
79
  var mapSearchStmts = [
80
    '#street',
81
    ', ',
82
    '#zipcode',
83
    ' ',
84
    '#city',
85
    ', ',
86
    '#country'
87
  ];
88

  
89
  this.showMapWidget = function(prefix, widgetWrapper) {
90
    var result = {
91
    };
92

  
93
    $(function(){
94

  
95
      widgetWrapper = $(widgetWrapper);
96

  
97
      var mapSearchElements = [];
98
      for(var i in mapSearchStmts) {
99
        var stmt = mapSearchStmts[i];
100
        if( stmt.charAt(0) == '#' ) {
101
          var elem = $('#'+ prefix + stmt.substring(1));
102
          if( elem )
103
            mapSearchElements.push(elem);
104
        }
105
      }
106

  
107
      var isNotEmpty = function() {
108
        for(var i in mapSearchElements)
109
          if( mapSearchElements[i].val() == '' )
110
            return false;
111
        return true;
112
      };
65 113

  
66
  this.showMap = function(prefix) {
67
    var searchStmts = [
68
      '#street',
69
      ', ',
70
      '#zipcode',
71
      ' ',
72
      '#city',
73
      ', ',
74
      '#country'
75
    ];
114
      widgetWrapper
115
        .html('<img src="image/map.png" alt="'+ kivi.t8("Map") +'" title="'+ kivi.t8("Map") +'" />')
116
        .click(function(){
117
          ns.showMap(prefix);
118
        });
76 119

  
120
      var testInputs = function() {
121
        if( isNotEmpty() )
122
          widgetWrapper.show();
123
        else
124
          widgetWrapper.hide();
125
      };
126

  
127
      result.testInputs = testInputs;
128

  
129
      $(mapSearchElements)
130
        .map(function() {
131
          return this.toArray();
132
        })
133
        .keyup(testInputs)
134

  
135
      if( !isNotEmpty() )
136
        widgetWrapper.hide();
137

  
138
    });
139

  
140
    return result;
141
  };
142

  
143
  this.showMap = function(prefix) {
77 144
    var searchString = "";
78 145

  
79
    for(var i in searchStmts) {
80
      var stmt = searchStmts[i];
146
    for(var i in mapSearchStmts) {
147
      var stmt = mapSearchStmts[i];
81 148
      if( stmt.charAt(0) == '#' ) {
82 149
        var val = $('#'+ prefix + stmt.substring(1)).val();
83 150
        if( val )
js/locale/de.js
1 1
namespace("kivi").setupLocale({
2 2
"Are you sure?":"Sind Sie sicher?",
3
"Map":"Karte",
3 4
"The description is missing.":"Die Beschreibung fehlt.",
4 5
"The name is missing.":"Der Name fehlt.",
5 6
"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.",
templates/webpages/customer_vendor/tabs/billing.html
87 87

  
88 88
      <td>
89 89
        [% L.input_tag('cv.street', SELF.cv.street) %]
90
        <a href="#" onclick="namespace('kivi.CustomerVendor').showMap('cv_');" title="[% 'Map' | $T8 %]">
91
          <img src="image/map.png" alt="[% 'Map' | $T8 %]" />
92
        </a>
90
        <span id="billing_map"></span>
91
        <script type="text/javascript">
92
          namespace('kivi.CustomerVendor').showMapWidget('cv_', $('#billing_map'));
93
        </script>
93 94
      </td>
94 95
    </tr>
95 96

  
templates/webpages/customer_vendor/tabs/contacts.html
18 18
            empty_title = LxERP.t8('New contact'),
19 19
            value_key = 'cp_id',
20 20
            title_key = 'full_name',
21
            onchange = "namespace('kivi.CustomerVendor').selectContact();")
21
            onchange = "namespace('kivi.CustomerVendor').selectContact({onFormSet: function(){contactsMapWidget.testInputs();}});",
22
          )
22 23
        %]
23 24
      </td>
24 25
    </tr>
......
156 157

  
157 158
      <td>
158 159
        [% L.input_tag('contact.cp_street', SELF.contact.cp_street, size = 40, maxlength = 75) %]
159

  
160
        <a href="#" onclick="namespace('kivi.CustomerVendor').showMap('contact_cp_');" title="[% 'Map' | $T8 %]">
161
          <img src="image/map.png" alt="[% 'Map' | $T8 %]" />
162
        </a>
160
        <span id="contact_map"></span>
161
        <script type="text/javascript">
162
        var contactsMapWidget = namespace('kivi.CustomerVendor').showMapWidget('contact_cp_', $('#contact_map'));
163
        </script>
163 164
      </td>
164 165
    </tr>
165 166

  
templates/webpages/customer_vendor/tabs/shipto.html
16 16
             title_key = 'displayable_id',
17 17
             with_empty = 1,
18 18
             empty_title = LxERP.t8('New shipto'),
19
             onchange = "namespace('kivi.CustomerVendor').selectShipto();"
19
             onchange = "namespace('kivi.CustomerVendor').selectShipto({onFormSet: function(){shiptoMapWidget.testInputs();}});",
20 20
           )
21 21
        %]
22 22
      </td>
......
45 45
      <td>
46 46
        [% L.input_tag('shipto.shiptostreet', SELF.shipto.shiptostreet,  size = 35, maxlength = 75) %]
47 47

  
48
        <a href="#" onclick="namespace('kivi.CustomerVendor').showMap('shipto_shipto');" title="[% 'Map' | $T8 %]">
49
          <img src="image/map.png" alt="[% 'Map' | $T8 %]" />
50
        </a>
48
        <span id="shipto_map"></span>
49
        <script type="text/javascript">
50
          var shiptoMapWidget = namespace('kivi.CustomerVendor').showMapWidget('shipto_shipto', $('#shipto_map'));
51
        </script>
51 52
      </td>
52 53
    </tr>
53 54

  

Auch abrufbar als: Unified diff