[Notice] Announcing the End of Demo Server [Read me]

fix: fileUpload error for issue/board edit page
@1c7f6cb713c23a74093f448e47ff3fae1c9eefc5
--- app/views/board/editPost.scala.html
+++ app/views/board/editPost.scala.html
... | ... | @@ -46,7 +46,7 @@ |
46 | 46 |
<div class="avatar-wrap"> |
47 | 47 |
<img src="@User.findByLoginId(session.get("loginId")).avatarUrl" class="img-rounded" width="32" height="32" alt="avatar"> |
48 | 48 |
</div> |
49 |
- <div id="upload" class="attach-info-wrap" resourceType="@ResourceType.BOARD_POST"> |
|
49 |
+ <div id="upload" class="attach-info-wrap" resourceType="@ResourceType.BOARD_POST" resourceId="@postId"> |
|
50 | 50 |
<div> |
51 | 51 |
<span class="progress-num">0%</span> <span class="sp-line"> </span> |
52 | 52 |
<strong>total</strong> <span class="total-num">0MB</span> |
--- public/javascripts/common/hive.FileUploader.js
+++ public/javascripts/common/hive.FileUploader.js
... | ... | @@ -22,9 +22,13 @@ |
22 | 22 |
function _init(htOptions){ |
23 | 23 |
htOptions = htOptions || {}; |
24 | 24 |
|
25 |
- _initVar(htOptions); |
|
26 | 25 |
_initElement(htOptions); |
26 |
+ _initVar(htOptions); |
|
27 | 27 |
_attachEvent(); |
28 |
+ |
|
29 |
+ if(htVar.sMode == "edit") { |
|
30 |
+ _requestList(); |
|
31 |
+ } |
|
28 | 32 |
} |
29 | 33 |
|
30 | 34 |
/** |
... | ... | @@ -42,6 +46,10 @@ |
42 | 46 |
"beforeSubmit" : _onBeforeSubmitForm, |
43 | 47 |
"uploadProgress": _onUploadProgressForm |
44 | 48 |
}; |
49 |
+ |
|
50 |
+ htVar.sMode = htOptions.sMode; |
|
51 |
+ htVar.sResourceId = htElements.welTarget.attr('resourceId'); |
|
52 |
+ htVar.sResourceType = htElements.welTarget.attr('resourceType'); |
|
45 | 53 |
} |
46 | 54 |
|
47 | 55 |
/** |
... | ... | @@ -66,6 +74,60 @@ |
66 | 74 |
htElements.welInputFile.click(function(){ |
67 | 75 |
_setProgressBar(0); |
68 | 76 |
}); |
77 |
+ } |
|
78 |
+ |
|
79 |
+ /** |
|
80 |
+ * request attached file list |
|
81 |
+ */ |
|
82 |
+ function _requestList(){ |
|
83 |
+ var htData = _getRequestData(); |
|
84 |
+ |
|
85 |
+ $hive.sendForm({ |
|
86 |
+ "sURL" : htVar.sAction, |
|
87 |
+ "htData" : htData, |
|
88 |
+ "htOptForm": {"method":"get"}, |
|
89 |
+ "fOnLoad" : _onLoadRequest |
|
90 |
+ }); |
|
91 |
+ } |
|
92 |
+ |
|
93 |
+ /** |
|
94 |
+ * get request parameters |
|
95 |
+ * @return {Hash Table} |
|
96 |
+ */ |
|
97 |
+ function _getRequestData(){ |
|
98 |
+ var htData = {}; |
|
99 |
+ |
|
100 |
+ if(typeof htVar.sResourceType !== "undefined"){ |
|
101 |
+ htData.containerType = htVar.sResourceType; |
|
102 |
+ } |
|
103 |
+ |
|
104 |
+ if(typeof htVar.sResourceId !== "undefined"){ |
|
105 |
+ htData.containerId = htVar.sResourceId; |
|
106 |
+ } |
|
107 |
+ |
|
108 |
+ return htData; |
|
109 |
+ } |
|
110 |
+ |
|
111 |
+ function _onLoadRequest(oRes) { |
|
112 |
+ |
|
113 |
+ var aItems = []; |
|
114 |
+ var aFiles = oRes.attachments; |
|
115 |
+ |
|
116 |
+ if(aFiles == null || aFiles.length === 0){ |
|
117 |
+ return; |
|
118 |
+ } |
|
119 |
+ |
|
120 |
+ var totalFileSize = 0; |
|
121 |
+ aFiles.forEach(function(oFile) { |
|
122 |
+ var welItem = _createFileItem(oFile); |
|
123 |
+ welItem.click(_onClickListItem); |
|
124 |
+ htElements.welFileList.append(welItem); |
|
125 |
+ totalFileSize = totalFileSize + parseInt(oFile.size); |
|
126 |
+ }); |
|
127 |
+ |
|
128 |
+ _setProgressBar(100); |
|
129 |
+ _updateTotalFilesize(totalFileSize); |
|
130 |
+ |
|
69 | 131 |
} |
70 | 132 |
|
71 | 133 |
/** |
... | ... | @@ -132,7 +194,7 @@ |
132 | 194 |
|
133 | 195 |
// create list item |
134 | 196 |
var welItem = _createFileItem(oRes); |
135 |
- welItem.click(_onClickListItem); |
|
197 |
+ welItem.click(_onClickListItem); |
|
136 | 198 |
htElements.welFileList.append(welItem); |
137 | 199 |
|
138 | 200 |
_setProgressBar(100); |
--- public/javascripts/service/hive.board.Write.js
+++ public/javascripts/service/hive.board.Write.js
... | ... | @@ -82,7 +82,8 @@ |
82 | 82 |
"elTarget" : htElement.welTarget, |
83 | 83 |
"elTextarea" : htElement.welTextarea, |
84 | 84 |
"sTplFileItem": htVar.sTplFileItem, |
85 |
- "sAction" : htVar.sUploaderAction |
|
85 |
+ "sAction" : htVar.sUploaderAction, |
|
86 |
+ "sMode" : htVar.sMode |
|
86 | 87 |
}); |
87 | 88 |
} |
88 | 89 |
|
--- public/javascripts/service/hive.issue.Write.js
+++ public/javascripts/service/hive.issue.Write.js
... | ... | @@ -65,7 +65,8 @@ |
65 | 65 |
"elTarget" : htElement.welTarget, |
66 | 66 |
"elTextarea" : htElement.welTextarea, |
67 | 67 |
"sTplFileItem": htVar.sTplFileItem, |
68 |
- "sAction" : htVar.sUploaderAction |
|
68 |
+ "sAction" : htVar.sUploaderAction, |
|
69 |
+ "sMode" : htVar.sMode |
|
69 | 70 |
}); |
70 | 71 |
} |
71 | 72 |
|
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?