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

cardView : apart js
@4860fba62d6c058b4607e8511caebe2510b08ae7
--- app/controllers/TaskApp.java
+++ app/controllers/TaskApp.java
... | ... | @@ -41,7 +41,7 @@ |
41 | 41 |
|
42 | 42 |
// TestCode 나중에 전부 웹소켓으로 바꾼다. 당연히 그걸 고려해서 짜야한다. |
43 | 43 |
public static Result cardView(String userName, String projectName) { |
44 |
- return ok(cardView.render()); |
|
44 |
+ return ok(cardView.render(ProjectApp.getProject(userName, projectName))); |
|
45 | 45 |
} |
46 | 46 |
|
47 | 47 |
@BodyParser.Of(BodyParser.Json.class) |
--- app/views/code/gitView.scala.html
+++ app/views/code/gitView.scala.html
... | ... | @@ -1,62 +1,63 @@ |
1 | 1 |
@(url : String, project:Project) @main("코드", project){ |
2 | 2 |
<ul class="nav nav-tabs"> |
3 |
- <a href="@routes.CodeApp.codeBrowser(project.owner, project.name)">@Messages("Files")</a></li> |
|
4 |
- <a href="@routes.CodeHistoryApp.historyUntilHead(project.owner, project.name)">@Messages("Commits")</a></li> |
|
3 |
+ <a href="@routes.CodeApp.codeBrowser(project.owner, project.name)">@Messages("Files")</a> |
|
4 |
+ </li> |
|
5 |
+ <a href="@routes.CodeHistoryApp.historyUntilHead(project.owner, project.name)">@Messages("Commits")</a> |
|
6 |
+ </li> |
|
5 | 7 |
</ul> |
6 |
- |
|
7 | 8 |
<div class="well">Clone this repository : git clone @url</div> |
8 | 9 |
<div class="row" id="codeBrowser"> |
9 |
- <div class="span3"> |
|
10 |
- <ul id="codeRoot" class="well nav nav-list"> |
|
11 |
- <li id="codeBrowserHeader"><a href="#">코드 탐색기</a></li> |
|
12 |
- </ul> |
|
10 |
+ <div class="span3"> |
|
11 |
+ <ul id="codeRoot" class="well nav nav-list"> |
|
12 |
+ <li id="codeBrowserHeader"><a href="#">코드 탐색기</a></li> |
|
13 |
+ </ul> |
|
14 |
+ </div> |
|
15 |
+ <div class="span9"> |
|
16 |
+ <div> |
|
17 |
+ <span id="breadcrumbs">Breadcrumbs</span> <span> <select> |
|
18 |
+ <option>master</option> |
|
19 |
+ </select> |
|
20 |
+ </span> |
|
13 | 21 |
</div> |
14 |
- <div class="span9" > |
|
15 |
- <div> |
|
16 |
- <span id="breadcrumbs">Breadcrumbs</span> |
|
17 |
- <span> |
|
18 |
- <select> |
|
19 |
- <option>master</option> |
|
20 |
- </select> |
|
21 |
- </span> |
|
22 |
- </div> |
|
23 |
- <div id="folderView"> |
|
24 |
- <table class="table table-bordered"> |
|
25 |
- <thead> |
|
26 |
- <tr> |
|
27 |
- <th>FileName</th> |
|
28 |
- <th>Commit Message</th> |
|
29 |
- <th>Commit Date</th> |
|
30 |
- <th>Author</th> |
|
31 |
- </tr> |
|
32 |
- </thead> |
|
33 |
- <tbody> |
|
34 |
- </tbody> |
|
35 |
- </table> |
|
36 |
- </div> |
|
37 |
- <div id="codeView" class="hide"> |
|
38 |
- <div> |
|
39 |
- <span id="commiter"></span> | <span id="commitDate"></span> | <span id="commitMessage"></span> |
|
40 |
- <span class="pull-right"><a id="rawCode" class="btn btn-mini" target="_blank">Raw</a></span> |
|
41 |
- </div> |
|
42 |
- <hr /> |
|
43 |
- <div> |
|
44 |
- <pre><code style="overflow:hidden"></code></pre> |
|
45 |
- </div> |
|
46 |
- </div> |
|
47 |
- |
|
22 |
+ <div id="folderView"> |
|
23 |
+ <table class="table table-bordered"> |
|
24 |
+ <thead> |
|
25 |
+ <tr> |
|
26 |
+ <th>FileName</th> |
|
27 |
+ <th>Commit Message</th> |
|
28 |
+ <th>Commit Date</th> |
|
29 |
+ <th>Author</th> |
|
30 |
+ </tr> |
|
31 |
+ </thead> |
|
32 |
+ <tbody> |
|
33 |
+ </tbody> |
|
34 |
+ </table> |
|
48 | 35 |
</div> |
49 |
- |
|
36 |
+ <div id="codeView" class="hide"> |
|
37 |
+ <div> |
|
38 |
+ <span id="commiter"></span> | <span id="commitDate"></span> | <span id="commitMessage"></span> <span |
|
39 |
+ class="pull-right"><a id="rawCode" class="btn btn-mini" target="_blank">Raw</a></span> |
|
40 |
+ </div> |
|
41 |
+ <hr /> |
|
42 |
+ <div> |
|
43 |
+ <pre> |
|
44 |
+ <code style="overflow: hidden"></code> |
|
45 |
+ </pre> |
|
46 |
+ </div> |
|
47 |
+ </div> |
|
48 |
+ </div> |
|
50 | 49 |
</div> |
51 | 50 |
<div id="codeError" class="hide row"> |
52 |
- <div class="well span12"> |
|
53 |
- <p>HEAD커밋이 존재하지 않습니다. 다음과 같은 방법을 시도해 보세요</p> |
|
54 |
- <pre><code>git clone @url |
|
51 |
+ <div class="well span12"> |
|
52 |
+ <p>HEAD커밋이 존재하지 않습니다. 다음과 같은 방법을 시도해 보세요</p> |
|
53 |
+ <pre> |
|
54 |
+ <code>git clone @url |
|
55 | 55 |
touch readme.md |
56 | 56 |
git add readme.md |
57 | 57 |
git commit -m "init" |
58 |
-git push origin master</code></pre> |
|
59 |
- </div> |
|
58 |
+git push origin master</code> |
|
59 |
+ </pre> |
|
60 |
+ </div> |
|
60 | 61 |
</div> |
61 | 62 |
<script type="text/javascript" src="/assets/javascripts/hljs.js"></script> |
62 | 63 |
<script type="text/javascript" src="/assets/javascripts/hljs.jquery.js"></script> |
--- app/views/task/cardView.scala.html
+++ app/views/task/cardView.scala.html
... | ... | @@ -1,3 +1,5 @@ |
1 |
+@(project:Project) |
|
2 |
+ |
|
1 | 3 |
<!-- 실제로 이것들은 미리 로딩되어 있음 --> |
2 | 4 |
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script> |
3 | 5 |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script> |
... | ... | @@ -63,145 +65,11 @@ |
63 | 65 |
</form> |
64 | 66 |
</div> |
65 | 67 |
</div> |
68 |
+<script src="/assets/javascripts/CardView.js"></script> |
|
66 | 69 |
<script> |
67 |
- //웹소켓은 그야말로 클라 노티에만 쓰고 노티오면 다시 리로딩. |
|
68 |
- //taskBoard는 완전히 따로 생각한다. 리로딩시 문제는 없음. |
|
69 |
- var cardLoad; |
|
70 |
- $(function() { |
|
71 |
- //angular! |
|
72 |
- var cardapp = angular.module('cardApp', [ 'ui' ]); |
|
73 |
- function CardCtrl($scope) { |
|
74 |
- $scope.card; //model |
|
75 |
- $scope.board = {}; |
|
76 |
- $scope.input = { |
|
77 |
- comment : "" |
|
78 |
- }; |
|
79 |
- cardLoad = function(id) { |
|
80 |
- $.ajax("c/" + id, { |
|
81 |
- dataType : "json", |
|
82 |
- success : function(data) { |
|
83 |
- $scope.card = data; |
|
84 |
- $scope.$apply(); |
|
85 |
- adjust(); |
|
86 |
- } |
|
87 |
- }); |
|
88 |
- } |
|
89 |
- $.ajax("member", { |
|
90 |
- success : function(data) { |
|
91 |
- $scope.board.members = data; |
|
92 |
- adjust(); |
|
93 |
- } |
|
94 |
- }); |
|
95 |
- function adjust() { |
|
96 |
- if ($scope.card && $scope.board && $scope.board.members) { |
|
97 |
- var assignee = $scope.card.assignee; |
|
98 |
- var members = $scope.board.members; |
|
99 |
- for ( var i = 0; i < members.length; i++) { |
|
100 |
- members[i].assigned = false; |
|
101 |
- for ( var j = 0; j < assignee.length; j++) { |
|
102 |
- if (members[i]._id == assignee[j]._id) { |
|
103 |
- members[i].assigned = true; |
|
104 |
- assignee[j] = members[i]; |
|
105 |
- } |
|
106 |
- } |
|
107 |
- } |
|
108 |
- $scope.$apply(); |
|
109 |
- } |
|
110 |
- if ($scope.card && $scope.board && $scope.board.labels) { |
|
111 |
- var cardLabels = $scope.card.labels; |
|
112 |
- var boardLabels = $scope.board.labels; |
|
113 |
- for ( var i = 0; i < boardLabels.length; i++) { |
|
114 |
- boardLabels[i].state = false; |
|
115 |
- for ( var j = 0; j < cardLabels.length; j++) { |
|
116 |
- if (cardLabels[j]._id == boardLabels[i]._id) { |
|
117 |
- boardLabels[i].state = true; |
|
118 |
- } |
|
119 |
- } |
|
120 |
- } |
|
121 |
- } |
|
122 |
- $scope.$apply() |
|
123 |
- } |
|
124 |
- $.ajax("labels", { |
|
125 |
- success : function(data) { |
|
126 |
- $scope.board.labels = data; |
|
127 |
- adjust(); |
|
128 |
- }, |
|
129 |
- dataType : "json" |
|
130 |
- }); |
|
131 |
- //inti function end |
|
132 |
- $scope.addComment = function() { |
|
133 |
- $scope.card.comments.push($scope.input.comment); |
|
134 |
- server.addComment($scope.card._id, $scope.input.comment); |
|
135 |
- $scope.input.comment = ""; |
|
136 |
- |
|
137 |
- } |
|
138 |
- $scope.saveCard = function() { |
|
139 |
- $scope.card.labels = []; |
|
140 |
- for ( var i = 0; i < $scope.board.labels.length; i++) { |
|
141 |
- if ($scope.board.labels[i].state == true) { |
|
142 |
- $scope.card.labels.push($scope.board.labels[i]); |
|
143 |
- } |
|
144 |
- } |
|
145 |
- server.saveCard($scope.card); |
|
146 |
- console.log($scope.card); |
|
147 |
- } |
|
148 |
- $scope.showMemberList = function() { |
|
149 |
- $scope.input.assign = !$scope.input.assign; |
|
150 |
- } |
|
151 |
- $scope.makeCheckList = function(){ |
|
152 |
- $scope.card.checklist = { |
|
153 |
- items : [], |
|
154 |
- title : "TODO" |
|
155 |
- }; |
|
156 |
- } |
|
157 |
- $scope.addChecklist = function() { |
|
158 |
- $scope.card.checklist.items.push({ |
|
159 |
- body : $scope.input.checklist, |
|
160 |
- state : false |
|
161 |
- }); |
|
162 |
- $scope.input.checklist = ""; |
|
163 |
- $scope.saveCard(); |
|
164 |
- } |
|
165 |
- $scope.checkItem = function(item) { |
|
166 |
- $scope.saveCard(); |
|
167 |
- } |
|
168 |
- $scope.assign = function(member) { |
|
169 |
- if (member.assigned) { |
|
170 |
- $scope.card.assignee.push(member); |
|
171 |
- } else { |
|
172 |
- $scope.card.assignee = _.without($scope.card.assignee, member); |
|
173 |
- } |
|
174 |
- $scope.saveCard(); |
|
175 |
- } |
|
176 |
- cardLoad(1);// for TEST |
|
177 |
- } |
|
178 |
- cardapp.controller('CardCtrl', CardCtrl);//여기는 실제함수와 어트리뷰트간의 관계맺기 |
|
179 |
- angular.bootstrap(document, [ 'cardApp' ]); |
|
180 |
- |
|
181 |
- var server = {}; |
|
182 |
- server.addComment = function(_id, str) { |
|
183 |
- $.ajax("comment", { |
|
184 |
- type : "POST", |
|
185 |
- data : { |
|
186 |
- body : str, |
|
187 |
- _id : _id |
|
188 |
- }, |
|
189 |
- success : function(data) { |
|
190 |
- cardLoad(_id); |
|
191 |
- } |
|
192 |
- }); |
|
193 |
- }; |
|
194 |
- server.saveCard = function(card, callback) { |
|
195 |
- //서버로 카드 전체를 보내서 저장합니다. |
|
196 |
- $.ajax("card", { |
|
197 |
- type : "post", |
|
198 |
- data : JSON.stringify(card), |
|
199 |
- contentType : "text/json", |
|
200 |
- success : function(data) { |
|
201 |
- if (callback) |
|
202 |
- callback(); |
|
203 |
- } |
|
204 |
- }); |
|
205 |
- } |
|
206 |
- }); |
|
70 |
+$(document).ready(function(){ |
|
71 |
+ initCardView("/@project.owner/@project.name/task/"); |
|
72 |
+ cardLoad(1);// for TEST |
|
73 |
+}) |
|
207 | 74 |
</script> |
75 |
+ |
--- app/views/task/taskView.scala.html
+++ app/views/task/taskView.scala.html
... | ... | @@ -1,129 +1,142 @@ |
1 |
-@(project:Project) |
|
1 |
+@(project:Project) @main("TaskManager", project){ |
|
2 |
+<h1>TaskManager</h1> |
|
3 |
+<style> |
|
4 |
+section.line { |
|
5 |
+ width: 150px; |
|
6 |
+ float: left; |
|
7 |
+ border: 2px solid #666666; |
|
8 |
+ background: #fafafa; |
|
9 |
+ margin-right: 5px; |
|
10 |
+ border-radius: 5px; |
|
11 |
+ text-align: center; |
|
12 |
+ cursor: move; |
|
13 |
+} |
|
2 | 14 |
|
3 |
-@main("TaskManager", project){ |
|
4 |
- |
|
5 |
- <h1>TaskManager</h1> |
|
6 |
- <style> |
|
7 |
- section.line { |
|
8 |
- width : 150px; |
|
9 |
- float : left; |
|
10 |
- border : 2px solid #666666; |
|
11 |
- background : #fafafa; |
|
12 |
- margin-right : 5px; |
|
13 |
- border-radius : 5px; |
|
14 |
- text-align : center; |
|
15 |
- cursor : move; |
|
16 |
- } |
|
17 |
- section.line header { |
|
18 |
- padding : 5px; |
|
19 |
- background-color : #dadada; |
|
20 |
- border-top-left-radius : 5px; |
|
21 |
- border-top-right-radius : 5px; |
|
22 |
- } |
|
23 |
- article.card { |
|
24 |
- background : #b9a; |
|
25 |
- margin : 4px; |
|
26 |
- border-radius : 3px; |
|
27 |
- border : 1px solid gray; |
|
28 |
- min-height : 20px; |
|
29 |
- } |
|
30 |
- .cardlist { |
|
31 |
- border: 2px solid #f1f1f1; |
|
32 |
- background: #f1f1f1; |
|
33 |
- } |
|
34 |
- .over { |
|
35 |
- border: 2px dashed #000; |
|
36 |
- } |
|
37 |
- |
|
38 |
- .dragTargetCard{ |
|
39 |
- background-color: dadada; |
|
40 |
- color: dadada; |
|
41 |
- } |
|
42 |
- .blank{ |
|
43 |
- min-height: 3px; |
|
44 |
- } |
|
45 |
- .overBlank{ |
|
46 |
- min-height: 25px; |
|
47 |
- background-color: #ddd; |
|
48 |
- } |
|
49 |
- .fade{ |
|
50 |
- background : #333; |
|
51 |
- } |
|
52 |
- </style> |
|
53 |
- <div ng-controller="controller"> |
|
54 |
- <section ng-repeat="line in lines" class="line"> |
|
55 |
- <header>{{line.title}}</header> |
|
56 |
- <div class="cardlist" id="cardlist_{{line._id}}" > |
|
15 |
+section.line header { |
|
16 |
+ padding: 5px; |
|
17 |
+ background-color: #dadada; |
|
18 |
+ border-top-left-radius: 5px; |
|
19 |
+ border-top-right-radius: 5px; |
|
20 |
+} |
|
21 |
+ |
|
22 |
+article.card { |
|
23 |
+ background: #b9a; |
|
24 |
+ margin: 4px; |
|
25 |
+ border-radius: 3px; |
|
26 |
+ border: 1px solid gray; |
|
27 |
+ min-height: 20px; |
|
28 |
+} |
|
29 |
+ |
|
30 |
+.cardlist { |
|
31 |
+ border: 2px solid #f1f1f1; |
|
32 |
+ background: #f1f1f1; |
|
33 |
+} |
|
34 |
+ |
|
35 |
+.over { |
|
36 |
+ border: 2px dashed #000; |
|
37 |
+} |
|
38 |
+ |
|
39 |
+.dragTargetCard { |
|
40 |
+ background-color: dadada; |
|
41 |
+ color: dadada; |
|
42 |
+} |
|
43 |
+ |
|
44 |
+.blank { |
|
45 |
+ min-height: 3px; |
|
46 |
+} |
|
47 |
+ |
|
48 |
+.overBlank { |
|
49 |
+ min-height: 25px; |
|
50 |
+ background-color: #ddd; |
|
51 |
+} |
|
52 |
+ |
|
53 |
+.fade { |
|
54 |
+ background: #333; |
|
55 |
+} |
|
56 |
+</style> |
|
57 |
+<div ng-controller="controller"> |
|
58 |
+ <section ng-repeat="line in lines" class="line"> |
|
59 |
+ <header>{{line.title}}</header> |
|
60 |
+ <div class="cardlist" id="cardlist_{{line._id}}"> |
|
61 |
+ <article class="blank"></article> |
|
62 |
+ <div ng-repeat="card in line.cards"> |
|
63 |
+ <article class="card" draggable="true" ui-event="{'dragstart': 'onDragStart(line, card)'}"> |
|
64 |
+ {{card.title}}</article> |
|
57 | 65 |
<article class="blank"></article> |
58 |
- <div ng-repeat="card in line.cards" > |
|
59 |
- <article class="card" draggable="true" ui-event="{'dragstart': 'onDragStart(line, card)'}" > |
|
60 |
- {{card.title}} |
|
61 |
- </article> |
|
62 |
- <article class="blank"></article> |
|
63 |
- </div> |
|
64 | 66 |
</div> |
65 |
- <article> |
|
66 |
- <button ng-hide="newCard && newCard.targetLine == line" ng-click="showCardInput(line)">new Card</button> |
|
67 |
- <form ng-submit="addCard(line)" ng-show="newCard && newCard.targetLine == line"> |
|
68 |
- <textarea ng-model="newCard.title"></textarea> |
|
69 |
- <input type="submit" value="add"/> |
|
70 |
- </form> |
|
71 |
- </article> |
|
72 |
- </section> |
|
73 |
- <section> |
|
67 |
+ </div> |
|
68 |
+ <article> |
|
69 |
+ <button ng-hide="newCard && newCard.targetLine == line" ng-click="showCardInput(line)">new Card</button> |
|
70 |
+ <form ng-submit="addCard(line)" ng-show="newCard && newCard.targetLine == line"> |
|
71 |
+ <textarea ng-model="newCard.title"></textarea> |
|
72 |
+ <input type="submit" value="add" /> |
|
73 |
+ </form> |
|
74 |
+ </article> |
|
75 |
+ </section> |
|
76 |
+ <section style="float: right"> |
|
77 |
+ <fieldset> |
|
78 |
+ <legend>label List</legend> |
|
74 | 79 |
<article id="lables" ng-repeat="label in labels"> |
75 | 80 |
<span>{{label.name}}</span> |
76 | 81 |
</article> |
77 |
- <aritcle ng-repeat="member in members"> |
|
78 |
- <span>{{member.loginId}}</span> |
|
79 |
- </aritcle> |
|
80 |
- </section> |
|
81 |
- </div> |
|
82 |
- <script> |
|
83 |
- $(function(){ |
|
84 |
- var myapp = angular.module('myapp', ['ui']); |
|
85 |
- var TaskCtrl = function($scope){ |
|
82 |
+ </fieldset> |
|
83 |
+ <fieldset> |
|
84 |
+ <legend>memberList</legend> |
|
85 |
+ <aritcle ng-repeat="member in members"> <span>{{member.loginId}}</span> </aritcle> |
|
86 |
+ </fieldset> |
|
87 |
+ </section> |
|
88 |
+</div> |
|
89 |
+<script> |
|
90 |
+ $(function() { |
|
91 |
+ var myapp = angular.module('myapp', [ 'ui' ]); |
|
92 |
+ var TaskCtrl = function($scope) { |
|
86 | 93 |
var dragStart = {}; |
87 |
- var webSocket = new WebSocket("ws://" +location.host + location.pathname + "/connect"); |
|
88 |
- webSocket.onmessage = function(e){ |
|
94 |
+ var webSocket = new WebSocket("ws://" + location.host + location.pathname |
|
95 |
+ + "/connect"); |
|
96 |
+ webSocket.onmessage = function(e) { |
|
89 | 97 |
$scope.lines = JSON.parse(e.data); |
90 | 98 |
$scope.$apply(); |
91 | 99 |
} |
92 |
- webSocket.onopen = function(){ |
|
100 |
+ webSocket.onopen = function() { |
|
93 | 101 |
console.log("socket Open!"); |
94 | 102 |
} |
95 |
- webSocket.onclose = function(){ |
|
103 |
+ webSocket.onclose = function() { |
|
96 | 104 |
console.log("disconnected!"); |
97 | 105 |
console.log("trying to reconnect..."); |
98 | 106 |
console.log("unimplement"); |
99 | 107 |
} |
100 |
- $scope.showCardInput = function(line){ |
|
101 |
- $scope.newCard = {targetLine : line}; |
|
108 |
+ $scope.showCardInput = function(line) { |
|
109 |
+ $scope.newCard = { |
|
110 |
+ targetLine : line |
|
111 |
+ }; |
|
102 | 112 |
}; |
103 |
- $scope.addCard = function(line){ |
|
113 |
+ $scope.addCard = function(line) { |
|
104 | 114 |
$.ajax("task/newCard", { |
105 |
- success : function(data){ |
|
115 |
+ success : function(data) { |
|
106 | 116 |
$scope.newCard.title = ""; |
107 |
- line.cards.push(data); |
|
117 |
+ line.cards.push(data); |
|
108 | 118 |
$scope.$apply(); |
109 | 119 |
}, |
110 | 120 |
contentType : "text/json", |
111 | 121 |
dataType : "json", |
112 |
- data : JSON.stringify({line_id : line._id, card_data : $scope.newCard.title}), |
|
122 |
+ data : JSON.stringify({ |
|
123 |
+ line_id : line._id, |
|
124 |
+ card_data : $scope.newCard.title |
|
125 |
+ }), |
|
113 | 126 |
type : "POST" |
114 | 127 |
}); |
115 | 128 |
return false; |
116 | 129 |
} |
117 | 130 |
|
118 | 131 |
$.ajax("task/labels", { |
119 |
- success : function(data){ |
|
132 |
+ success : function(data) { |
|
120 | 133 |
$scope.labels = data; |
121 | 134 |
}, |
122 | 135 |
dataType : "json" |
123 | 136 |
}); |
124 | 137 |
|
125 | 138 |
$.ajax("task/member", { |
126 |
- success: function(data){ |
|
139 |
+ success : function(data) { |
|
127 | 140 |
$scope.members = data; |
128 | 141 |
} |
129 | 142 |
}); |
... | ... | @@ -135,21 +148,23 @@ |
135 | 148 |
$event.preventDefault(); |
136 | 149 |
}; |
137 | 150 |
$scope.onDrop = function($event, targetLine) { |
138 |
- if (dragStart === null ) return; |
|
139 |
- if( targetLine._id !== dragStart.line._id){ |
|
140 |
- if (dragStart !== null ) { |
|
151 |
+ if (dragStart === null) |
|
152 |
+ return; |
|
153 |
+ if (targetLine._id !== dragStart.line._id) { |
|
154 |
+ if (dragStart !== null) { |
|
141 | 155 |
targetLine.cards.push(dragStart.card); |
142 |
- dragStart.line.cards = _.without(dragStart.line.cards, dragStart.card); |
|
156 |
+ dragStart.line.cards = _.without(dragStart.line.cards, |
|
157 |
+ dragStart.card); |
|
143 | 158 |
} |
144 | 159 |
} |
145 | 160 |
webSocket.send(JSON.stringify($scope.lines)); |
146 | 161 |
}; |
147 | 162 |
$scope.onDragStart = function(currentLine, currentCard) { |
148 |
- dragStart = { |
|
149 |
- line: currentLine, |
|
150 |
- card: currentCard, |
|
151 |
- idx: _.indexOf(currentLine.cards, currentCard) |
|
152 |
- }; |
|
163 |
+ dragStart = { |
|
164 |
+ line : currentLine, |
|
165 |
+ card : currentCard, |
|
166 |
+ idx : _.indexOf(currentLine.cards, currentCard) |
|
167 |
+ }; |
|
153 | 168 |
}; |
154 | 169 |
|
155 | 170 |
$scope.onDragOverBlank = function($event) { |
... | ... | @@ -159,53 +174,62 @@ |
159 | 174 |
$event.preventDefault(); |
160 | 175 |
}; |
161 | 176 |
$scope.onDropBlank = function($event, targetLine, targetCard) { |
162 |
- if (dragStart === null ) return; |
|
177 |
+ if (dragStart === null) |
|
178 |
+ return; |
|
163 | 179 |
var prvIdx = null; |
164 |
- if( targetLine._id == dragStart.line._id){ |
|
180 |
+ if (targetLine._id == dragStart.line._id) { |
|
165 | 181 |
targetLine.cards.splice(dragStart.idx, 1); |
166 | 182 |
} else { |
167 |
- dragStart.line.cards = _.without(dragStart.line.cards, dragStart.card); |
|
183 |
+ dragStart.line.cards = _ |
|
184 |
+ .without(dragStart.line.cards, dragStart.card); |
|
168 | 185 |
} |
169 |
- targetLine.cards.splice(_.indexOf(targetLine.cards, targetCard)+1, 0, dragStart.card); |
|
186 |
+ targetLine.cards.splice(_.indexOf(targetLine.cards, targetCard) + 1, 0, |
|
187 |
+ dragStart.card); |
|
170 | 188 |
dragStart = null; |
171 | 189 |
webSocket.send(JSON.stringify($scope.lines)); |
172 | 190 |
}; |
173 | 191 |
}; |
174 | 192 |
myapp.controller('controller', TaskCtrl); |
175 |
- angular.bootstrap(document, ['myapp']); |
|
193 |
+ angular.bootstrap(document, [ 'myapp' ]); |
|
176 | 194 |
}); |
177 |
- (function(){ |
|
178 |
- $(".cardlist").live("drop", function(e){ |
|
179 |
- if (e.stopPropagation) e.stopPropagation(); |
|
195 |
+ (function() { |
|
196 |
+ $(".cardlist").live("drop", function(e) { |
|
197 |
+ if (e.stopPropagation) |
|
198 |
+ e.stopPropagation(); |
|
180 | 199 |
e.preventDefault(); |
181 | 200 |
}); |
182 | 201 |
|
183 |
- $(".cardlist") |
|
184 |
- .live("dragover", function(e){ |
|
185 |
- $(this).addClass("over"); |
|
186 |
- return e.preventDefault(); |
|
187 |
- }) |
|
188 |
- .live("drop dragleave", function(e){ |
|
189 |
- $(this).removeClass("over"); |
|
190 |
- }); |
|
191 |
- $(".card").live("dragstart", function(e){ |
|
202 |
+ $(".cardlist").live("dragover", function(e) { |
|
203 |
+ $(this).addClass("over"); |
|
204 |
+ return e.preventDefault(); |
|
205 |
+ }).live("drop dragleave", function(e) { |
|
206 |
+ $(this).removeClass("over"); |
|
207 |
+ }); |
|
208 |
+ $(".card").live("dragstart", function(e) { |
|
192 | 209 |
}); |
193 | 210 |
|
211 |
+ $(".blank").live("dragover", function(e) { |
|
212 |
+ $(this).addClass("overBlank"); |
|
213 |
+ return e.preventDefault(); |
|
214 |
+ }).live("drop dragleave", function(e) { |
|
215 |
+ $(this).removeClass("overBlank"); |
|
216 |
+ }); |
|
217 |
+ $(".cardlist") |
|
218 |
+ .attr( |
|
219 |
+ "ui-event", |
|
220 |
+ "{dragover: 'onDragOver($event)', dragleave: 'onDragLeave($event)', drop: 'onDrop($event, line)'}"); |
|
194 | 221 |
$(".blank") |
195 |
- .live("dragover", function(e){ |
|
196 |
- $(this).addClass("overBlank"); |
|
197 |
- return e.preventDefault(); |
|
198 |
- }) |
|
199 |
- .live("drop dragleave", function(e){ |
|
200 |
- $(this).removeClass("overBlank"); |
|
201 |
- }); |
|
202 |
- $(".cardlist").attr("ui-event", "{dragover: 'onDragOver($event)', dragleave: 'onDragLeave($event)', drop: 'onDrop($event, line)'}"); |
|
203 |
- $(".blank").attr("ui-event", "{dragover: 'onDragOverBlank($event)', dragleave: 'onDragLeaveBlank($event)', drop: 'onDropBlank($event, line, card)'}"); |
|
222 |
+ .attr( |
|
223 |
+ "ui-event", |
|
224 |
+ "{dragover: 'onDragOverBlank($event)', dragleave: 'onDragLeaveBlank($event)', drop: 'onDropBlank($event, line, card)'}"); |
|
204 | 225 |
})(); |
205 |
- </script> |
|
206 |
- <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script> |
|
207 |
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script> |
|
208 |
- <script type="text/javascript" src="http://underscorejs.org/underscore.js"></script> |
|
209 |
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js"></script> |
|
210 |
- <script type="text/javascript" src="https://raw.github.com/angular-ui/angular-ui/master/build/angular-ui.min.js"></script> |
|
226 |
+ |
|
227 |
+ //=============================== |
|
228 |
+ var URL_PREFIX = "/@project.owner/@project.name/task/"; |
|
229 |
+</script> |
|
230 |
+<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script> |
|
231 |
+<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script> |
|
232 |
+<script type="text/javascript" src="http://underscorejs.org/underscore.js"></script> |
|
233 |
+<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js"></script> |
|
234 |
+<script type="text/javascript" src="https://raw.github.com/angular-ui/angular-ui/master/build/angular-ui.min.js"></script> |
|
211 | 235 |
} |
+++ public/javascripts/CardView.js
... | ... | @@ -0,0 +1,141 @@ |
1 | +var cardLoad; | |
2 | +(function() { | |
3 | + //angular! | |
4 | + var URL_PREFIX = ""; | |
5 | + var cardapp = angular.module('cardApp', [ 'ui' ]); | |
6 | + function CardCtrl($scope) { | |
7 | + $scope.card; //model | |
8 | + $scope.board = {}; | |
9 | + $scope.input = { | |
10 | + comment : "" | |
11 | + }; | |
12 | + cardLoad = function(id) { | |
13 | + $.ajax(URL_PREFIX + "c/" + id, { | |
14 | + dataType : "json", | |
15 | + success : function(data) { | |
16 | + $scope.card = data; | |
17 | + $scope.$apply(); | |
18 | + adjust(); | |
19 | + } | |
20 | + }); | |
21 | + } | |
22 | + $.ajax(URL_PREFIX + "member", { | |
23 | + success : function(data) { | |
24 | + $scope.board.members = data; | |
25 | + adjust(); | |
26 | + } | |
27 | + }); | |
28 | + $.ajax(URL_PREFIX + "labels", { | |
29 | + success : function(data) { | |
30 | + $scope.board.labels = data; | |
31 | + adjust(); | |
32 | + }, | |
33 | + dataType : "json" | |
34 | + }); | |
35 | + function adjust() { | |
36 | + if ($scope.card && $scope.board && $scope.board.members) { | |
37 | + var assignee = $scope.card.assignee; | |
38 | + var members = $scope.board.members; | |
39 | + for ( var i = 0; i < members.length; i++) { | |
40 | + members[i].assigned = false; | |
41 | + for ( var j = 0; j < assignee.length; j++) { | |
42 | + if (members[i]._id == assignee[j]._id) { | |
43 | + members[i].assigned = true; | |
44 | + assignee[j] = members[i]; | |
45 | + } | |
46 | + } | |
47 | + } | |
48 | + $scope.$apply(); | |
49 | + } | |
50 | + if ($scope.card && $scope.board && $scope.board.labels) { | |
51 | + var cardLabels = $scope.card.labels; | |
52 | + var boardLabels = $scope.board.labels; | |
53 | + for ( var i = 0; i < boardLabels.length; i++) { | |
54 | + boardLabels[i].state = false; | |
55 | + for ( var j = 0; j < cardLabels.length; j++) { | |
56 | + if (cardLabels[j]._id == boardLabels[i]._id) { | |
57 | + boardLabels[i].state = true; | |
58 | + } | |
59 | + } | |
60 | + } | |
61 | + } | |
62 | + $scope.$apply() | |
63 | + } | |
64 | + //inti function end | |
65 | + $scope.addComment = function() { | |
66 | + $scope.card.comments.push($scope.input.comment); | |
67 | + server.addComment($scope.card._id, $scope.input.comment); | |
68 | + $scope.input.comment = ""; | |
69 | + | |
70 | + } | |
71 | + $scope.saveCard = function() { | |
72 | + $scope.card.labels = []; | |
73 | + for ( var i = 0; i < $scope.board.labels.length; i++) { | |
74 | + if ($scope.board.labels[i].state == true) { | |
75 | + $scope.card.labels.push($scope.board.labels[i]); | |
76 | + } | |
77 | + } | |
78 | + server.saveCard($scope.card); | |
79 | + console.log($scope.card); | |
80 | + } | |
81 | + $scope.showMemberList = function() { | |
82 | + $scope.input.assign = !$scope.input.assign; | |
83 | + } | |
84 | + $scope.makeCheckList = function() { | |
85 | + $scope.card.checklist = { | |
86 | + items : [], | |
87 | + title : "TODO" | |
88 | + }; | |
89 | + } | |
90 | + $scope.addChecklist = function() { | |
91 | + $scope.card.checklist.items.push({ | |
92 | + body : $scope.input.checklist, | |
93 | + state : false | |
94 | + }); | |
95 | + $scope.input.checklist = ""; | |
96 | + $scope.saveCard(); | |
97 | + } | |
98 | + $scope.checkItem = function(item) { | |
99 | + $scope.saveCard(); | |
100 | + } | |
101 | + $scope.assign = function(member) { | |
102 | + if (member.assigned) { | |
103 | + $scope.card.assignee.push(member); | |
104 | + } else { | |
105 | + $scope.card.assignee = _.without($scope.card.assignee, member); | |
106 | + } | |
107 | + $scope.saveCard(); | |
108 | + } | |
109 | + } | |
110 | + | |
111 | + window.initCardView = function(url){ | |
112 | + URL_PREFIX = url; | |
113 | + cardapp.controller('CardCtrl', CardCtrl);//여기는 실제함수와 어트리뷰트간의 관계맺기 | |
114 | + angular.bootstrap(document, [ 'cardApp' ]); | |
115 | + } | |
116 | + var server = {}; | |
117 | + server.addComment = function(_id, str) { | |
118 | + $.ajax(URL_PREFIX + "comment", { | |
119 | + type : "POST", | |
120 | + data : { | |
121 | + body : str, | |
122 | + _id : _id | |
123 | + }, | |
124 | + success : function(data) { | |
125 | + cardLoad(_id); | |
126 | + } | |
127 | + }); | |
128 | + }; | |
129 | + server.saveCard = function(card, callback) { | |
130 | + //서버로 카드 전체를 보내서 저장합니다. | |
131 | + $.ajax(URL_PREFIX + "card", { | |
132 | + type : "post", | |
133 | + data : JSON.stringify(card), | |
134 | + contentType : "text/json", | |
135 | + success : function(data) { | |
136 | + if (callback) | |
137 | + callback(); | |
138 | + } | |
139 | + }); | |
140 | + } | |
141 | +})(); |
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?