diff --git a/module/bug/control.php b/module/bug/control.php
index ea51597d6d..27bc43a2d7 100644
--- a/module/bug/control.php
+++ b/module/bug/control.php
@@ -679,7 +679,6 @@ class bug extends control
$this->view->openedBuilds = $openedBuilds;
$this->view->resolvedBuilds = array('' => '') + $openedBuilds + $oldResolvedBuild;
$this->view->actions = $this->action->getList('bug', $bugID);
- $this->view->templates = $this->bug->getUserBugTemplates($this->app->user->account);
$this->display();
}
@@ -1291,44 +1290,6 @@ class bug extends control
}
}
- /**
- * Save current template.
- *
- * @access public
- * @return string
- */
- public function saveTemplate()
- {
- $this->bug->saveUserBugTemplate();
- if(dao::isError()) echo js::error(dao::getError(), $full = false);
- die($this->fetch('bug', 'buildTemplates'));
- }
-
- /**
- * Build the user templates selection code.
- *
- * @access public
- * @return void
- */
- public function buildTemplates()
- {
- $this->view->templates = $this->bug->getUserBugTemplates($this->app->user->account);
- $this->display('bug', 'buildTemplates');
- }
-
- /**
- * Delete a user template.
- *
- * @param int $templateID
- * @access public
- * @return void
- */
- public function deleteTemplate($templateID)
- {
- $this->dao->delete()->from(TABLE_USERTPL)->where('id')->eq($templateID)->andWhere('account')->eq($this->app->user->account)->exec();
- die();
- }
-
/**
* AJAX: get bugs of a user in html select.
*
diff --git a/module/bug/css/create.css b/module/bug/css/create.css
index 881b8f6efd..5de40e5853 100644
--- a/module/bug/css/create.css
+++ b/module/bug/css/create.css
@@ -7,14 +7,6 @@
#buildBoxActions {padding-left: 15px;}
-#tplBoxWrapper {position: relative; z-index: 10;}
-#tplBoxWrapper > .btn-toolbar {position: absolute; right: 0px; top: 0px;}
-#tplBoxWrapper .btn {padding: 4px 8px}
-#tplBox li {position: relative;}
-#tplBox li .btn-delete {position: absolute; right: 0; top: -5px; display: block; width: 40px; text-align:center;}
-#tplBox li:hover .btn-delete {color:#fff;}
-#tplBox li .tpl-name {padding-right: 40px;}
-
#module_chosen.chosen-container .chosen-drop {min-width: 400px; border-top: 1px solid #ddd!important}
#openedBuild_chosen.chosen-container .chosen-drop {min-width: 450px; border-top: 1px solid #ddd!important}
#module + .chosen-container-single .chosen-single,
diff --git a/module/bug/js/create.js b/module/bug/js/create.js
index 87fe6176a9..6bf629899b 100644
--- a/module/bug/js/create.js
+++ b/module/bug/js/create.js
@@ -64,59 +64,9 @@ function setAssignedTo(moduleID, productID)
});
}
-/* Set template. */
-function setTemplate(templateID)
-{
- $('#tplBox .list-group-item.active').removeClass('active');
- $('#tplTitleBox' + templateID).closest('.list-group-item').addClass('active');
- var steps = $('#template' + templateID).html();
- editor['#'].html(steps);
-}
-
-/* Delete template. */
-function deleteTemplate(templateID)
-{
- if(!templateID) return;
- if(confirm(confirmDeleteTemplate))
- {
- hiddenwin.location.href = createLink('bug', 'deleteTemplate', 'templateID=' + templateID);
- $('#tplBox' + templateID).addClass('hidden');
- }
-}
-
-/* Display template x icon. */
-function displayXIcon(templateID)
-{
- $('#templateID' + templateID).removeClass('hidden');
-}
-
-/* Hide template x icon. */
-function hideXIcon(templateID)
-{
- $('#templateID' + templateID).addClass('hidden');
-}
-
$(function()
{
if($('#project').val()) loadProjectRelated($('#project').val());
- $('#saveTplModal').on('hide.zui.modal', function(){$(this).find('#title').val('');});
- $('#saveTplBtn').click(function(){$('#saveTplModal').modal('show');});
- $('#saveTplModal #submit').click(function()
- {
- 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)
- {
- $('#tplBox').html(data);
- // If has error then not hide.
- if(data.indexOf('alert') == -1) $('#saveTplModal').modal('hide');
- });
- });
$('[data-toggle=tooltip]').tooltip();
diff --git a/module/bug/lang/zh-cn.php b/module/bug/lang/zh-cn.php
index 05d85d7f23..8094f9afaf 100644
--- a/module/bug/lang/zh-cn.php
+++ b/module/bug/lang/zh-cn.php
@@ -95,9 +95,6 @@ $lang->bug->reportChart = '报表统计';
$lang->bug->export = '导出数据';
$lang->bug->delete = '删除';
$lang->bug->deleted = '已删除';
-$lang->bug->saveTemplate = '保存模板';
-$lang->bug->setPublic = '设为公共模板';
-$lang->bug->deleteTemplate = '删除模板';
$lang->bug->confirmStoryChange = '确认需求变动';
$lang->bug->copy = '复制Bug';
$lang->bug->search = '搜索';
@@ -163,11 +160,8 @@ $lang->bug->buttonConfirm = '确认';
$lang->bug->summary = "本页共 %s 个Bug,未解决 %s。";
$lang->bug->confirmChangeProduct = "修改{$lang->productCommon}会导致相应的{$lang->projectCommon}、需求和任务发生变化,确定吗?";
$lang->bug->confirmDelete = '您确认要删除该Bug吗?';
-$lang->bug->setTemplateTitle = '请输入bug模板标题';
$lang->bug->remindTask = '该Bug已经转化为任务,是否更新任务(编号:%s)状态 ?';
$lang->bug->skipClose = 'Bug %s 不是已解决状态,不能关闭。';
-$lang->bug->applyTemplate = '应用模板';
-$lang->bug->confirmDeleteTemplate = '您确认要删除该模板吗?';
/* 模板。*/
$lang->bug->tplStep = "
[步骤]
";
diff --git a/module/bug/model.php b/module/bug/model.php
index 53075b9a37..5e04ef616e 100644
--- a/module/bug/model.php
+++ b/module/bug/model.php
@@ -1939,45 +1939,6 @@ class bugModel extends model
foreach($commonOption->graph as $key => $value) if(!isset($chartOption->graph->$key)) $chartOption->graph->$key = $value;
}
- /**
- * Get bug templates of a user.
- *
- * @param string $account
- * @access public
- * @return array
- */
- public function getUserBugTemplates($account)
- {
- $templates = $this->dao->select('id,account,title,content,public')
- ->from(TABLE_USERTPL)
- ->where('type')->eq('bug')
- ->andwhere('account', true)->eq($account)
- ->orWhere('public')->eq('1')
- ->markRight(1)
- ->orderBy('id')
- ->fetchAll();
- return $templates;
- }
-
- /**
- * Save user template.
- *
- * @access public
- * @return void
- */
- public function saveUserBugTemplate()
- {
- $template = fixer::input('post')
- ->setDefault('account', $this->app->user->account)
- ->setDefault('type', 'bug')
- ->stripTags('content', $this->config->allowedTags)
- ->get();
-
- $condition = "`type`='bug' and account='{$this->app->user->account}'";
- $this->dao->insert(TABLE_USERTPL)->data($template)->batchCheck('title, content', 'notempty')->check('title', 'unique', $condition)->exec();
- if(!dao::isError()) $this->loadModel('score')->create('bug', 'saveTplModal', $this->dao->lastInsertID());
- }
-
/**
* Return the file => label pairs of some fields.
*
diff --git a/module/bug/view/buildtemplates.html.php b/module/bug/view/buildtemplates.html.php
deleted file mode 100644
index 59f831824f..0000000000
--- a/module/bug/view/buildtemplates.html.php
+++ /dev/null
@@ -1,11 +0,0 @@
- $template)
-{
- echo "";
- echo "";
- if($template->public) echo "{$lang->public} ";
- echo $template->title . "";
- if(empty($template->public) or $template->account == $app->user->account)echo "";
- echo "$template->content";
- echo '';
-}
diff --git a/module/bug/view/create.html.php b/module/bug/view/create.html.php
index 110e9e4d45..4039170c43 100644
--- a/module/bug/view/create.html.php
+++ b/module/bug/view/create.html.php
@@ -217,17 +217,7 @@ js::set('confirmDeleteTemplate', $lang->bug->confirmDeleteTemplate);
| bug->steps;?> |
-
+ fetch('user', 'ajaxPrintTemplates', 'type=bug&link=steps');?>
|
@@ -305,24 +295,5 @@ js::set('confirmDeleteTemplate', $lang->bug->confirmDeleteTemplate);
-
-
-
-
-
-
-
-
- $lang->public))?>
-
-
-
-
-
-
-
bug->module);?>
diff --git a/module/common/lang/zh-cn.php b/module/common/lang/zh-cn.php
index f1c3d0121c..63666cfd3c 100644
--- a/module/common/lang/zh-cn.php
+++ b/module/common/lang/zh-cn.php
@@ -94,6 +94,13 @@ $lang->preShortcutKey = '[快捷键:←]';
$lang->nextShortcutKey = '[快捷键:→]';
$lang->backShortcutKey = '[快捷键:Alt+↑]';
+$lang->saveTemplate = '保存模板';
+$lang->setPublic = '设为公共模板';
+$lang->deleteTemplate = '删除模板';
+$lang->setTemplateTitle = '请输入模板标题';
+$lang->applyTemplate = '应用模板';
+$lang->confirmDeleteTemplate = '您确认要删除该模板吗?';
+
$lang->select = '选择';
$lang->selectAll = '全选';
$lang->selectReverse = '反选';
diff --git a/module/group/lang/resource.php b/module/group/lang/resource.php
index fee7d3c098..1cc2e5fa22 100644
--- a/module/group/lang/resource.php
+++ b/module/group/lang/resource.php
@@ -498,9 +498,6 @@ $lang->resource->bug->report = 'reportChart';
$lang->resource->bug->export = 'export';
$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->resource->bug->batchChangeModule = 'batchChangeModule';
$lang->resource->bug->batchChangeBranch = 'batchChangeBranch';
@@ -525,12 +522,9 @@ $lang->bug->methodOrder[80] = 'report';
$lang->bug->methodOrder[85] = 'export';
$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';
-$lang->bug->methodOrder[115] = 'linkBugs';
-$lang->bug->methodOrder[125] = 'batchChangeModule';
-$lang->bug->methodOrder[130] = 'batchChangeBranch';
+$lang->bug->methodOrder[100] = 'linkBugs';
+$lang->bug->methodOrder[105] = 'batchChangeModule';
+$lang->bug->methodOrder[110] = 'batchChangeBranch';
/* Test case. */
$lang->resource->testcase = new stdclass();
@@ -856,6 +850,7 @@ $lang->resource->user->dynamic = 'dynamic';
$lang->resource->user->profile = 'profile';
$lang->resource->user->batchEdit = 'batchEdit';
$lang->resource->user->unbind = 'unbind';
+$lang->resource->user->setPublicTemplate = 'setPublicTemplate';
$lang->user->methodOrder[5] = 'create';
$lang->user->methodOrder[7] = 'batchCreate';
@@ -871,6 +866,7 @@ $lang->user->methodOrder[50] = 'dynamic';
$lang->user->methodOrder[55] = 'profile';
$lang->user->methodOrder[60] = 'batchEdit';
$lang->user->methodOrder[75] = 'unbind';
+$lang->user->methodOrder[80] = 'setPublicTemplate';
/* Tree. */
$lang->resource->tree = new stdclass();
diff --git a/module/product/view/create.html.php b/module/product/view/create.html.php
index 89db5640aa..f416000449 100644
--- a/module/product/view/create.html.php
+++ b/module/product/view/create.html.php
@@ -63,7 +63,10 @@
| product->desc;?> |
- |
+
+ fetch('user', 'ajaxPrintTemplates', "type=product&link=desc");?>
+
+ |
| product->acl;?> |
diff --git a/module/project/view/create.html.php b/module/project/view/create.html.php
index 836cb184e8..6957949541 100644
--- a/module/project/view/create.html.php
+++ b/module/project/view/create.html.php
@@ -134,7 +134,10 @@
| project->desc;?> |
- |
+
+ fetch('user', 'ajaxPrintTemplates', 'type=project&link=desc');?>
+
+ |
| project->acl;?> |
diff --git a/module/story/view/create.html.php b/module/story/view/create.html.php
index 53555876f5..9508b8631d 100644
--- a/module/story/view/create.html.php
+++ b/module/story/view/create.html.php
@@ -159,7 +159,10 @@
| story->spec;?> |
- story->specTemplate) . "'");?> |
+
+ fetch('user', 'ajaxPrintTemplates', 'type=story&link=spec');?>
+ story->specTemplate) . "'");?>
+ |
diff --git a/module/task/view/create.html.php b/module/task/view/create.html.php
index d28a0e593c..def7e99e55 100644
--- a/module/task/view/create.html.php
+++ b/module/task/view/create.html.php
@@ -200,7 +200,10 @@
| task->desc;?> |
- desc, "rows='10' class='form-control'");?> |
+
+ fetch('user', 'ajaxPrintTemplates', 'type=task&link=desc');?>
+ desc, "rows='10' class='form-control'");?>
+ |
| files;?> |
diff --git a/module/user/control.php b/module/user/control.php
index b2af1add19..1e4dd2f316 100644
--- a/module/user/control.php
+++ b/module/user/control.php
@@ -1007,4 +1007,46 @@ class user extends control
if(empty($contactList)) return false;
return print(html::select('', $contactList, '', "class='form-control' onchange=\"setMailto('mailto', this.value)\""));
}
+
+ /**
+ * Ajax print templates.
+ *
+ * @param int $type
+ * @param string $link
+ * @access public
+ * @return void
+ */
+ public function ajaxPrintTemplates($type, $link = '')
+ {
+ $this->view->link = $link;
+ $this->view->type = $type;
+ $this->view->templates = $this->user->getUserTemplates($type);
+ $this->display();
+ }
+
+ /**
+ * Save current template.
+ *
+ * @access public
+ * @return string
+ */
+ public function ajaxSaveTemplate($type)
+ {
+ $this->user->saveUserTemplate($type);
+ if(dao::isError()) echo js::error(dao::getError(), $full = false);
+ die($this->fetch('user', 'ajaxPrintTemplates', "type=$type"));
+ }
+
+ /**
+ * Delete a user template.
+ *
+ * @param int $templateID
+ * @access public
+ * @return void
+ */
+ public function ajaxDeleteTemplate($templateID)
+ {
+ $this->dao->delete()->from(TABLE_USERTPL)->where('id')->eq($templateID)->andWhere('account')->eq($this->app->user->account)->exec();
+ die();
+ }
}
diff --git a/module/user/lang/en.php b/module/user/lang/en.php
index 688e20eaee..b0baf24699 100644
--- a/module/user/lang/en.php
+++ b/module/user/lang/en.php
@@ -48,27 +48,28 @@ $lang->user->originalPassword = 'Old Password';
$lang->user->verifyPassword = 'Your Login Password';
$lang->user->resetPassword = 'Forgot Password?';
-$lang->user->index = "Home";
-$lang->user->view = "Overview";
-$lang->user->create = "Add User";
-$lang->user->batchCreate = "Batch Add";
-$lang->user->edit = "Edit";
-$lang->user->batchEdit = "Batch Edit";
-$lang->user->unlock = "Unlock";
-$lang->user->delete = "Delete";
-$lang->user->unbind = "Unbind Zdoo";
-$lang->user->login = "Login";
-$lang->user->mobileLogin = "Mobile";
-$lang->user->editProfile = "Edit";
-$lang->user->deny = "Your access is denied.";
-$lang->user->confirmDelete = "Do you want to delete this user?";
-$lang->user->confirmUnlock = "Do you want to unlock this user?";
-$lang->user->confirmUnbind = "Do you want to unbind this user from Zdoo?";
-$lang->user->relogin = "Login Again";
-$lang->user->asGuest = "Guest";
-$lang->user->goback = "Back";
-$lang->user->deleted = '(Deleted)';
-$lang->user->search = 'Search';
+$lang->user->index = "Home";
+$lang->user->view = "Overview";
+$lang->user->create = "Add User";
+$lang->user->batchCreate = "Batch Add";
+$lang->user->edit = "Edit";
+$lang->user->batchEdit = "Batch Edit";
+$lang->user->unlock = "Unlock";
+$lang->user->delete = "Delete";
+$lang->user->unbind = "Unbind Zdoo";
+$lang->user->login = "Login";
+$lang->user->mobileLogin = "Mobile";
+$lang->user->editProfile = "Edit";
+$lang->user->deny = "Your access is denied.";
+$lang->user->confirmDelete = "Do you want to delete this user?";
+$lang->user->confirmUnlock = "Do you want to unlock this user?";
+$lang->user->confirmUnbind = "Do you want to unbind this user from Zdoo?";
+$lang->user->relogin = "Login Again";
+$lang->user->asGuest = "Guest";
+$lang->user->goback = "Back";
+$lang->user->deleted = '(Deleted)';
+$lang->user->search = 'Search';
+$lang->user->setPublicTemplate = 'Set as Public Template';
$lang->user->profile = 'Profile';
$lang->user->project = $lang->projectCommon;
diff --git a/module/user/lang/zh-cn.php b/module/user/lang/zh-cn.php
index 5382cfe538..05e9c20f56 100644
--- a/module/user/lang/zh-cn.php
+++ b/module/user/lang/zh-cn.php
@@ -48,27 +48,28 @@ $lang->user->originalPassword = '原密码';
$lang->user->verifyPassword = '您的系统登录密码';
$lang->user->resetPassword = '忘记密码';
-$lang->user->index = "用户视图首页";
-$lang->user->view = "用户详情";
-$lang->user->create = "添加用户";
-$lang->user->batchCreate = "批量添加用户";
-$lang->user->edit = "编辑用户";
-$lang->user->batchEdit = "批量编辑";
-$lang->user->unlock = "解锁用户";
-$lang->user->delete = "删除用户";
-$lang->user->unbind = "解除然之绑定";
-$lang->user->login = "用户登录";
-$lang->user->mobileLogin = "手机访问";
-$lang->user->editProfile = "修改档案";
-$lang->user->deny = "访问受限";
-$lang->user->confirmDelete = "您确定删除该用户吗?";
-$lang->user->confirmUnlock = "您确定解除该用户的锁定状态吗?";
-$lang->user->confirmUnbind = "您确定解除该用户跟然之的绑定吗?";
-$lang->user->relogin = "重新登录";
-$lang->user->asGuest = "游客访问";
-$lang->user->goback = "返回前一页";
-$lang->user->deleted = '(已删除)';
-$lang->user->search = '搜索';
+$lang->user->index = "用户视图首页";
+$lang->user->view = "用户详情";
+$lang->user->create = "添加用户";
+$lang->user->batchCreate = "批量添加用户";
+$lang->user->edit = "编辑用户";
+$lang->user->batchEdit = "批量编辑";
+$lang->user->unlock = "解锁用户";
+$lang->user->delete = "删除用户";
+$lang->user->unbind = "解除然之绑定";
+$lang->user->login = "用户登录";
+$lang->user->mobileLogin = "手机访问";
+$lang->user->editProfile = "修改档案";
+$lang->user->deny = "访问受限";
+$lang->user->confirmDelete = "您确定删除该用户吗?";
+$lang->user->confirmUnlock = "您确定解除该用户的锁定状态吗?";
+$lang->user->confirmUnbind = "您确定解除该用户跟然之的绑定吗?";
+$lang->user->relogin = "重新登录";
+$lang->user->asGuest = "游客访问";
+$lang->user->goback = "返回前一页";
+$lang->user->deleted = '(已删除)';
+$lang->user->search = '搜索';
+$lang->user->setPublicTemplate = '设为公共模板';
$lang->user->profile = '档案';
$lang->user->project = $lang->projectCommon;
diff --git a/module/user/model.php b/module/user/model.php
index 773816c0ae..9c30eac2a1 100644
--- a/module/user/model.php
+++ b/module/user/model.php
@@ -1504,4 +1504,43 @@ class userModel extends model
return true;
}
+
+ /**
+ * Save user template.
+ *
+ * @param string $type
+ * @access public
+ * @return void
+ */
+ public function saveUserTemplate($type)
+ {
+ $template = fixer::input('post')
+ ->setDefault('account', $this->app->user->account)
+ ->setDefault('type', $type)
+ ->stripTags('content', $this->config->allowedTags)
+ ->get();
+
+ $condition = "`type`='$type' and account='{$this->app->user->account}'";
+ $this->dao->insert(TABLE_USERTPL)->data($template)->batchCheck('title, content', 'notempty')->check('title', 'unique', $condition)->exec();
+ if(!dao::isError()) $this->loadModel('score')->create('bug', 'saveTplModal', $this->dao->lastInsertID());
+ }
+
+ /**
+ * Get User Template.
+ *
+ * @param string $type
+ * @access public
+ * @return array
+ */
+ public function getUserTemplates($type)
+ {
+ return $this->dao->select('id,account,title,content,public')
+ ->from(TABLE_USERTPL)
+ ->where('type')->eq($type)
+ ->andwhere('account', true)->eq($this->app->user->account)
+ ->orWhere('public')->eq('1')
+ ->markRight(1)
+ ->orderBy('id')
+ ->fetchAll();
+ }
}
diff --git a/module/user/view/ajaxprinttemplates.html.php b/module/user/view/ajaxprinttemplates.html.php
new file mode 100644
index 0000000000..2fd8854805
--- /dev/null
+++ b/module/user/view/ajaxprinttemplates.html.php
@@ -0,0 +1,118 @@
+
+ $template)
+{
+ echo "";
+ echo "";
+ if($template->public) echo "{$lang->public} ";
+ echo $template->title . "";
+ if(empty($template->public) or $template->account == $app->user->account)echo "";
+ echo "$template->content";
+ echo '';
+}
+?>
+
+
+
+
+
+
+
+
+
+
+
+ $lang->public))?>
+
+ save, "id='submit'", 'btn btn-primary')?>
+
+
+
+
+
+
+