manage_documents.html

 1   <#macro setBtnAction action_nb>
 2   	<#switch action_nb>
 3   		<#case 1>
 4   		<#case 6>
 5   		<#case 8>
 6   		<#case 11>
 7   			<#assign btnAction='danger' />
 8   			<#break>
 9   		<#case 14>
 10   		<#case 15>
 11   			<#assign btnAction='info' />
 12   			<#break>
 13   		<#case 4>
 14   		<#case 12>
 15   		<#case 13>
 16   			<#assign btnAction='success' />
 17   			<#break>
 18   		<#case 5>
 19   			<#assign btnAction='warning' />
 20   			<#break>
 21   		<#default>
 22   		<#assign btnAction='primary' />
 23   	</#switch>${btnAction}
 24   </#macro>
 25   
 26   <@pageContainer>
 27       <@pageColumn>
 28   		<@pageHeader title='#i18n{document.adminFeature.documents_management.name}' />
 29   		<@row>
 30   			<@columns xl=3>
 31   				<@box>
 32   					<@boxHeader title='#i18n{document.manage_documents.labelSpaces}'>
 33   						<#if space_actions_list?size != 0>
 34   							<@btnGroup>
 35   							<#list space_actions_list as space_action>
 36   								<#if space_action.permission="DELETE">
 37   									<#assign btnClass = 'danger' />
 38   								<#else>
 39   									<#assign btnClass = 'primary' />
 40   								</#if>
 41   								<@aButton href='${space_action.url}?id_space=${space.id}' title='${space_action.description}' class='btn-space-action' color='${btnClass}' buttonIcon='${space_action.iconUrl}' size='sm' hideTitle=['all'] />
 42   							</#list>
 43   							</@btnGroup>
 44   						</#if>
 45   					</@boxHeader>
 46   					<@boxBody>
 47   						<@icon style='folder-open' /> #i18n{document.manage_documents.labelSpaces}
 48   						${spaces_tree}
 49   					</@boxBody>
 50   				</@box>
 51   				
 52   				<#if mass_action?has_content && mass_action>
 53   					<@box>
 54   						<@boxHeader title='#i18n{document.manage_documents.labelMoreActions}' />
 55   						<@boxBody>
 56   							<@listGroup>
 57   								<@listGroupItem>
 58   									<@tform type='inline' method='post' id='archiveForm' name='archiveForm' action='jsp/admin/plugins/document/MassArchivalDocument.jsp'>
 59   										<@button class='btn btn-link' type='submit' buttonIcon='file-archive' title='#i18n{document.manage_document.mass_archival_labelBtn}' />
 60   									</@tform>
 61   								</@listGroupItem>
 62   							</@listGroup>
 63   						</@boxBody>
 64   					</@box>
 65   				</#if>
 66   			</@columns>
 67   			<@columns xl=9>
 68   			<#if space?has_content>
 69   				<@box>
 70   					<@boxHeader title='#i18n{document.manage_documents.buttonSearch}' />
 71   					<@boxBody>
 72   						<@tform method='post' id='SearchDocumentById' name='SearchDocumentById' action='jsp/admin/plugins/document/DoSearchDocumentById.jsp'>
 73   							 <@formGroup labelFor='id_document' labelKey='#i18n{document.manage_documents.buttonSearch}' helpKey='#i18n{document.manage_documents.labelSearchById}'>
 74   								<@inputGroup>
 75   									<@input type='text' id='id_document' name='id_document' maxlength=10 />
 76   									<@inputGroupItem>
 77   										<@button type='submit' title='#i18n{document.manage_documents.buttonSearch}' buttonIcon='search' hideTitle=['all'] />
 78   									</@inputGroupItem>
 79   								</@inputGroup>
 80   							</@formGroup>
 81   						</@tform>
 82   						<@tform method='post' id='FullTextSearchDocument' name='FullTextSearchDocument' action='jsp/admin/plugins/document/DocumentSearch.jsp'>
 83   							<@input type='hidden' id='id_document' name='id_document' />
 84   							<@formGroup labelFor='query' labelKey='#i18n{document.manage_documents.buttonSearch}' helpKey='#i18n{document.manage_documents.labelFullTextSearch}'>
 85   								<@inputGroup>
 86   									<@input type='text' id='query' name='query' maxlength=50 />
 87   									<@inputGroupItem type='btn'>
 88   										<@button type='submit' title='#i18n{document.manage_documents.buttonSearch}' buttonIcon='search' hideTitle=['all'] />
 89   									</@inputGroupItem>
 90   								</@inputGroup>
 91   							</@formGroup>
 92   						</@tform>
 93   
 94   						<#if document_types_filter_list?size &gt; 1 >
 95   							<@tform method='post' name='FilterDocumentsForm' action='jsp/admin/plugins/document/ManageDocuments.jsp'>
 96   								<@formGroup labelFor='document_type_code_filter' labelKey='#i18n{document.manage_documents.labelType}'>
 97   									<@select name='document_type_code_filter' default_value='${default_document_type}' items=document_types_filter_list />
 98   								</@formGroup>
 99   								<@formGroup labelFor='id_state_filter' labelKey='#i18n{document.manage_documents.labelState}'>
 100   									<@inputGroup>
 101   										<@select name='id_state_filter' default_value='${default_state}' items=states_filter_list />
 102   										<@inputGroupItem type='btn'>
 103   											<@button type='submit' title='#i18n{document.manage_documents.buttonFilter}' buttonIcon='filter' hideTitle=['all'] />
 104   										</@inputGroupItem>
 105   									</@inputGroup>
 106   								</@formGroup>
 107   								<@formGroup labelFor='view_type' labelKey='#i18n{document.manage_documents.labelViewType}'>
 108   									<@inputGroup>
 109   										<@select name='view_type' default_value='${view_type}' items=view_types_list />
 110   										<@inputGroupItem type='btn'>
 111   											<@button type='submit' buttonIcon='check' />
 112   										</@inputGroupItem>
 113   									</@inputGroup>
 114   								</@formGroup>
 115   							</@tform>
 116   						</#if>
 117   							
 118   						<#if space.documentCreationAllowed >
 119   							<#if document_types_list?has_content>
 120   								<@tform method='post' name='CreateDocument' action='jsp/admin/plugins/document/CreateDocument.jsp'>
 121   									<@formGroup labelFor='document_type_code' labelKey='#i18n{document.manage_documents.labelCreate}'>
 122   										<@inputGroup>
 123   											<@select name='document_type_code' default_value='' items=document_types_list />
 124   											<@inputGroupItem type='btn'>
 125   												<@button type='submit' title='#i18n{document.manage_documents.buttonCreate}' buttonIcon='plus' hideTitle=['all'] />
 126   											</@inputGroupItem>
 127   										</@inputGroup>
 128   									</@formGroup>
 129   									<#if is_files2docs_plugin_active?has_content && is_files2docs_plugin_active>
 130   										<@button type='button' title='#i18n{document.manage_documents.buttonImport}' id='importLinkButton' buttonIcon='plus-circle' /> 
 131   									</#if>
 132   								</@tform>                                                                
 133   							</#if>
 134   						</#if>
 135   						
 136   						<hr style="margin:50px 0;"></hr>
 137   
 138   
 139   						<#if documents_list?size = 0>
 140   							<br>
 141   							<@alert color='warning'>
 142   								<@icon style='exclamation-triangle' />
 143   								<b>#i18n{document.manage_documents.noDocument}</b>
 144   							</@alert>
 145   						<#else>
 146   							<#if view_type = 'detail' >
 147   								<@tform id='documents_form' name='documents_form' method='post' action='jsp/admin/plugins/document/DoActionSelectionDocument.jsp'>
 148   									<@table>
 149   										<@tr>
 150   											<@th>
 151   												<@checkBox id='select_all' name='select_all' />
 152   											</@th>
 153   											<@th>
 154   												#i18n{document.manage_documents.labelDocumentId} <@sort jsp_url='jsp/admin/plugins/document/ManageDocuments.jsp' attribute='id' />
 155   											</@th>
 156   											<@th>
 157   												#i18n{document.manage_documents.labelDocument}<@sort jsp_url='jsp/admin/plugins/document/ManageDocuments.jsp' attribute='title' />
 158   												<@formGroup labelFor='selection' rows=2>
 159   													<@inputGroup>
 160   														<@select id='selection' name='selection' disabled=true>
 161   															<option value="validate">#i18n{document.manage_document.validate}</option>
 162   															<option value="submit">#i18n{document.manage_document.submit}</option>
 163   															<option value="refuse">#i18n{document.manage_document.refuse}</option>
 164   															<option value="remove">#i18n{document.manage_document.remove}</option>
 165   															<option value="archive">#i18n{document.manage_document.archive}</option>
 166   															<option value="unarchive">#i18n{document.manage_document.unarchive}</option>
 167   														</@select>
 168   														<@inputGroupItem type='btn'>
 169   															<@button type='submit' title='#i18n{document.manage_documents.applyToSelection}' buttonIcon='check' hideTitle=['all'] />
 170   														</@inputGroupItem>
 171   													</@inputGroup>
 172   												</@formGroup>
 173   											</@th>
 174   											<@th>#i18n{document.manage_documents.labelPublishedStatus}<@sort jsp_url='jsp/admin/plugins/document/ManageDocuments.jsp' attribute='publishedStatus' /></@th>
 175   											<@th>#i18n{document.manage_documents.labelActions}</@th>
 176   										</@tr>
 177   										<#list documents_list as document >
 178   										<@tr class='document-row' params='data-document="${document.id} ${document.title}"'>
 179   											<@td><@checkBox id='document_selection' name='document_selection' value='${document.id}' /></@td>
 180   											<@td>${document.id}</@td>
 181   											<@td>
 182   												<p>
 183   													<strong title="${document.title}"><#if document.title?length &gt; 60>${document.title?substring(0,60)}...<#else>${document.title}</#if></strong>
 184   												</p>
 185   												<p>
 186   													<@icon style='calendar' title='#i18n{document.manage_documents.labelDateModification}' />&nbsp;
 187   													${document.dateModification}
 188   													<#if document.stateId = 3>
 189   													&nbsp;
 190   													<@tag color='success' title='#i18n{document.manage_documents.labelState}' tagIcon='check-circle'>${document.state}&nbsp;&nbsp;&nbsp;</@tag>
 191   													<#else>
 192   														<@tag color='info' title='#i18n{document.manage_documents.labelState}' tagIcon='times'>${document.state}
 193   														</@tag>
 194   													</#if>
 195   												</p>
 196   												<#if document.comment != ''>
 197   													<@alert color='info'>
 198   														<@icon style='info-circle' /> ${document.comment}
 199   													</@alert>
 200   												</#if>
 201   											</@td>
 202   											<@td>
 203   												<#if document.publishedStatus = 0>
 204   													<@tag color='success' tagIcon='check-circle'>#i18n{document.manage_documents.PublishedStatus}</@tag>
 205   												<#else>
 206   													<@tag color='danger' tagIcon='times'>#i18n{document.manage_documents.UnPublishedStatus}</@tag>
 207   												</#if>
 208   											</@td>
 209   											<@td>
 210   												<#list document.actions?sort_by("idAction") as action>
 211   													<#if action.url?has_content>
 212   														<#assign aBtnColor>
 213   															<@setBtnAction action_nb=action.idAction />
 214   														</#assign>
 215   														<@aButton href='${action.url}id_document=${document.id}&id_action=${action.idAction}' title='${action.description}' buttonIcon='${action.iconUrl}' color=aBtnColor?trim hideTitle=['all'] size='sm' />
 216   													</#if>
 217   												</#list>
 218   											</@td>
 219   										</@tr>
 220   										</#list>
 221   									</@table>
 222   								</@tform>
 223   							</#if>
 224   							<#if view_type = "thumbnail">
 225   								<@columns>
 226   									<@row>
 227   									<#list documents_list as document >
 228   									<@columns sm=6 class='document-row' params='data-document="${document.id} ${document.title}"'>
 229   										<div id="document_${document.id}" class="thumbnail" style="background-color:rgba(0,0,0,0.05); padding:10px; border-radius:4px; margin-bottom:15px;">
 230   											<img src="${document.thumbnail}" class="thumbnail" alt="${document.title}" title="${document.title} - ${document.type}" style="max-width:100%;" />
 231   											<div class="caption" style="margin-top:20px;">
 232   												<h3>
 233   													<@tag>${document.id}</@tag>
 234   													<strong title="${document.title}">
 235   														<#if document.title?length &gt; 18>${document.title?substring(0,18)}...<#else>${document.title}</#if>
 236   													</strong>
 237   												</h3>
 238   												<@btnGroup size='sm'>
 239   													<#list document.actions?sort_by("idAction") as action>
 240   														<#if action.url?has_content>
 241   															<#assign aBtnColor>
 242   																<@setBtnAction action_nb=action.idAction />
 243   															</#assign>
 244   															<@aButton href='${action.url}id_document=${document.id}&id_action=${action.idAction}' title='${action.description}' buttonIcon='${action.iconUrl}' color=aBtnColor?trim hideTitle=['all'] />
 245   														</#if>
 246   													</#list>
 247   												</@btnGroup>
 248   											</div>
 249   										</div>
 250   										<a href="#document_${document.id}"></a>
 251   									</@columns>
 252   									</#list>
 253   									</@row>
 254   								</@columns>
 255   							</#if>
 256   							<@paginationAdmin paginator=paginator combo=1 />
 257   						</#if>
 258   					</@boxBody>
 259   				</@box>
 260   			<#else>
 261   				<#if child_spaces_list?size != 0 >
 262   					<@box>
 263   						<@boxHeader title='#i18n{document.manage_documents.childSpacesList}' />
 264   						<@boxBody>
 265   							<@ul>
 266   								<#list child_spaces_list as child_space>
 267   								<@li>
 268   									<h4>
 269   										<@link href='jsp/admin/plugins/document/ManageDocuments.jsp?id_space_filter=${child_space.id}'>
 270   											<img src="${child_space.iconUrl}" alt="${child_space.description}" title="${child_space.description}"> ${child_space.name} <small>${child_space.description}</small>
 271   										</@link>
 272   									</h4>
 273   								</@li>
 274   								</#list>
 275   							</@ul>
 276   						</@boxBody>
 277   					</@box>
 278   				</#if>
 279   			</#if>
 280   			</@columns>
 281   		</@row>
 282   	</@pageColumn>
 283   </@pageContainer>
 284   <script src="js/jquery/plugins/ui/jstree/jquery.jstree.js"></script>
 285   <script src="js/jquery/plugins/ui/jstree/jquery.cookie.js"></script>
 286   <script type="text/javascript">
 287   jQuery(function($) {
 288   
 289   	/****** Space Tree ******/
 290   	// Set space_id
 291   	var spaceid = ${space.id};
 292   	// Get space_id from url parameter
 293   	var loc = location.search;
 294   	if ( spaceid != loc ) {
 295   		if ( loc.indexOf("id_space_filter") > 0 ){
 296   			// Set space_id from url parameter if exists
 297   			spaceid =  loc.slice( loc.lastIndexOf("=") + 1 );
 298   		}
 299   	}
 300   	// Check length of tree names
 301   
 302   	// Set the cookie of jstree
 303   	$.cookie("jstree_select", "#node-" + spaceid );
 304   		$("#tree").jstree({
 305   			"ui" : {
 306   			"select_limit" : 1,
 307   		},"themes" : {
 308   				"theme" : "classic",
 309   				"icons" : false
 310   		},"cookies" : {
 311   			"save_opened" : true,
 312   		},"core" : { "initially_open" : [ "node-${space.id}" ]},
 313   		"plugins" : [ "themes", "html_data", "cookies", "ui" ]
 314   		});
 315   	});
 316   
 317   
 318   	/****** Space actions ******/
 319   		/*
 320   	$(".btn-space-action").toggle();
 321   
 322   	$( "#tree li a" ).hover(function() {
 323   		var leafTool="";
 324   		var leafStr = $(this).attr("href");
 325   		var found = leafStr.split("=");
 326   		var nId = found[1];
 327   		if( nId > 0){
 328   			$(".box-tools a").each( function(index){
 329   				var found = leafStr.split("=");
 330   				sUrl=found[0] + nId;
 331   				$(this).attr("href", sUrl);
 332   			});
 333   		$(this).prev().append( $(".box-tools").html() );
 334   		}
 335   	});
 336   
 337   	$( "#tree li a" ).mouseout(function() {
 338   		$( "#tree li a.btn-space-action" ).remove() ;
 339   	});
 340   	$( "#tree li a" ).mouseover(function() {
 341   		$( "#tree li a.btn-space-action" ).toggle() ;
 342   	});
 343   	*/
 344   
 345   
 346   	/****** Document search ******/
 347   	$("#FullTextSearchDocument p.help-block").text("#i18n{document.manage_documents.labelAllTextSearch}");
 348   	$("#FullTextSearchDocument").submit(function(){
 349   		if( $.isNumeric($("#FullTextSearchDocument input#query").val()) ){
 350   			$("#FullTextSearchDocument input#id_document").val($("#FullTextSearchDocument input#query").val());
 351   			$(this).attr("action", "jsp/admin/plugins/document/DoSearchDocumentById.jsp");
 352   		}
 353   	});
 354   	$("#SearchDocumentById").hide();
 355   
 356   
 357   	/* Filter document list */
 358   	$("#query").on("keyup", function(){
 359   		var addOrRemove;
 360   		var search = $("#query").val().toLowerCase();
 361   		$(".document-row").each( function( index ) {
 362   			var doc = $(this).attr("data-document").toLowerCase();
 363   			if ( doc.match( search ) == null ){
 364   				$(this).slideUp(200).fadeOut(500);
 365   			} else {
 366   				$(this).slideDown(200).fadeIn(500);
 367   			}
 368   		});
 369   	});
 370   
 371   </script>
 372   
 373   <script>
 374   	/****** Multiple selection ******/
 375   	document.getElementById('select_all').addEventListener('click', function() {
 376   		var checkboxes = document.querySelectorAll('input[type="checkbox"]');
 377   		checkboxes.forEach(function(checkbox) {
 378   			checkbox.checked = this.checked;
 379   		}, this);
 380   	});
 381   
 382   	document.querySelectorAll('input[type="checkbox"]').forEach(function(checkbox) {
 383   		checkbox.addEventListener('click', function() {
 384   			var selectedCheckboxes = document.querySelectorAll('input[type="checkbox"]:checked');
 385   			var selectionButton = document.getElementById('selection');
 386   
 387   			if (selectedCheckboxes.length > 0) {
 388   				selectionButton.removeAttribute('disabled');
 389   			} else {
 390   				selectionButton.setAttribute('disabled', 'disabled');
 391   			}
 392   		});
 393   	});
 394   </script>
 395   
 396   <#if is_files2docs_plugin_active?has_content && is_files2docs_plugin_active>
 397   <script type="text/javascript">
 398   /* document MASS import redirection */
 399   jQuery(function($) {
 400       $("#importLinkButton").click( function() {
 401           $(location).attr('href','jsp/admin/plugins/files2docs/SelectFiles.jsp?browser_selected_space_id=${current_space_id}&document_type_code=' + $("#document_type_code").val());
 402       });
 403   });
 404   </script>
 405   </#if>