Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 8f7bb9d5

Von Bernd Bleßmann vor fast 4 Jahren hinzugefügt

  • ID 8f7bb9d5dc2b961a2efc5f241dec43583f7ca21c
  • Vorgänger 3873385f
  • Nachfolger bd0dfb5f

Projekt-Picker: Parameter f. aktiv/gültig

und Filter-Daten via data an js übergeben

Unterschiede anzeigen:

SL/Presenter/Project.pm
38 38
  my @classes = $params{class} ? ($params{class}) : ();
39 39
  push @classes, 'project_autocomplete';
40 40

  
41

  
42
  my %data_params = map { $_ => delete $params{$_}  } grep { defined $params{$_} } qw(customer_id active valid);
43

  
41 44
  my $ret =
42
    input_tag($name, (ref $value && $value->can('id') ? $value->id : ''), class => "@classes", type => 'hidden', id => $id) .
43
    join('', map { $params{$_} ? input_tag("", delete $params{$_}, id => "${id}_${_}", type => 'hidden') : '' } qw(customer_id)) .
45
    input_tag($name, (ref $value && $value->can('id') ? $value->id : ''), class => "@classes", type => 'hidden', id => $id,
46
              'data-project-picker-data' => JSON::to_json(\%data_params),
47
    ) .
44 48
    input_tag("", ref $value ? $value->displayable_name : '', id => "${id}_name", %params);
45 49

  
46 50
  $::request->layout->add_javascripts('autocomplete_project.js');
js/autocomplete_project.js
25 25
    var o = $.extend({
26 26
      limit: 20,
27 27
      delay: 50,
28
    }, options);
28
    }, $real.data('project-picker-data'), options);
29 29
    var STATES = {
30 30
      PICKED:    CLASSES.PICKED,
31 31
      UNDEFINED: CLASSES.UNDEFINED
......
70 70
    function ajax_data(term) {
71 71
      var data = {
72 72
        'filter.all:substr:multi::ilike': term,
73
        'filter.valid': 'valid',
74
        'filter.active': 'active',
75 73
        no_paginate:  $('#no_paginate').prop('checked') ? 1 : 0,
76 74
        current:  $real.val(),
77 75
      };
78 76

  
79
      if ($customer_id && $customer_id.val())
80
        data['filter.customer_id'] = $customer_id.val().split(',');
77
      if (o.customer_id)
78
        data['filter.customer_id'] = o.customer_id.split(',');
79

  
80
      if (o.active) {
81
        if (o.active === 'active')   data['filter.active'] = 'active';
82
        if (o.active === 'inactive') data['filter.active'] = 'inactive';
83
        // both => no filter
84
      } else {
85
        data['filter.active'] = 'active'; // default
86
      }
87

  
88
      if (o.valid) {
89
        if (o.valid === 'valid')   data['filter.valid'] = 'valid';
90
        if (o.valid === 'invalid') data['filter.valid'] = 'invalid';
91
        // both => no filter
92
      } else {
93
        data['filter.valid'] = 'valid'; // default
94
      }
95

  
81 96
      return data;
82 97
    }
83 98

  
......
245 260
    var pp = {
246 261
      real:           function() { return $real },
247 262
      dummy:          function() { return $dummy },
248
      customer_id:    function() { return $customer_id },
249 263
      update_results: update_results,
250 264
      result_timer:   result_timer,
251 265
      set_item:       set_item,

Auch abrufbar als: Unified diff