diff --git a/db/update8.1.3.sql b/db/update8.1.3.sql index 3c23a07cb4..e7e3635db4 100644 --- a/db/update8.1.3.sql +++ b/db/update8.1.3.sql @@ -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'; diff --git a/module/bug/control.php b/module/bug/control.php index bcce7da4f4..b7201db518 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -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, 'fetch('bug', 'buildTemplates')); } diff --git a/module/bug/js/create.js b/module/bug/js/create.js index 98372a66e0..5f872c7cbb 100644 --- a/module/bug/js/create.js +++ b/module/bug/js/create.js @@ -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'); }); }); diff --git a/module/bug/lang/en.php b/module/bug/lang/en.php index 3df3e7ee3c..7dfc7256ee 100644 --- a/module/bug/lang/en.php +++ b/module/bug/lang/en.php @@ -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'; diff --git a/module/bug/lang/zh-cn.php b/module/bug/lang/zh-cn.php index 89a0ee79f8..a2203b2f26 100644 --- a/module/bug/lang/zh-cn.php +++ b/module/bug/lang/zh-cn.php @@ -87,6 +87,7 @@ $lang->bug->deleted = '已删除'; $lang->bug->saveTemplate = '保存模板'; $lang->bug->deleteTemplate = '删除模板'; $lang->bug->confirmStoryChange = '确认需求变动'; +$lang->bug->setPubic = '设为公共模板'; /* 查询条件列表。*/ $lang->bug->assignToMe = '指派给我'; diff --git a/module/bug/model.php b/module/bug/model.php index 97563c493b..387ece96ce 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -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(); } /** diff --git a/module/bug/view/buildtemplates.html.php b/module/bug/view/buildtemplates.html.php index 7ee1cafd06..0b8b2fce93 100644 --- a/module/bug/view/buildtemplates.html.php +++ b/module/bug/view/buildtemplates.html.php @@ -1,12 +1,11 @@ - $template) { echo "
  • "; - echo "$template->title"; - echo ""; + echo ""; + if($template->public) echo "{$lang->public} "; + echo $template->title . ""; + echo ""; echo ""; echo '
  • '; } diff --git a/module/bug/view/create.html.php b/module/bug/view/create.html.php index 598c5345dc..0d80b6659a 100644 --- a/module/bug/view/create.html.php +++ b/module/bug/view/create.html.php @@ -138,7 +138,7 @@ js::set('refresh', $lang->refresh);
    - +
    + bug->module);?> diff --git a/module/common/lang/en.php b/module/common/lang/en.php index 4f9fc2a66b..08a0883fdd 100644 --- a/module/common/lang/en.php +++ b/module/common/lang/en.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'; diff --git a/module/common/lang/zh-cn.php b/module/common/lang/zh-cn.php index 984344eb2e..07ecceb859 100644 --- a/module/common/lang/zh-cn.php +++ b/module/common/lang/zh-cn.php @@ -46,6 +46,7 @@ $lang->goPC = 'PC版'; $lang->more = '更多'; $lang->day = '天'; $lang->customConfig = '自定义'; +$lang->public = '公共'; $lang->actions = '操作'; $lang->comment = '备注'; diff --git a/module/common/view/customfield.html.php b/module/common/view/customfield.html.php index 0df72515d3..17ae1e3492 100644 --- a/module/common/view/customfield.html.php +++ b/module/common/view/customfield.html.php @@ -18,7 +18,7 @@