* finish task #2542.
This commit is contained in:
@@ -1 +1,2 @@
|
||||
ALTER TABLE `zt_module` ADD `short` varchar(30) COLLATE 'utf8_general_ci' NOT NULL AFTER `owner`;
|
||||
ALTER TABLE `zt_usertpl` ADD `public` enum('0','1') COLLATE 'utf8_general_ci' NOT NULL DEFAULT '0';
|
||||
|
||||
@@ -1069,7 +1069,14 @@ class bug extends control
|
||||
public function saveTemplate()
|
||||
{
|
||||
$this->bug->saveUserBugTemplate();
|
||||
if(dao::isError()) die(js::error(dao::getError()));
|
||||
if(dao::isError())
|
||||
{
|
||||
$error = js::error(dao::getError());
|
||||
/* Remove html and meta tag and only get script */
|
||||
$error = substr($error, strpos($error, '<script'));
|
||||
$error = substr($error, 0, strpos($error, '</script') + 9);
|
||||
echo $error;
|
||||
}
|
||||
die($this->fetch('bug', 'buildTemplates'));
|
||||
}
|
||||
|
||||
|
||||
+14
-9
@@ -75,17 +75,22 @@ function deleteTemplate(templateID)
|
||||
$(function()
|
||||
{
|
||||
if($('#project').val()) loadProjectRelated($('#project').val());
|
||||
$('#saveTplBtn').on('click', function()
|
||||
$('#saveTplModal').on('hide.zui.modal', function(){$(this).find('#title').val('');});
|
||||
$('#saveTplBtn').click(function(){$('#saveTplModal').modal('show');});
|
||||
$('#saveTplModal #submit').click(function()
|
||||
{
|
||||
var content = $('#steps').val();
|
||||
bootbox.prompt(setTemplateTitle, function(r)
|
||||
var $inputGroup = $('#saveTplModal div.input-group');
|
||||
var $publicBox = $inputGroup.find('input[id^="public"]');
|
||||
var title = $inputGroup.find('#title').val();
|
||||
var content = $('#steps').val();
|
||||
var isPublic = ($publicBox.size() > 0 && $publicBox.prop('checked')) ? $publicBox.val() : 0;
|
||||
if(!title || !content) return;
|
||||
saveTemplateLink = createLink('bug', 'saveTemplate');
|
||||
$.post(saveTemplateLink, {title:title, content:content, public:isPublic}, function(data)
|
||||
{
|
||||
if(!r || !content) return;
|
||||
saveTemplateLink = createLink('bug', 'saveTemplate');
|
||||
$.post(saveTemplateLink, {title:r, content:content}, function(data)
|
||||
{
|
||||
$('#tplBox').html(data);
|
||||
});
|
||||
$('#tplBox').html(data);
|
||||
// If has error then not hide.
|
||||
if(data.indexOf('alert') == -1) $('#saveTplModal').modal('hide');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -87,6 +87,7 @@ $lang->bug->deleted = 'Deleted';
|
||||
$lang->bug->saveTemplate = 'Save template';
|
||||
$lang->bug->deleteTemplate = 'Delete template';
|
||||
$lang->bug->confirmStoryChange = 'Confirm Story Change';
|
||||
$lang->bug->setPubic = 'Set public template';
|
||||
|
||||
/* Browse tabs. */
|
||||
$lang->bug->assignToMe = 'MyBugs';
|
||||
|
||||
@@ -87,6 +87,7 @@ $lang->bug->deleted = '已删除';
|
||||
$lang->bug->saveTemplate = '保存模板';
|
||||
$lang->bug->deleteTemplate = '删除模板';
|
||||
$lang->bug->confirmStoryChange = '确认需求变动';
|
||||
$lang->bug->setPubic = '设为公共模板';
|
||||
|
||||
/* 查询条件列表。*/
|
||||
$lang->bug->assignToMe = '指派给我';
|
||||
|
||||
@@ -1533,9 +1533,10 @@ class bugModel extends model
|
||||
*/
|
||||
public function getUserBugTemplates($account)
|
||||
{
|
||||
$templates = $this->dao->select('id, title, content')
|
||||
$templates = $this->dao->select('id,title,content,public')
|
||||
->from(TABLE_USERTPL)
|
||||
->where('account')->eq($account)
|
||||
->orWhere('public')->eq('1')
|
||||
->orderBy('id')
|
||||
->fetchAll();
|
||||
return $templates;
|
||||
@@ -1554,7 +1555,10 @@ class bugModel extends model
|
||||
->add('type', 'bug')
|
||||
->stripTags('content', $this->config->allowedTags)
|
||||
->get();
|
||||
$this->dao->insert(TABLE_USERTPL)->data($template)->batchCheck('title, content', 'notempty')->check('title', 'unique', "account='{$this->app->user->account}'")->exec();
|
||||
|
||||
$condition = "account='{$this->app->user->account}'";
|
||||
if($template->public == 1) $condition .= " or `public`='1'";
|
||||
$this->dao->insert(TABLE_USERTPL)->data($template)->batchCheck('title, content', 'notempty')->check('title', 'unique', $condition)->exec();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<script language='Javascript'>
|
||||
setTemplateTitle = '<?php echo $lang->bug->setTemplateTitle;?>';
|
||||
</script>
|
||||
<?php
|
||||
foreach($templates as $key => $template)
|
||||
{
|
||||
echo "<li id='tplBox$template->id'>";
|
||||
echo "<a title='{$lang->bug->applyTemplate}' class='tpl-name' id='tplTitleBox$template->id' href='javascript:setTemplate($template->id)'>$template->title</a>";
|
||||
echo "<a href='javascript:void();' onclick='deleteTemplate($template->id)' class='btn-delete'><i class='icon-remove'></i></a>";
|
||||
echo "<a title='{$lang->bug->applyTemplate}' class='tpl-name' id='tplTitleBox$template->id' href='javascript:setTemplate($template->id)'>";
|
||||
if($template->public) echo "<span class='label label-info label-badge'>{$lang->public}</span> ";
|
||||
echo $template->title . "</a>";
|
||||
echo "<a href='###' onclick='deleteTemplate($template->id)' class='btn-delete'><i class='icon-remove'></i></a>";
|
||||
echo "<span id='template$template->id' class='hidden'>$template->content</span>";
|
||||
echo '</li>';
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ js::set('refresh', $lang->refresh);
|
||||
<div id='tplBoxWrapper'>
|
||||
<div class='btn-toolbar'>
|
||||
<div class='btn-group'>
|
||||
<button id='saveTplBtn' type='button' class='btn btn-mini'><?php echo $lang->bug->saveTemplate?></button>
|
||||
<button id='saveTplBtn' type='button' class='btn btn-mini' data-toggle='saveTplModal'><?php echo $lang->bug->saveTemplate?></button>
|
||||
<button type='button' class='btn btn-mini dropdown-toggle' data-toggle='dropdown'><?php echo $lang->bug->applyTemplate?> <span class='caret'></span></button>
|
||||
<ul id='tplBox' class='dropdown-menu pull-right'>
|
||||
<?php echo $this->fetch('bug', 'buildTemplates');?>
|
||||
@@ -202,5 +202,24 @@ js::set('refresh', $lang->refresh);
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal fade" id="saveTplModal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog w-600px">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title"><?php echo $lang->bug->setTemplateTitle;?></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class='input-group'>
|
||||
<?php echo html::input('title', '' , "class='form-control'")?>
|
||||
<?php if(common::hasPriv('bug', 'setPublic')):?>
|
||||
<span class='input-group-addon'><?php echo html::checkbox('public', array('1' => $lang->public))?></span>
|
||||
<?php endif;?>
|
||||
<span class='input-group-btn'><?php echo html::submitButton()?></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php js::set('bugModule', $lang->bug->module);?>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
|
||||
@@ -46,6 +46,7 @@ $lang->goPC = 'PC';
|
||||
$lang->more = 'More';
|
||||
$lang->day = 'Day';
|
||||
$lang->customConfig = 'Custom';
|
||||
$lang->public = 'Public';
|
||||
|
||||
$lang->actions = 'Actions';
|
||||
$lang->comment = 'Comment';
|
||||
|
||||
@@ -46,6 +46,7 @@ $lang->goPC = 'PC版';
|
||||
$lang->more = '更多';
|
||||
$lang->day = '天';
|
||||
$lang->customConfig = '自定义';
|
||||
$lang->public = '公共';
|
||||
|
||||
$lang->actions = '操作';
|
||||
$lang->comment = '备注';
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<h4 class="modal-title"><i class="icon-cog"></i> <?php echo $lang->customConfig?></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form method='post' target='hiddenwin' action='<?php echo $customLink?>'>
|
||||
<form class='form-condensed' method='post' target='hiddenwin' action='<?php echo $customLink?>'>
|
||||
<p><?php echo html::checkbox('fields', $customFields, $hiddenFields);?></p>
|
||||
<p><?php echo html::submitButton() . ' ' . $lang->checked2Hide?></p>
|
||||
</form>
|
||||
|
||||
@@ -438,6 +438,7 @@ $lang->resource->bug->confirmStoryChange = 'confirmStoryChange';
|
||||
$lang->resource->bug->delete = 'delete';
|
||||
$lang->resource->bug->saveTemplate = 'saveTemplate';
|
||||
$lang->resource->bug->deleteTemplate = 'deleteTemplate';
|
||||
$lang->resource->bug->setPublic = 'setPublic';
|
||||
|
||||
$lang->bug->methodOrder[0] = 'index';
|
||||
$lang->bug->methodOrder[5] = 'browse';
|
||||
@@ -461,6 +462,7 @@ $lang->bug->methodOrder[90] = 'confirmStoryChange';
|
||||
$lang->bug->methodOrder[95] = 'delete';
|
||||
$lang->bug->methodOrder[100] = 'saveTemplate';
|
||||
$lang->bug->methodOrder[105] = 'deleteTemplate';
|
||||
$lang->bug->methodOrder[110] = 'setPublic';
|
||||
|
||||
/* Test case. */
|
||||
$lang->resource->testcase = new stdclass();
|
||||
|
||||
Reference in New Issue
Block a user