2 * FusionForge Documentation Manager
4 * Copyright 2010, Antoine Mercadal - Capgemini
5 * Copyright 2010-2011, Franck Villaume - Capgemini
6 * Copyright 2011, Alain Peyrat
7 * Copyright 2011-2017,2021, Franck Villaume - TrivialDev
8 * http://fusionforge.org
10 * This file is part of FusionForge. FusionForge is free software;
11 * you can redistribute it and/or modify it under the terms of the
12 * GNU General Public License as published by the Free Software
13 * Foundation; either version 2 of the Licence, or (at your option)
16 * FusionForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 /*! ListFileController
27 * @param groupId the current FusionForge groupID
29 var DocManListFileController = function(params)
31 this.lockInterval = [];
32 this.listfileparams = params;
34 if (this.listfileparams.enableResize) {
37 this.initModalEditWindow();
38 this.initModelNotifyWindow();
41 var DocManAddItemController = function(params)
43 this.additemparams = params;
47 var DocManAddFileController = function(params)
49 this.addfileparams = params;
53 var DocManSearchController = function(params)
55 this.searchparams = params;
59 DocManListFileController.prototype =
61 /*! Binds the controls to the actions
63 bindControls: function() {
64 if (typeof(this.listfileparams.buttonAddItem) != 'undefined') {
65 this.listfileparams.buttonAddItem.click(jQuery.proxy(this, "toggleAddItemView"));
67 if (typeof(jQuery('#versiontab')) != 'undefined') {
68 jQuery('#versiontab').click(jQuery.proxy(this, "setRequiredInputs", jQuery('#versiontab')));
70 if (typeof(jQuery('#reviewtab')) != 'undefined') {
71 jQuery('#reviewtab').click(jQuery.proxy(this, "setRequiredInputs", jQuery('#reviewtab')));
73 if (typeof(jQuery('#associationtab')) != 'undefined') {
74 jQuery('#associationtab').click(jQuery.proxy(this, "setRequiredInputs", jQuery('#associationtab')));
78 resizableDiv: function() {
79 var splitterPosition = '30%';
80 var mainwidth = jQuery('#maindiv').innerWidth();
82 if (jQuery.Storage.get('splitterStyle') !== undefined) {
83 var storedSplitterPosition = jQuery.Storage.get('splitterStyle').replace(/px;?/g, '').replace(/left: /g, '');
84 splitterPosition = Math.round(storedSplitterPosition * 100 / mainwidth )+'%';
86 if (this.listfileparams.page == 'trashfile') {
87 (this.listfileparams.divLeft.outerHeight() > this.listfileparams.divRight.outerHeight()) ? mainheight = this.listfileparams.divLeft.outerHeight() : mainheight = this.listfileparams.divRight.outerHeight();
91 if (jQuery('#editFile').length >= 1) {
92 fixwidth += jQuery('#editFile').outerHeight() - jQuery('[aria-describedby="editFile"]').outerHeight();
94 if (jQuery('#notifyUsers').length >= 1) {
95 fixwidth += jQuery('#notifyUsers').outerHeight() - jQuery('[aria-describedby="notifyUsers"]').outerHeight();
97 var totalRightHeight = 0;
98 this.listfileparams.divRight.children().each(function() {
99 if (jQuery(this).is(':visible')) {
100 totalRightHeight += jQuery(this).outerHeight();
103 totalRightHeight -= fixwidth;
104 (this.listfileparams.divRight.outerHeight() - fixwidth < 0) ? useRightHeight = this.listfileparams.divRight.outerHeight() : useRightHeight = this.listfileparams.divRight.outerHeight() - fixwidth;
105 if (useRightHeight < totalRightHeight) {
106 useRightHeight = totalRightHeight;
108 (this.listfileparams.divLeft.outerHeight() + 30 > this.listfileparams.divRight.outerHeight()) ? mainheight = this.listfileparams.divLeft.outerHeight() + 30 : mainheight = useRightHeight;
110 jQuery('#views').height(mainheight)
111 .split({orientation:'vertical', limit:100, position: splitterPosition});
112 jQuery('.vsplitter').mouseup(function(){
113 jQuery.Storage.set('splitterStyle',''+jQuery('.vsplitter').attr('style'));
117 initModalEditWindow: function() {
118 var modalId = this.listfileparams.divEditFile;
119 this.listfileparams.nocache = new Date().getTime();
120 jQuery(modalId).dialog({
125 Save: jQuery.proxy(function() {
126 jQuery('#editdocdata').submit();
127 var id = jQuery('#docid').attr('value');
128 jQuery.get(this.listfileparams.docManURL+'/', {
129 group_id: this.listfileparams.groupId,
134 childgroup_id: this.listfileparams.childGroupId,
135 rqd: this.listfileparams.nocache
137 jQuery.get(this.listfileparams.docManURL+'/', {
138 group_id: this.listfileparams.groupId,
141 itemid: this.listfileparams.docgroupId,
143 childgroup_id: this.listfileparams.childGroupId,
144 rqd: this.listfileparams.nocache
146 clearInterval(this.lockInterval[id]);
147 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
148 jQuery(modalId).dialog( "close" );
150 Cancel: jQuery.proxy(function() {
151 var id = jQuery('#docid').attr('value');
152 jQuery.get(this.listfileparams.docManURL+'/', {
153 group_id: this.listfileparams.groupId,
158 childgroup_id: this.listfileparams.childGroupId,
159 rqd: this.listfileparams.nocache
161 jQuery.get(this.listfileparams.docManURL+'/', {
162 group_id: this.listfileparams.groupId,
165 itemid: this.listfileparams.docgroupId,
167 childgroup_id: this.listfileparams.childGroupId,
168 rqd: this.listfileparams.nocache
170 clearInterval(this.lockInterval[id]);
171 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
172 jQuery(modalId).dialog('close');
176 jQuery(modalId).bind('dialogclose', jQuery.proxy(function() {
177 var id = jQuery('#docid').attr('value');
178 jQuery.get(this.listfileparams.docManURL+'/', {
179 group_id: this.listfileparams.groupId,
184 childgroup_id: this.listfileparams.childGroupId,
185 rqd: this.listfileparams.nocache
187 jQuery.get(this.listfileparams.docManURL+'/', {
188 group_id: this.listfileparams.groupId,
191 itemid: this.listfileparams.docgroupId,
193 childgroup_id: this.listfileparams.childGroupId,
194 rqd: this.listfileparams.nocache
196 clearInterval(this.lockInterval[id]);
197 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
198 jQuery('#editfile-userstatusreview').remove();
199 jQuery('#editfile-completedreview').remove();
200 jQuery('#editfile-datepickerreview-script').remove();
201 jQuery('#editfile-commentreview').remove();
205 initModelNotifyWindow: function() {
206 var modalId = this.listfileparams.divNotifyUsers;
207 this.listfileparams.nocache = new Date().getTime();
208 jQuery(modalId).dialog({
213 Save: { text: this.listfileparams.divNotifySaveButtonTxt,
214 click: jQuery.proxy(function() {
215 jQuery('#notifyusersdoc').submit();
216 var id = jQuery('#docid').attr('value');
217 jQuery.get(this.listfileparams.docManURL+'/', {
218 group_id: this.listfileparams.groupId,
223 childgroup_id: this.listfileparams.childGroupId,
224 rqd: this.listfileparams.nocache
226 jQuery.get(this.listfileparams.docManURL+'/', {
227 group_id: this.listfileparams.groupId,
230 itemid: this.listfileparams.docgroupId,
232 childgroup_id: this.listfileparams.childGroupId,
233 rqd: this.listfileparams.nocache
235 clearInterval(this.lockInterval[id]);
236 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
237 jQuery(modalId).dialog( "close" );
239 Cancel: jQuery.proxy(function() {
240 var id = jQuery('#docid').attr('value');
241 jQuery.get(this.listfileparams.docManURL+'/', {
242 group_id: this.listfileparams.groupId,
247 childgroup_id: this.listfileparams.childGroupId,
248 rqd: this.listfileparams.nocache
250 jQuery.get(this.listfileparams.docManURL+'/', {
251 group_id: this.listfileparams.groupId,
254 itemid: this.listfileparams.docgroupId,
256 childgroup_id: this.listfileparams.childGroupId,
257 rqd: this.listfileparams.nocache
259 clearInterval(this.lockInterval[id]);
260 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
261 jQuery(modalId).dialog('close');
265 jQuery(modalId).bind('dialogclose', jQuery.proxy(function() {
266 var id = jQuery('#docid').attr('value');
267 jQuery.get(this.listfileparams.docManURL+'/', {
268 group_id: this.listfileparams.groupId,
273 childgroup_id: this.listfileparams.childGroupId,
274 rqd: this.listfileparams.nocache
276 jQuery.get(this.listfileparams.docManURL+'/', {
277 group_id: this.listfileparams.groupId,
280 itemid: this.listfileparams.docgroupId,
282 childgroup_id: this.listfileparams.childGroupId,
283 rqd: this.listfileparams.nocache
285 clearInterval(this.lockInterval[id]);
286 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
290 /*! toggle edit group view div visibility
292 toggleEditDirectoryView: function() {
293 this.listfileparams.nocache = new Date().getTime();
295 var currentLeftHeight;
296 if (!this.listfileparams.divEditDirectory.is(":visible")) {
297 jQuery.getJSON(this.listfileparams.docManURL + '/?group_id='+this.listfileparams.groupId+'&action=lock&json=1&type=dir&itemid='+this.listfileparams.docgroupId+'&childgroup_id='+this.listfileparams.childGroupId+'&rqd='+this.listfileparams.nocache, jQuery.proxy(function(data){
298 if (typeof data.html != 'undefined') {
299 jQuery('#maindiv > .feedback').remove();
300 jQuery('#maindiv > .error').remove();
301 jQuery('#maindiv > .warning_msg').remove();
302 jQuery('#maindiv').prepend(data.html);
304 this.listfileparams.divEditDirectory.show();
305 if (typeof(this.listfileparams.divAddItem) != 'undefined') {
306 this.listfileparams.divAddItem.hide();
308 computeHeight = this.listfileparams.divRight.outerHeight() + this.listfileparams.divEditDirectory.outerHeight();
309 currentLeftHeight = this.listfileparams.divLeft.outerHeight();
310 this.listfileparams.divLeft.height(currentLeftHeight + this.listfileparams.divEditDirectory.outerHeight());
311 jQuery.get(this.listfileparams.docManURL+'/', {
312 group_id: this.listfileparams.groupId,
316 itemid: this.listfileparams.docgroupId,
317 childgroup_id: this.listfileparams.childGroupId,
318 rqd: this.listfileparams.nocache
320 this.lockInterval[this.listfileparams.docgroupId] = setInterval("jQuery.get('" + this.listfileparams.docManURL + "/', {group_id:"+this.listfileparams.groupId+", action:'lock', lock:1, type:'dir', itemid:"+this.listfileparams.docgroupId+", childgroup_id:"+this.listfileparams.childGroupId+", rqd:"+this.listfileparams.nocache+"})", this.listfileparams.lockIntervalDelay);
321 if (typeof(this.listfileparams.divLeft) != 'undefined' && typeof(this.listfileparams.divRight) != 'undefined') {
322 if (this.listfileparams.divLeft.outerHeight() > computeHeight) {
323 jQuery('#views').height(this.listfileparams.divLeft.outerHeight());
325 jQuery('#views').height(computeHeight);
329 }, this)).fail(function(jqXHR, textStatus, errorThrown) {
330 let error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
331 jQuery('#maindiv').prepend(error_msg);
334 this.listfileparams.divEditDirectory.hide();
335 computeHeight = this.listfileparams.divRight.outerHeight() - this.listfileparams.divEditDirectory.outerHeight();
336 currentLeftHeight = this.listfileparams.divLeft.outerHeight();
337 this.listfileparams.divLeft.height(currentLeftHeight - this.listfileparams.divEditDirectory.outerHeight());
338 jQuery.get(this.listfileparams.docManURL+'/', {
339 group_id: this.listfileparams.groupId,
343 itemid: this.listfileparams.docgroupId,
344 childgroup_id: this.listfileparams.childGroupId,
345 rqd: this.listfileparams.nocache
347 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
348 if (typeof(this.listfileparams.divLeft) != 'undefined' && typeof(this.listfileparams.divRight) != 'undefined') {
349 if (this.listfileparams.divLeft.outerHeight() > computeHeight) {
350 jQuery('#views').height(this.listfileparams.divLeft.outerHeight());
352 jQuery('#views').height(computeHeight);
359 /*! toggle add item view div visibility
361 toggleAddItemView: function() {
362 this.listfileparams.nocache = new Date().getTime();
364 var currentLeftHeight;
365 if (!this.listfileparams.divAddItem.is(":visible")) {
366 jQuery.getJSON(this.listfileparams.docManURL + '/?group_id='+this.listfileparams.groupId+'&action=lock&json=1&type=dir&itemid='+this.listfileparams.docgroupId+'&childgroup_id='+this.listfileparams.childGroupId+'&rqd='+this.listfileparams.nocache, jQuery.proxy(function(data){
367 if (typeof data.html != 'undefined') {
368 jQuery('#maindiv > .feedback').remove();
369 jQuery('#maindiv > .error').remove();
370 jQuery('#maindiv > .warning_msg').remove();
371 jQuery('#maindiv').prepend(data.html);
373 jQuery.get(this.listfileparams.docManURL+'/', {
374 group_id: this.listfileparams.groupId,
378 itemid: this.listfileparams.docgroupId,
379 childgroup_id: this.listfileparams.childGroupId
381 this.lockInterval[this.listfileparams.docgroupId] = setInterval("jQuery.get('"+this.listfileparams.docManURL+"/', {group_id:"+this.listfileparams.groupId+", action:'lock', lock:1, type:'dir', itemid:"+this.listfileparams.docgroupId+", childgroup_id:"+this.listfileparams.childGroupId+", rqd:"+this.listfileparams.nocache+"})", this.listfileparams.lockIntervalDelay);
382 this.listfileparams.divAddItem.show();
383 this.listfileparams.divEditDirectory.hide();
384 computeHeight = this.listfileparams.divRight.outerHeight() + jQuery(this.listfileparams.divAddItem).outerHeight();
385 currentLeftHeight = this.listfileparams.divLeft.outerHeight();
386 this.listfileparams.divLeft.height(currentLeftHeight + jQuery(this.listfileparams.divAddItem).outerHeight());
387 if (typeof(this.listfileparams.divLeft) != 'undefined' && typeof(this.listfileparams.divRight) != 'undefined') {
388 if (this.listfileparams.divLeft.outerHeight() > computeHeight) {
389 jQuery('#views').height(this.listfileparams.divLeft.outerHeight());
391 jQuery('#views').height(computeHeight);
395 }, this)).fail(function(jqXHR, textStatus, errorThrown) {
396 let error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
397 jQuery('#maindiv').prepend(error_msg);
400 jQuery.get(this.listfileparams.docManURL+'/', {
401 group_id: this.listfileparams.groupId,
405 itemid: this.listfileparams.docgroupId,
406 childgroup_id: this.listfileparams.childGroupId,
407 rqd: this.listfileparams.nocache
409 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
410 this.listfileparams.divAddItem.hide();
411 computeHeight = this.listfileparams.divRight.outerHeight() - jQuery(this.listfileparams.divAddItem).outerHeight();
412 currentLeftHeight = this.listfileparams.divLeft.outerHeight();
413 this.listfileparams.divLeft.height(currentLeftHeight - jQuery(this.listfileparams.divAddItem).outerHeight());
414 if (typeof(this.listfileparams.divLeft) != 'undefined' && typeof(this.listfileparams.divRight) != 'undefined') {
415 if (this.listfileparams.divLeft.outerHeight() > computeHeight) {
416 jQuery('#views').height(this.listfileparams.divLeft.outerHeight());
418 jQuery('#views').height(computeHeight);
425 /*! toggle add file edit view div visibility and play with lock
427 * @param params array
429 toggleEditFileView: function(params) {
430 this.docparams = params;
431 this.listfileparams.tableAddVersion.hide();
432 jQuery('#doc_group').empty();
433 jQuery('#editfile-userstatusreview').empty();
434 jQuery('#editfile-completedreview').empty();
435 jQuery('#editfile-commentreview').empty();
436 for (let dictentry of this.docparams.docgroupDict) {
437 jQuery('#doc_group').append(jQuery('<option>').text(dictentry[1]).attr('value', dictentry[0]));
439 jQuery('#doc_group option[value='+this.docparams.docgroupId+']').attr('selected', 'selected');
440 jQuery('#stateid').empty();
441 jQuery.each(this.docparams.statusDict, function(key, value) {
442 jQuery('#stateid').append(jQuery('<option>').text(key).attr('value',value));
444 jQuery('#stateid option[value='+this.docparams.statusId+']').attr('selected', 'selected');
445 jQuery('#docid').val(this.docparams.id);
446 var docid_groupid = this.listfileparams.groupId;
447 if (this.listfileparams.childGroupId != 0) {
448 docid_groupid = this.listfileparams.childGroupId;
450 var nocache = new Date().getTime();
451 jQuery.getJSON(this.listfileparams.docManURL + '/?group_id=' + docid_groupid + '&action=getdocversions&docid='+ this.docparams.id+'&rqd='+nocache, jQuery.proxy(function(data){
452 if (typeof data.html != 'undefined') {
453 jQuery('#editFile > .feedback').remove();
454 jQuery('#editFile > .error').remove();
455 jQuery('#editFile > .warning_msg').remove();
456 jQuery('#editFile > .information').remove();
457 jQuery('#editFile').prepend(data.html);
459 jQuery('#sortable_doc_version_table > tbody').children().remove();
460 jQuery('#sortable_doc_version_table > tbody').css('max-height', '400px').css('overflow-y', 'auto').css('display', 'block');
461 jQuery('#sortable_doc_version_table > thead > tr').css('display', 'block');
462 let eachdocparams = this.docparams;
463 jQuery.each(data, function (x, val) {
464 //_('ID (x)'), _('Filename'), _('Title'), _('Description'), _('Comment'), _('Author'), _('Last Time'), _('Size'), _('Actions'));
465 let currenttdcontent = '';
466 if (val.current_version == 1) {
467 currenttdcontent += ' (x)';
469 let filenametdcontent;
470 if (eachdocparams.statusId != 2) {
471 filenametdcontent = jQuery('<a>'+val.filename+'</a>');
472 if (val.filetype == 'URL') {
474 filenametdcontent.attr('href', val.filename);
476 filenametdcontent.attr('href', eachdocparams.docManURL+'/view.php/'+eachdocparams.groupId+'/versions/'+eachdocparams.id+'/'+val.version.substring(1));
479 filenametdcontent = jQuery('<span>'+val.filename+'</span>');
481 let versionactiontdcontent = '';
482 let versionActionsArrayLength = val.versionactions.length;
483 for (let i = 0; i < versionActionsArrayLength; i++) {
484 versionactiontdcontent += val.versionactions[i];
486 // please sync with the editfile.php widths if you change it here.
487 var htmlString = '<tr id="docversion'+val.version.substr(1)+'" ><td style="width: 60px">'+val.version.substr(1)+currenttdcontent+'</td><td style="width: 150px">'+filenametdcontent[0].outerHTML+'</td><td style="width: 150px">'+val.title+'</td><td style="width: 150px">'+val.new_description.replace(/\\n/g, '<br />')+'</td><td style="width: 110px">'+val.vcomment.replace(/\\n/g, '<br />')+'</td><td style="width: 100px">'+val.created_by_username+'</td><td style="width: 100px">'+val.lastdate+'</td><td style="width: 50px">'+val.filesize_readable+'</td><td style="width: 50px">'+versionactiontdcontent+'</td></tr>'
488 jQuery('#sortable_doc_version_table > tbody:last-child').append(htmlString);
491 }, this)).fail(function(jqXHR, textStatus, errorThrown) {
492 let error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
493 jQuery('#editFile').prepend(error_msg);
496 jQuery.getJSON(this.listfileparams.docManURL + '/?group_id=' + docid_groupid + '&action=getassociations&docid='+ this.docparams.id+'&rqd='+nocache, jQuery.proxy(function(data){
497 if (typeof data.html != 'undefined') {
498 jQuery('#tabbereditfile-association > .feedback').remove();
499 jQuery('#tabbereditfile-association > .error').remove();
500 jQuery('#tabbereditfile-association > .warning_msg').remove();
501 jQuery('#tabbereditfile-association > .information').remove();
502 jQuery('#tabbereditfile-association > table').remove();
503 jQuery('#tabbereditfile-association > span').remove();
504 jQuery('#tabbereditfile-association > p').remove();
505 jQuery('#tabbereditfile-association').prepend(data.html);
507 if (typeof data.htmltab != 'undefined') {
508 jQuery('#associationtab').text(data.htmltab);
510 }, this)).fail(function(jqXHR, textStatus, errorThrown) {
511 error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
512 jQuery('#tabbereditfile-association').prepend(error_msg);
515 jQuery.getJSON(this.listfileparams.docManURL + '/?group_id=' + docid_groupid + '&action=getdocreviews&docid='+ this.docparams.id+'&rqd='+nocache, jQuery.proxy(function(data){
516 if (typeof data.html != 'undefined') {
517 jQuery('#tabbereditfile-review > .feedback').remove();
518 jQuery('#tabbereditfile-review > .error').remove();
519 jQuery('#tabbereditfile-review > .warning_msg').remove();
520 jQuery('#tabbereditfile-review > .information').remove();
521 jQuery('#tabbereditfile-review > table').remove();
522 jQuery('#tabbereditfile-review > span').remove();
523 jQuery('#tabbereditfile-review > p').remove();
524 jQuery('#editfile-createreview').remove();
525 jQuery('#doc_review_addbutton').remove();
526 jQuery('#tabbereditfile-review').prepend(data.html);
527 jQuery('#doc_review_addbutton').button();
529 if (typeof data.htmltab != 'undefined') {
530 jQuery('#reviewtab').text(data.htmltab);
532 jQuery('#review-select-mandatory-users').gentleSelect({columns: 3, itemWidth: 150});
533 jQuery('#review-select-optional-users').gentleSelect({columns: 3, itemWidth: 150});
534 }, this)).fail(function(jqXHR, textStatus, errorThrown) {
535 error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
536 jQuery('#tabbereditfile-association').prepend(error_msg);
539 jQuery('#editdocdata').attr('action', this.docparams.action);
541 jQuery.get(this.docparams.docManURL+'/', {
542 group_id: this.docparams.groupId,
546 itemid: this.docparams.docgroupId,
547 childgroup_id: this.docparams.childGroupId,
550 this.lockInterval[this.docparams.id] = setInterval("jQuery.get('" + this.docparams.docManURL + "/', {group_id:"+this.docparams.groupId+", action:'lock', lock:1, type:'file', itemid:"+this.docparams.id+", childgroup_id:"+this.docparams.childGroupId+", rqd:"+nocache+"})", this.docparams.lockIntervalDelay);
551 this.lockInterval[this.docparams.docgroupId] = setInterval("jQuery.get('" + this.docparams.docManURL + "/', {group_id:"+this.docparams.groupId+", action:'lock', lock:1, type: 'dir', itemid:"+this.docparams.docgroupId+", childgroup_id:"+this.docparams.childGroupId+", rqd:"+nocache+"})", this.docparams.lockIntervalDelay);
552 jQuery('#tabbereditfile').tabs("option", "active", 0);
553 this.setRequiredInputs(jQuery('#versiontab'));
554 jQuery(this.listfileparams.divEditFile).dialog('option', 'title', '[D'+this.docparams.id+'] '+this.listfileparams.divEditTitle).dialog('open');
558 toggleAddVersionView: function() {
559 jQuery('#title').val('');
560 jQuery('#description').val('');
561 jQuery(':file').val('');
562 jQuery('#edit_version').val('');
563 jQuery('#defaulteditzone').text();
564 jQuery('#current_version').prop('checked', false);
565 jQuery('#current_version').attr('onclick', 'return true');
566 if (!this.listfileparams.tableAddVersion.is(':visible')) {
567 jQuery('#new_version').val(1);
568 this.listfileparams.tableAddVersion.show();
570 this.listfileparams.tableAddVersion.hide();
571 jQuery('#new_version').val(0);
575 toggleAddReviewView: function() {
576 jQuery('#review_newcomment').val(0);
577 jQuery('#review-title').val('');
578 jQuery('#review-description').val('');
579 jQuery('#review-notificationcomment').val('');
580 jQuery('#datepicker_end_review_date').val('');
581 jQuery('#review-serialid').val();
582 jQuery('[class^=gentle]').remove();
583 jQuery('#review-select-mandatory-users').val('');
584 jQuery('#review-select-optional-users').val('');
585 jQuery('#review-select-mandatory-users').gentleSelect({columns: 3, itemWidth: 150});
586 jQuery('#review-select-optional-users').gentleSelect({columns: 3, itemWidth: 150});
587 jQuery('#editfile-userstatusreview').empty();
588 jQuery('#editfile-completedreview').empty();
589 jQuery('#editfile-commentreview').empty();
590 jQuery('#editfile-remindernotification').hide();
591 jQuery('#review-remindernotification').val('');
592 if (jQuery('#editfile-createreview').is(':visible')) {
593 jQuery('#editfile-createreview').hide();
594 jQuery('#new_review').val(0);
596 jQuery('#new_review').val(1);
597 jQuery('#editfile-createreview').show();
598 jQuery('#review-notificationcomment-row').show();
602 toggleEditReviewView: function(params) {
603 this.review = params;
604 jQuery('#editfile-commentreview').empty();
605 jQuery('#review_newcomment').val(0);
606 jQuery('#editfile-remindernotification').hide();
607 jQuery('#review-remindernotification').val('');
608 if (jQuery('#editfile-createreview').is(':visible')) {
609 jQuery('#editfile-createreview').hide();
610 jQuery('#new_review').val(0);
611 jQuery('#review_id').val(0);
612 jQuery('#review_complete').val(0);
613 jQuery('#editfile-userstatusreview').empty();
614 jQuery('#editfile-completedreview').empty();
616 jQuery('#review_id').val(this.review.review);
617 jQuery('#review-title').val(this.review.title);
618 jQuery('#review-description').val(this.review.description.replace(/\\n/g, String.fromCharCode(13,10)));
619 jQuery('#datepicker_end_review_date').val(this.review.endreviewdate);
620 jQuery('#review-serialid').val(this.review.serialid);
621 var nocache = new Date().getTime();
622 if (this.review.complete) {
623 jQuery('#tr-mandatory-reviewers').hide();
624 jQuery('#tr-optional-reviewers').hide();
625 jQuery('#review_complete').val(1);
626 jQuery.getJSON(this.listfileparams.docManURL + '/?group_id=' + this.review.groupId + '&action=getdocreviewcompleteform&docid='+this.review.docid+'&revid='+this.review.review+'&rqd='+nocache, jQuery.proxy(function(data){
627 jQuery('#editfile-completedreview').empty();
628 if (typeof data.html != 'undefined') {
629 jQuery('#editfile-completedreview').prepend(data.html);
631 }, this.review)).fail(function(jqXHR, textStatus, errorThrown) {
632 error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
633 jQuery('#editfile-completedreview').prepend(error_msg);
636 jQuery('#tr-mandatory-reviewers').show();
637 jQuery('#tr-optional-reviewers').show();
638 jQuery('[class^=gentle]').remove();
639 jQuery('#review-select-mandatory-users').val(this.review.mandatoryusers);
640 jQuery('#review-select-optional-users').val(this.review.optionalusers);
641 jQuery('#review-select-mandatory-users').gentleSelect({columns: 3, itemWidth: 150});
642 jQuery('#review-select-optional-users').gentleSelect({columns: 3, itemWidth: 150});
644 jQuery.getJSON(this.listfileparams.docManURL + '/?group_id=' + this.review.groupId + '&action=getdocreviewuserstatus&docid='+this.review.docid+'&revid='+this.review.review+'&rqd='+nocache, jQuery.proxy(function(data){
645 jQuery('#editfile-userstatusreview').empty();
646 if (typeof data.html != 'undefined') {
647 jQuery('#editfile-userstatusreview').prepend(data.html);
649 }, this.review)).fail(function(jqXHR, textStatus, errorThrown) {
650 error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
651 jQuery('#editfile-userstatusreview').prepend(error_msg);
653 jQuery('#new_review').val(0);
654 jQuery('#editfile-createreview').show();
655 jQuery('#review-notificationcomment-row').hide();
659 toggleCommentReviewView: function(params) {
660 this.comment = params;
661 jQuery('#editfile-createreview').hide();
662 jQuery('#new_review').val(0);
663 jQuery('#review_id').val(0);
664 jQuery('#review_complete').val(0);
665 jQuery('#review_newcomment').val(1);
666 jQuery('#review_id').val(this.comment.review);
667 jQuery('#editfile-userstatusreview').empty();
668 jQuery('#editfile-completedreview').empty();
669 jQuery('#editfile-remindernotification').hide();
670 jQuery('#review-remindernotification').val('');
671 var nocache = new Date().getTime();
672 jQuery.getJSON(this.listfileparams.docManURL + '/?group_id=' + this.comment.groupId + '&action=getdocreviewcomments&docid='+this.comment.docid+'&revid='+this.comment.review+'&rqd='+nocache, jQuery.proxy(function(data){
673 jQuery('#editfile-commentreview').empty();
674 if (typeof data.html != 'undefined') {
675 jQuery('#editfile-commentreview').prepend(data.html);
677 }, this.comment)).fail(function(jqXHR, textStatus, errorThrown) {
678 error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
679 jQuery('#editfile-commentreview').prepend(error_msg);
683 toggleEditVersionView: function(params) {
684 this.version = params;
685 jQuery('#new_version').val(0);
686 if (this.version.isHtml) {
687 jQuery('#defaulteditfiletype').val('text/html');
689 if (this.version.isText && !this.version.isHtml) {
690 jQuery('#defaulteditfiletype').val('text/plain');
692 if (this.version.isText) {
693 var nocache = new Date().getTime();
694 jQuery.getJSON(this.listfileparams.docManURL+'/?group_id='+this.version.groupId+'&action=getfile&type=file&itemid='+this.version.id+'&version='+this.version.version+'&rqd='+nocache, jQuery.proxy(function(data){
696 jQuery('#defaulteditzone').text(data.body);
698 }, this)).fail(function(jqXHR, textStatus, errorThrown) {
699 error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
700 jQuery('#defaulteditzone').prepend(error_msg);
704 if (!this.listfileparams.tableAddVersion.is(':visible')) {
705 if (this.version.isURL) {
706 jQuery('#uploadnewroweditfile').hide();
707 jQuery('#fileurlroweditfile').show();
708 jQuery('#fileurlroweditfile').find('input').attr('required', 'required').prop('required', true);
709 jQuery('#fileurlroweditfile').find('input').val(this.version.filename);
710 jQuery('#editonlineroweditfile').hide();
711 jQuery('#editor').attr('disabled', true);
712 jQuery('#editButtonUrl').prop('checked', true);
713 } else if (this.listfileparams.useCreateOnline && this.version.isText){
714 jQuery('#fileurlroweditfile').hide();
715 jQuery('#uploadnewroweditfile').hide();
716 jQuery('#editonlineroweditfile').show();
717 jQuery('#editor').removeAttr('disabled');
718 jQuery('#editButtonEditor').prop('checked', true);
720 jQuery('#onlineroweditfile').hide();
721 jQuery('#editor').attr('disabled', true);
722 jQuery('#fileurlroweditfile').hide();
723 jQuery('#uploadnewroweditfile').show();
724 jQuery('#editButtonFile').prop('checked', true);
726 jQuery('#title').val(this.version.title);
727 jQuery('#description').val(this.version.description.replace(/\\n/g, String.fromCharCode(13,10)));
728 jQuery('#vcomment').val(this.version.vcomment.replace(/\\n/g, String.fromCharCode(13,10)));
729 jQuery('#edit_version').val(this.version.version);
730 if (this.version.current_version == 1) {
731 jQuery('#current_version').attr('checked', 'checked').prop('checked', true);
732 jQuery('#current_version').attr('onclick', 'return false');
734 this.listfileparams.tableAddVersion.show();
736 this.listfileparams.tableAddVersion.hide();
737 jQuery('#title').val('');
738 jQuery('#description').val('');
739 jQuery('#vcomment').val('');
740 jQuery(':file').val('');
741 jQuery('#edit_version').val('');
742 jQuery('#current_version').removeAttr('checked');
743 jQuery('#current_version').attr('onclick', 'return true');
744 jQuery('#fileurlroweditfile').find('input').val('');
745 jQuery('#fileurlroweditfile').find('input').removeAttr('required');
746 jQuery('#fileurlroweditfile').hide();
747 jQuery('#uploadnewroweditfile').hide();
748 jQuery('#editonlineroweditfile').hide();
749 jQuery('#defaulteditzone').text('');
753 deleteVersion: function(params) {
754 this.delversion = params;
755 var nocache = new Date().getTime();
756 jQuery.getJSON(this.listfileparams.docManURL + '/?group_id=' + this.delversion.groupId + '&action=deleteversion&docid='+this.delversion.docid+'&version='+this.delversion.version+'&rqd='+nocache, jQuery.proxy(function(data){
757 if (typeof data.html != 'undefined') {
758 jQuery('#editFile > .feedback').remove();
759 jQuery('#editFile > .error').remove();
760 jQuery('#editFile > .warning_msg').remove();
761 jQuery('#editFile').prepend(data.html);
763 if (typeof data.status != 'undefined') {
764 if (data.status == 1) {
765 jQuery('#docversion'+this.version).remove();
766 //adjust review tab & version tab number?
767 if (jQuery('#docversionreview'+this.version) != 'undefined') {
768 jQuery('#docversionreview'+this.version).parent.remove();
770 if (jQuery('#sortable_doc_version_table tr').length <= 2) {
771 jQuery('#version_action_delete').remove();
775 }, this.delversion)).fail(function(jqXHR, textStatus, errorThrown) {
776 error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
777 jQuery('#editFile').prepend(error_msg);
781 deleteReview: function(params) {
782 this.delreview = params;
783 jQuery('#editfile-createreview').hide();
784 jQuery('#new_review').val(0);
785 jQuery('#review_id').val(0);
786 jQuery('#review_complete').val(0);
787 jQuery('#editfile-userstatusreview').empty();
788 jQuery('#editfile-completedreview').empty();
789 jQuery('#editfile-remindernotification').hide();
790 jQuery('#review-remindernotification').val('');
791 var nocache = new Date().getTime();
792 jQuery.getJSON(this.docparams.docManURL + '/?group_id=' + this.docparams.groupId + '&action=deletereview&docid='+this.docparams.id+'&review='+this.delreview.review+'&rqd='+nocache, jQuery.proxy(function(data){
793 if (typeof data.html != 'undefined') {
794 jQuery('#editFile > .feedback').remove();
795 jQuery('#editFile > .error').remove();
796 jQuery('#editFile > .warning_msg').remove();
797 jQuery('#editFile').prepend(data.html);
799 if (typeof data.status != 'undefined') {
800 if (data.status == 1) {
801 jQuery('#docreview'+this.review).remove();
802 //adjust review tab number?
805 }, this.delreview)).fail(function(jqXHR, textStatus, errorThrown) {
806 error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
807 jQuery('#editFile').prepend(error_msg);
811 reminderReview: function(params) {
812 this.reminderreview = params;
813 if (jQuery('#editfile-remindernotification').is(':visible')) {
814 jQuery('#editfile-remindernotification').hide();
815 jQuery('#review-remindernotification').val('');
817 jQuery('#new_review').val(2);
818 jQuery('#review_id').val(this.reminderreview.review);
819 jQuery('#editfile-createreview').hide();
820 jQuery('#editfile-commentreview').empty();
821 jQuery('#editfile-userstatusreview').empty();
822 jQuery('#editfile-completedreview').empty();
823 jQuery('#editfile-remindernotification').show();
827 toggleMoveFileView: function() {
828 if (!this.listfileparams.divMoveFile.is(':visible')) {
829 this.listfileparams.divMoveFile.show();
830 jQuery('#movefileinput').val(function() {
831 var CheckedBoxes = new Array();
832 for (let h of jQuery('input:checked')) {
833 if (typeof(h.className) != 'undefined' && h.className.match('checkeddocidactive')) {
834 CheckedBoxes.push(h.value);
840 this.listfileparams.divMoveFile.hide();
844 toggleNotifyUserView: function(params) {
845 this.notifyparams = params;
846 var nocache = new Date().getTime();
847 jQuery('#notifytitle').text(this.notifyparams.title);
848 jQuery('#notifydescription').text(this.notifyparams.description);
849 jQuery('#notifydocid').val(this.notifyparams.id);
850 jQuery('#notifyfilelink').text(this.notifyparams.filename);
851 if (this.notifyparams.statusId != 2) {
852 if (this.notifyparams.isURL) {
853 jQuery('#notifyfilelink').attr('href', this.notifyparams.filename);
855 jQuery('#notifyfilelink').attr('href', this.notifyparams.docManURL+'/view.php/'+this.notifyparams.groupId+'/'+this.notifyparams.id);
859 jQuery('#notifyusersdoc').attr('action', this.notifyparams.action);
860 jQuery.get(this.notifyparams.docManURL+'/', {
861 group_id: this.notifyparams.groupId,
865 itemid: this.notifyparams.docgroupId,
866 childgroup_id: this.notifyparams.childGroupId,
869 this.lockInterval[this.notifyparams.id] = setInterval("jQuery.get('" + this.notifyparams.docManURL + "/', {group_id:"+this.notifyparams.groupId+",action:'lock',lock:1,type:'file',itemid:"+this.notifyparams.id+",childgroup_id:"+this.notifyparams.childGroupId+", rqd:"+nocache+"})", this.notifyparams.lockIntervalDelay);
870 this.lockInterval[this.notifyparams.docgroupId] = setInterval("jQuery.get('" + this.notifyparams.docManURL + "/', {group_id:"+this.notifyparams.groupId+",action:'lock',lock:1,type:'dir',itemid:"+this.notifyparams.docgroupId+",childgroup_id:"+this.notifyparams.childGroupId+", rqd:"+nocache+"})", this.notifyparams.lockIntervalDelay);
871 jQuery('#notify-userids').gentleSelect({columns: 2, itemWidth: 120});
872 jQuery(this.listfileparams.divNotifyUsers).dialog('option', 'title', '[D'+this.notifyparams.id+'] '+this.listfileparams.divNotifyTitle).dialog('open');
878 /*! build list of id, comma separated
880 buildUrlByCheckbox: function(id) {
881 var CheckedBoxes = new Array();
882 for (let h of jQuery('input:checked')) {
883 if (typeof(h.className) != 'undefined' && h.className.match('checkeddocid'+id)) {
884 CheckedBoxes.push(h.value);
890 checkAll: function(id, type) {
891 if (jQuery('#checkall'+type).is(':checked')) {
892 jQuery('.'+id).each(function() {
893 jQuery(this).prop('checked', true);
895 jQuery('#massaction'+type).show();
897 jQuery('.'+id).each(function() {
898 jQuery(this).prop('checked', false);
900 jQuery('#massaction'+type).hide();
904 checkgeneral: function(id) {
905 if (jQuery(this).attr('checked', false)) {
906 jQuery('#checkall'+id).prop('checked', false);
907 jQuery('#massaction'+id).hide();
908 jQuery('#movefile').hide();
910 for (let h of jQuery('input:checked')) {
911 if (typeof(h.className) != 'undefined' && h.className.match('checkeddocid'+id)) {
912 jQuery('#massaction'+id).show();
918 setRequiredInputs: function(id) {
919 if (id.attr('id') == 'reviewtab') {
920 jQuery('#tabbereditfile-version :input').not(':input[type=hidden], :input[type=button]').prop('disabled', true);
921 jQuery('#tabbereditfile-association').prop('disabled', true);
922 jQuery('#tabbereditfile-review :input').removeAttr('disabled');
923 jQuery('#subaction').val('review');
924 } else if (id.attr('id') == 'associationtab') {
925 jQuery('#tabbereditfile-version :input').not(':input[type=hidden], :input[type=button]').prop('disabled', true);
926 jQuery('#tabbereditfile-association').removeAttr('disabled');
927 jQuery('#tabbereditfile-review :input').prop('disabled', true);
928 jQuery('#subaction').val('association');
929 } else if (id.attr('id') == 'versiontab') {
930 jQuery('#tabbereditfile-version :input').not(':input[type=hidden], :input[type=button]').removeAttr('disabled');
931 jQuery('#tabbereditfile-association').prop('disabled', true);
932 jQuery('#tabbereditfile-review :input').prop('disabled', true);
933 jQuery('#subaction').val('version');
938 DocManAddItemController.prototype =
940 /*! Binds the controls to the actions
942 bindControls: function() {
943 this.additemparams.submitZip.click(jQuery.proxy(this, "submitFormZip"));
946 submitFormZip: function() {
947 this.additemparams.injectZip.submit();
948 this.additemparams.submitZip.attr('disabled', true);
952 DocManAddFileController.prototype =
954 /*! Binds the controls to the actions
956 bindControls: function() {
957 this.addfileparams.buttonFile.click(jQuery.proxy(this, "toggleFileRowView"));
958 this.addfileparams.buttonUrl.click(jQuery.proxy(this, "toggleUrlRowView"));
959 if (typeof(this.addfileparams.buttonManualUpload) != 'undefined') {
960 this.addfileparams.buttonManualUpload.click(jQuery.proxy(this, "toggleManualUploadView"));
962 if (typeof(this.addfileparams.buttonEditor) != 'undefined') {
963 this.addfileparams.buttonEditor.click(jQuery.proxy(this, "toggleEditorView"));
967 toggleFileRowView: function() {
968 this.addfileparams.fileRow.show();
969 this.addfileparams.fileRow.find('input').attr("required", "required");
970 this.addfileparams.urlRow.hide();
971 this.addfileparams.urlRow.find('input').removeAttr("required");
972 this.addfileparams.pathRow.hide();
973 this.addfileparams.pathRow.find('input').removeAttr("required");
974 this.addfileparams.editRow.hide();
975 this.addfileparams.editNameRow.hide();
978 toggleUrlRowView: function() {
979 this.addfileparams.fileRow.hide();
980 this.addfileparams.fileRow.find('input').removeAttr("required");
981 this.addfileparams.urlRow.show();
982 this.addfileparams.urlRow.find('input').attr("required", "required");
983 this.addfileparams.pathRow.hide();
984 this.addfileparams.pathRow.find('input').removeAttr("required");
985 this.addfileparams.editRow.hide();
986 this.addfileparams.editNameRow.hide();
989 toggleManualUploadView: function() {
990 this.addfileparams.fileRow.hide();
991 this.addfileparams.fileRow.find('input').removeAttr("required");
992 this.addfileparams.urlRow.hide();
993 this.addfileparams.urlRow.find('input').removeAttr("required");
994 this.addfileparams.pathRow.show();
995 this.addfileparams.pathRow.find('input').attr("required", "required");
996 this.addfileparams.editRow.hide();
997 this.addfileparams.editNameRow.hide();
1000 toggleEditorView: function() {
1001 this.addfileparams.fileRow.hide();
1002 this.addfileparams.fileRow.find('input').removeAttr("required");
1003 this.addfileparams.urlRow.hide();
1004 this.addfileparams.urlRow.find('input').removeAttr("required");
1005 this.addfileparams.pathRow.hide();
1006 this.addfileparams.pathRow.find('input').removeAttr("required");
1007 this.addfileparams.editRow.show();
1008 this.addfileparams.editNameRow.show();
1012 DocManSearchController.prototype =
1014 /*! Binds the controls to the actions
1016 bindControls: function() {
1017 this.searchparams.buttonStartDate.click(jQuery.proxy(this, 'setStartDate'));
1018 this.searchparams.buttonEndDate.click(jQuery.proxy(this, 'setEndDate'));
1021 setStartDate: function() {
1022 if (this.searchparams.buttonStartDate.is(':checked')) {
1023 this.searchparams.datePickerStartDate.removeAttr('disabled');
1024 this.searchparams.datePickerStartDate.attr('required', 'required');
1026 this.searchparams.datePickerStartDate.attr('disabled', 'disabled');
1027 this.searchparams.datePickerStartDate.removeAttr('required');
1031 setEndDate: function() {
1032 if (this.searchparams.buttonEndDate.is(':checked')) {
1033 this.searchparams.datePickerEndDate.removeAttr('disabled');
1034 this.searchparams.datePickerEndDate.attr('required', 'required');
1036 this.searchparams.datePickerEndDate.attr('disabled', 'disabled');
1037 this.searchparams.datePickerEndDate.removeAttr('required');