Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 5b64d6fc

Von Moritz Bunkus vor mehr als 15 Jahren hinzugefügt

  • ID 5b64d6fcbd6a3b97fe0d7689bae9d72f04ad7307
  • Vorgänger 20bb56c1
  • Nachfolger 69c9c335

Umstellung der Verwaltung der benutzerdefinierten Variablen zum Sparen von Menüeinträgen.

Unterschiede anzeigen:

bin/mozilla/amcvar.pl
36 36
use SL::Form;
37 37

  
38 38
use Data::Dumper;
39
use List::MoreUtils qw(any);
39 40

  
40 41
1;
41 42

  
......
54 55

  
55 56
our @types = qw(text textfield number date bool select); # timestamp
56 57

  
58
our @modules = ({ module => 'CT',       description => $locale->text('Customers and vendors')          },
59
                { module => 'IC',       description => $locale->text('Parts, services and assemblies') },
60
                { module => 'Projects', description => $locale->text('Projects')                       },
61
               );
62

  
57 63
sub add {
58 64
  add_cvar_config();
59 65
}
......
62 68
  edit_cvar_config();
63 69
}
64 70

  
71
sub _is_valid_module {
72
  my $module = shift;
73

  
74
  return any { $_->{module} eq $module } @modules;
75
}
76

  
65 77
sub list_cvar_configs {
66 78
  $lxdebug->enter_sub();
67 79

  
68 80
  $auth->assert('config');
69 81

  
70
  $form->{module} ||= $form->{cvar_module};
82
  $form->{module} = $form->{module} || $form->{cvar_module} || 'CT';
83
  $form->{module} = 'CT' unless _is_valid_module($form->{module});
71 84

  
72
  my @configs = grep { $_->{module} eq $form->{module} } @{ CVar->get_configs() };
85
  my @configs = @{ CVar->get_configs(module => $form->{module}) };
73 86

  
74 87
  my $previous_config;
75 88

  
......
86 99

  
87 100
  $form->{title} = $locale->text('List of custom variables');
88 101
  $form->header();
89
  print $form->parse_html_template('amcvar/list_cvar_configs', { 'CONFIGS' => \@configs });
102
  print $form->parse_html_template('amcvar/list_cvar_configs', { CONFIGS => \@configs,
103
                                                                 MODULES => \@modules });
104

  
105
  $main::lxdebug->dump(0, "modules", \@modules);
90 106

  
91 107
  $lxdebug->leave_sub();
92 108
}
......
96 112

  
97 113
  $auth->assert('config');
98 114

  
99
  $form->{module} ||= $form->{cvar_module};
115
  $form->{module} = $form->{module} || $form->{cvar_module} || 'CT';
100 116

  
101 117
  $form->{edit} = 0;
102 118
  display_cvar_config_form();
......
176 192
  $form->{title} = $form->{edit} ? $locale->text("Edit custom variable") : $locale->text("Add custom variable");
177 193

  
178 194
  $form->header();
179
  print $form->parse_html_template("amcvar/display_cvar_config_form", { 'TYPES' => \@types });
195
  print $form->parse_html_template("amcvar/display_cvar_config_form", { TYPES   => \@types,
196
                                                                        MODULES => \@modules });
180 197

  
181 198
  $lxdebug->leave_sub();
182 199
}
......
191 208
  $lxdebug->leave_sub();
192 209
}
193 210

  
211
sub dispatcher {
212
  foreach my $action (qw(list_cvar_configs add_cvar_config)) {
213
    if ($form->{"action_${action}"}) {
214
      call_sub($action);
215
      return;
216
    }
217
  }
218

  
219
  $form->error($locale->text('No action defined.'));
220
}
221

  
194 222
1;

Auch abrufbar als: Unified diff