+ var imgSrc = iconsMap[file.contentType] || prefix + 'Default.png';
+ var title = file.fileName;
+ var downloadUrl = file.url;
+ var thumbnailUrl = file.thumbnailUrl;
+ var fileSize = formatBytes(file.size, 3);
+ var imageLinkHtml = '';
+
+ var $newHtml = $(`
@@ -949,39 +912,36 @@
`);
- let imgLoadCheck = new Image();
- imgLoadCheck.src = imgSrc;
+ let imgLoadCheck = new Image();
+ imgLoadCheck.src = imgSrc;
- imgLoadCheck.onload = function () {
- $portfolioContainer.append($newHtml);
- portfolioIsotope.appended($newHtml[0]);
- portfolioIsotope.arrange();
- };
- });
- }
- }
+ imgLoadCheck.onload = function () {
+ $portfolioContainer.append($newHtml);
+ portfolioIsotope.appended($newHtml[0]);
+ portfolioIsotope.arrange();
+ };
+ });
+ }
+ }
- /* data-filter 통해서 이미지, 문서, 기타 파일로 클릭 시 나눠지는 부분 */
- $('#portfolio-flters li').on('click', function(e){
- e.preventDefault();
- $('#portfolio-flters li').removeClass('filter-active');
- $(this).addClass('filter-active');
+ /* data-filter 통해서 이미지, 문서, 기타 파일로 클릭 시 나눠지는 부분 */
+ $('#portfolio-flters li').on('click', function(e){
+ e.preventDefault();
+ $('#portfolio-flters li').removeClass('filter-active');
+ $(this).addClass('filter-active');
- portfolioIsotope.arrange({
- filter: $(this).attr('data-filter')
- });
+ portfolioIsotope.arrange({
+ filter: $(this).attr('data-filter')
+ });
- portfolioIsotope.on( 'arrangeComplete', function() {
- AOS.refresh();
- });
+ portfolioIsotope.on( 'arrangeComplete', function() {
+ AOS.refresh();
+ });
- portfolioIsotope.reloadItems();
- portfolioIsotope.arrange();
- });
- }
-
- jSuccess("파일 조회가 완료 되었습니다.");
+ portfolioIsotope.reloadItems();
+ portfolioIsotope.arrange();
});
+
}
function formatBytes(bytes, decimals = 2) {
@@ -1049,10 +1009,7 @@
var pageSize = 10;
var totalPages = 0;
var curPage = pageNum;
- /* 전체 게시판 게시물 갯수 가져오는 API 호출 필요 */
- console.log(totalReqCommentCount);
-
if (totalReqCommentCount !== null && totalReqCommentCount > 0) {
totalPages = Math.ceil(totalReqCommentCount / pageSize);
console.log("totalPages : " + totalPages);
@@ -1063,14 +1020,7 @@
$(".pagination").append(htmlStr);
}
else{
- //alert("검색되는 주소없음")
- var $chatMessages = $('#chat_messages');
- $chatMessages.empty();
-
- var $noDataHtml = $(`
- 등록된 글이 없습니다.
-
`);
- $chatMessages.append($noDataHtml);
+ noReqCommentMessage();
return;
}
@@ -1085,7 +1035,6 @@
type: "GET",
data: {
c_pdservice_link: selectedPdService,
- /*c_version_link: selectedPdServiceVersion,*/
c_req_link: selectedJsTreeId,
pageIndex: pageNum,
pageUnit: pageSize
@@ -1094,125 +1043,24 @@
dataType: "json",
statusCode: {
200: function (data) {
- //모달 팝업 끝내고
var $chatMessages = $('#chat_messages');
$chatMessages.empty();
console.log(data.response);
if (data.response.length === 0) {
/* 게시글이 없을 경우 처리 필요 */
- var $noDataHtml = $(`
- 등록된 글이 없습니다.
-
`);
- $chatMessages.append($noDataHtml);
+ noReqCommentMessage();
return;
}
- for (var k in data.response) {
- var comment = data.response[k];
-
- var c_id = comment.c_id;
- var sender = comment.c_req_comment_sender;
- var date = dateFormat(comment.c_req_comment_date);
- var title = comment.c_title;
- var req_comment_contents = comment.c_req_comment_contents.replace(/\n/g, '
');
- var contents = `
` + req_comment_contents +`
`;
- var $newHtml;
-
- /* 로그인한 사용자 일 경우 우측으로 아닐 경우 좌측으로 보이게 하기 */
- var iconPosition = (sender !== userName) ? 'left' : 'right';
- var position = (sender !== userName) ? '' : 'on-left';
- var personIcon = (sender !== userName) ? 'bi-person-fill' : 'bi-person';
- var buttonsHtml = '';
-
- if (sender === userName) {
- buttonsHtml = `
`;
- }
-
- $newHtml = $(`
-
-
- ${buttonsHtml}
-
-
- ${(position === "on-left") ? `${date} \t` : ''}
- ${sender}
- ${(position === "") ? ` ${date}` : ''}
-
-
- ${contents}
-
-
-
-
-
`);
-
- $chatMessages.append($newHtml);
- }
-
- $('.edit-chat-btn').on('click', function(e){
- var parentDiv = $(this).closest('.chat-message-body');
- var commentText = parentDiv.find('#contents').html();
- commentText = commentText.replace(/
/g, "\n");
-
- parentDiv.find('.edit-text').val(commentText);
- parentDiv.find('#contents').hide();
- parentDiv.find('.dropdown-button').hide();
- parentDiv.find('.dropdown-content').addClass('hide');
- parentDiv.find('.edit-comment').show();
-
- $('.edit-text').on('input', function () {
- this.style.height = 'auto';
- this.style.height = (this.scrollHeight) + 'px';
- });
- console.log(commentText);
- // req_comment_edit_btn_click(c_id);
+ data.response.forEach(function(comment) {
+ var commentHtml = createReqCommentList(comment);
+ $chatMessages.append(commentHtml);
});
- $('.delete-chat-btn').on('click', function(e){
- var c_id = $(this).val();
- req_comment_delete_btn_click(c_id);
- });
+ reqCommentRegisterEventHandlers();
- $('.cancel-button').on('click', function(e){
- var commentDiv = $(this).closest('.chat-message-body');
- commentDiv.find('#contents').show();
- commentDiv.find('.dropdown-button').show();
- commentDiv.find('.dropdown-content').removeClass('hide');
- commentDiv.find('.edit-comment').hide();
- });
-
- $('.edit-save-button').on('click', function(e){
- var c_id = $(this).val();
- console.log(c_id);
- var editText = $(this).closest('.edit-comment');
- var commentText = editText.find('.edit-text').val();
- console.log(commentText);
- req_comment_edit_btn_click(c_id, commentText);
- });
}
},
beforeSend: function () {
@@ -1271,6 +1119,123 @@
return pageUrl;
}
+function noReqCommentMessage() {
+ var $chatMessages = $('#chat_messages');
+ $chatMessages.empty();
+
+ var $noDataHtml = $(`
+ 등록된 글이 없습니다.
+
`);
+ $chatMessages.append($noDataHtml);
+}
+
+function createReqCommentList(comment) {
+ var c_id = comment.c_id;
+ var sender = comment.c_req_comment_sender;
+ var date = dateFormat(comment.c_req_comment_date);
+ var title = comment.c_title;
+ var req_comment_contents = comment.c_req_comment_contents.replace(/\n/g, '
');
+ var contents = `
` + req_comment_contents +`
`;
+ var $newHtml;
+
+ /* 로그인한 사용자 일 경우 우측으로 아닐 경우 좌측으로 보이게 하기 */
+ var iconPosition = (sender !== userName) ? 'left' : 'right';
+ var position = (sender !== userName) ? '' : 'on-left';
+ var personIcon = (sender !== userName) ? 'bi-person-fill' : 'bi-person';
+ var buttonsHtml = '';
+
+ if (sender === userName) {
+ buttonsHtml = `
`;
+ }
+
+ $newHtml = $(`
+
+
+ ${buttonsHtml}
+
+
+ ${(position === "on-left") ? `${date} \t` : ''}
+ ${sender}
+ ${(position === "") ? ` ${date}` : ''}
+
+
+ ${contents}
+
+
+
+
+
`);
+
+ return $newHtml;
+}
+
+function reqCommentRegisterEventHandlers() {
+ $('.edit-chat-btn').on('click', handleEditClick);
+ $('.delete-chat-btn').on('click', handleDeleteClick);
+ $('.cancel-button').on('click', handleCancelClick);
+ $('.edit-save-button').on('click', handleSaveClick);
+}
+
+function handleEditClick(e){
+ var parentDiv = $(this).closest('.chat-message-body');
+ var commentText = parentDiv.find('#contents').html();
+ commentText = commentText.replace(/
/g, "\n");
+
+ parentDiv.find('.edit-text').val(commentText);
+ parentDiv.find('#contents').hide();
+ parentDiv.find('.dropdown-button').hide();
+ parentDiv.find('.dropdown-content').addClass('hide');
+ parentDiv.find('.edit-comment').show();
+
+ $('.edit-text').on('input', function () {
+ this.style.height = 'auto';
+ this.style.height = (this.scrollHeight) + 'px';
+ });
+}
+
+function handleDeleteClick(e){
+ var c_id = $(this).val();
+ req_comment_delete_btn_click(c_id);
+}
+
+function handleCancelClick(e){
+ var commentDiv = $(this).closest('.chat-message-body');
+ commentDiv.find('#contents').show();
+ commentDiv.find('.dropdown-button').show();
+ commentDiv.find('.dropdown-content').removeClass('hide');
+ commentDiv.find('.edit-comment').hide();
+}
+
+function handleSaveClick(e){
+ var c_id = $(this).val();
+ var editText = $(this).closest('.edit-comment');
+ var commentText = editText.find('.edit-text').val();
+
+ req_comment_edit_btn_click(c_id, commentText);
+}
+
function req_comment_save_btn_click() {
addReqComment();
}
@@ -1393,7 +1358,8 @@
}
function req_comment_message_size_change() {
- $('#comment-contents').on('input propertychange', function() {
- $('.chat-footer').height($(this).height());
+ $('#comment-contents').on('input', function () {
+ this.style.height = 'auto';
+ this.style.height = (this.scrollHeight) + 'px';
});
}