* Finish task #60388.

This commit is contained in:
zhouxudong
2022-07-15 05:14:48 +00:00
parent 6a4d372473
commit 92c323d600
3 changed files with 82 additions and 72 deletions
+2 -4
View File
@@ -341,12 +341,10 @@ class file extends control
/* Update test case version for test case synchronization. */
if($file->objectType == 'testcase' and $file->title != $fileName) $this->file->updateTestcaseVersion($file);
$newFile = $this->file->getByID($fileID);
return print(js::reload('parent.parent'));
echo json_encode($newFile);
}
$this->view->file = $this->file->getById($fileID);
$this->display();
}
/**
-62
View File
@@ -1,62 +0,0 @@
<?php
/**
* The export view file of file module of ZenTaoPMS.
*
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
* @author Yangyang Shi <shiyangyang@cnezsoft.com>
* @package file
* @version $Id$
* @link http://www.zentao.net
*/
?>
<?php include '../../common/view/header.lite.html.php';?>
<style>.main-form {margin: 15px -15px 0}</style>
<script>
function setFileName()
{
time = setInterval("closeWindow()", 200);
return true;
}
function closeWindow()
{
parent.$.closeModal();
clearInterval(time);
}
</script>
<main id="main">
<div class="container">
<div id='mainContent' class='main-content'>
<div class='main-header'>
<h2><?php echo $lang->file->inputFileName;?></h2>
</div>
<?php
if(strrpos($file->title, '.') !== false)
{
/* Fix the file name exe.exe */
$title = explode('.', $file->title);
$extension = end($title);
if($file->extension == 'txt' && $extension != $file->extension) $file->extension = $extension;
array_pop($title);
$file->title = join('.', $title);
}
?>
<form class='main-form' method='post' target='hiddenwin' onsubmit='setFileName();'>
<table class='table table-form'>
<tr>
<td>
<div class='input-group'>
<?php echo html::input('fileName', $file->title, "class='form-control' size='40'");?>
<input type="hidden" name="extension" value="<?php echo $file->extension;?>"/>
<strong class='input-group-addon'>.<?php echo $file->extension;?></strong>
</div>
</td>
<td class='w-80px'><?php echo html::submitButton('', '', 'btn btn-primary btn-block');?></td>
</tr>
</table>
</form>
</div>
</div>
</main>
<?php include '../../common/view/footer.lite.html.php';?>
+80 -6
View File
@@ -9,6 +9,10 @@
.files-list>li>a {display: inline; word-wrap: break-word;}
.files-list>li>.right-icon {opacity: 1;}
.fileAction {color: #0c64eb !important;}
.renameFile {display: flex;}
.renameFile .input-group {margin-left: 10px;}
.renameFile .icon {margin-top: 8px;}
.renameFile .input-group-addon {width: 60px;}
</style>
<script>
/* Delete a file. */
@@ -45,6 +49,40 @@
}
return false;
}
function showRenameBox(fileID)
{
$('#renameFile' + fileID).closest('li').addClass('hidden');
$('#renameBox' + fileID).removeClass('hidden');
}
function showFile(fileID)
{
$('#renameBox' + fileID).addClass('hidden');
$('#renameFile' + fileID).closest('li').removeClass('hidden');
}
function setFileName(fileID)
{
var fileName = $('#fileName' + fileID).val();
var extension = $('#extension' + fileID).val();
var postData = {'fileName' : fileName, 'extension' : extension};
$('#renameBox' + fileID ).addClass('hidden');
$.ajax(
{
url:createLink('file', 'edit', 'fileID=' + fileID),
dataType: 'json',
method: 'post',
data: postData,
success: function(data)
{
console.log(data['title']);
$('#fileTitle' + fileID).html("<i class='icon icon-file-text'></i> &nbsp;" + data['title']);
$('#renameFile' + fileID).closest('li').removeClass('hidden');
$('#renameBox' + fileID).addClass('hidden');
}
})
}
</script>
<ul class="files-list">
<?php
@@ -87,7 +125,7 @@
$downloadLink = $this->createLink('file', 'download', "fileID=$file->id");
$downloadLink .= strpos($downloadLink, '?') === false ? '?' : '&';
$downloadLink .= $sessionString;
echo "<li title='{$uploadDate}'>" . html::a($downloadLink, $fileTitle . " <span class='text-muted'>({$fileSize})</span>", '_blank', "onclick=\"return downloadFile($file->id, '$file->extension', $imageWidth, '$file->title')\"");
echo "<li title='{$uploadDate}'>" . html::a($downloadLink, $fileTitle . " <span class='text-muted'>({$fileSize})</span>", '_blank', "id='fileTitle$file->id' onclick=\"return downloadFile($file->id, '$file->extension', $imageWidth, '$file->title')\"");
$objectType = zget($this->config->file->objectType, $file->objectType);
if(common::hasPriv($objectType, 'edit', $object))
@@ -120,14 +158,50 @@
}
common::printLink('file', 'download', "fileID=$file->id", $lang->file->downloadFile, '_blank', "class='fileAction btn btn-link text-primary' title='{$lang->file->downloadFile}'");
common::printLink('file', 'edit', "fileID=$file->id", $lang->file->edit, '', "data-width='400' class='fileAction btn btn-link edit iframe text-primary' title='{$lang->file->edit}'");
if(common::hasPriv('file', 'edit')) echo html::a('###', $lang->file->edit, '', "id='renameFile$file->id' class='fileAction btn btn-link edit text-primary' onclick='showRenameBox($file->id)' title='{$lang->file->edit}'");
if(common::hasPriv('file', 'delete')) echo html::a('###', $lang->delete, '', "class='fileAction btn btn-link text-primary' onclick='deleteFile($file->id)' title='$lang->delete'");
echo '</span>';
}
echo '</li>';
}
}
?>
echo '</li>';?>
<li>
<div>
<?php
if(strrpos($file->title, '.') !== false)
{
/* Fix the file name exe.exe */
$title = explode('.', $file->title);
$extension = end($title);
if($file->extension == 'txt' && $extension != $file->extension) $file->extension = $extension;
array_pop($title);
$file->title = join('.', $title);
}
?>
<form class='main-form hidden form-ajax' id='renameBox<?php echo $file->id;?>' method='post'>
<table class='w-300px'>
<tr>
<td>
<div class="renameFile">
<i class='icon icon-file-text'></i>
<div class='input-group'>
<?php echo html::input('fileName' . $file->id, $file->title, "class='form-control' size='40'");?>
<input type="hidden" name="extension" id="extension<?php echo $file->id?>" value="<?php echo $file->extension;?>"/>
<strong class='input-group-addon'>.<?php echo $file->extension;?></strong>
</div>
<div class="input-group-btn">
<button type="button" class="btn btn-success file-name-confirm" onclick="setFileName(<?php echo $file->id;?>)" style="border-radius: 0px 2px 2px 0px; border-left-color: transparent;"><i class="icon icon-check"></i></button>
<button type="button" class="btn btn-gray file-name-cancel" onclick="showFile(<?php echo $file->id;?>)" style="border-radius: 0px 2px 2px 0px; border-left-color: transparent;"><i class="icon icon-close"></i></button>
</div>
</div>
</td>
</tr>
</table>
</form>
</div>
</li>
<?php }
}?>
</ul>
<?php if($fieldset == 'true'):?>
</div>