diff --git a/lib/admin.pm b/lib/admin.pm index 213f819..e2fac7c 100644 --- a/lib/admin.pm +++ b/lib/admin.pm @@ -16,7 +16,7 @@ use XML::Simple; use Catalyst::Log::Log4perl; -use Catalyst qw/ConfigLoader Static::Simple Unicode +use Catalyst qw/-Debug ConfigLoader Static::Simple Unicode Authentication Authentication::Store::Minimal Authentication::Credential::Password Session Session::Store::FastMmap Session::State::Cookie /; diff --git a/lib/admin/Controller/sound.pm b/lib/admin/Controller/sound.pm index 9a856e3..33fe333 100644 --- a/lib/admin/Controller/sound.pm +++ b/lib/admin/Controller/sound.pm @@ -45,6 +45,11 @@ sub handle : Chained('set') PathPart('handle') CaptureArgs(1) { $c->stash->{handle_id} = $handle_id; } +sub edit_handle : Chained('handle') PathPart('edit') Args(0) { + my ($self, $c) = @_; + $c->stash->{template} = 'tt/sound_edit_files.tt'; +} + sub upload_soundfile : Chained('handle') PathPart('soundfile/upload') Args(0) { my ($self, $c) = @_; my %messages; @@ -91,8 +96,7 @@ sub upload_soundfile : Chained('handle') PathPart('soundfile/upload') Args(0) { } $c->session->{messages} = \%messages; - # $c->response->redirect('/sound/set/' . $c->stash->{set_id} . '/edit#set_' . $c->stash->{set_id}); - $c->response->redirect('/sound/set/' . $c->stash->{set_id} . '/editfiles'); + $c->response->redirect('/sound/set/' . $c->stash->{set_id} . '/edithandles'); } sub get_soundfile : Chained('handle') PathPart('soundfile/get') Args(0) { @@ -117,7 +121,7 @@ sub edit_set : Chained('set') PathPart('edit') Args(0) { $c->stash->{template} = 'tt/sound.tt'; } -sub edit_files : Chained('set') PathPart('editfiles') Args(0) { +sub edit_files : Chained('set') PathPart('edithandles') Args(0) { my ($self, $c) = @_; $c->stash->{template} = 'tt/sound_edit_files.tt'; } @@ -161,8 +165,7 @@ sub delete_handle : Chained('handle') PathPart('delete') Args(0) { $messages{sound_set_err} = 'Client.Voip.InputErrorFound'; } - # $c->response->redirect('/sound/set/' . $c->stash->{set_id} . '/edit#set_' . $c->stash->{set_id}); - $c->response->redirect('/sound/set/' . $c->stash->{set_id} . '/editfiles'); + $c->response->redirect('/sound/set/' . $c->stash->{set_id} . '/edithandles'); } sub save_set : Chained('set') PathPart('save') Args(0) { @@ -202,6 +205,29 @@ sub save_set : Chained('set') PathPart('save') Args(0) { $c->response->redirect("/sound"); } +sub save_handle : Chained('handle') PathPart('save') Args(0) { + my ($self, $c) = @_; + $c->stash->{template} = 'tt/sound_edit_files.tt'; + my %messages; + + if ($c->model('Provisioning')->call_prov($c, 'voip', + 'update_sound_handle', + { set_id => $c->stash->{set_id}, + handle_id => $c->stash->{handle_id}, + loopplay => $c->request->params->{loopplay} eq 'on' ? 1 : 0, + }, + undef)) + { + $messages{sound_set_msg} = 'Server.Voip.SavedSettings'; + } + else { + $messages{sound_set_err} = 'Client.Voip.InputErrorFound'; + } + + $c->session->{messages} = \%messages; + $c->response->redirect('/sound/set/' . $c->stash->{set_id} . '/edithandles'); +} + sub load_sets :Private { my ($self, $c) = @_; diff --git a/root/tt/sound.tt b/root/tt/sound.tt index 19c33e2..5079349 100644 --- a/root/tt/sound.tt +++ b/root/tt/sound.tt @@ -37,7 +37,7 @@
  • - [% set.name %] + [% set.name %] [% IF count > 0 %] [% plural = 's' IF count > 1 %] (mapped [% count %] time[% plural %]) diff --git a/root/tt/sound_edit_files.tt b/root/tt/sound_edit_files.tt index ca9b3fc..8e54ada 100644 --- a/root/tt/sound_edit_files.tt +++ b/root/tt/sound_edit_files.tt @@ -11,7 +11,8 @@
  • Setname
    Handle
    -
    Filename
    +
    Loopplay
    +
    Filename
  • @@ -28,26 +29,42 @@
  • [% h.name %]
    - - [% IF h.filename.length AND NOT h.err %] -
    [% h.filename %]
    -
    -
    - [% UNLESS Catalyst.session.admin.read_only %] - - [% END %] - -
    - [% ELSE %] + + [% IF NOT h.filename.length %] [%# kein file %]
    -
    +
    +
    [%# value='' is ignored by browsers for security reasons for file-input-fields %]
    -
    +
    + [% ELSIF handle_id == h.id %] [%# edit %] +
    +
    +
    [% h.filename %]
    +
    + +
    +
    + Cancel +
    +
    + [% ELSE %] [%# view %] +
    + +
    + [% UNLESS Catalyst.session.admin.read_only %] +
    + Edit +
    +
    + +
    + [% END %] +
    [% END %]
  • [% END %]