FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
browse.js
1 /*
2  Copyright (C) 2014-2015, Siemens AG
3  Author: Steffen Weber, Johannes Najjar
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License
7  version 2 as published by the Free Software Foundation.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License along
15  with this program; if not, write to the Free Software Foundation, Inc.,
16  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 var myKey = 0;
20 var myVal = 0;
21 
22 var commentModal = null;
23 var uploadId = 0;
24 var statusId = 0;
25 
26 var assigneeSelected = 0;
27 var statusSelected = 0;
28 
29 var staSel = null;
30 
31 $(document).ready(function () {
32  table = createBrowseTable();
33  $('#insert_browsetbl_filter').append($('#browsetbl_filter'));
34  initPrioClick();
35  table.on('draw', function () {
36  initPrioClick();
37  initPrioDraw();
38  $('.cc').dblclick( function (){
39  var source=table.cell(this).data();
40  openCommentModal(source[0],source[1],source[2]);
41  } );
42  $('select.goto-active-option').change(function() {
43  var url = $(this).val();
44  if(url){ window.location = url;}
45  });
46  });
47  commentModal = $('#commentModal').plainModal();
48  $(document).tooltip({'items':"img"});
49 });
50 
51 function initPrioClick() {
52  $("td.priobucket").click(function () {
53  table = createBrowseTable();
54  elementData = table.cell(this).data();
55  yourKey = elementData[0];
56  if (myKey > 0 && myKey !== yourKey) {
57  changePriority(myKey, yourKey);
58  myKey = 0;
59  myVal = 0;
60  return;
61  }
62  else if (yourKey === myKey) {
63  myKey = 0;
64  myVal = 0;
65  }
66  else
67  {
68  myKey = elementData[0]; //upload_pk
69  myVal = elementData[1]; //priority
70  }
71  initPrioDraw();
72  });
73 }
74 function initPrioDraw() {
75  $("td.priobucket").each(function () {
76  $('.ui-tooltip').remove();
77  $(this).html(function () {
78  return prioColumn(table.cell(this).data(), 'display');
79  });
80  });
81 
82  $('.limit-mover').click(function(){
83  var uploadId = $(this).attr('data-source');
84  var dir = $(this).attr('data-dir');
85  move2limit(uploadId,dir);
86  });
87 
88 }
89 
90 function move2limit(uploadId, direction) {
91  myKey = 0;
92  var post_data = {
93  "uploadId": uploadId,
94  "direction": direction
95  };
96  $.ajax({
97  type: "POST",
98  url: "?mod=browse-processPost",
99  data: post_data,
100  success: mysuccess4
101  });
102 }
103 
104 function openCommentModal(upload, status, comment) {
105  uploadId = upload;
106  statusId = status;
107  $("#commentText").val(comment);
108  commentModal.plainModal('open');
109 }
110 
111 function closeCommentModal() {
112  $(staSel).val( $(staSel).find('option[selected]').val() );
113  commentModal.plainModal('close');
114 }
115 
116 
117 function mysuccess() {
118  var oTable = createBrowseTable();
119  oTable.draw(false);
120 }
121 
122 function mysuccess3() {
123  closeCommentModal();
124  var oTable = createBrowseTable();
125  oTable.draw(false);
126 }
127 
128 function mysuccess4() {
129  myKey = 0;
130  initPrioDraw();
131  var oTable = createBrowseTable();
132  oTable.draw(false);
133 }
134 
135 function changeTableEntry(sel, uploadId, columnName) {
136  if (columnName == 'status_fk' && (sel.value == 3 || sel.value == 4)) {
137  staSel = sel;
138  openCommentModal(uploadId, sel.value, '');
139  }
140  else {
141  var post_data = {
142  "columnName": columnName,
143  "uploadId": uploadId,
144  "value": sel.value
145  };
146  $.ajax({
147  type: "POST",
148  url: "?mod=browse-processPost",
149  data: post_data,
150  success: mysuccess
151  });
152  }
153 }
154 
155 function filterAssignee() {
156  assigneeSelected = $('#assigneeSelector').val();
157  var oTable = createBrowseTable();
158  oTable.draw(false);
159 }
160 
161 function filterStatus() {
162  statusSelected = $('#statusSelector').val();
163  var oTable = createBrowseTable();
164  oTable.draw(false);
165 }
166 
167 function changePriority(move, beyond) {
168  var post_data = {
169  "move": move,
170  "beyond": beyond
171  };
172  $.ajax({
173  type: "POST",
174  url: "?mod=browse-processPost",
175  data: post_data,
176  success: mysuccess
177  });
178 }
179 
180 function submitComment( ) {
181  var post_data = {
182  "uploadId": uploadId,
183  "commentText": $("#commentText").val(),
184  "statusId": statusId
185  };
186  $.ajax({
187  type: "POST",
188  url: "?mod=browse-processPost",
189  data: post_data,
190  success: mysuccess3
191  });
192 }