From: gibus Date: Tue, 23 Jan 2018 15:47:22 +0000 (+0100) Subject: #57165 add periodic autosave feature to RT-Extension-Drafts X-Git-Url: http://git.home-dn.net/?p=manu%2FRT-Extension-Drafts.git;a=commitdiff_plain;h=55f6e31abfc10cdf39978def5b11730ac5383a42 #57165 add periodic autosave feature to RT-Extension-Drafts --- diff --git a/html/Callbacks/Drafts/Ticket/Update.html/AfterMessageBox b/html/Callbacks/Drafts/Ticket/Update.html/AfterMessageBox index 2a92f3c..fb9e389 100644 --- a/html/Callbacks/Drafts/Ticket/Update.html/AfterMessageBox +++ b/html/Callbacks/Drafts/Ticket/Update.html/AfterMessageBox @@ -2,6 +2,21 @@ % } + + <%init> my $Ticket = LoadTicket($ARGS{'id'}); diff --git a/html/Helpers/SaveDraft b/html/Helpers/SaveDraft new file mode 100644 index 0000000..c7e0ac5 --- /dev/null +++ b/html/Helpers/SaveDraft @@ -0,0 +1,27 @@ +<%ARGS> +$UserId => undef; +$TicketId => undef; +$Content => undef; +$ContentType => undef; + + +<%INIT> +my $Ticket = LoadTicket($TicketId); +my $Draft = RT::Attribute->new($session{'CurrentUser'}); +$Draft->LoadByNameAndObject(Object => $session{'CurrentUser'}->UserObj, Name => 'Draft-' . $Ticket->id); +my ($ok, $msg) = (0, ''); +if ($Content) { + if ($Draft && $Draft->Id) { + ($ok, $msg) = $Draft->SetContent($Content); + $Draft->SetContentType($ContentType); + } else { + ($ok, $msg) = $Draft->Create(Name => 'Draft-' . $Ticket->id, + Object => $session{'CurrentUser'}->UserObj, + Content => $Content, + ContentType => $ContentType, + ); + } +} +$m->out($msg); +$m->abort; + diff --git a/lib/RT/Extension/Drafts.pm b/lib/RT/Extension/Drafts.pm index 90f0581..818a3ca 100644 --- a/lib/RT/Extension/Drafts.pm +++ b/lib/RT/Extension/Drafts.pm @@ -78,4 +78,15 @@ Request Tracker (RT) is Copyright Best Practical Solutions, LLC. =cut +# User overridable options +$RT::Config::META{AutoSaveDraftPeriod} = { + Section => 'Ticket composition', + Overridable => 1, + SortOrder => 20, + Widget => '/Widgets/Form/Integer', + WidgetArguments => { + Description => 'Period (in seconds) to automatically save a response/comment draft' + }, +}; + 1; # End of RT::Extension::Drafts