Bug 26431: Use split button to offer choice of WYSIWYG or code editor for news
This patch modifies the news interface so that the user is offered a
choice of editing news items using the default editor as defined by the
NewsToolEditor system preference or the non-default one.
To test, apply the patch and go to Tools -> News.
- In the list of news items you should see an "Edit" split button in
each row.
- Clicking the "Edit" part of the button should open the edit view with
the correct editor as defined by the NewsToolEditor preference.
- Clicking the menu arrow on the button should offer the other editing
method:
- If NewsToolEditor is set to "WYSIWYG," the menu should offer "text
editor."
- If NewsToolEditor is set to "text editor," the menu should offer
"WYSIWYG editor."
- Test the button with the NewsToolEditor preference set to both options
and confirm that the button and menu work correctly.
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit 7248562956)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
49de13e03a
commit
8d4069ca27
|
|
@ -9,7 +9,7 @@
|
|||
[% INCLUDE 'doc-head-close.inc' %]
|
||||
[% IF ( opac_news_count ) %]
|
||||
[% END %]
|
||||
[% IF Koha.Preference('NewsToolEditor') == 'codemirror' %]
|
||||
[% UNLESS ( wysiwyg ) %]
|
||||
[% Asset.css("lib/codemirror/codemirror.css") | $raw %]
|
||||
[% Asset.css("lib/codemirror/lint.min.css") | $raw %]
|
||||
<style>
|
||||
|
|
@ -159,8 +159,28 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div>
|
|||
[% opac_new.content | $raw %]
|
||||
</td>
|
||||
<td class="actions">
|
||||
<a href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&id=[% opac_new.idnew | uri %]" class="btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
|
||||
<a href="/cgi-bin/koha/tools/koha-news.pl?op=del&ids=[% opac_new.idnew | uri %]" class="delete_news btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</a>
|
||||
[% IF ( wysiwyg ) %]
|
||||
[% SET editmode = "wysiwyg" %]
|
||||
[% ELSE %]
|
||||
[% SET editmode = "text" %]
|
||||
[% END %]
|
||||
<div class="btn-group dropup">
|
||||
<a href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&id=[% opac_new.idnew | uri %]&editmode=[% editmode | uri %]" class="btn btn-default btn-xs"> <i class="fa fa-pencil"></i> Edit</a><button class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu pull-right">
|
||||
<li>
|
||||
[% IF ( wysiwyg ) %]
|
||||
<a href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&id=[% opac_new.idnew | uri %]&editmode=text"><i class="fa fa-pencil"></i> Edit with text editor</a>
|
||||
[% ELSE %]
|
||||
<a href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&id=[% opac_new.idnew | uri %]&editmode=wysiwyg"><i class="fa fa-pencil"></i> Edit with WYSIWYG editor</a>
|
||||
[% END %]
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<a href="/cgi-bin/koha/tools/koha-news.pl?op=del&ids=[% opac_new.idnew | uri %]" class="delete_news btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
[% END %]</tbody>
|
||||
|
|
@ -305,7 +325,7 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div>
|
|||
});
|
||||
</script>
|
||||
[% END %]
|
||||
[% IF Koha.Preference('NewsToolEditor') == 'codemirror' %]
|
||||
[% UNLESS ( wysiwyg ) %]
|
||||
[% Asset.js( "lib/codemirror/codemirror.min.js" ) | $raw %]
|
||||
[% Asset.js( "lib/codemirror/xml.min.js" ) | $raw %]
|
||||
[% Asset.js( "lib/codemirror/lint.min.js" ) | $raw %]
|
||||
|
|
|
|||
|
|
@ -47,6 +47,12 @@ my $number = $cgi->param('number');
|
|||
my $lang = $cgi->param('lang');
|
||||
my $branchcode = $cgi->param('branch');
|
||||
my $error_message = $cgi->param('error_message');
|
||||
my $wysiwyg;
|
||||
if( $cgi->param('editmode') ){
|
||||
$wysiwyg = $cgi->param('editmode') eq "wysiwyg" ? 1 : 0;
|
||||
} else {
|
||||
$wysiwyg = C4::Context->preference("NewsToolEditor") eq "tinymce" ? 1 : 0;
|
||||
}
|
||||
|
||||
# Foreign Key constraints work with NULL, not ''
|
||||
# NULL = All branches.
|
||||
|
|
@ -158,5 +164,8 @@ else {
|
|||
opac_news_count => $opac_news_count,
|
||||
);
|
||||
}
|
||||
$template->param( lang => $lang );
|
||||
$template->param(
|
||||
lang => $lang,
|
||||
wysiwyg => $wysiwyg,
|
||||
);
|
||||
output_html_with_http_headers $cgi, $cookie, $template->output;
|
||||
|
|
|
|||
Loading…
Reference in New Issue