Commit 66e432911c89fab7d12066babc287a4f1a60625c
1 parent
33dce699
Voir le code source des messages
Showing
8 changed files
with
59 additions
and
12 deletions
Show diff stats
app/routes/ApiRtes.js
... | ... | @@ -91,12 +91,13 @@ sessionData = function (session, cb) { |
91 | 91 | // Permissions |
92 | 92 | session.canAddMembre = session.bureau; |
93 | 93 | session.canDelMembre = session.bureau; |
94 | + session.canAddDoss = session.bureau; | |
95 | + session.canDelDoss = session.bureau; | |
94 | 96 | session.canAddConv = true; |
95 | 97 | session.canDelConv = session.bureau; |
96 | 98 | session.canAddMess = true; |
99 | + session.canEditMess = false; | |
97 | 100 | session.canDelMess = session.bureau; |
98 | - session.canAddDoss = session.bureau; | |
99 | - session.canDelDoss = session.bureau; | |
100 | 101 | cb(session); |
101 | 102 | }); |
102 | 103 | }); | ... | ... |
public/css/style.css
... | ... | @@ -36,6 +36,16 @@ body { |
36 | 36 | animation: zoomOut 0.5s; |
37 | 37 | } |
38 | 38 | |
39 | +[mess-edit] .ng-enter { | |
40 | + -webkit-animation: flipInY 0.5s; | |
41 | + animation: flipInY 0.5s; | |
42 | +} | |
43 | + | |
44 | +[mess-edit] .ng-leave { | |
45 | + -webkit-animation: flipOutY 0.5s; | |
46 | + animation: flipOutY 0.5s; | |
47 | +} | |
48 | + | |
39 | 49 | body > .container { |
40 | 50 | position: relative; |
41 | 51 | } | ... | ... |
public/js/controllers/ForumConvCtrl.js
1 | -angular.module('ForumConvCtrl', ['SessionsServ', 'ApiServ', 'ngSanitize', 'btford.markdown']) | |
1 | +angular.module('ForumConvCtrl', ['SessionsServ', 'ApiServ', 'MessEditDrct']) | |
2 | 2 | .controller('ForumConvCtrl', function ($scope, $routeParams, SessionServ, ApiServ) { |
3 | 3 | $scope.messs = []; |
4 | 4 | $scope.conv = {}; |
... | ... | @@ -20,8 +20,10 @@ angular.module('ForumConvCtrl', ['SessionsServ', 'ApiServ', 'ngSanitize', 'btfor |
20 | 20 | }); |
21 | 21 | |
22 | 22 | $scope.addMess = function () { |
23 | - data = $scope.formData; | |
24 | - data.conv = $scope.conv._id; | |
23 | + data = { | |
24 | + content: $scope.mess.content, | |
25 | + conv: $scope.conv._id | |
26 | + }; | |
25 | 27 | ApiServ("envoi du message", 'post', 'messs', data, function (err, mess) { |
26 | 28 | if (!err) { |
27 | 29 | $scope.formData = {}; |
... | ... | @@ -37,4 +39,15 @@ angular.module('ForumConvCtrl', ['SessionsServ', 'ApiServ', 'ngSanitize', 'btfor |
37 | 39 | }); |
38 | 40 | }; |
39 | 41 | |
42 | + $scope.editButton = function (index) { | |
43 | + mess = $scope.messs[index]; | |
44 | + if (mess.editMode) { | |
45 | + mess.viewSource = false; | |
46 | + console.log('Submit edition'); | |
47 | + } else { | |
48 | + mess.viewSource = true; | |
49 | + } | |
50 | + mess.editMode = !mess.editMode; | |
51 | + }; | |
52 | + | |
40 | 53 | }); | ... | ... |
... | ... | @@ -0,0 +1,11 @@ |
1 | +angular.module('MessEditDrct', ['ngSanitize', 'btford.markdown']) | |
2 | + .directive('messEdit', function () { | |
3 | + return { | |
4 | + templateUrl: 'views/messEdit.html' | |
5 | + }; | |
6 | + }) | |
7 | + .directive('messViewsource', function () { | |
8 | + return { | |
9 | + templateUrl: 'views/messViewsource.html' | |
10 | + }; | |
11 | + }); | ... | ... |
public/views/forumConv.html
... | ... | @@ -24,24 +24,28 @@ |
24 | 24 | <br/> {{ mess.auteur.role }} |
25 | 25 | <br/> {{ doss.date }} |
26 | 26 | </td> |
27 | - <td btf-markdown="mess.content"> | |
28 | - </td> | |
27 | + <!-- <td btf-markdown="mess.content"></td> --> | |
28 | + <td mess-edit></td> | |
29 | 29 | <td> |
30 | + <mess-viewsource></mess-viewsource> | |
31 | + <button type="button" class="btn btn-primary" ng-show="session.canEditMess" ng-click="editButton($index)"> | |
32 | + <span class="glyphicon glyphicon-edit" aria-hidden="true" ng-hide="mess.editMode"></span> | |
33 | + <span class="glyphicon glyphicon-ok" aria-hidden="true" ng-show="mess.editMode"></span> | |
34 | + </button> | |
30 | 35 | <button type="button" class="btn btn-danger" ng-show="session.canDelMess" ng-click="delMess($index)"> |
31 | 36 | <span class="glyphicon glyphicon-remove" aria-hidden="true"></span> |
32 | 37 | </button> |
33 | 38 | </td> |
34 | 39 | </tr> |
35 | 40 | <tr ng-show="session.canAddMess"> |
36 | - <form> | |
41 | + <form ng-init="mess = {content: '', editMode: true, viewSource: true}"> | |
37 | 42 | <td> |
38 | 43 | <label for="nvMessTitre">Nouveau message</label> |
39 | 44 | </td> |
40 | - <td class="form-group"> | |
41 | - <textarea class="form-control" id="nvMessTitre" rows="7" placeholder="Contenu du message" ng-model="formData.content"></textarea> | |
42 | - </td> | |
45 | + <td mess-edit></td> | |
43 | 46 | <td> |
44 | - <button type="submit" class="btn btn-primary" ng-class="{disabled: !formData.content}" ng-click="addMess()"> | |
47 | + <mess-viewsource></mess-viewsource> | |
48 | + <button type="submit" class="btn btn-primary" ng-class="{disabled: !mess.content}" ng-click="addMess()"> | |
45 | 49 | <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> |
46 | 50 | </button> |
47 | 51 | </td> | ... | ... |
public/views/index.html
... | ... | @@ -27,6 +27,7 @@ |
27 | 27 | <script src="js/services/ApiServ.js"></script> |
28 | 28 | <script src="js/services/EncryptServ.js"></script> |
29 | 29 | <script src="js/services/SessionServ.js"></script> |
30 | + <script src="js/directives/MessEditDrct.js"></script> | |
30 | 31 | <script src="js/controllers/SessionCtrl.js"></script> |
31 | 32 | <script src="js/controllers/ConnectCtrl.js"></script> |
32 | 33 | <script src="js/controllers/MembreCtrl.js"></script> | ... | ... |
... | ... | @@ -0,0 +1,3 @@ |
1 | +<div btf-markdown="mess.content" ng-show="!mess.viewSource"></div> | |
2 | +<code ng-show="mess.viewSource && !mess.editMode">{{ mess.content }}</code> | |
3 | +<textarea class="form-control" id="nvMessTitre" rows="7" placeholder="Contenu du message" ng-model="mess.content" ng-show="mess.viewSource && mess.editMode"></textarea> | |
0 | 4 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,4 @@ |
1 | +<button type="button" class="btn btn-default" ng-click="mess.viewSource = !mess.viewSource"> | |
2 | + <span class="glyphicon glyphicon-console" aria-hidden="true" ng-hide="mess.viewSource"></span> | |
3 | + <span class="glyphicon glyphicon-file" aria-hidden="true" ng-show="mess.viewSource"></span> | |
4 | +</button> | |
0 | 5 | \ No newline at end of file | ... | ... |