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-2022, 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 if (this.listfileparams.divLeft.outerHeight() > this.listfileparams.divRight.outerHeight()) {
88 mainheight = this.listfileparams.divLeft.outerHeight();
90 mainheight = this.listfileparams.divRight.outerHeight();
95 if (jQuery('#editFile').length >= 1) {
96 fixwidth += jQuery('#editFile').outerHeight() - jQuery('[aria-describedby="editFile"]').outerHeight();
98 if (jQuery('#notifyUsers').length >= 1) {
99 fixwidth += jQuery('#notifyUsers').outerHeight() - jQuery('[aria-describedby="notifyUsers"]').outerHeight();
101 var totalRightHeight = 0;
102 this.listfileparams.divRight.children().each(function() {
103 if (jQuery(this).is(':visible')) {
104 totalRightHeight += jQuery(this).outerHeight();
107 totalRightHeight -= fixwidth;
108 if (this.listfileparams.divRight.outerHeight() - fixwidth < 0) {
109 useRightHeight = this.listfileparams.divRight.outerHeight();
111 useRightHeight = this.listfileparams.divRight.outerHeight() - fixwidth;
113 if (useRightHeight < totalRightHeight) {
114 useRightHeight = totalRightHeight;
116 if (this.listfileparams.divLeft.outerHeight() + 30 > this.listfileparams.divRight.outerHeight()) {
117 mainheight = this.listfileparams.divLeft.outerHeight() + 30;
119 mainheight = useRightHeight;
122 jQuery('#views').height(mainheight)
123 .split({orientation:'vertical', limit:100, position: splitterPosition});
124 jQuery('.vsplitter').mouseup(function(){
125 jQuery.Storage.set('splitterStyle',''+jQuery('.vsplitter').attr('style'));
129 initModalEditWindow: function() {
130 var modalId = this.listfileparams.divEditFile;
131 this.listfileparams.nocache = new Date().getTime();
132 jQuery(modalId).dialog({
137 Save: jQuery.proxy(function() {
138 jQuery('#editdocdata').submit();
139 var id = jQuery('#docid').attr('value');
140 jQuery.get(this.listfileparams.docManURL+'/', {
141 group_id: this.listfileparams.groupId,
146 childgroup_id: this.listfileparams.childGroupId,
147 rqd: this.listfileparams.nocache
149 jQuery.get(this.listfileparams.docManURL+'/', {
150 group_id: this.listfileparams.groupId,
153 itemid: this.listfileparams.docgroupId,
155 childgroup_id: this.listfileparams.childGroupId,
156 rqd: this.listfileparams.nocache
158 clearInterval(this.lockInterval[id]);
159 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
160 jQuery(modalId).dialog( "close" );
162 Cancel: jQuery.proxy(function() {
163 var id = jQuery('#docid').attr('value');
164 jQuery.get(this.listfileparams.docManURL+'/', {
165 group_id: this.listfileparams.groupId,
170 childgroup_id: this.listfileparams.childGroupId,
171 rqd: this.listfileparams.nocache
173 jQuery.get(this.listfileparams.docManURL+'/', {
174 group_id: this.listfileparams.groupId,
177 itemid: this.listfileparams.docgroupId,
179 childgroup_id: this.listfileparams.childGroupId,
180 rqd: this.listfileparams.nocache
182 clearInterval(this.lockInterval[id]);
183 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
184 jQuery(modalId).dialog('close');
188 jQuery(modalId).bind('dialogclose', jQuery.proxy(function() {
189 var id = jQuery('#docid').attr('value');
190 jQuery.get(this.listfileparams.docManURL+'/', {
191 group_id: this.listfileparams.groupId,
196 childgroup_id: this.listfileparams.childGroupId,
197 rqd: this.listfileparams.nocache
199 jQuery.get(this.listfileparams.docManURL+'/', {
200 group_id: this.listfileparams.groupId,
203 itemid: this.listfileparams.docgroupId,
205 childgroup_id: this.listfileparams.childGroupId,
206 rqd: this.listfileparams.nocache
208 clearInterval(this.lockInterval[id]);
209 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
210 jQuery('#editfile-userstatusreview').remove();
211 jQuery('#editfile-completedreview').remove();
212 jQuery('#editfile-datepickerreview-script').remove();
213 jQuery('#editfile-commentreview').remove();
217 initModelNotifyWindow: function() {
218 var modalId = this.listfileparams.divNotifyUsers;
219 this.listfileparams.nocache = new Date().getTime();
220 jQuery(modalId).dialog({
225 Save: { text: this.listfileparams.divNotifySaveButtonTxt,
226 click: jQuery.proxy(function() {
227 jQuery('#notifyusersdoc').submit();
228 var id = jQuery('#docid').attr('value');
229 jQuery.get(this.listfileparams.docManURL+'/', {
230 group_id: this.listfileparams.groupId,
235 childgroup_id: this.listfileparams.childGroupId,
236 rqd: this.listfileparams.nocache
238 jQuery.get(this.listfileparams.docManURL+'/', {
239 group_id: this.listfileparams.groupId,
242 itemid: this.listfileparams.docgroupId,
244 childgroup_id: this.listfileparams.childGroupId,
245 rqd: this.listfileparams.nocache
247 clearInterval(this.lockInterval[id]);
248 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
249 jQuery(modalId).dialog( "close" );
251 Cancel: jQuery.proxy(function() {
252 var id = jQuery('#docid').attr('value');
253 jQuery.get(this.listfileparams.docManURL+'/', {
254 group_id: this.listfileparams.groupId,
259 childgroup_id: this.listfileparams.childGroupId,
260 rqd: this.listfileparams.nocache
262 jQuery.get(this.listfileparams.docManURL+'/', {
263 group_id: this.listfileparams.groupId,
266 itemid: this.listfileparams.docgroupId,
268 childgroup_id: this.listfileparams.childGroupId,
269 rqd: this.listfileparams.nocache
271 clearInterval(this.lockInterval[id]);
272 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
273 jQuery(modalId).dialog('close');
277 jQuery(modalId).bind('dialogclose', jQuery.proxy(function() {
278 var id = jQuery('#docid').attr('value');
279 jQuery.get(this.listfileparams.docManURL+'/', {
280 group_id: this.listfileparams.groupId,
285 childgroup_id: this.listfileparams.childGroupId,
286 rqd: this.listfileparams.nocache
288 jQuery.get(this.listfileparams.docManURL+'/', {
289 group_id: this.listfileparams.groupId,
292 itemid: this.listfileparams.docgroupId,
294 childgroup_id: this.listfileparams.childGroupId,
295 rqd: this.listfileparams.nocache
297 clearInterval(this.lockInterval[id]);
298 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
302 /*! toggle edit group view div visibility
304 toggleEditDirectoryView: function() {
305 this.listfileparams.nocache = new Date().getTime();
307 var currentLeftHeight;
308 if (!this.listfileparams.divEditDirectory.is(":visible")) {
309 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){
310 if (typeof data.html != 'undefined') {
311 jQuery('#maindiv > .feedback').remove();
312 jQuery('#maindiv > .error').remove();
313 jQuery('#maindiv > .warning_msg').remove();
314 jQuery('#maindiv').prepend(data.html);
316 this.listfileparams.divEditDirectory.show();
317 if (typeof(this.listfileparams.divAddItem) != 'undefined') {
318 this.listfileparams.divAddItem.hide();
320 computeHeight = this.listfileparams.divRight.outerHeight() + this.listfileparams.divEditDirectory.outerHeight();
321 currentLeftHeight = this.listfileparams.divLeft.outerHeight();
322 this.listfileparams.divLeft.height(currentLeftHeight + this.listfileparams.divEditDirectory.outerHeight());
323 jQuery.get(this.listfileparams.docManURL+'/', {
324 group_id: this.listfileparams.groupId,
328 itemid: this.listfileparams.docgroupId,
329 childgroup_id: this.listfileparams.childGroupId,
330 rqd: this.listfileparams.nocache
332 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);
333 if (typeof(this.listfileparams.divLeft) != 'undefined' && typeof(this.listfileparams.divRight) != 'undefined') {
334 if (this.listfileparams.divLeft.outerHeight() > computeHeight) {
335 jQuery('#views').height(this.listfileparams.divLeft.outerHeight());
337 jQuery('#views').height(computeHeight);
341 }, this)).fail(function(jqXHR, textStatus, errorThrown) {
342 var error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
343 jQuery('#maindiv').prepend(error_msg);
346 this.listfileparams.divEditDirectory.hide();
347 computeHeight = this.listfileparams.divRight.outerHeight() - this.listfileparams.divEditDirectory.outerHeight();
348 currentLeftHeight = this.listfileparams.divLeft.outerHeight();
349 this.listfileparams.divLeft.height(currentLeftHeight - this.listfileparams.divEditDirectory.outerHeight());
350 jQuery.get(this.listfileparams.docManURL+'/', {
351 group_id: this.listfileparams.groupId,
355 itemid: this.listfileparams.docgroupId,
356 childgroup_id: this.listfileparams.childGroupId,
357 rqd: this.listfileparams.nocache
359 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
360 if (typeof(this.listfileparams.divLeft) != 'undefined' && typeof(this.listfileparams.divRight) != 'undefined') {
361 if (this.listfileparams.divLeft.outerHeight() > computeHeight) {
362 jQuery('#views').height(this.listfileparams.divLeft.outerHeight());
364 jQuery('#views').height(computeHeight);
371 /*! toggle add item view div visibility
373 toggleAddItemView: function() {
374 this.listfileparams.nocache = new Date().getTime();
376 var currentLeftHeight;
377 if (!this.listfileparams.divAddItem.is(":visible")) {
378 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){
379 if (typeof data.html != 'undefined') {
380 jQuery('#maindiv > .feedback').remove();
381 jQuery('#maindiv > .error').remove();
382 jQuery('#maindiv > .warning_msg').remove();
383 jQuery('#maindiv').prepend(data.html);
385 jQuery.get(this.listfileparams.docManURL+'/', {
386 group_id: this.listfileparams.groupId,
390 itemid: this.listfileparams.docgroupId,
391 childgroup_id: this.listfileparams.childGroupId
393 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);
394 this.listfileparams.divAddItem.show();
395 this.listfileparams.divEditDirectory.hide();
396 computeHeight = this.listfileparams.divRight.outerHeight() + jQuery(this.listfileparams.divAddItem).outerHeight();
397 currentLeftHeight = this.listfileparams.divLeft.outerHeight();
398 this.listfileparams.divLeft.height(currentLeftHeight + jQuery(this.listfileparams.divAddItem).outerHeight());
399 if (typeof(this.listfileparams.divLeft) != 'undefined' && typeof(this.listfileparams.divRight) != 'undefined') {
400 if (this.listfileparams.divLeft.outerHeight() > computeHeight) {
401 jQuery('#views').height(this.listfileparams.divLeft.outerHeight());
403 jQuery('#views').height(computeHeight);
407 }, this)).fail(function(jqXHR, textStatus, errorThrown) {
408 var error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
409 jQuery('#maindiv').prepend(error_msg);
412 jQuery.get(this.listfileparams.docManURL+'/', {
413 group_id: this.listfileparams.groupId,
417 itemid: this.listfileparams.docgroupId,
418 childgroup_id: this.listfileparams.childGroupId,
419 rqd: this.listfileparams.nocache
421 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
422 this.listfileparams.divAddItem.hide();
423 computeHeight = this.listfileparams.divRight.outerHeight() - jQuery(this.listfileparams.divAddItem).outerHeight();
424 currentLeftHeight = this.listfileparams.divLeft.outerHeight();
425 this.listfileparams.divLeft.height(currentLeftHeight - jQuery(this.listfileparams.divAddItem).outerHeight());
426 if (typeof(this.listfileparams.divLeft) != 'undefined' && typeof(this.listfileparams.divRight) != 'undefined') {
427 if (this.listfileparams.divLeft.outerHeight() > computeHeight) {
428 jQuery('#views').height(this.listfileparams.divLeft.outerHeight());
430 jQuery('#views').height(computeHeight);
437 /*! toggle add file edit view div visibility and play with lock
439 * @param params array
441 toggleEditFileView: function(params) {
442 this.docparams = params;
443 this.listfileparams.tableAddVersion.hide();
444 jQuery('#doc_group').empty();
445 jQuery('#editfile-userstatusreview').empty();
446 jQuery('#editfile-completedreview').empty();
447 jQuery('#editfile-commentreview').empty();
448 for (let dictentry of this.docparams.docgroupDict) {
449 jQuery('#doc_group').append(jQuery('<option>').text(dictentry[1]).attr('value', dictentry[0]));
451 jQuery('#doc_group option[value='+this.docparams.docgroupId+']').attr('selected', 'selected');
452 jQuery('#stateid').empty();
453 jQuery.each(this.docparams.statusDict, function(key, value) {
454 jQuery('#stateid').append(jQuery('<option>').text(key).attr('value',value));
456 jQuery('#stateid option[value='+this.docparams.statusId+']').attr('selected', 'selected');
457 jQuery('#docid').val(this.docparams.id);
458 var docid_groupid = this.listfileparams.groupId;
459 if (this.listfileparams.childGroupId != 0) {
460 docid_groupid = this.listfileparams.childGroupId;
462 var nocache = new Date().getTime();
463 jQuery.getJSON(this.listfileparams.docManURL + '/?group_id=' + docid_groupid + '&action=getdocversions&docid='+ this.docparams.id+'&rqd='+nocache, jQuery.proxy(function(data){
464 if (typeof data.html != 'undefined') {
465 jQuery('#editFile > .feedback').remove();
466 jQuery('#editFile > .error').remove();
467 jQuery('#editFile > .warning_msg').remove();
468 jQuery('#editFile > .information').remove();
469 jQuery('#editFile').prepend(data.html);
471 jQuery('#sortable_doc_version_table > tbody').children().remove();
472 jQuery('#sortable_doc_version_table > tbody').css('max-height', '400px').css('overflow-y', 'auto').css('display', 'block');
473 jQuery('#sortable_doc_version_table > thead > tr').css('display', 'block');
474 let eachdocparams = this.docparams;
475 jQuery.each(data, function (x, val) {
476 //_('ID (x)'), _('Filename'), _('Title'), _('Description'), _('Comment'), _('Author'), _('Last Time'), _('Size'), _('Actions'));
477 let currenttdcontent = '';
478 if (val.current_version == 1) {
479 currenttdcontent += ' (x)';
481 let filenametdcontent;
482 if (eachdocparams.statusId != 2) {
483 filenametdcontent = jQuery('<a>'+val.filename+'</a>');
484 if (val.filetype == 'URL') {
486 filenametdcontent.attr('href', val.filename);
488 filenametdcontent.attr('href', eachdocparams.docManURL+'/view.php/'+eachdocparams.groupId+'/versions/'+eachdocparams.id+'/'+val.version.substring(1));
491 filenametdcontent = jQuery('<span>'+val.filename+'</span>');
493 let versionactiontdcontent = '';
494 let versionActionsArrayLength = val.versionactions.length;
495 for (let i = 0; i < versionActionsArrayLength; i++) {
496 versionactiontdcontent += val.versionactions[i];
498 // please sync with the editfile.php widths if you change it here.
499 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.new_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>'
500 jQuery('#sortable_doc_version_table > tbody:last-child').append(htmlString);
503 }, this)).fail(function(jqXHR, textStatus, errorThrown) {
504 var error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
505 jQuery('#editFile').prepend(error_msg);
508 jQuery.getJSON(this.listfileparams.docManURL + '/?group_id=' + docid_groupid + '&action=getassociations&docid='+ this.docparams.id+'&rqd='+nocache, jQuery.proxy(function(data){
509 if (typeof data.html != 'undefined') {
510 jQuery('#tabbereditfile-association > .feedback').remove();
511 jQuery('#tabbereditfile-association > .error').remove();
512 jQuery('#tabbereditfile-association > .warning_msg').remove();
513 jQuery('#tabbereditfile-association > .information').remove();
514 jQuery('#tabbereditfile-association > table').remove();
515 jQuery('#tabbereditfile-association > span').remove();
516 jQuery('#tabbereditfile-association > p').remove();
517 jQuery('#tabbereditfile-association').prepend(data.html);
519 if (typeof data.htmltab != 'undefined') {
520 jQuery('#associationtab').text(data.htmltab);
522 }, this)).fail(function(jqXHR, textStatus, errorThrown) {
523 var error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
524 jQuery('#tabbereditfile-association').prepend(error_msg);
527 jQuery.getJSON(this.listfileparams.docManURL + '/?group_id=' + docid_groupid + '&action=getdocreviews&docid='+ this.docparams.id+'&rqd='+nocache, jQuery.proxy(function(data){
528 if (typeof data.html != 'undefined') {
529 jQuery('#tabbereditfile-review > .feedback').remove();
530 jQuery('#tabbereditfile-review > .error').remove();
531 jQuery('#tabbereditfile-review > .warning_msg').remove();
532 jQuery('#tabbereditfile-review > .information').remove();
533 jQuery('#tabbereditfile-review > table').remove();
534 jQuery('#tabbereditfile-review > span').remove();
535 jQuery('#tabbereditfile-review > p').remove();
536 jQuery('#editfile-createreview').remove();
537 jQuery('#doc_review_addbutton').remove();
538 jQuery('#tabbereditfile-review').prepend(data.html);
539 jQuery('#doc_review_addbutton').button();
541 if (typeof data.htmltab != 'undefined') {
542 jQuery('#reviewtab').text(data.htmltab);
544 jQuery('#review-select-mandatory-users').gentleSelect({columns: 3, itemWidth: 150});
545 jQuery('#review-select-optional-users').gentleSelect({columns: 3, itemWidth: 150});
546 }, this)).fail(function(jqXHR, textStatus, errorThrown) {
547 var error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
548 jQuery('#tabbereditfile-association').prepend(error_msg);
551 jQuery('#editdocdata').attr('action', this.docparams.action);
553 jQuery.get(this.docparams.docManURL+'/', {
554 group_id: this.docparams.groupId,
558 itemid: this.docparams.docgroupId,
559 childgroup_id: this.docparams.childGroupId,
562 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);
563 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);
564 jQuery('#tabbereditfile').tabs("option", "active", 0);
565 this.setRequiredInputs(jQuery('#versiontab'));
566 jQuery(this.listfileparams.divEditFile).dialog('option', 'title', '[D'+this.docparams.id+'] '+this.listfileparams.divEditTitle).dialog('open');
570 toggleAddVersionView: function() {
571 jQuery('#title').val('');
572 jQuery('#description').val('');
573 jQuery(':file').val('');
574 jQuery('#edit_version').val('');
575 jQuery('#defaulteditzone').text();
576 jQuery('#current_version').prop('checked', false);
577 jQuery('#current_version').attr('onclick', 'return true');
578 if (!this.listfileparams.tableAddVersion.is(':visible')) {
579 jQuery('#new_version').val(1);
580 this.listfileparams.tableAddVersion.show();
582 this.listfileparams.tableAddVersion.hide();
583 jQuery('#new_version').val(0);
587 toggleAddReviewView: function() {
588 jQuery('#review_newcomment').val(0);
589 jQuery('#review-title').val('');
590 jQuery('#review-description').val('');
591 jQuery('#review-notificationcomment').val('');
592 jQuery('#datepicker_end_review_date').val('');
593 jQuery('#review-serialid').val();
594 jQuery('[class^=gentle]').remove();
595 jQuery('#review-select-mandatory-users').val('');
596 jQuery('#review-select-optional-users').val('');
597 jQuery('#review-select-mandatory-users').gentleSelect({columns: 3, itemWidth: 150});
598 jQuery('#review-select-optional-users').gentleSelect({columns: 3, itemWidth: 150});
599 jQuery('#editfile-userstatusreview').empty();
600 jQuery('#editfile-completedreview').empty();
601 jQuery('#editfile-commentreview').empty();
602 jQuery('#editfile-remindernotification').hide();
603 jQuery('#review-remindernotification').val('');
604 if (jQuery('#editfile-createreview').is(':visible')) {
605 jQuery('#editfile-createreview').hide();
606 jQuery('#new_review').val(0);
608 jQuery('#new_review').val(1);
609 jQuery('#editfile-createreview').show();
610 jQuery('#review-notificationcomment-row').show();
614 toggleEditReviewView: function(params) {
615 this.review = params;
616 jQuery('#editfile-commentreview').empty();
617 jQuery('#review_newcomment').val(0);
618 jQuery('#editfile-remindernotification').hide();
619 jQuery('#review-remindernotification').val('');
620 if (jQuery('#editfile-createreview').is(':visible')) {
621 jQuery('#editfile-createreview').hide();
622 jQuery('#new_review').val(0);
623 jQuery('#review_id').val(0);
624 jQuery('#review_complete').val(0);
625 jQuery('#editfile-userstatusreview').empty();
626 jQuery('#editfile-completedreview').empty();
628 jQuery('#review_id').val(this.review.review);
629 jQuery('#review-title').val(this.review.title);
630 jQuery('#review-description').val(this.review.description.replace(/\\n/g, String.fromCharCode(13,10)));
631 jQuery('#datepicker_end_review_date').val(this.review.endreviewdate);
632 jQuery('#review-serialid').val(this.review.serialid);
633 var nocache = new Date().getTime();
634 if (this.review.complete) {
635 jQuery('#tr-mandatory-reviewers').hide();
636 jQuery('#tr-optional-reviewers').hide();
637 jQuery('#review_complete').val(1);
638 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){
639 jQuery('#editfile-completedreview').empty();
640 if (typeof data.html != 'undefined') {
641 jQuery('#editfile-completedreview').prepend(data.html);
643 }, this.review)).fail(function(jqXHR, textStatus, errorThrown) {
644 var error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
645 jQuery('#editfile-completedreview').prepend(error_msg);
648 jQuery('#tr-mandatory-reviewers').show();
649 jQuery('#tr-optional-reviewers').show();
650 jQuery('[class^=gentle]').remove();
651 jQuery('#review-select-mandatory-users').val(this.review.mandatoryusers);
652 jQuery('#review-select-optional-users').val(this.review.optionalusers);
653 jQuery('#review-select-mandatory-users').gentleSelect({columns: 3, itemWidth: 150});
654 jQuery('#review-select-optional-users').gentleSelect({columns: 3, itemWidth: 150});
656 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){
657 jQuery('#editfile-userstatusreview').empty();
658 if (typeof data.html != 'undefined') {
659 jQuery('#editfile-userstatusreview').prepend(data.html);
661 }, this.review)).fail(function(jqXHR, textStatus, errorThrown) {
662 var error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
663 jQuery('#editfile-userstatusreview').prepend(error_msg);
665 jQuery('#new_review').val(0);
666 jQuery('#editfile-createreview').show();
667 jQuery('#review-notificationcomment-row').hide();
671 toggleCommentReviewView: function(params) {
672 this.comment = params;
673 jQuery('#editfile-createreview').hide();
674 jQuery('#new_review').val(0);
675 jQuery('#review_id').val(0);
676 jQuery('#review_complete').val(0);
677 jQuery('#review_newcomment').val(1);
678 jQuery('#review_id').val(this.comment.review);
679 jQuery('#editfile-userstatusreview').empty();
680 jQuery('#editfile-completedreview').empty();
681 jQuery('#editfile-remindernotification').hide();
682 jQuery('#review-remindernotification').val('');
683 var nocache = new Date().getTime();
684 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){
685 jQuery('#editfile-commentreview').empty();
686 if (typeof data.html != 'undefined') {
687 jQuery('#editfile-commentreview').prepend(data.html);
689 }, this.comment)).fail(function(jqXHR, textStatus, errorThrown) {
690 var error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
691 jQuery('#editfile-commentreview').prepend(error_msg);
695 toggleEditVersionView: function(params) {
696 this.version = params;
697 jQuery('#new_version').val(0);
698 if (this.version.isHtml) {
699 jQuery('#defaulteditfiletype').val('text/html');
701 if (this.version.isText && !this.version.isHtml) {
702 jQuery('#defaulteditfiletype').val('text/plain');
704 if (this.version.isText) {
705 var nocache = new Date().getTime();
706 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){
708 jQuery('#defaulteditzone').text(data.body);
710 }, this)).fail(function(jqXHR, textStatus, errorThrown) {
711 var error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
712 jQuery('#defaulteditzone').prepend(error_msg);
716 if (!this.listfileparams.tableAddVersion.is(':visible')) {
717 if (this.version.isURL) {
718 jQuery('#uploadnewroweditfile').hide();
719 jQuery('#fileurlroweditfile').show();
720 jQuery('#fileurlroweditfile').find('input').attr('required', 'required').prop('required', true);
721 jQuery('#fileurlroweditfile').find('input').val(this.version.filename);
722 jQuery('#editonlineroweditfile').hide();
723 jQuery('#editor').attr('disabled', true);
724 jQuery('#editButtonUrl').prop('checked', true);
725 } else if (this.listfileparams.useCreateOnline && this.version.isText){
726 jQuery('#fileurlroweditfile').hide();
727 jQuery('#uploadnewroweditfile').hide();
728 jQuery('#editonlineroweditfile').show();
729 jQuery('#editor').removeAttr('disabled');
730 jQuery('#editButtonEditor').prop('checked', true);
732 jQuery('#onlineroweditfile').hide();
733 jQuery('#editor').attr('disabled', true);
734 jQuery('#fileurlroweditfile').hide();
735 jQuery('#uploadnewroweditfile').show();
736 jQuery('#editButtonFile').prop('checked', true);
738 jQuery('#title').val(this.version.title);
739 jQuery('#description').val(this.version.description.replace(/\\n/g, String.fromCharCode(13,10)));
740 jQuery('#vcomment').val(this.version.vcomment.replace(/\\n/g, String.fromCharCode(13,10)));
741 jQuery('#edit_version').val(this.version.version);
742 if (this.version.current_version == 1) {
743 jQuery('#current_version').attr('checked', 'checked').prop('checked', true);
744 jQuery('#current_version').attr('onclick', 'return false');
746 this.listfileparams.tableAddVersion.show();
748 this.listfileparams.tableAddVersion.hide();
749 jQuery('#title').val('');
750 jQuery('#description').val('');
751 jQuery('#vcomment').val('');
752 jQuery(':file').val('');
753 jQuery('#edit_version').val('');
754 jQuery('#current_version').removeAttr('checked');
755 jQuery('#current_version').attr('onclick', 'return true');
756 jQuery('#fileurlroweditfile').find('input').val('');
757 jQuery('#fileurlroweditfile').find('input').removeAttr('required');
758 jQuery('#fileurlroweditfile').hide();
759 jQuery('#uploadnewroweditfile').hide();
760 jQuery('#editonlineroweditfile').hide();
761 jQuery('#defaulteditzone').text('');
765 deleteVersion: function(params) {
766 this.delversion = params;
767 var nocache = new Date().getTime();
768 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){
769 if (typeof data.html != 'undefined') {
770 jQuery('#editFile > .feedback').remove();
771 jQuery('#editFile > .error').remove();
772 jQuery('#editFile > .warning_msg').remove();
773 jQuery('#editFile').prepend(data.html);
775 if (typeof data.status != 'undefined') {
776 if (data.status == 1) {
777 jQuery('#docversion'+this.version).remove();
778 //adjust review tab & version tab number?
779 if (jQuery('#docversionreview'+this.version) != 'undefined') {
780 jQuery('#docversionreview'+this.version).parent.remove();
782 if (jQuery('#sortable_doc_version_table tr').length <= 2) {
783 jQuery('#version_action_delete').remove();
787 }, this.delversion)).fail(function(jqXHR, textStatus, errorThrown) {
788 var error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
789 jQuery('#editFile').prepend(error_msg);
793 deleteReview: function(params) {
794 this.delreview = params;
795 jQuery('#editfile-createreview').hide();
796 jQuery('#new_review').val(0);
797 jQuery('#review_id').val(0);
798 jQuery('#review_complete').val(0);
799 jQuery('#editfile-userstatusreview').empty();
800 jQuery('#editfile-completedreview').empty();
801 jQuery('#editfile-remindernotification').hide();
802 jQuery('#review-remindernotification').val('');
803 var nocache = new Date().getTime();
804 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){
805 if (typeof data.html != 'undefined') {
806 jQuery('#editFile > .feedback').remove();
807 jQuery('#editFile > .error').remove();
808 jQuery('#editFile > .warning_msg').remove();
809 jQuery('#editFile').prepend(data.html);
811 if (typeof data.status != 'undefined') {
812 if (data.status == 1) {
813 jQuery('#docreview'+this.review).remove();
814 //adjust review tab number?
817 }, this.delreview)).fail(function(jqXHR, textStatus, errorThrown) {
818 var error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
819 jQuery('#editFile').prepend(error_msg);
823 reminderReview: function(params) {
824 this.reminderreview = params;
825 if (jQuery('#editfile-remindernotification').is(':visible')) {
826 jQuery('#editfile-remindernotification').hide();
827 jQuery('#review-remindernotification').val('');
829 jQuery('#new_review').val(2);
830 jQuery('#review_id').val(this.reminderreview.review);
831 jQuery('#editfile-createreview').hide();
832 jQuery('#editfile-commentreview').empty();
833 jQuery('#editfile-userstatusreview').empty();
834 jQuery('#editfile-completedreview').empty();
835 jQuery('#editfile-remindernotification').show();
839 toggleMoveFileView: function() {
840 if (!this.listfileparams.divMoveFile.is(':visible')) {
841 this.listfileparams.divMoveFile.show();
842 jQuery('#movefileinput').val(function() {
843 var CheckedBoxes = new Array();
844 for (let h of jQuery('input:checked')) {
845 if (typeof(h.className) != 'undefined' && h.className.match('checkeddocidactive')) {
846 CheckedBoxes.push(h.value);
852 this.listfileparams.divMoveFile.hide();
856 toggleNotifyUserView: function(params) {
857 this.notifyparams = params;
858 var nocache = new Date().getTime();
859 jQuery('#notifytitle').text(this.notifyparams.title);
860 jQuery('#notifydescription').text(this.notifyparams.description);
861 jQuery('#notifydocid').val(this.notifyparams.id);
862 jQuery('#notifyfilelink').text(this.notifyparams.filename);
863 if (this.notifyparams.statusId != 2) {
864 if (this.notifyparams.isURL) {
865 jQuery('#notifyfilelink').attr('href', this.notifyparams.filename);
867 jQuery('#notifyfilelink').attr('href', this.notifyparams.docManURL+'/view.php/'+this.notifyparams.groupId+'/'+this.notifyparams.id);
871 jQuery('#notifyusersdoc').attr('action', this.notifyparams.action);
872 jQuery.get(this.notifyparams.docManURL+'/', {
873 group_id: this.notifyparams.groupId,
877 itemid: this.notifyparams.docgroupId,
878 childgroup_id: this.notifyparams.childGroupId,
881 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);
882 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);
883 jQuery('#notify-userids').gentleSelect({columns: 2, itemWidth: 120});
884 jQuery(this.listfileparams.divNotifyUsers).dialog('option', 'title', '[D'+this.notifyparams.id+'] '+this.listfileparams.divNotifyTitle).dialog('open');
890 /*! build list of id, comma separated
892 buildUrlByCheckbox: function(id) {
893 var CheckedBoxes = new Array();
894 for (let h of jQuery('input:checked')) {
895 if (typeof(h.className) != 'undefined' && h.className.match('checkeddocid'+id)) {
896 CheckedBoxes.push(h.value);
902 checkAll: function(id, type) {
903 if (jQuery('#checkall'+type).is(':checked')) {
904 jQuery('.'+id).each(function() {
905 jQuery(this).prop('checked', true);
907 jQuery('#massaction'+type).show();
909 jQuery('.'+id).each(function() {
910 jQuery(this).prop('checked', false);
912 jQuery('#massaction'+type).hide();
916 checkgeneral: function(id) {
917 if (jQuery(this).attr('checked', false)) {
918 jQuery('#checkall'+id).prop('checked', false);
919 jQuery('#massaction'+id).hide();
920 jQuery('#movefile').hide();
922 for (let h of jQuery('input:checked')) {
923 if (typeof(h.className) != 'undefined' && h.className.match('checkeddocid'+id)) {
924 jQuery('#massaction'+id).show();
930 setRequiredInputs: function(id) {
931 if (id.attr('id') == 'reviewtab') {
932 jQuery('#tabbereditfile-version :input').not(':input[type=hidden], :input[type=button]').prop('disabled', true);
933 jQuery('#tabbereditfile-association').prop('disabled', true);
934 jQuery('#tabbereditfile-review :input').removeAttr('disabled');
935 jQuery('#subaction').val('review');
936 } else if (id.attr('id') == 'associationtab') {
937 jQuery('#tabbereditfile-version :input').not(':input[type=hidden], :input[type=button]').prop('disabled', true);
938 jQuery('#tabbereditfile-association').removeAttr('disabled');
939 jQuery('#tabbereditfile-review :input').prop('disabled', true);
940 jQuery('#subaction').val('association');
941 } else if (id.attr('id') == 'versiontab') {
942 jQuery('#tabbereditfile-version :input').not(':input[type=hidden], :input[type=button]').removeAttr('disabled');
943 jQuery('#tabbereditfile-association').prop('disabled', true);
944 jQuery('#tabbereditfile-review :input').prop('disabled', true);
945 jQuery('#subaction').val('version');
950 DocManAddItemController.prototype =
952 /*! Binds the controls to the actions
954 bindControls: function() {
955 this.additemparams.submitZip.click(jQuery.proxy(this, "submitFormZip"));
958 submitFormZip: function() {
959 this.additemparams.injectZip.submit();
960 this.additemparams.submitZip.attr('disabled', true);
964 DocManAddFileController.prototype =
966 /*! Binds the controls to the actions
968 bindControls: function() {
969 this.addfileparams.buttonFile.click(jQuery.proxy(this, "toggleFileRowView"));
970 this.addfileparams.buttonUrl.click(jQuery.proxy(this, "toggleUrlRowView"));
971 if (typeof(this.addfileparams.buttonManualUpload) != 'undefined') {
972 this.addfileparams.buttonManualUpload.click(jQuery.proxy(this, "toggleManualUploadView"));
974 if (typeof(this.addfileparams.buttonEditor) != 'undefined') {
975 this.addfileparams.buttonEditor.click(jQuery.proxy(this, "toggleEditorView"));
979 toggleFileRowView: function() {
980 this.addfileparams.fileRow.show();
981 this.addfileparams.fileRow.find('input').attr("required", "required");
982 this.addfileparams.urlRow.hide();
983 this.addfileparams.urlRow.find('input').removeAttr("required");
984 this.addfileparams.pathRow.hide();
985 this.addfileparams.pathRow.find('input').removeAttr("required");
986 this.addfileparams.editRow.hide();
987 this.addfileparams.editNameRow.hide();
990 toggleUrlRowView: function() {
991 this.addfileparams.fileRow.hide();
992 this.addfileparams.fileRow.find('input').removeAttr("required");
993 this.addfileparams.urlRow.show();
994 this.addfileparams.urlRow.find('input').attr("required", "required");
995 this.addfileparams.pathRow.hide();
996 this.addfileparams.pathRow.find('input').removeAttr("required");
997 this.addfileparams.editRow.hide();
998 this.addfileparams.editNameRow.hide();
1001 toggleManualUploadView: function() {
1002 this.addfileparams.fileRow.hide();
1003 this.addfileparams.fileRow.find('input').removeAttr("required");
1004 this.addfileparams.urlRow.hide();
1005 this.addfileparams.urlRow.find('input').removeAttr("required");
1006 this.addfileparams.pathRow.show();
1007 this.addfileparams.pathRow.find('input').attr("required", "required");
1008 this.addfileparams.editRow.hide();
1009 this.addfileparams.editNameRow.hide();
1012 toggleEditorView: function() {
1013 this.addfileparams.fileRow.hide();
1014 this.addfileparams.fileRow.find('input').removeAttr("required");
1015 this.addfileparams.urlRow.hide();
1016 this.addfileparams.urlRow.find('input').removeAttr("required");
1017 this.addfileparams.pathRow.hide();
1018 this.addfileparams.pathRow.find('input').removeAttr("required");
1019 this.addfileparams.editRow.show();
1020 this.addfileparams.editNameRow.show();
1024 DocManSearchController.prototype =
1026 /*! Binds the controls to the actions
1028 bindControls: function() {
1029 this.searchparams.buttonStartDate.click(jQuery.proxy(this, 'setStartDate'));
1030 this.searchparams.buttonEndDate.click(jQuery.proxy(this, 'setEndDate'));
1033 setStartDate: function() {
1034 if (this.searchparams.buttonStartDate.is(':checked')) {
1035 this.searchparams.datePickerStartDate.removeAttr('disabled');
1036 this.searchparams.datePickerStartDate.attr('required', 'required');
1038 this.searchparams.datePickerStartDate.attr('disabled', 'disabled');
1039 this.searchparams.datePickerStartDate.removeAttr('required');
1043 setEndDate: function() {
1044 if (this.searchparams.buttonEndDate.is(':checked')) {
1045 this.searchparams.datePickerEndDate.removeAttr('disabled');
1046 this.searchparams.datePickerEndDate.attr('required', 'required');
1048 this.searchparams.datePickerEndDate.attr('disabled', 'disabled');
1049 this.searchparams.datePickerEndDate.removeAttr('required');