Bug 7626: Delete multiple tags in OPAC at once
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / opac-tags.tt
1 [% USE Koha %]
2 [% USE KohaDates %]
3
4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; Tags</title>
6 [% INCLUDE 'doc-head-close.inc' %]
7 [% BLOCK cssinclude %]
8     <style type="text/css">
9         fieldset { padding : .3em;margin:.3em 0;}
10         #tagcloud    {background-color: #F3F3F3; text-align: justify;padding:7px;}
11         .tag a       {text-decoration: none;}
12         .tag a:hover {text-decoration: underline;}
13         .tag         {display: block; padding-left: 1em;}
14         .tagcount    {display: none;}
15         .cloudweight {display: none;}
16         .tagweight {
17             display: none;
18             position: relative;
19             bottom: 0.4em;
20             color: red;
21             font-size: 12px;
22         }
23     </style>
24 [% END %]
25 </head>
26 [% IF ( loggedinusername ) %][% INCLUDE 'bodytag.inc' bodyid='opac-usertags' bodyclass='scrollto' %][% ELSE %][% INCLUDE 'bodytag.inc' bodyid='opac-tags' bodyclass='scrollto' %][% END %]
27 [% INCLUDE 'masthead.inc' %]
28
29 <div class="main">
30     <ul class="breadcrumb">
31         <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
32         <li><a href="#">Tags</a></li>
33     </ul>
34
35     <div class="container-fluid">
36         <div class="row-fluid">
37             [% IF ( OpacNav||loggedinusername ) %]
38                 <div class="span2">
39                     <div id="navigation">
40                         [% INCLUDE 'navigation.inc' IsPatronPage=1 %]
41                     </div>
42                 </div>
43                 <div class="span10">
44             [% ELSE %]
45                 <div class="span12">
46             [% END %]
47
48                     <div id="usertags" class="maincontent">
49                         [% IF ( ERRORS ) %]
50                             [% FOREACH ERROR IN ERRORS %]
51                                 <div class="alert">
52                                     There was a problem with this operation:
53                                     [% IF ( ERROR.tagsdisabled ) %]
54                                         Sorry, tags are not enabled on this system.
55                                     [% ELSIF ( ERROR.badparam ) %]
56                                         ERROR: illegal parameter [% ERROR.badparam %]
57                                     [% ELSIF ( ERROR.login ) %]
58                                         ERROR: You must log in to complete that action.
59                                     [% ELSIF ( ERROR.failed_delete ) %]
60                                         ERROR: You cannot delete the tag [% ERROR.failed_delete %].
61                                         <br />Note: you can only delete your own tags.
62                                     [% ELSIF ( ERROR.scrubbed ) %]
63                                         Note: your tag contained markup code that was removed.
64                                         <br />The tag was added as &quot;[% ERROR.scrubbed %]&quot;.
65                                     [% ELSIF ( ERROR.scrubbed_all_bad ) %]
66                                         Note: your tag was entirely markup code.  It was NOT added.
67                                         <br />Please try again with plain text.
68                                     [% ELSE %]Unrecognized error.
69                                     [% END %]
70                                 </div>
71                             [% END %]
72                         [% END # /IF ERRORS %]
73                         <h1>All Tags</h1>
74
75                         <form method="get" action="opac-tags.pl" class="form-inline">
76                             <fieldset>
77                                 <label>
78                                     [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
79                                         Tags to show from other users
80                                     [% ELSE %]
81                                         Tags to show
82                                     [% END %]:
83                                 </label>
84                                 <div class="input-append">
85                                     <input type="text" name="limit" style="text-align: right;" maxlength="4" size="4" value="[% limit or "100" %]" />
86                                     <input type="submit" value="OK" class="btn" />
87                                 </div>
88                                 [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
89                                     [% UNLESS ( loggedinusername ) %]
90                                         <p><a class="loginModal-trigger" href="/cgi-bin/koha/opac-user.pl">Log in to see your own saved tags.</a></p>
91                                     [% END %]
92                                 [% END %]
93                             </fieldset>
94                         </form>
95
96                         [% IF ( TAGLOOP ) %]
97                             <div id="tagcloud">
98                                 [% FOREACH TAGLOO IN TAGLOOP %]
99                                     <span class="tag tagweight[% TAGLOO.stratum %]" id="tag[% loop.count %]" style="display:inline;">
100                                     <a href="/cgi-bin/koha/opac-search.pl?tag=[% TAGLOO.term |url %]&amp;q=[% TAGLOO.term |url %]">[% TAGLOO.term |html %]</a>
101                                     <span class="tagweight">[% TAGLOO.weight_total %]</span>
102                                     </span>
103                                 [% END %]
104                             </div>
105                         [% END # / TAGLOOP%]
106                         [% IF ( add_op ) %]
107                             [% IF ( added_count ) %]
108                                 <div class="dialog message">[% added_count %] [% IF ( added_count == 1 ) %]tag[% ELSE %]tags[% END %] successfully added.</div>
109                             [% END %]
110                             [% IF ( deleted_count ) %]
111                             <div class="dialog message">[% deleted_count %] [% IF ( deleted_count == 1 ) %]tag[% ELSE %]tags[% END %] successfully deleted.</div>
112                             [% END %]
113                         [% END # /add_op %]
114
115                         [% IF ( MY_TAGS ) %]
116                         <form id="deletetags" method="post" action="opac-tags.pl">
117                             <h2>Your tags</h2>
118                             <table id="mytagst" class="table table-bordered table-striped">
119                                 <thead><tr><th>&nbsp;</th><th>Term</th><th>Title</th><th>Date added</th></tr></thead>
120                                 <tbody>
121                                     [% FOREACH MY_TAG IN MY_TAGS %]
122                                         <tr>
123                                             <td>
124                                                 <input type="checkbox" name="del[% MY_TAG.tag_id %]" value="del[% MY_TAG.tag_id %]">
125                                             </td>
126                                             <td class="tagterm">
127                                                 <span class="tdlabel">Tag:</span>
128                                                 [% IF MY_TAG.approved == 1 %]
129                                                     <a href="/cgi-bin/koha/opac-search.pl?tag=[% MY_TAG.term |url %]&amp;q=[% MY_TAG.term |url %]">[% MY_TAG.term |html %]</a>
130                                                 [% ELSE %]
131                                                     [% MY_TAG.term |html %] (not approved)
132                                                 [% END %]
133                                             </td>
134                                             <td>
135                                                 [% IF ( MY_TAG.XSLTBloc ) %]
136                                                     [% MY_TAG.XSLTBloc %]
137                                                 [% ELSE %]
138                                                     <span class="tdlabel">Title:</span>
139                                                     <a class="title" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% MY_TAG.biblionumber %]">
140                                                         [% MY_TAG.title |html %]
141                                                         [% IF ( MY_TAG.subtitle ) %]
142                                                             [% FOREACH subtitle IN MY_TAG.subtitle %]
143                                                                 [% subtitle.subfield |html %]
144                                                             [% END %]
145                                                         [% END %]
146                                                     </a>
147                                                     [% IF ( MY_TAG.author ) %]
148                                                         by [% MY_TAG.author %]
149                                                     [% END %]
150                                                 [% END # /IF MY_TAG.XSLTBloc %]
151                                             </td>
152                                             <td>
153                                                 <span title="[% MY_TAG.date_created %]">
154                                                     <span class="tdlabel">Date added:</span>
155                                                     [% MY_TAG.date_created | $KohaDates %]
156                                                 </span>
157                                             </td>
158                                         </tr>
159                                     [% END %]
160                                 </tbody>
161                             </table>
162                             <input type="submit" value="Delete selected tags" class="btn btn-danger btn-sm delete">
163                         </form>
164                         [% END # /MY_TAGS %]
165                     </div> <!-- / .usertags -->
166                 </div> <!-- / .span10/12 -->
167             </div> <!-- / .row-fluid -->
168         </div> <!-- / .container-fluid -->
169     </div> <!-- / .main -->
170
171 [% INCLUDE 'opac-bottom.inc' %]
172 [% BLOCK jsinclude %]
173 [% INCLUDE 'datatables.inc' %]
174 <script type="text/javascript">
175 //<![CDATA[
176     function checkboxesChecked() {
177         if ($("#deletetags input:checkbox:checked").length > 0) {
178             return 1;
179         } else {
180             return 0;
181         }
182     }
183
184     $(document).ready(function(){
185         var MSG_DELETE_TAG = _("Are you sure you want to delete the selected tag(s)?");
186         $(".delete").on("click", function(e){
187             if ( checkboxesChecked() == 1 ) {
188                 return confirmDelete(MSG_DELETE_TAG);
189             } else {
190                 alert(_("Please select a tag to delete."));
191                 e.preventDefault();
192             }
193         });
194
195         $("#mytagst").dataTable($.extend(true, {}, dataTablesDefaults, {
196             "aaSorting": [[ 2, "asc" ]],
197             "aoColumnDefs": [
198               { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false }
199             ],
200             "aoColumns": [
201                 null,
202                 { "sType": "anti-the" },
203                 { "sType": "title-string" },
204                 null
205             ]
206         }));
207     });
208 //]]>
209 </script>
210 [% END %]