added primitive issue comment editing

This commit is contained in:
hyung-hwan 2016-01-18 10:30:29 +00:00
parent 678143d72a
commit 21742a46c5
14 changed files with 483 additions and 150 deletions

View File

@ -24,6 +24,8 @@ UPGRADING FROM 0.2.0
mysql> ALTER TABLE project ADD COLUMN (codecharset VARCHAR(32)); mysql> ALTER TABLE project ADD COLUMN (codecharset VARCHAR(32));
mysql> DROP TABLE issue_attachment; mysql> DROP TABLE issue_attachment;
mysql> create the issue_file_list table according to the definition found in codepot.mysql mysql> create the issue_file_list table according to the definition found in codepot.mysql
mysql> ALTER TABLE issue_change ADD COLUMN(createdon datetime not null, createdby varchar(32) not null);
mysql> UPDATE issue_change SET createdby=updatedby, createdon=updatedon;
INSTALLATION ON CENTOS INSTALLATION ON CENTOS

View File

@ -134,7 +134,9 @@ CREATE TABLE issue_change (
priority VARCHAR(32) NOT NULL, priority VARCHAR(32) NOT NULL,
comment TEXT NOT NULL, comment TEXT NOT NULL,
createdon DATETIME NOT NULL,
updatedon DATETIME NOT NULL, updatedon DATETIME NOT NULL,
createdby VARCHAR(32) NOT NULL,
updatedby VARCHAR(32) NOT NULL, updatedby VARCHAR(32) NOT NULL,
PRIMARY KEY (projectid, id, sno), PRIMARY KEY (projectid, id, sno),

View File

@ -14,9 +14,9 @@
-- DROP TABLE "cpot_log"; -- DROP TABLE "cpot_log";
-- DROP TABLE "cpot_code_review"; -- DROP TABLE "cpot_code_review";
-- DROP TABLE "cpot_file"; -- DROP TABLE "cpot_file";
-- DROP TABLE "cpot_issue_change_attachment"; -- DROP TABLE "cpot_issue_change_file_list";
-- DROP TABLE "cpot_issue_change"; -- DROP TABLE "cpot_issue_change";
-- DROP TABLE "cpot_issue_attachment"; -- DROP TABLE "cpot_issue_file_list";
-- DROP TABLE "cpot_issue"; -- DROP TABLE "cpot_issue";
-- DROP TABLE "cpot_wiki_attachment"; -- DROP TABLE "cpot_wiki_attachment";
-- DROP TABLE "cpot_wiki"; -- DROP TABLE "cpot_wiki";
@ -130,7 +130,9 @@ CREATE TABLE "cpot_issue_change" (
"owner" VARCHAR(255) NOT NULL, "owner" VARCHAR(255) NOT NULL,
"priority" VARCHAR(32) NOT NULL, "priority" VARCHAR(32) NOT NULL,
"comment" CLOB NOT NULL, "comment" CLOB NOT NULL,
"createdon" TIMESTAMP NOT NULL,
"updatedon" TIMESTAMP NOT NULL, "updatedon" TIMESTAMP NOT NULL,
"createdby" VARCHAR(32) NOT NULL,
"updatedby" VARCHAR(32) NOT NULL, "updatedby" VARCHAR(32) NOT NULL,
PRIMARY KEY ("projectid", "id", "sno"), PRIMARY KEY ("projectid", "id", "sno"),
CONSTRAINT issue_update_id FOREIGN KEY ("projectid","id") REFERENCES "cpot_issue"("projectid","id") CONSTRAINT issue_update_id FOREIGN KEY ("projectid","id") REFERENCES "cpot_issue"("projectid","id")

View File

@ -152,7 +152,9 @@ CREATE TABLE issue_change (
priority VARCHAR(32) NOT NULL, priority VARCHAR(32) NOT NULL,
comment TEXT NOT NULL, comment TEXT NOT NULL,
createdon TIMESTAMP NOT NULL,
updatedon TIMESTAMP NOT NULL, updatedon TIMESTAMP NOT NULL,
createdby VARCHAR(32) NOT NULL,
updatedby VARCHAR(32) NOT NULL, updatedby VARCHAR(32) NOT NULL,
PRIMARY KEY (projectid, id, sno), PRIMARY KEY (projectid, id, sno),

View File

@ -663,6 +663,67 @@ class Issue extends Controller
print $status; print $status;
} }
function xhr_edit_comment ($projectid = '', $issueid = '')
{
$this->load->model ('ProjectModel', 'projects');
$this->load->model ('IssueModel', 'issues');
$login = $this->login->getUser ();
$revision_saved = -1;
if ($login['id'] == '')
{
$status = 'error - anonymous user';
}
else
{
$issueid = $this->converter->HexToAscii ($issueid);
$project = $this->projects->get ($projectid);
if ($project === FALSE)
{
$status = "error - failed to get the project {$projectid}";
}
else if ($project === NULL)
{
$status = "error - no such project {$projectid}";
}
else if (($comment_sno = $this->input->post('issue_edit_comment_sno')) === FALSE || $comment_sno <= 0)
{
$status = "error - invalid comment number";
}
else if (!$login['sysadmin?'] &&
/*$this->projects->projectHasMember($projectid, $login['id']) === FALSE &&*/
$this->issues->isIssueChangeCreatedBy($projectid, $issueid, $comment_sno, $login['id']) === FALSE)
{
$status = "error - comment not created by {$login['id']}";
}
else
{
$text = $this->input->post('issue_edit_comment_text');
if ($text === FALSE ||$text == '')
{
$status = "error - empty comment text";
}
else
{
if ($this->issues->editComment ($login['id'], $projectid, $issueid, $comment_sno, $text) === FALSE)
{
$status = 'error - ' . $this->issues->getErrorMessage();
}
else
{
$status = 'ok';
}
}
}
}
print $status;
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Handling of attached files share the (almost) same code // Handling of attached files share the (almost) same code
// between issue.php and wiki.php. It would be way better // between issue.php and wiki.php. It would be way better
@ -884,6 +945,25 @@ class Issue extends Controller
} }
if ($part[2] != '') $filename = $part[2]; if ($part[2] != '') $filename = $part[2];
} }
else if (count($part) == 2)
{
//$target => wikiname:attachment
//$target => #I1:file
if ($part[0] != '')
{
if ($part[0][0] == '#' && $part[0][1] == 'I')
{
$issueid = substr ($part[0],2);
$wikiname = '';
}
else
{
$wikiname = $part[0];
$issueid = '';
}
}
if ($part[1] != '') $filename = $part[1];
}
if ($wikiname != '') if ($wikiname != '')
$this->_handle_wiki_attachment ($login, $projectid, $wikiname, $filename); $this->_handle_wiki_attachment ($login, $projectid, $wikiname, $filename);

View File

@ -25,7 +25,6 @@ $lang['ISSUE_PRIORITY_OTHER'] = 'Other';
$lang['ISSUE_MSG_CHANGED_X_TO_Z'] = "Changed <span class='quoted'>%s</span> to <span class='quoted'>%s</span>"; $lang['ISSUE_MSG_CHANGED_X_TO_Z'] = "Changed <span class='quoted'>%s</span> to <span class='quoted'>%s</span>";
$lang['ISSUE_MSG_CHANGED_X_FROM_Y_TO_Z'] = "Changed <span class='quoted'>%s</span> from <span class='quoted'>%s</span> to <span class='quoted'>%s</span>"; $lang['ISSUE_MSG_CHANGED_X_FROM_Y_TO_Z'] = "Changed <span class='quoted'>%s</span> from <span class='quoted'>%s</span> to <span class='quoted'>%s</span>";
$lang['ISSUE_MSG_CONFIRM_UNDO'] = 'Are you sure to undo the last change?'; $lang['ISSUE_MSG_CONFIRM_UNDO'] = 'Are you sure to undo the last change?';
$lang['ISSUE_MSG_CREATED'] = 'Created';
$lang['ISSUE_MSG_NO_ISSUES_AVAILABLE'] = 'No outstanding issues'; $lang['ISSUE_MSG_NO_ISSUES_AVAILABLE'] = 'No outstanding issues';
$lang['ISSUE_MSG_NO_SUCH_ISSUE'] = 'No such issue - %s'; $lang['ISSUE_MSG_NO_SUCH_ISSUE'] = 'No such issue - %s';
$lang['ISSUE_MSG_TOTAL_NUM_ISSUES'] = 'Total %d issues'; $lang['ISSUE_MSG_TOTAL_NUM_ISSUES'] = 'Total %d issues';

View File

@ -24,7 +24,6 @@ $lang['ISSUE_PRIORITY_OTHER'] = '기타';
$lang['ISSUE_MSG_CHANGED_X_TO_Z'] = "<span class='quoted'>%s</span>을/를 <span class='quoted'>%s</span>(으)로 변경"; $lang['ISSUE_MSG_CHANGED_X_TO_Z'] = "<span class='quoted'>%s</span>을/를 <span class='quoted'>%s</span>(으)로 변경";
$lang['ISSUE_MSG_CHANGED_X_FROM_Y_TO_Z'] = "<span class='quoted'>%s</span>을/를 <span class='quoted'>%s</span>에서 <span class='quoted'>%s</span>(으)로 변경"; $lang['ISSUE_MSG_CHANGED_X_FROM_Y_TO_Z'] = "<span class='quoted'>%s</span>을/를 <span class='quoted'>%s</span>에서 <span class='quoted'>%s</span>(으)로 변경";
$lang['ISSUE_MSG_CONFIRM_UNDO'] = '마지막 변경내용을 취소할까요?'; $lang['ISSUE_MSG_CONFIRM_UNDO'] = '마지막 변경내용을 취소할까요?';
$lang['ISSUE_MSG_CREATED'] = '생성됨';
$lang['ISSUE_MSG_NO_ISSUES_AVAILABLE'] = '처리해야 할 이슈가 없습니다'; $lang['ISSUE_MSG_NO_ISSUES_AVAILABLE'] = '처리해야 할 이슈가 없습니다';
$lang['ISSUE_MSG_NO_SUCH_ISSUE'] = '해당 이슈가 없습니다 - %s'; $lang['ISSUE_MSG_NO_SUCH_ISSUE'] = '해당 이슈가 없습니다 - %s';
$lang['ISSUE_MSG_TOTAL_NUM_ISSUES'] = '전체 이슈 %d개'; $lang['ISSUE_MSG_TOTAL_NUM_ISSUES'] = '전체 이슈 %d개';

View File

@ -181,6 +181,8 @@ class IssueModel extends Model
function create ($userid, $issue) function create ($userid, $issue)
{ {
$now = codepot_nowtodbdate();
// TODO: check if userid can do this.. // TODO: check if userid can do this..
$this->db->trans_start (); $this->db->trans_start ();
@ -206,8 +208,8 @@ class IssueModel extends Model
$this->db->set ('status', $issue->status); $this->db->set ('status', $issue->status);
$this->db->set ('owner', $issue->owner); $this->db->set ('owner', $issue->owner);
$this->db->set ('priority', $issue->priority); $this->db->set ('priority', $issue->priority);
$this->db->set ('createdon', codepot_nowtodbdate()); $this->db->set ('createdon', $now);
$this->db->set ('updatedon', codepot_nowtodbdate()); $this->db->set ('updatedon', $now);
$this->db->set ('createdby', $userid); $this->db->set ('createdby', $userid);
$this->db->set ('updatedby', $userid); $this->db->set ('updatedby', $userid);
$this->db->insert ('issue'); $this->db->insert ('issue');
@ -220,11 +222,13 @@ class IssueModel extends Model
$this->db->set ('owner', $issue->owner); $this->db->set ('owner', $issue->owner);
$this->db->set ('comment', ''); $this->db->set ('comment', '');
$this->db->set ('priority', $issue->priority); $this->db->set ('priority', $issue->priority);
$this->db->set ('updatedon', codepot_nowtodbdate()); $this->db->set ('createdon', $now);
$this->db->set ('createdby', $userid);
$this->db->set ('updatedon', $now);
$this->db->set ('updatedby', $userid); $this->db->set ('updatedby', $userid);
$this->db->insert ('issue_change'); $this->db->insert ('issue_change');
$this->db->set ('createdon', codepot_nowtodbdate()); $this->db->set ('createdon', $now);
$this->db->set ('type', 'issue'); $this->db->set ('type', 'issue');
$this->db->set ('action', 'create'); $this->db->set ('action', 'create');
$this->db->set ('projectid', $issue->projectid); $this->db->set ('projectid', $issue->projectid);
@ -240,16 +244,18 @@ class IssueModel extends Model
function update_partial ($userid, $issue) function update_partial ($userid, $issue)
{ {
$now = codepot_nowtodbdate();
$this->db->trans_start (); $this->db->trans_start ();
$this->db->where ('projectid', $issue->projectid); $this->db->where ('projectid', $issue->projectid);
$this->db->where ('id', $issue->id); $this->db->where ('id', $issue->id);
$this->db->set ('summary', $issue->summary); $this->db->set ('summary', $issue->summary);
$this->db->set ('description', $issue->description); $this->db->set ('description', $issue->description);
$this->db->set ('updatedon', codepot_nowtodbdate()); $this->db->set ('updatedon', $now);
$this->db->set ('updatedby', $userid); $this->db->set ('updatedby', $userid);
$this->db->update ('issue'); $this->db->update ('issue');
$this->db->set ('createdon', codepot_nowtodbdate()); $this->db->set ('createdon', $now);
$this->db->set ('type', 'issue'); $this->db->set ('type', 'issue');
$this->db->set ('action', 'update'); $this->db->set ('action', 'update');
$this->db->set ('projectid', $issue->projectid); $this->db->set ('projectid', $issue->projectid);
@ -265,6 +271,8 @@ class IssueModel extends Model
function update ($userid, $issue) function update ($userid, $issue)
{ {
$now = codepot_nowtodbdate();
// TODO: check if userid can do this.. // TODO: check if userid can do this..
$this->db->trans_start (); $this->db->trans_start ();
$this->db->where ('projectid', $issue->projectid); $this->db->where ('projectid', $issue->projectid);
@ -275,7 +283,7 @@ class IssueModel extends Model
$this->db->set ('status', $issue->status); $this->db->set ('status', $issue->status);
$this->db->set ('owner', $issue->owner); $this->db->set ('owner', $issue->owner);
$this->db->set ('priority', $issue->priority); $this->db->set ('priority', $issue->priority);
$this->db->set ('updatedon', codepot_nowtodbdate()); $this->db->set ('updatedon', $now);
$this->db->set ('updatedby', $userid); $this->db->set ('updatedby', $userid);
$this->db->update ('issue'); $this->db->update ('issue');
@ -287,11 +295,11 @@ class IssueModel extends Model
$this->db->set ('owner', $issue->owner); $this->db->set ('owner', $issue->owner);
$this->db->set ('priority', $issue->priority); $this->db->set ('priority', $issue->priority);
$this->db->set ('comment', ''); $this->db->set ('comment', '');
$this->db->set ('updatedon', codepot_nowtodbdate()); $this->db->set ('updatedon', $now);
$this->db->set ('updatedby', $userid); $this->db->set ('updatedby', $userid);
$this->db->update ('issue_change'); $this->db->update ('issue_change');
$this->db->set ('createdon', codepot_nowtodbdate()); $this->db->set ('createdon', $now);
$this->db->set ('type', 'issue'); $this->db->set ('type', 'issue');
$this->db->set ('action', 'update'); $this->db->set ('action', 'update');
$this->db->set ('projectid', $issue->projectid); $this->db->set ('projectid', $issue->projectid);
@ -307,6 +315,8 @@ class IssueModel extends Model
function change ($userid, $project, $id, $change) function change ($userid, $project, $id, $change)
{ {
$now = codepot_nowtodbdate();
$this->db->trans_start (); $this->db->trans_start ();
$this->db->where ('projectid', $project->id); $this->db->where ('projectid', $project->id);
@ -330,7 +340,9 @@ class IssueModel extends Model
$this->db->set ('owner', $change->owner); $this->db->set ('owner', $change->owner);
$this->db->set ('priority', $change->priority); $this->db->set ('priority', $change->priority);
$this->db->set ('comment', $change->comment); $this->db->set ('comment', $change->comment);
$this->db->set ('updatedon', codepot_nowtodbdate()); $this->db->set ('createdon', $now);
$this->db->set ('createdby', $userid);
$this->db->set ('updatedon', $now);
$this->db->set ('updatedby', $userid); $this->db->set ('updatedby', $userid);
$this->db->insert ('issue_change'); $this->db->insert ('issue_change');
@ -340,11 +352,11 @@ class IssueModel extends Model
$this->db->set ('status', $change->status); $this->db->set ('status', $change->status);
$this->db->set ('owner', $change->owner); $this->db->set ('owner', $change->owner);
$this->db->set ('priority', $change->priority); $this->db->set ('priority', $change->priority);
$this->db->set ('updatedon', codepot_nowtodbdate()); $this->db->set ('updatedon', $now);
$this->db->set ('updatedby', $userid); $this->db->set ('updatedby', $userid);
$this->db->update ('issue'); $this->db->update ('issue');
$this->db->set ('createdon', codepot_nowtodbdate()); $this->db->set ('createdon', $now);
$this->db->set ('type', 'issue'); $this->db->set ('type', 'issue');
$this->db->set ('action', 'change'); $this->db->set ('action', 'change');
$this->db->set ('projectid', $project->id); $this->db->set ('projectid', $project->id);
@ -505,6 +517,8 @@ class IssueModel extends Model
$this->db->set ('owner', $issue->owner); $this->db->set ('owner', $issue->owner);
$this->db->set ('comment', ''); $this->db->set ('comment', '');
$this->db->set ('priority', $issue->priority); $this->db->set ('priority', $issue->priority);
$this->db->set ('createdon', $now);
$this->db->set ('createdby', $userid);
$this->db->set ('updatedon', $now); $this->db->set ('updatedon', $now);
$this->db->set ('updatedby', $userid); $this->db->set ('updatedby', $userid);
$this->db->insert ('issue_change'); $this->db->insert ('issue_change');
@ -888,7 +902,7 @@ class IssueModel extends Model
} }
} }
$this->db->set ('createdon', codepot_nowtodbdate()); $this->db->set ('createdon', $now);
$this->db->set ('type', 'issue'); $this->db->set ('type', 'issue');
$this->db->set ('action', 'update'); $this->db->set ('action', 'update');
$this->db->set ('projectid', $projectid); $this->db->set ('projectid', $projectid);
@ -917,6 +931,55 @@ class IssueModel extends Model
return $x; return $x;
} }
private function _edit_comment ($userid, $projectid, $issueid, $sno, $text)
{
$this->db->trans_begin (); // manual transaction. not using trans_start().
$now = codepot_nowtodbdate();
$this->db->where ('projectid', $projectid);
$this->db->where ('id', $issueid);
$this->db->where ('sno', $sno);
$this->db->set ('comment', $text);
$this->db->set ('updatedon', $now);
$this->db->set ('updatedby', $userid);
$this->db->update ('issue_change');
if ($this->db->trans_status() === FALSE)
{
$this->errmsg = $this->db->_error_message();
$this->db->trans_rollback ();
return FALSE;
}
/*
$this->db->set ('createdon', codepot_nowtodbdate());
$this->db->set ('type', 'issue');
$this->db->set ('action', 'update');
$this->db->set ('projectid', $projectid);
$this->db->set ('userid', $userid);
$this->db->set ('message', $issueid);
$this->db->insert ('log');
if ($this->db->trans_status() === FALSE)
{
$this->errmsg = $this->db->_error_message();
$this->db->trans_rollback ();
return FALSE;
}*/
$this->db->trans_commit ();
return TRUE;
}
function editComment ($userid, $projectid, $issueid, $sno, $text)
{
set_error_handler (array ($this, 'capture_error'));
$errmsg = '';
$x = $this->_edit_comment ($userid, $projectid, $issueid, $sno, $text);
restore_error_handler ();
return $x;
}
function isIssueCreatedBy ($projectid, $issueid, $userid) function isIssueCreatedBy ($projectid, $issueid, $userid)
{ {
$this->db->trans_begin (); // manual transaction. not using trans_start(). $this->db->trans_begin (); // manual transaction. not using trans_start().
@ -926,6 +989,7 @@ class IssueModel extends Model
$query = $this->db->get ('issue'); $query = $this->db->get ('issue');
if ($this->db->trans_status() === FALSE) if ($this->db->trans_status() === FALSE)
{ {
$this->errmsg = $this->db->_error_message();
$this->db->trans_rollback (); $this->db->trans_rollback ();
return FALSE; return FALSE;
} }
@ -940,7 +1004,63 @@ class IssueModel extends Model
$this->db->trans_commit (); $this->db->trans_commit ();
$issue = &$result[0]; $issue = &$result[0];
return ($issue->created_by == $userid); return ($issue->createdby == $userid);
}
function isIssueChangeCreatedBy ($projectid, $issueid, $sno, $userid)
{
$this->db->trans_begin (); // manual transaction. not using trans_start().
$this->db->where ('projectid', $projectid);
$this->db->where ('id', $issueid);
$this->db->where ('sno', $sno);
$query = $this->db->get ('issue_change');
if ($this->db->trans_status() === FALSE)
{
$this->errmsg = $this->db->_error_message();
$this->db->trans_rollback ();
return FALSE;
}
$result = $query->result ();
if (empty($result))
{
$this->db->trans_commit ();
return FALSE;
}
$this->db->trans_commit ();
$issue = &$result[0];
return $issue->createdby == $userid;
}
function isIssueChangeMadeBy ($projectid, $issueid, $sno, $userid)
{
$this->db->trans_begin (); // manual transaction. not using trans_start().
$this->db->where ('projectid', $projectid);
$this->db->where ('id', $issueid);
$this->db->where ('sno', $sno);
$query = $this->db->get ('issue_change');
if ($this->db->trans_status() === FALSE)
{
$this->errmsg = $this->db->_error_message();
$this->db->trans_rollback ();
return FALSE;
}
$result = $query->result ();
if (empty($result))
{
$this->db->trans_commit ();
return FALSE;
}
$this->db->trans_commit ();
$issue = &$result[0];
return ($issue->createdby == $userid || $issue->updatedby == $userid);
} }
} }

View File

@ -42,7 +42,7 @@ function show_alert (outputMsg, titleMsg)
width: 'auto', width: 'auto',
height: 'auto', height: 'auto',
buttons: { buttons: {
"OK": function () { '<?php print $this->lang->line('OK')?>': function () {
$(this).dialog("close"); $(this).dialog("close");
} }
} }

View File

@ -27,6 +27,8 @@ $issue_file_count = count ($issue->files);
$creole_base = site_url() . "/wiki/show/{$project->id}/"; $creole_base = site_url() . "/wiki/show/{$project->id}/";
$creole_file_base = site_url() . "/issue/file/{$project->id}/{$issue->id}/"; $creole_file_base = site_url() . "/issue/file/{$project->id}/{$issue->id}/";
$change_count = count($issue->changes);
?> ?>
<script type="text/javascript"> <script type="text/javascript">
@ -40,13 +42,36 @@ function show_alert (outputMsg, titleMsg)
width: 'auto', width: 'auto',
height: 'auto', height: 'auto',
buttons: { buttons: {
"OK": function () { '<?php print $this->lang->line('OK')?>': function () {
$(this).dialog("close"); $(this).dialog("close");
} }
} }
}); });
} }
function render_wiki()
{
creole_render_wiki (
"issue_show_description_pre",
"issue_show_description",
"<?php print $creole_base?>",
"<?php print $creole_file_base?>",
false
);
<?php
for ($i = 1; $i < $change_count; $i++)
{
print "creole_render_wiki (
'issue_show_comment_pre_{$i}',
'issue_show_comment_{$i}',
'{$creole_base}', '{$creole_file_base}', false);\n";
}
?>
prettyPrint ();
}
$.widget("ui.combobox", { $.widget("ui.combobox", {
_create: function() { _create: function() {
var self = this; var self = this;
@ -184,6 +209,20 @@ function preview_edit_description (input_text)
prettyPrint (); prettyPrint ();
} }
function preview_issue_change_comment(input_text)
{
creole_render_wiki_with_input_text (
input_text,
"issue_change_comment_preview",
"<?php print $creole_base?>",
"<?php print $creole_file_base?>",
true
);
prettyPrint ();
}
var work_in_progress = false; var work_in_progress = false;
var original_file_name = [ var original_file_name = [
@ -208,6 +247,60 @@ var original_file_desc = [
?> ?>
]; ];
<?php if (isset($login['id']) && $login['id'] != ''): ?>
function save_issue_comment (comment_no)
{
if (!!window.FormData)
{
// FormData is supported
var form_elem_id = '#issue_show_edit_comment_form_' + comment_no;
var sno_elem_id = '#issue_show_edit_comment_sno_' + comment_no;
var text_elem_id = '#issue_show_edit_comment_text_' + comment_no;
var form_data = new FormData();
form_data.append ('issue_edit_comment_sno', $(sno_elem_id).val());
form_data.append ('issue_edit_comment_text', $(text_elem_id).val());
$(form_elem_id).dialog('disable');
$.ajax({
url: codepot_merge_path('<?php print site_url() ?>', '<?php print "/issue/xhr_edit_comment/{$project->id}/{$hex_issue_id}"; ?>'),
type: 'POST',
data: form_data,
mimeType: 'multipart/form-data',
contentType: false,
processData: false,
cache: false,
success: function (data, textStatus, jqXHR) {
$(form_elem_id).dialog('enable');
$(form_elem_id).dialog('close');
if (data == 'ok')
{
// refresh the page to the head revision
$(location).attr ('href', codepot_merge_path('<?php print site_url(); ?>', '<?php print "/issue/show/{$project->id}/${hex_issue_id}"; ?>'));
}
else
{
show_alert ('<pre>' + codepot_htmlspecialchars(data) + '</pre>', "<?php print $this->lang->line('Error')?>");
}
},
error: function (jqXHR, textStatus, errorThrown) {
$(form_elem_id).dialog('enable');
$(form_elem_id).dialog('close');
show_alert ('Failed - ' + errorThrown, "<?php print $this->lang->line('Error')?>");
}
});
}
else
{
show_alert ('<pre>NOT SUPPORTED</pre>', "<?php print $this->lang->line('Error')?>");
}
}
<?php endif; ?>
$(function () { $(function () {
$('#issue_show_state').accordion({ $('#issue_show_state').accordion({
@ -670,6 +763,47 @@ $(function () {
} }
); );
<?php if (isset($login['id']) && $login['id'] != ''): ?>
for (var i = 1; i < <?php print $change_count; ?>; i++)
{
$('#issue_show_edit_comment_form_' + i).dialog ({
title: '<?php print $this->lang->line('Comment')?>',
autoOpen: false,
modal: true,
width: '85%',
buttons: {
'<?php print $this->lang->line('OK')?>': function () {
if (work_in_progress) return;
work_in_progress = true;
var id = $(this).attr('id');
var comment_no = id.replace('issue_show_edit_comment_form_', '');
save_issue_comment (comment_no);
work_in_progress = false;
},
'<?php print $this->lang->line('Cancel')?>': function () {
if (work_in_progress) return;
$(this).dialog ('close');
}
},
beforeClose: function() {
// if importing is in progress, prevent dialog closing
return !work_in_progress;
}
});
$('#issue_show_edit_comment_button_' + i).button().click(
function () {
var id = $(this).attr('id');
var comment_no = id.replace('issue_show_edit_comment_button_', '');
$('#issue_show_edit_comment_form_' + comment_no).dialog('open'); // @issue_show_edit_comment_form_xxx
return false;
}
);
}
<?php endif; ?>
render_wiki(); render_wiki();
}); });
</script> </script>
@ -736,9 +870,16 @@ $this->load->view (
</div> </div>
<div id='issue_show_state' class='collapsible-box'> <div id='issue_show_state' class='collapsible-box'>
<div id='issue_show_state_header' class='collapsible-box-header'><?php print $this->lang->line('State')?></div> <div id='issue_show_metadata_header' class='collapsible-box-header'><?php print $this->lang->line('State')?></div>
<div id='issue_show_state_body'> <div id='issue_show_metadata_body'>
<ul> <ul id='issue_show_metadata_list'>
<li><?php print $this->lang->line('Created on')?> <?php print codepot_dbdatetodispdate($issue->createdon); ?></li>
<li><?php print $this->lang->line('Created by')?> <?php print htmlspecialchars($issue->createdby); ?></li>
<li><?php print $this->lang->line('Last updated on')?> <?php print codepot_dbdatetodispdate($issue->updatedon); ?></li>
<li><?php print $this->lang->line('Last updated by')?> <?php print htmlspecialchars($issue->updatedby); ?></li>
</ul>
<ul id='issue_show_state_list'>
<?php <?php
$type = array_key_exists($issue->type, $issue_type_array)? $type = array_key_exists($issue->type, $issue_type_array)?
@ -778,6 +919,8 @@ $this->load->view (
} }
?> ?>
</ul> </ul>
<div style='clear: both'></div>
</div> </div>
</div> </div>
@ -838,17 +981,16 @@ $this->load->view (
<div id="issue_show_changes"> <div id="issue_show_changes">
<?php <?php
$commentno = 0;
$msgfmt_changed_from_to = $this->lang->line ('ISSUE_MSG_CHANGED_X_FROM_Y_TO_Z'); $msgfmt_changed_from_to = $this->lang->line ('ISSUE_MSG_CHANGED_X_FROM_Y_TO_Z');
$msgfmt_changed_to = $this->lang->line ('ISSUE_MSG_CHANGED_X_TO_Z'); $msgfmt_changed_to = $this->lang->line ('ISSUE_MSG_CHANGED_X_TO_Z');
$count = count($issue->changes);
print '<table id="issue_show_changes_table" class="codepot-full-width-table">'; print '<table id="issue_show_changes_table" class="codepot-full-width-table">';
while ($count > 1) // TODO: displa changes[0];
for ($i = 1; $i < $change_count; $i++)
{ {
$new = $issue->changes[--$count]; $new = $issue->changes[$i];
$old = $issue->changes[$count-1]; $old = $issue->changes[$i - 1];
print '<tr>'; print '<tr>';
@ -856,21 +998,31 @@ $this->load->view (
print codepot_dbdatetodispdate($new->updatedon); print codepot_dbdatetodispdate($new->updatedon);
print '</td>'; print '</td>';
print '<td class="updater">';
print htmlspecialchars($new->updatedby);
print '</td>';
print '<td class="details">'; print '<td class="details">';
if ($new->comment != "")
print "<div>";
print "<div class='codepot-issue-comment-updater'>";
$user_icon_url = codepot_merge_path (site_url(), '/user/icon/' . $this->converter->AsciiToHex($new->updatedby));
print "<img src='{$user_icon_url}' class='codepot-committer-icon-24x24' /> ";
print htmlspecialchars($new->updatedby);
print "</div>";
printf ("<div class='codepot-issue-comment-actions'><a href='#' id='issue_show_edit_comment_button_%d' class='codepot-issue-comment-action-button'>%s</a></div>", $i, $this->lang->line('Edit'));
print "<div style='clear: both;'></div>";
print "</div>";
$escaped_comment = htmlspecialchars($new->comment);
if(isset($login['id']) && $login['id'] != '')
{ {
print "<div id='issue_show_changes_comment_{$commentno}' class='codepot-styled-text-view'>"; print "<div id='issue_show_edit_comment_form_{$i}'>";
print "<pre id='issue_show_changes_comment_pre_{$commentno}'>"; printf ('<input type="hidden" id="issue_show_edit_comment_sno_%d" value="%s" />', $i, addslashes($new->sno));
print htmlspecialchars($new->comment); printf ('<textarea id="issue_show_edit_comment_text_%d" class="codepot-issue-edit-comment" rows="20">%s</textarea>', $i, $escaped_comment);
print '</pre>';
print '</div>'; print '</div>';
$commentno++;
} }
print "<div id='issue_show_comment_{$i}' class='codepot-styled-text-view'>";
printf ("<pre id='issue_show_comment_pre_%d'>%s</pre>", $i, $escaped_comment);
print '</div>';
print '<div class="list">'; print '<div class="list">';
print '<ul>'; print '<ul>';
if ($new->type != $old->type) if ($new->type != $old->type)
@ -931,21 +1083,6 @@ $this->load->view (
print '</tr>'; print '</tr>';
} }
print '<tr>';
print '<td class="date">';
print codepot_dbdatetodispdate($issue->createdon);
print '</td>';
print '<td class="updater">';
print htmlspecialchars($issue->createdby);
print '</td>';
print '<td class="details">';
print $this->lang->line('ISSUE_MSG_CREATED');
print '</td>';
print '</tr>';
print '</table>'; print '</table>';
?> ?>
</div> <!-- issue_show_changes --> </div> <!-- issue_show_changes -->
@ -971,7 +1108,7 @@ $this->load->view (
</ul> </ul>
<div id='issue_show_edit_description_input'> <div id='issue_show_edit_description_input'>
<textarea type='textarea' id='issue_show_edit_description' name='issue_show_edit_description' rows=24 cols=100 style='width:100%;'><?php print htmlspecialchars($issue->description); ?></textarea> <textarea id='issue_show_edit_description' name='issue_show_edit_description' rows=24 cols=100 style='width:100%;'><?php print htmlspecialchars($issue->description); ?></textarea>
</div> </div>
<div id='issue_show_edit_description_preview' class='codepot-styled-text-preview'> <div id='issue_show_edit_description_preview' class='codepot-styled-text-preview'>
</div> </div>
@ -1110,47 +1247,6 @@ $this->load->view (
<!----------------------------------------------------------------------------> <!---------------------------------------------------------------------------->
<script type="text/javascript">
function render_wiki()
{
creole_render_wiki (
"issue_show_description_pre",
"issue_show_description",
"<?php print $creole_base?>",
"<?php print $creole_file_base?>",
false
);
<?php
if ($commentno > 0)
{
for ($xxx = 0; $xxx < $commentno; $xxx++)
{
print "creole_render_wiki (
'issue_show_changes_comment_pre_{$xxx}',
'issue_show_changes_comment_{$xxx}',
'{$creole_base}', '{$creole_file_base}', false);";
}
}
?>
prettyPrint ();
}
function preview_issue_change_comment(input_text)
{
creole_render_wiki_with_input_text (
input_text,
"issue_change_comment_preview",
"<?php print $creole_base?>",
"<?php print $creole_file_base?>",
true
);
prettyPrint ();
}
</script>
</body> </body>
</html> </html>

View File

@ -45,7 +45,7 @@ function show_alert (outputMsg, titleMsg)
width: 'auto', width: 'auto',
height: 'auto', height: 'auto',
buttons: { buttons: {
"OK": function () { '<?php print $this->lang->line('OK')?>': function () {
$(this).dialog("close"); $(this).dialog("close");
} }
} }
@ -68,7 +68,7 @@ function show_in_progress_message (outputMsg, titleMsg)
height: 'auto', height: 'auto',
buttons: { buttons: {
"OK": function () { '<?php print $this->lang->line('OK')?>': function () {
// do nothing, don't event close the dialog. // do nothing, don't event close the dialog.
} }
}, },
@ -381,11 +381,11 @@ function save_wiki_with_confirmation (outputMsg, titleMsg, wiki_new_name, wiki_n
width: 'auto', width: 'auto',
height: 'auto', height: 'auto',
buttons: { buttons: {
"OK": function () { '<?php print $this->lang->line('OK')?>': function () {
$(this).dialog("close"); $(this).dialog("close");
save_wiki (wiki_new_name, wiki_new_text); save_wiki (wiki_new_name, wiki_new_text);
}, },
"Cancel": function () { '<?php print $this->lang->line('Cancel')?>': function () {
$(this).dialog("close"); $(this).dialog("close");
} }
} }

View File

@ -52,7 +52,7 @@ function show_alert (outputMsg, titleMsg)
width: 'auto', width: 'auto',
height: 'auto', height: 'auto',
buttons: { buttons: {
"OK": function () { '<?php print $this->lang->line('OK')?>': function () {
$(this).dialog("close"); $(this).dialog("close");
} }
} }

View File

@ -1,3 +1,27 @@
.codepot-issue-comment-updater {
float: left;
}
.codepot-issue-comment-actions {
float: right;
}
.codepot-issue-comment-action-button {
font-size: 75% !important;
}
textarea.codepot-issue-edit-comment {
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
border: 0 none;
width: 100%;
font-size: 0.9em;
}
li.issue-type-defect { li.issue-type-defect {
background-color: #D9534F; background-color: #D9534F;
color: #FFFFFF; color: #FFFFFF;
@ -179,23 +203,38 @@ li.issue-owner {
/*--------------------------------------------- /*---------------------------------------------
* issue show * issue show
*---------------------------------------------*/ *---------------------------------------------*/
#issue_show_state_body { #issue_show_metadata_body {
background-color: #FCFCFC; background-color: #FCFCFC;
padding: 1em 1em; padding: 1em 1em;
} }
#issue_show_state_body ul { #issue_show_metadata_list,
#issue_show_state_list {
clear: both;
padding: 0; padding: 0;
margin: 0; margin: 0;
list-style: outside none none; list-style: outside none none;
} }
#issue_show_state_body ul li { #issue_show_state_list {
padding-top: 0.2em;
}
#issue_show_metadata_list li,
#issue_show_state_list li {
padding: 0.2em 0.2em 0.2em 0.2em; padding: 0.2em 0.2em 0.2em 0.2em;
margin: 0 0.2em 0 0.2em; margin: 0 0.2em 0 0.2em;
float: left; float: left;
} }
#issue_show_metadata_list li {
background-color: #EAEAEA !important;
color: #000000 !important;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
}
#issue_show_change_form { #issue_show_change_form {
} }
@ -229,11 +268,6 @@ li.issue-owner {
} }
#issue_show_changes { #issue_show_changes {
/*
margin-top: 1em;
padding-top: 0.5em;
padding-bottom: 0.5em;
*/
overflow: auto; overflow: auto;
} }
@ -246,10 +280,7 @@ li.issue-owner {
#issue_show_changes_table td.date { #issue_show_changes_table td.date {
min-width: 5em; min-width: 5em;
width: 1px; width: 1px;
} vertical-align: top;
#issue_show_changes_table td.updater {
width: 1px;
} }
#issue_show_changes_table td.details { #issue_show_changes_table td.details {
@ -304,7 +335,7 @@ li.issue-owner {
} }
/*----------------------------------------------- /*-----------------------------------------------
* issue home show - edit issue dialog * issue show - edit issue dialog
*-----------------------------------------------*/ *-----------------------------------------------*/
#issue_show_edit_description_tabs { #issue_show_edit_description_tabs {
border: none !important; border: none !important;