source: indico/indico/MaKaC/webinterface/tpls/ConfReviewingAssignContributions.tpl @ 423698

burotelhello-world-walkthroughipv6v0.98-seriesv0.98.2v0.98.3v0.98b1v0.98b2v0.99v1.0v1.1
Last change on this file since 423698 was 423698, checked in by Jose Benito <jose.benito.gonzalez@…>, 3 years ago

[FIXED] - wording & layout & ListofContr? bug

  • wording everywhere in the module
  • layout
  • List of Contributions for the Content Reviewer - if the materials are not sibmitted - the link is unclickable.
  • Property mode set to 100644
File size: 48.9 KB
Line 
1<% import MaKaC.webinterface.urlHandlers as urlHandlers %>
2<% from MaKaC.common.timezoneUtils import nowutc %>
3<% from MaKaC.conference import ContribStatusNone %>
4
5<% dueDateFormat = "%a %d %b %Y" %>
6<% color = '' %>
7<% if not ConfReview.hasReviewing(): %>
8<p style="padding-left: 25px;"><font color="gray"><%= _("Type of reviewing has not been chosen yet")%></font></p>
9<% end %>
10<% else: %>
11<% if len(Conference.getContributionListSortedById()) == 0: %>
12<p style="padding-left: 25px;"><font color="gray"><%= _("There are no contributions to assign.")%></font></p>
13<% end %>
14<%else:%>
15<div style="padding-top:10px; padding-bottom: 10px;padding-left: 10px"><em><%= _("Please, select one or more contributions to assign Reviewers")%></em></div>
16
17<div id="showHideFilteringHelp" style="padding-top: 10px;padding-left: 40px"><div id="showHideFiltering" style="display:inline"></div></div>
18<br/>
19<table id="filteringTable" class="Revtab" width="90%%" align="center">
20    <thead>
21        <tr style="text-align:center;">
22            <td nowrap class="titleCellFormat" style="border-right:5px solid #FFFFFF;border-left:5px solid #FFFFFF;border-bottom:1px solid #BBBBBB;">
23                <%= _("types")%>
24            </td>
25            <td nowrap class="titleCellFormat" style="border-right:5px solid #FFFFFF;border-left:5px solid #FFFFFF;border-bottom:1px solid #BBBBBB;">
26                <%= _("sessions")%>
27            </td>
28            <td nowrap class="titleCellFormat" style="border-right:5px solid #FFFFFF;border-left:5px solid #FFFFFF;border-bottom:1px solid #BBBBBB;">
29                <%= _("tracks")%>
30            </td>
31            <td nowrap class="titleCellFormat" style="border-right:5px solid #FFFFFF;border-left:5px solid #FFFFFF;border-bottom:1px solid #BBBBBB;">
32                <%= _("assign status")%>
33            </td>
34        </tr>
35    </thead>
36    <tbody>
37        <tr style="vertical-align:top">
38            <td>
39                <table cellpadding="0px" cellspacing="0px" border="0px">
40                    <tr>
41                        <td><img src="<%= Config.getInstance().getSystemIconURL("checkAll") %>" alt="Select all" title="Select all" onclick="selectAll('selTypes')" style="border:none;"><img src="<%= Config.getInstance().getSystemIconURL("uncheckAll") %>" alt="Deselect all" title="Deselect all" onclick="deselectAll('selTypes')" style="border:none;"></td>
42                    </tr>
43                    <tr>
44                        <td><input type="checkbox" id="typeShowNoValue" name="selTypes" value="not specified" checked/></td>
45                        <td> --<%= _("not specified")%>--</td>
46                    </tr>
47                    <% for type in self._conf.getContribTypeList(): %>
48                        <tr>
49                            <td><input type="checkbox" name="selTypes" value="<%=type.getId()%>" checked></td>
50                            <td><%= type.getName() %></td>
51                        </tr>
52                    <% end %>
53                </table>
54            </td>
55            <td>
56                <table cellpadding="0px" cellspacing="0px" border="0px">
57                    <tr>
58                        <td><img src="<%= Config.getInstance().getSystemIconURL("checkAll") %>" alt="Select all" title="Select all" onclick="selectAll('selSessions')" style="border:none;"><img src="<%= Config.getInstance().getSystemIconURL("uncheckAll") %>" alt="Deselect all" title="Deselect all" onclick="deselectAll('selSessions')" style="border:none;"></td>
59                    </tr>
60                    <tr>
61                        <td><input type="checkbox" id="sessionShowNoValue" name="selSessions" value="not specified" checked/></td>
62                        <td> --<%= _("not specified")%>--</td>
63                    </tr>
64                    <% for s in self._conf.getSessionListSorted(): %>
65                        <tr>
66                            <td><input type="checkbox" name="selSessions" value="<%=s.getId()%>" checked></td>
67                            <td><%= s.getTitle() %></td>
68                        </tr>
69                    <% end %>
70                </table>
71            </td>
72            <td>
73                <table cellpadding="0px" cellspacing="0px" border="0px">
74                    <tr>
75                        <td><img src="<%= Config.getInstance().getSystemIconURL("checkAll") %>" alt="Select all" title="Select all" onclick="selectAll('selTracks')" style="border:none;"><img src="<%= Config.getInstance().getSystemIconURL("uncheckAll") %>" alt="Deselect all" title="Deselect all" onclick="deselectAll('selTracks')" style="border:none;"></td>
76                    </tr>
77                    <tr>
78                        <td><input type="checkbox" id="trackShowNoValue" name="selTracks" value="not specified" checked/></td>
79                        <td> --<%= _("not specified")%>--</td>
80                    </tr>
81                    <% for t in Conference.getTrackList(): %>
82                        <tr>
83                            <td><input type="checkbox" name="selTracks" value="<%=t.getId()%>" checked></td>
84                            <td><%= t.getTitle() %></td>
85                        </tr>
86                    <% end %>
87                </table>
88            </td>
89            <td>
90                <ul style="list-style-type:none">
91                    <% if not IsOnlyReferee: %>
92                        <li><input type="checkbox" id="showWithReferee" checked/> <%= _("With Referee assigned")%></li>
93                    <% end %>
94                    <li><input type="checkbox" id="showWithEditor" checked/> <%= _("With Layout Reviewer assigned")%></li>
95                    <li><input type="checkbox" id="showWithReviewer" checked/> <%= _("With at least 1 Content Reviewer assigned")%></li>
96
97                </ul>
98            </td>
99        </tr>
100        <tr>
101            <td id="applyFilterHelp" colspan="4" style="border-top: 1px solid rgb(119, 119, 119); padding: 10px;text-align:center">
102                <input id="applyFilter" type="button" class="popUpButton" value="Apply filter"/>
103            </td>
104        </tr>
105    </tbody>
106</table>
107
108<table style="padding-left: 40px">
109    <% if not IsOnlyReferee and not (ConfReview.getChoice() == 3 or ConfReview.getChoice() == 1): %>
110    <tr>
111        <td><%= _("Referee")%>:</td>
112        <td id="assignRefereeHelp">
113            <input id="assignRefereeButton_top" type="button" class="popUpButton" value="Assign">
114            <input id="removeRefereeButton_top" type="button" class="popUpButton" value="Remove">
115        </td>
116    </tr>
117    <% end %>
118    <%if not (ConfReview.getChoice() == 2 or ConfReview.getChoice() == 1):%>
119    <tr>
120        <td><%= _("Layout Reviewer")%>:</td>
121        <td id="assignEditorHelp">
122            <input id="assignEditorButton_top" type="button" class="popUpButton" value="Assign">
123            <input id="removeEditorButton_top" type="button" class="popUpButton" value="Remove">
124        </td>
125    </tr>
126    <% end %>
127    <% if not (ConfReview.getChoice() == 3 or ConfReview.getChoice() == 1): %>
128    <tr>
129        <td><%= _("Content Reviewers")%>:</td>
130        <td id="assignReviewerHelp">
131            <input id="addReviewerButton_top" type="button" class="popUpButton" value="Assign">
132            <input id="removeReviewerButton_top" type="button" class="popUpButton" value="Remove">
133            <input id="removeAllReviewersButton_top" type="button" class="popUpButton" value="Remove All">
134        </td>
135    </tr>
136    <% end %>
137</table>
138<!--  and not (ConfReview.getChoice() == 3 or ConfReview.getChoice() == 1) -->
139<div id="userSelection_top" style="margin-top: 1em">
140    <span id="userSelectionMessage_top"></span>
141    <ul id="userList_top">
142    </ul>
143</div>
144
145<table style="padding-left:40px; margin-bottom:1em;">
146        <tr>
147            <td style="padding-bottom: 20px; padding-top: 20px">
148                <%= _("Select:") %>
149            </td>
150            <td nowrap class="titleCellFormat" style="padding-bottom: 20px;  padding-top: 20px; border-right:5px solid #FFFFFF;border-left:5px solid #FFFFFF">
151                 <span onclick="selectAll('selectedContributions')" align="left" style="cursor:pointer;padding-bottom:5px;color:#0B63A5;list-style-type:none;" onmouseover="this.style.color='#E25300'" onmouseout="this.style.color='#0B63A5'">
152                        <%= _("All")%>
153                 </span>,
154                 <span onclick="deselectAll('selectedContributions')" align="left" style="cursor:pointer;padding-bottom:5px;color:#0B63A5;list-style-type:none;" onmouseover="this.style.color='#E25300'" onmouseout="this.style.color='#0B63A5'">
155                        <%= _("None")%>
156                 </span>
157            </td>
158        </tr>
159</table>
160
161   <table class="Revtab" width="95%%" cellspacing="0" align="center" border="0" style="padding-left:20px; margin-bottom:1em">
162<!--
163    <tr>
164        <td nowrap class="groupTitle" colspan=4>Contributions to judge as Referee</td>
165    </tr>
166-->
167    <thead>
168        <tr>
169            <td></td>
170            <td nowrap class="titleCellFormat" style="border-right:5px solid #FFFFFF;border-left:5px solid #FFFFFF;">
171                <%= _("Id")%>
172            </td>
173            <td nowrap class="titleCellFormat" style="border-right:5px solid #FFFFFF;border-left:5px solid #FFFFFF;">
174                <%= _("Title")%>
175            </td>
176            <td nowrap class="titleCellFormat" style="border-right:5px solid #FFFFFF;border-left:5px solid #FFFFFF;">
177                <%= _("Type")%>
178            </td>
179            <td nowrap class="titleCellFormat" style="border-right:5px solid #FFFFFF;border-left:5px solid #FFFFFF;">
180                <%= _("Track")%>
181            </td>
182            <td nowrap class="titleCellFormat" style="border-right:5px solid #FFFFFF;border-left:5px solid #FFFFFF;">
183                <%= _("Session")%>
184            </td>
185            <!--
186            <td nowrap class="titleCellFormat" style="border-right:5px solid #FFFFFF;border-left:5px solid #FFFFFF;border-bottom: 1px solid #5294CC;">
187                State
188            </td>
189            -->
190            <td nowrap class="titleCellFormat" style="border-right:5px solid #FFFFFF;border-left:5px solid #FFFFFF;">
191                <%= _("Reviewing team")%>
192            </td>
193            <td nowrap class="titleCellFormat" style="border-right:5px solid #FFFFFF;border-left:5px solid #FFFFFF;">
194                <%= _("Deadline")%>
195            </td>
196        </tr>
197    </thead>
198   
199   <tbody id="tablebody">
200    <% for c in Conference.getContributionListSortedById(): %>
201        <% rm = c.getReviewManager() %>
202        <% if not isinstance(c.getStatus(), ContribStatusNone): %>
203         <tr valign="top">
204            <td></td>         
205            <td style="border-right:5px solid #FFFFFF;border-left:5px solid #FFFFFF;">
206                <%= c.getId() %>
207            </td>
208           
209            <td style="border-right:5px solid #FFFFFF;border-left:5px solid #FFFFFF;">
210                <a href="<%= urlHandlers.UHContributionModifReviewing.getURL(c) %>">
211                    <%= c.getTitle() %>
212                </a>
213            </td>
214           
215            <td style="border-right:5px solid #FFFFFF;border-left:5px solid #FFFFFF;">
216                <% if c.getType(): %>
217                    <%= c.getType().getName() %>
218                <% end %>
219            </td>
220           
221            <td style="border-right:5px solid #FFFFFF;border-left:5px solid #FFFFFF;">
222                <% if c.getTrack(): %>
223                    <%= c.getTrack().getTitle() %>
224                <% end %>
225            </td>
226           
227            <td style="border-right:5px solid #FFFFFF;border-left:5px solid #FFFFFF;">
228                <% if c.getSession(): %>
229                    <%= c.getSession().getTitle() %>
230                <% end %>
231            </td>
232           
233            <!--
234            <td style="border-right:5px solid #FFFFFF;border-left:5px solid #FFFFFF;">
235            <% if rm.getLastReview().getRefereeJudgement().isSubmitted(): %>
236                <span style="color:green;">
237                    Judged: <%= rm.getLastReview().getRefereeJudgement().getJudgement() %>
238                </span>
239            <% end %>
240            <% else: %>
241                <span style="color:red;">Not judged yet<br>
242                <%= "<br>".join(rm.getLastReview().getReviewingStatus()) %>
243                </span>
244            <% end %>
245            </td>
246            -->
247            <td>
248                <ul>
249                    <% if not (ConfReview.getChoice() == 3 or ConfReview.getChoice() == 1): %>
250                    <li>
251                        <em><%= _("Referee")%>:</em>
252                    </li>
253                    <% end %>
254                    <li>
255                        <em><%= _("Layout Reviewer")%>:</em>
256                    </li>
257                    <li>
258                        <em><%= _("Content Reviewers")%>:</em>
259                        <ul>
260                        <% for reviewer in rm.getReviewersList() :%>
261                            <li>a</li>
262                        <% end %>
263                        </ul>
264                    </li>
265                </ul>
266            </td>
267           
268            <td style="border-right:5px solid #FFFFFF; border-left:5px solid #FFFFFF;">
269                <% date = rm.getLastReview().getAdjustedRefereeDueDate() %>
270                <% if date is None: %>
271                    <%= _("Deadline not set.")%>
272                <% end %>
273                <% else: %>
274                    <%= date.strftime(dueDateFormat) %>                   
275                <% end %>
276            </td>           
277        </tr>
278        <% end %>
279    <% end %>
280    </tbody>
281</table>
282
283<table style="padding-left: 40px">
284    <% if not IsOnlyReferee and not (ConfReview.getChoice() == 3 or ConfReview.getChoice() == 1): %>
285    <tr>
286        <td><%= _("Referee")%>:</td>
287        <td id="assignRefereeHelp">
288            <input id="assignRefereeButton_bottom" type="button" class="popUpButton" value="Assign">
289            <input id="removeRefereeButton_bottom" type="button" class="popUpButton" value="Remove">
290        </td>
291    </tr>
292    <% end %>
293    <% if not (ConfReview.getChoice() == 2 or ConfReview.getChoice() == 1): %>
294    <tr>
295        <td><%= _("Layout Reviewer")%>:</td>
296        <td id="assignEditorHelp">
297            <input id="assignEditorButton_bottom" type="button" class="popUpButton" value="Assign">
298            <input id="removeEditorButton_bottom" type="button" class="popUpButton" value="Remove">
299        </td>
300    </tr>
301    <% end %>
302    <% if not (ConfReview.getChoice() == 3 or ConfReview.getChoice() == 1): %>
303    <tr>
304        <td><%= _("Content Reviewers")%>:</td>
305        <td id="assignReviewerHelp">
306            <input id="addReviewerButton_bottom" type="button" class="popUpButton" value="Assign">
307            <input id="removeReviewerButton_bottom" type="button" class="popUpButton" value="Remove">
308            <input id="removeAllReviewersButton_bottom" type="button" class="popUpButton" value="Remove All">
309        </td>
310    </tr>
311    <% end %>
312</table>
313
314<div id="userSelection_bottom" style="margin-top: 1em">
315    <span id="userSelectionMessage_bottom"></span>
316    <ul id="userList_bottom">
317    </ul>
318</div>
319
320
321
322
323<script type="text/javascript">
324
325var contributions = $L(); // watchlist of contribution objects, pickled from Indico Contribution objects
326var contributionsIndexes = []; //array that maps contribution ids to the index of the contribution in the 'contributions' watchlist
327var action = ''; // stores which button has been pressed, in order to know which list of users has to be retrieved
328
329/**
330 * Returns a contribution object given its id.
331 * The contribution object is obtained from the 'contributions' watchlist.
332 * @param {Object} id The id of the contribution.
333 */
334var getContribution = function (id) {
335    return contributions.item(contributionsIndexes[id]);
336}
337
338/**
339 * Selects all the checkboxes of a given name
340 */
341var selectAll = function (name) {
342    var checkBoxes = document.getElementsByName(name);
343    if ( checkBoxes ) { // true if there is at least 1 checkbox
344        if ( !checkBoxes.length) { // true if there is only 1 checkbox
345            checkBoxes.checked=true
346        } else { // there is more than 1 checkbox
347            for (i = 0; i < checkBoxes.length; i++) {
348                checkBoxes[i].checked=true
349            }
350        }
351    }
352}
353
354/**
355 * Deselects all the contributions by unticking their checkboxes
356 */
357var deselectAll = function(name) {
358    var checkBoxes = document.getElementsByName(name)
359    if ( checkBoxes ) { // true if there is at least 1 checkbox
360        if ( !checkBoxes.length) { // true if there is only 1 checkbox
361            checkBoxes.checked=false
362        } else { // there is more than 1 checkbox
363            for (i = 0; i < checkBoxes.length; i++) {
364                checkBoxes[i].checked=false
365            }
366        }
367    }
368}
369
370/**
371 * Builds the 'link' to show and hide the filtering options.
372 */
373var buildShowHideFiltering = function() {
374    var option = new Chooser({
375        showFiltering: command(function(){
376            $E('filteringTable').dom.style.display = '';
377            option.set('hideFiltering');
378        }, $T('Show Filtering Criteria')),
379        hideFiltering: command(function(){
380            $E('filteringTable').dom.style.display = 'none';
381            option.set('showFiltering');
382        }, $T('Hide Filtering Criteria'))
383    });
384    option.set('showFiltering');
385   
386    $E('showHideFiltering').set(Widget.link(option));
387}
388
389/**
390 * Builds a table row element from a contribution object, pickled from an Indico's Contribution object
391 * @param {Object} contribution
392 */
393var backgroundColorOver = function() {
394    IndicoUI.Widgets.Generic.tooltip(this.style.backgroundColor='#ECECEC');
395}
396
397var backgroundColorOut = function() {
398    IndicoUI.Widgets.Generic.tooltip(this.style.backgroundColor='transparent');
399}
400
401var contributionTemplate = function(contribution) {
402       
403    var row = Html.tr();
404    row.dom.onmouseover = backgroundColorOver;
405    row.dom.onmouseout = backgroundColorOut;
406    // Cell1: checkbox to select this contribution
407    var cell1 = Html.td({style:{"textAlign":"center", "width":"0px"}});
408    var id = ("cb" + contribution.id);
409    var name = ("selectedContributions");
410   
411    /*
412    //creating the checkbox IE way
413    if (document.all) {   
414    var checkbox = document.createElement('<input name='+name+'>');
415    checkbox.type = "checkbox";
416    checkbox.id = id ;
417    }
418    //the other browsers
419    else {
420        var checkbox = Html.checkbox({id: id, name:name});
421    }
422    cell1.set(checkbox);
423    //checkbox.dom.value = contribution.id; // has to be added after constructor because of IE
424    */
425    var checkbox = Html.input('checkbox', {id: id, name:name});
426    checkbox.dom.value = contribution.id;
427    cell1.set(checkbox);
428   
429    row.append(cell1);
430   
431    // Cell2: contribution id
432    var cell2 = Html.td({style:{"textAlign":"center", "width":"0px"}});
433    cell2.set(contribution.id)
434    row.append(cell2);
435
436    // Cell3: contribution title
437    var cell3 = Html.td();
438    // Sadly this hack is necessary to get the link since getURL() needs a Contribution object (from Indico, not the local one from Javascript)
439    // and contributions are loaded asynchronously...
440    linkString = "<%= urlHandlers.UHContributionModifReviewing.getURL() %>" + "?contribId=" + contribution.id + "&confId=<%= Conference.getId()%>"
441    var link = Html.a({href: linkString});
442    link.set(contribution.title);
443    cell3.set(link);
444    row.append(cell3);
445
446    // Cell4: contribution type
447    var cell4 = Html.td({style:{"marginLeft":"5px"}});
448    cell4.set(contribution.type)
449    row.append(cell4);
450   
451    // Cell5: contribution track
452    var cell5 = Html.td({style:{"marginLeft":"5px"}});
453    cell5.set(contribution.track ? contribution.track.title : "")
454    row.append(cell5);
455   
456    // Cell6: contribution session
457    var cell6 = Html.td({style:{"marginLeft":"5px"}});
458    cell6.set(contribution.session ? contribution.session.title : "")
459    row.append(cell6);
460
461    /*
462    // Cell7: contribution status
463    var cell7 = Html.td();
464   
465    if (contribution.reviewManager.lastReview.refereeJudgement.isSubmitted) {
466        var span = Html.span();
467        span.dom.style.color = 'green';
468        span.set("Judged" + contribution.reviewManager.lastReview.refereeJudgement.judgement);
469        cell7.set(span);
470       
471    } else {
472        var ul = Html.ul();
473        ul.dom.style.color = 'red';
474        ul.dom.style.listStyleType = 'none';
475        ul.dom.style.padding = 0;
476        ul.dom.style.marginLeft = '5px';
477       
478        var li = Html.li();
479        li.set("Not judged yet");
480        ul.append(li);
481       
482        statusList = contribution.reviewManager.lastReview.reviewingStatus;
483        for (j in statusList) {
484            var li = Html.li();
485            li.set(statusList[j])
486            ul.append(li)
487        }
488       
489        cell7.set(ul);
490    }
491
492    row.append(cell7);
493    */
494
495    // Cell8: reviewing team assigned to the contribution
496    var cell8 = Html.td();
497   
498    var ul = Html.ul();
499    ul.dom.style.listStyleType = 'none';
500    ul.dom.style.padding = 0;
501    ul.dom.style.marginLeft = '5px';
502   
503    <% if not (ConfReview.getChoice() == 3 or ConfReview.getChoice() == 1): %>
504    var li1 = Html.li();
505    var span1 = Html.span({}, $T('Referee: '))
506    var span2 = contribution.reviewManager.referee ?
507                    Html.span({id: ("creferee" + contribution.id), style:{"fontWeight":"bolder"}},  contribution.reviewManager.referee.name) :
508                    Html.span({id: ("creferee" + contribution.id)},$T('No referee'));
509    li1.set(Widget.block([span1,span2]));
510    ul.append(li1);
511    <% end %>
512   
513    <% if not (ConfReview.getChoice() == 2 or ConfReview.getChoice() == 1): %>
514    var li2 = Html.li();
515    var span1 = Html.span({}, $T('Layout reviewer: '))
516    var span2 = contribution.reviewManager.editor ?
517                    Html.span({id: ("ceditor" + contribution.id), style:{"fontWeight":"bolder"}},  contribution.reviewManager.editor.name) :
518                    Html.span({id: ("ceditor" + contribution.id)},$T('No layout reviewer'));
519    li2.set(Widget.block([span1,span2]));
520    ul.append(li2);
521    <% end %>
522   
523    <% if not (ConfReview.getChoice() == 3 or ConfReview.getChoice() == 1): %>
524    var li3 = Html.li();
525    var span = Html.span({id : ("creviewerstitle" + contribution.id)}, $T('Content reviewers: '));
526    li3.append(span);
527   
528   
529    var ulReviewers = Html.ul();
530    if (contribution.reviewManager.reviewersList.length > 0){
531        for (j in contribution.reviewManager.reviewersList) {
532            var li = Html.li({id: ("creviewer" + contribution.id + "_" + contribution.reviewManager.reviewersList[j].id), style:{"fontWeight":"bolder"}});
533            li.set(contribution.reviewManager.reviewersList[j].name);
534            ulReviewers.append(li);
535        }
536        li3.append(ulReviewers);
537    } else {
538        var span = Html.span({id: ("creviewer" + contribution.id)},$T('No content reviewers' ));
539        li3.append(span);
540    }
541    ul.append(li3);
542    <% end %>
543   
544    cell8.set(ul);
545    row.append(cell8);
546
547    // Cell9: due date of the contribution
548    var cell9 = Html.td();
549    cell9.set(contribution.reviewManager.lastReview.refereeDueDate)
550    row.append(cell9);
551   
552    return row;
553}
554
555
556/**
557 * Updates the display of the contribution row.
558 * @param {Object} id The id of the contribution.
559 */
560var updateContribution = function (id) {
561    index = contributionsIndexes[id];
562    var c = contributions.item(index);
563    contributions.removeAt(index);
564    contributions.insert(c, index);
565}
566
567
568/**
569 * Returns a list of checkbox values, for a given checkbox name
570 * ('name' attribute of an 'input' HTML element)
571 * The list only contains the checkboxes who are selected.
572 * The first checkbox ('--not specified--' one) is discarded.
573 * @param {Object} checkboxName
574 */
575var getCheckedBoxes = function(checkboxName) {
576   
577    var checkBoxes = document.getElementsByName(checkboxName);
578    var checkedIds = []
579    for (var i=0; i<checkBoxes.length; i++) {
580        var cb = checkBoxes[i];
581        if (cb.checked && cb.value != "not specified") {
582            checkedIds.push(cb.value)
583        }
584    }
585    return checkedIds;
586}
587
588
589/**
590 * Returns a list of contribution ids.
591 * Only the contributios whose checkbox has been selected are returned.
592 */
593var getCheckedContributions = function() {
594   
595    var checkBoxes = document.getElementsByName('selectedContributions');
596    var checkedContributions = []
597   
598    for (var i=0; i<checkBoxes.length; i++) {
599        var cb = checkBoxes[i];
600        if (cb.checked) {
601            checkedContributions.push(cb.id.slice(2))
602        }
603    }
604    return checkedContributions;
605}
606
607/**
608 * Turns the given user orange for some seconds to indicate that it has changed
609 * @param {Object} contributionId The id of the contribution where a user has been assigned
610 * @param {Object} role The role that has been assigned
611 * @param {Object} reviewerId In case of a reviewerm the reviewerId. Otherwise leave to null.
612 */
613var colorify = function(contributionId, role, reviewerId) {
614    id = "c" + role + contributionId;
615    if (reviewerId) {
616        id = id + "_" + reviewerId;
617    }
618    IndicoUI.Effect.highLight(id, 'orange', 2000);
619}
620
621/**
622 * Among a list of contributions (given as contribution ids),
623 * this function unchecks the checboxes of the contributions
624 * who don't ahve a refree yet.
625 * @param {array} contributions List of contribution ids
626 */
627var deselectWithoutReferee = function(contributions) {
628    for (i in contributions) {
629        contributionId = contributions[i];
630        contribution = getContribution(contributionId);
631        if (contribution.reviewManager.referee == null) {
632            $E('cb' + contributionId).dom.checked = false;
633        }
634    }
635}
636
637/**
638 * Among a list of contributions (given as contribution ids),
639 * this function unchecks the checboxes of the contributions
640 * who don't have a reviewer.
641 * @param {array} contributions List of contribution ids
642 */
643var deselectWithoutReviewer = function(contributions) {
644    for (i in contributions) {
645        contributionId = contributions[i];
646        contribution = getContribution(contributionId);
647        if (contribution.reviewManager.reviewersList.length == 0) {
648            $E('cb' + contributionId).dom.checked = false;
649        }
650    }
651}
652
653/**
654 * Checks that all contributions have a Referee.
655 * Returns true if all have a referee, false otherwise.
656 * If none have a referee, an alert message appear.
657 * If some have a referee and others don't, a dialog will appear offering
658 * the choice to only apply the assignment to contributions with referee.
659 * @param {Object} contributions
660 * @param {Object} order
661 * @param {Object} role
662 */
663var checkAllHaveReferee = function(contributions, order, role) {
664    var contributionsWithoutReferee = []
665    for (i in contributions) {
666        contributionId = contributions[i]
667        contribution = getContribution(contributionId)
668        if (contribution.reviewManager.referee == null) {
669            contributionsWithoutReferee.push(contributionId)
670        }
671    }
672    if (contributionsWithoutReferee.length == contributions.length) {
673        alert($T("None of the contributions you checked have a Referee.") +
674            $T("You can only add an editor or a reviewer if the contribution has a referee.")
675        );
676        return false;
677    }
678   
679    if (contributionsWithoutReferee.length > 0) {
680        title =$T('Contributions without referee');   
681           
682        var popup = new ExclusivePopup(title, function(){popup.close();});
683       
684        popup.draw = function(){
685       
686            var span1 = Html.span({}, $T("Some of the contributions you checked do not have a Referee."));
687            var span2 = Html.span({}, $T("You can only add an editor or a reviewer if the contribution has a referee."));
688            var span3 = Html.span({}, $T("Do you want to add that " + role + " only to the contributions with a referee?"));
689            var yesButton = Html.button('popUpButton', $T("Yes"));
690            yesButton.observeClick(function(){
691                deselectWithoutReferee(contributions);
692                fetchUsers(order, role);
693                popup.close();
694            });
695                       
696             var noButton = Html.button('popUpButton', $T("No"));
697            noButton.observeClick(function(){
698                popup.close();
699            });
700              var buttons = Widget.inline([yesButton, noButton])
701              var all = Widget.lines([span1, span2, span3, buttons])
702         return this.ExclusivePopup.prototype.draw.call(this, Html.div({style: {height: '130px', width: '420px'}},[all])); 
703                };
704             popup.open();
705         
706        return false;
707    }
708    return true;
709}
710
711/**
712 * When removing a reviewer from one or more contributions this function takes care for the alert messages.
713 * Returns true if there are no warnings, returns false otherwise.
714 * If are checked contributions with no reviewers assigned, an alert message appears.
715 * If some have a reviewers and others don't, a dialog will appear offering
716 * the choice to only apply the assignment to contributions with reviewer.
717 * @param {Object} contributions
718 * @param {Object} order
719 * @param {Object} role
720 */
721var removeReviewersAlerts = function(contributions, role) {
722    contributionsWithoutReviewers = []
723    for (i in contributions) {
724        contributionId = contributions[i]
725        contribution = getContribution(contributionId)
726        if (contribution.reviewManager.reviewersList.length == 0) {
727            contributionsWithoutReviewers.push(contributionId)
728        }
729    }
730    if (contributionsWithoutReviewers.length == contributions.length) {
731        alert($T("There is no assigned Content Reviewer to remove.")
732        );
733        return false;
734    }
735   
736    if (contributionsWithoutReviewers.length > 0) {
737        title =$T('Contributions without reviewer');   
738           
739        var popup = new ExclusivePopup(title, function(){popup.close();});
740       
741        popup.draw = function(){
742       
743            var span1 = Html.span({}, $T("The Content Reviewers will be removed only from the contributions that have one."));
744            var okButton = Html.button('popUpButton', $T("OK"));
745            okButton.observeClick(function(){
746                deselectWithoutReviewer(contributions);
747                removeUser('allReviewers');
748                popup.close();
749            });
750           
751              var all = Widget.lines([span1, okButton])
752              return this.ExclusivePopup.prototype.draw.call(this, Html.div({style: {height: '130px', width: '420px'}},[all])); 
753                };
754             popup.open();
755         
756        return false;
757    }
758   
759    return true;   
760}
761
762/**
763 * When removing a refereee from one or more contributions this function checks
764 * if there are alredy assigned reviewers or editor, or both
765 * @param {array} contributions List of contribution ids
766 */
767var removeRefereeAlerts = function(contributions){
768    for (i in contributions) {
769        contributionId = contributions[i]
770        contribution = getContribution(contributionId)
771    }
772    if(contribution.reviewManager.reviewersList.length != 0 && contribution.reviewManager.editor != null) {
773            return false;
774        }
775    if(contribution.reviewManager.reviewersList.length != 0 && contribution.reviewManager.editor == null){
776           return false;
777        }
778    if(contribution.reviewManager.reviewersList.length == 0 && contribution.reviewManager.editor != null) {
779            return false;
780        }
781   
782    return true;
783}
784
785/**
786 * When removing a refereee from one or more contributions this function takes care for the alert messages.
787 * If are checked contributions with alredy assigned reviewers/editor
788 * alert message appears that a referee should be assigned
789 * @param {array} contributions List of contribution ids
790 */   
791var removeRefereeAlertsMessage = function(contributions){
792    for (i in contributions) {
793        contributionId = contributions[i]
794        contribution = getContribution(contributionId)
795    }
796    var warning = $T("You have to assign new referee.")
797    var message = $T("")
798    if(contribution.reviewManager.reviewersList.length != 0 && contribution.reviewManager.editor != null) {       
799            message = $T("Please note that layout and content have already been assigned for this/these contributions."+ warning)
800            return message;
801        }
802    if(contribution.reviewManager.reviewersList.length != 0 && contribution.reviewManager.editor == null){
803           message = $T("Please note that a content reviewer has already been assigned for this/these contributions."+ warning)
804           return message;
805        }
806    if(contribution.reviewManager.reviewersList.length == 0 && contribution.reviewManager.editor != null) {
807           message = $T("Please note that a layout reviewer has already been assigned for this/these contributions."+ warning)
808            return message;
809        }
810   
811    return message;
812}
813                       
814/**
815 * Function that is called when a user (referee, editor, reviewer) is clicked.
816 * Depending on what has been sotred in the variable 'action', the user will be
817 * added as a referee, added as an editor, removed as a reviewer, etc on the checked contributions.
818 * @param {Object} user The user that has been clicked.
819 */
820var userSelected = function(user){
821   
822    var checkedContributions = getCheckedContributions()
823
824    if (checkedContributions.length > 0) {
825       
826        var params = {conference: '<%= Conference.getId() %>',contributions: checkedContributions, user: user.id}
827       
828        switch(action) {
829        case 'assign_referee':
830            indicoRequest(
831                'reviewing.conference.assignReferee',
832                params,
833                function(result,error) {
834                    if (!error) {
835                        for (i in checkedContributions) {
836                            contributionId = checkedContributions[i];
837                            contribution = getContribution(contributionId);
838                            contribution.reviewManager.referee = user;
839                            updateContribution(contributionId);
840                            colorify(contributionId,'referee');
841                            $E('cb' + contributionId).dom.checked = true; //updateContribution will build a row with an unchecked checkbox
842                        }
843                    } else {
844                        IndicoUtil.errorReport(error);
845                    }
846                }
847            );
848            break;
849           
850        case 'assign_editor':
851            indicoRequest(
852                'reviewing.conference.assignEditor',
853                params,
854                function(result,error) {
855                    if (!error) {
856                        for (i in checkedContributions) {
857                            contributionId = checkedContributions[i]
858                            contribution = getContribution(contributionId)
859                            contribution.reviewManager.editor = user
860                            updateContribution(contributionId)
861                            colorify(contributionId,'editor');
862                            $E('cb' + contributionId).dom.checked = true; //updateContribution will build a row with an unchecked checkbox
863                        }
864                    } else {
865                        IndicoUtil.errorReport(error);
866                    }     
867                }
868            );
869            break;
870           
871        case 'add_reviewer':
872            indicoRequest(
873                'reviewing.conference.addReviewer',
874                params,
875                function(result,error) {
876                    if (!error) {
877                        for (i in checkedContributions) {
878                            contributionId = checkedContributions[i]
879                            contribution = getContribution(contributionId)
880                           
881                            var present = false;
882                            for (j in contribution.reviewManager.reviewersList) {
883                                if (contribution.reviewManager.reviewersList[j].id == user.id) {
884                                    present = true;
885                                    break;
886                                }
887                            }
888                            if (!present) {
889                                contribution.reviewManager.reviewersList.push(user)
890                            }
891
892                            updateContribution(contributionId);
893                            colorify(contributionId,'reviewer', user.id);
894                            $E('cb' + contributionId).dom.checked = true; //updateContribution will build a row with an unchecked checkbox
895                        }
896                    } else {
897                        IndicoUtil.errorReport(error);
898                    } 
899                }
900            );
901            break;
902           
903        case 'remove_reviewer':
904            indicoRequest(
905                'reviewing.conference.removeReviewer',
906                params,
907                function(result, error) {
908                    notinlist2 = [];
909                    if(!error) {
910                        for (i in checkedContributions) {
911                            contributionId = checkedContributions[i]
912                            contribution = getContribution(contributionId)
913                           
914                            notinlist = false;
915                            deleted = false;
916                            for (j in contribution.reviewManager.reviewersList) {
917                                if (contribution.reviewManager.reviewersList[j].id == user.id) {
918                                    contribution.reviewManager.reviewersList.splice(j,1);
919                                    updateContribution(contributionId);
920                                    colorify(contributionId,'reviewerstitle');
921                                    $E('cb' + contributionId).dom.checked = true; //updateContribution will build a row with an unchecked checkbox
922                                    deleted = true;
923                                } else {
924                                    notinlist = true;
925                                    notinlist2.push(contributionId)
926                                    $E('cb' + contributionId).dom.checked = false;
927                                   
928                                }
929                            }                   
930                        }
931                   } else {
932                        IndicoUtil.errorReport(error);
933                   }
934                }
935            );
936            break;
937           
938        default:
939            break;
940        }
941               
942    }
943}
944
945
946
947/**
948 * Requests the list of contribution from the server,
949 * given the filtering parameters.
950 */
951var fetchContributions = function() {
952   
953    contributions.clear();
954    contributionsIndexes = []
955    indicoRequest('event.contributions.list',
956        {
957            conference: '<%= Conference.getId() %>',
958            typeShowNoValue : $E('typeShowNoValue').dom.checked,
959            trackShowNoValue : $E('trackShowNoValue').dom.checked,
960            sessionShowNoValue : $E('sessionShowNoValue').dom.checked,
961            selTypes : getCheckedBoxes('selTypes'),
962            selTracks : getCheckedBoxes('selTracks'),
963            selSessions : getCheckedBoxes('selSessions'),
964            <% if not IsOnlyReferee: %>
965            showWithReferee: $E('showWithReferee').dom.checked,
966            <% end %>
967            showWithEditor: $E('showWithEditor').dom.checked,
968            showWithReviewer: $E('showWithReviewer').dom.checked
969        },
970        function(result, error){
971            if (!error) {
972                for (i in result) {
973                    c = result[i]
974                    contributions.append(c);
975                    contributionsIndexes[c.id] = i;
976                }
977            } else {
978                IndicoUtil.errorReport(error);
979            }
980        }
981    )
982}
983
984/**
985 * Retrieves a list of users from the server.
986 * @param {string} order The action that will be taken on the users: 'assign', 'remove'.
987 * @param {string} role The role of the users: 'referee', 'editor', 'reviewer'.
988 */
989var fetchUsers = function(order, role) {
990   
991    var checkedContributions = getCheckedContributions();
992    if (checkedContributions.length == 0) {
993        alert($T("Please select at least 1 contribution"));
994        return;
995    }
996   
997    if ((order == 'assign' && role == 'editor') || (order == 'add' && role == 'reviewer')) {
998        if (!checkAllHaveReferee(checkedContributions, order, role)) {
999            return;
1000        }
1001   }
1002   
1003   if (order == 'remove' && role == 'reviewer')  {
1004        if (!removeReviewersAlerts(checkedContributions, role)) {
1005            return;
1006        }
1007   }
1008   
1009    indicoRequest(
1010        'reviewing.conference.userCompetencesList',
1011        {conference: '<%= Conference.getId() %>', role: role},
1012        function(result,error) {
1013            if (!error) {
1014               
1015                action = order + '_' + role;
1016               
1017                var title = '';
1018                if (role == 'editor') {
1019                    title = $T('Click on a user name to ') + order + $T(' an layout reviewer:');
1020                }
1021                if (role == 'reviewer') {
1022                    title = $T('Click on a user name to ') + order + ' a ' + $T('content reviewer:');
1023                } else {
1024                    title = $T('Click on a user name to ') + order + ' a ' + role + ':';
1025                }
1026               
1027                var popup = new ExclusivePopup(title, function(){popup.close();});
1028               
1029                popup.draw = function(){
1030                        var users = $L();
1031                        var userTemplate = function(user) {
1032                            var li = Html.li();
1033                            var userName = Widget.link(command(function(){
1034                                userSelected(user);
1035                                var killProgress = IndicoUI.Dialogs.Util.progress()
1036                                popup.close();
1037                                killProgress();
1038                            }, user.name));
1039                       
1040                       
1041                        var userCompetences = Html.span({style:{marginLeft:'5px'}},
1042                            user.competences.length == 0 ? $T('(no competences defined)') : $T('(competences: ') + user.competences.join(', ') + ')'
1043                        );
1044                       
1045                        li.set(Widget.inline([userName, userCompetences]));
1046                        return li;
1047                    }   
1048                   
1049                        var userList = Html.ul();
1050                        bind.element(userList, users, userTemplate);
1051                       
1052                        for (i in result) {
1053                        users.append(result[i]);
1054                        }                       
1055                         
1056                        var cancelButton = Html.button({style:{marginLeft:pixels(5)}}, $T("Cancel"));
1057                          cancelButton.observeClick(function(){
1058                          popup.close();
1059                           });
1060                       
1061                       var span1 = Html.span({}, "");
1062                       var message = '';
1063                       if(role == 'referee' && order == 'assign' && !removeRefereeAlerts(checkedContributions)) {
1064                            span1 = Html.span({}, removeRefereeAlertsMessage(checkedContributions));
1065                       }   
1066                       if(role == 'reviewer' && order == 'remove') {
1067                            if (checkedContributions.length == 1){
1068                                    message = $T("The Reviewer you choose will be removed only from the contribution that is assigned to him/her.")
1069                                } else {
1070                                    message = $T("The Reviewer you choose will be removed only from the contributions that are assigned to him/her.")
1071                                }
1072                            span1 = Html.span({}, message);
1073                       }   
1074                        return this.ExclusivePopup.prototype.draw.call(this, Widget.block([span1, userList, cancelButton])); 
1075                };
1076             popup.open();
1077             
1078            } else {
1079                IndicoUtil.errorReport(error);
1080            }
1081        }
1082    );
1083}
1084
1085/**
1086 * Removes the referee, the editor, or all the reviewers from the contributions that are selected.
1087 * @param {Object} role 'referee', 'editor', 'allReviewers'
1088 */
1089var removeUser = function(role) {
1090   
1091    var checkedContributions = getCheckedContributions();
1092    if (checkedContributions.length == 0) {
1093        alert($T("Please select at least 1 contribution"));
1094        return;
1095    }
1096   
1097    var params = {conference: '<%= Conference.getId() %>',contributions: checkedContributions}
1098   
1099    switch(role) {
1100    case 'referee':
1101        indicoRequest(
1102            'reviewing.conference.removeReferee',
1103            params,
1104            function(result,error) {
1105                if (!error) {
1106                    for (i in checkedContributions) {
1107                        contributionId = checkedContributions[i];
1108                        contribution = getContribution(contributionId);
1109                        contribution.reviewManager.referee = null;
1110                        updateContribution(contributionId);
1111                        colorify(contributionId, 'referee')
1112                        $E('cb' + contributionId).dom.checked = true; //updateContribution will build a row with an unchecked checkbox
1113                                               
1114                    }
1115                    if(!removeRefereeAlerts(checkedContributions)){
1116                      fetchUsers('assign', 'referee')
1117                    }
1118                } else {
1119                    IndicoUtil.errorReport(error);
1120                }
1121            }
1122        );
1123        break;
1124    case 'editor':
1125        indicoRequest(
1126            'reviewing.conference.removeEditor',
1127            params,
1128            function(result,error) {
1129                if (!error) {
1130                    for (i in checkedContributions) {
1131                        contributionId = checkedContributions[i];
1132                        contribution = getContribution(contributionId);
1133                        contribution.reviewManager.editor = null;
1134                        updateContribution(contributionId);
1135                        colorify(contributionId, 'editor')
1136                        $E('cb' + contributionId).dom.checked = true; //updateContribution will build a row with an unchecked checkbox
1137                    }
1138                } else {
1139                    IndicoUtil.errorReport(error);
1140                }
1141            }
1142        );
1143        break;
1144    case 'allReviewers':
1145        indicoRequest(
1146            'reviewing.conference.removeAllReviewers',
1147            params,
1148            function(result,error) {
1149                if (!error) {
1150                    if (!removeReviewersAlerts(checkedContributions, role)) {
1151                                return;
1152                        }
1153                    for (i in checkedContributions) {
1154                        contributionId = checkedContributions[i];
1155                        contribution = getContribution(contributionId);
1156                        contribution.reviewManager.reviewersList = [];
1157                        updateContribution(contributionId);
1158                        colorify(contributionId, 'reviewer')
1159                        $E('cb' + contributionId).dom.checked = true; //updateContribution will build a row with an unchecked checkbox
1160                    }
1161                } else {
1162                    IndicoUtil.errorReport(error);
1163                }
1164            }
1165        );
1166    default:
1167        break;
1168    }
1169}
1170
1171// Code to be executed on page load
1172
1173buildShowHideFiltering();
1174$E('filteringTable').dom.style.display = 'none';
1175
1176bind.element($E("tablebody"), contributions, contributionTemplate);
1177
1178$E('applyFilter').observeClick(fetchContributions);
1179
1180<% if not IsOnlyReferee and not (ConfReview.getChoice() == 3 or ConfReview.getChoice() == 1): %>
1181$E('assignRefereeButton_top').observeClick(function(){ fetchUsers('assign', 'referee'); });
1182$E('assignRefereeButton_bottom').observeClick(function(){ fetchUsers('assign', 'referee'); });
1183$E('removeRefereeButton_top').observeClick(function(){ removeUser('referee') });
1184$E('removeRefereeButton_bottom').observeClick(function(){ removeUser('referee') });
1185<% end %>
1186
1187<% if not (ConfReview.getChoice() == 2 or ConfReview.getChoice() == 1): %>
1188$E('assignEditorButton_top').observeClick(function(){ fetchUsers('assign', 'editor'); });
1189$E('assignEditorButton_bottom').observeClick(function(){ fetchUsers('assign', 'editor'); });
1190$E('removeEditorButton_top').observeClick(function(){ removeUser('editor') });
1191$E('removeEditorButton_bottom').observeClick(function(){ removeUser('editor') });
1192<% end %>
1193
1194<% if not (ConfReview.getChoice() == 3 or ConfReview.getChoice() == 1): %>
1195$E('addReviewerButton_top').observeClick(function(){ fetchUsers('add', 'reviewer'); });
1196$E('addReviewerButton_bottom').observeClick(function(){ fetchUsers('add', 'reviewer'); });
1197$E('removeReviewerButton_top').observeClick(function(){ fetchUsers('remove', 'reviewer'); });
1198$E('removeReviewerButton_bottom').observeClick(function(){ fetchUsers('remove', 'reviewer'); });
1199$E('removeAllReviewersButton_top').observeClick(function(){ removeUser('allReviewers') });
1200$E('removeAllReviewersButton_bottom').observeClick(function(){ removeUser('allReviewers') });
1201<% end %>
1202
1203
1204fetchContributions();
1205   
1206</script>
1207<% end %>
1208<% end %>
Note: See TracBrowser for help on using the repository browser.