Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision a3afc944

Von Moritz Bunkus vor mehr als 7 Jahren hinzugefügt

  • ID a3afc944f025a130a55d440b045eceadb0630466
  • Vorgänger 9ea32302
  • Nachfolger 5781315d

ActionBar: Verwendung bei »System« → »Einheiten bearbeiten«

Unterschiede anzeigen:

bin/mozilla/am.pl
39 39
use SL::AM;
40 40
use SL::CA;
41 41
use SL::Form;
42
use SL::Helper::Flash;
42 43
use SL::User;
43 44
use SL::USTVA;
44 45
use SL::Iconv;
......
795 796
  $main::lxdebug->leave_sub();
796 797
}
797 798

  
799
sub add_unit {
800
  $::auth->assert('config');
801

  
802
  # my $units = AM->retrieve_units(\%::myconfig, $::form, "resolved_");
803
  # # AM->units_in_use(\%::myconfig, $::form, $units);
804

  
805
  # $units->{$_}->{BASE_UNIT_DDBOX} = AM->unit_select_data($units, $units->{$_}->{base_unit}, 1) for keys %{$units};
806

  
807
  my @languages = @{ SL::DB::Manager::Language->get_all_sorted };
808

  
809
  my $units = AM->retrieve_units(\%::myconfig, $::form);
810
  my $ddbox = AM->unit_select_data($units, undef, 1);
811

  
812
  setup_am_add_unit_action_bar();
813

  
814
  $::form->{title} = $::locale->text("Add unit");
815
  $::form->header();
816
  print($::form->parse_html_template("am/add_unit", {
817
    NEW_BASE_UNIT_DDBOX => $ddbox,
818
    LANGUAGES           => \@languages,
819
  }));
820
}
821

  
798 822
sub edit_units {
799 823
  $main::lxdebug->enter_sub();
800 824

  
......
831 855
  $units = AM->retrieve_units(\%myconfig, $form);
832 856
  my $ddbox = AM->unit_select_data($units, undef, 1);
833 857

  
834
  $form->{"title"} = $locale->text("Add and edit units");
858
  setup_am_edit_units_action_bar();
859

  
860
  $form->{"title"} = $locale->text("Edit units");
835 861
  $form->header();
836 862
  print($form->parse_html_template("am/edit_units",
837 863
                                   { "UNITS"               => \@unit_list,
......
842 868
  $main::lxdebug->leave_sub();
843 869
}
844 870

  
845
sub add_unit {
871
sub create_unit {
846 872
  $main::lxdebug->enter_sub();
847 873

  
848 874
  my $form     = $main::form;
......
877 903

  
878 904
  AM->add_unit(\%myconfig, $form, $form->{"new_name"}, $base_unit, $factor, \@languages);
879 905

  
880
  $form->{"saved_message"} = $locale->text("The unit has been saved.");
906
  flash_later('info', $locale->text("The unit has been added."));
881 907

  
882
  edit_units();
908
  print $form->redirect_header('am.pl?action=edit_units');
883 909

  
884 910
  $main::lxdebug->leave_sub();
885 911
}
......
983 1009

  
984 1010
  AM->save_units(\%myconfig, $form, $new_units, \@delete_units);
985 1011

  
986
  $form->{"saved_message"} = $locale->text("The units have been saved.");
1012
  flash_later('info', $locale->text("The units have been saved."));
987 1013

  
988
  edit_units();
1014
  print $form->redirect_header('am.pl?action=edit_units');
989 1015

  
990 1016
  $main::lxdebug->leave_sub();
991 1017
}
......
1463 1489
    );
1464 1490
  }
1465 1491
}
1492

  
1493
sub setup_am_add_unit_action_bar {
1494
  my %params = @_;
1495

  
1496
  for my $bar ($::request->layout->get('actionbar')) {
1497
    $bar->add(
1498
      action => [
1499
        t8('Save'),
1500
        submit    => [ '#form', { action => "create_unit" } ],
1501
        accesskey => 'enter',
1502
      ],
1503

  
1504
      'separator',
1505

  
1506
      link => [
1507
        t8('Back'),
1508
        link => 'am.pl?action=edit_units',
1509
      ],
1510
    );
1511
  }
1512
}
1513

  
1514
sub setup_am_edit_units_action_bar {
1515
  my %params = @_;
1516

  
1517
  for my $bar ($::request->layout->get('actionbar')) {
1518
    $bar->add(
1519
      action => [
1520
        t8('Save'),
1521
        submit    => [ '#form', { action => "save_unit" } ],
1522
        accesskey => 'enter',
1523
      ],
1524

  
1525
      'separator',
1526

  
1527
      link => [
1528
        t8('Add'),
1529
        link => 'am.pl?action=add_unit',
1530
      ],
1531
    );
1532
  }
1533
}

Auch abrufbar als: Unified diff