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,12 +91,13 @@ sessionData = function (session, cb) { | ||
91 | // Permissions | 91 | // Permissions |
92 | session.canAddMembre = session.bureau; | 92 | session.canAddMembre = session.bureau; |
93 | session.canDelMembre = session.bureau; | 93 | session.canDelMembre = session.bureau; |
94 | + session.canAddDoss = session.bureau; | ||
95 | + session.canDelDoss = session.bureau; | ||
94 | session.canAddConv = true; | 96 | session.canAddConv = true; |
95 | session.canDelConv = session.bureau; | 97 | session.canDelConv = session.bureau; |
96 | session.canAddMess = true; | 98 | session.canAddMess = true; |
99 | + session.canEditMess = false; | ||
97 | session.canDelMess = session.bureau; | 100 | session.canDelMess = session.bureau; |
98 | - session.canAddDoss = session.bureau; | ||
99 | - session.canDelDoss = session.bureau; | ||
100 | cb(session); | 101 | cb(session); |
101 | }); | 102 | }); |
102 | }); | 103 | }); |
public/css/style.css
@@ -36,6 +36,16 @@ body { | @@ -36,6 +36,16 @@ body { | ||
36 | animation: zoomOut 0.5s; | 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 | body > .container { | 49 | body > .container { |
40 | position: relative; | 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 | .controller('ForumConvCtrl', function ($scope, $routeParams, SessionServ, ApiServ) { | 2 | .controller('ForumConvCtrl', function ($scope, $routeParams, SessionServ, ApiServ) { |
3 | $scope.messs = []; | 3 | $scope.messs = []; |
4 | $scope.conv = {}; | 4 | $scope.conv = {}; |
@@ -20,8 +20,10 @@ angular.module('ForumConvCtrl', ['SessionsServ', 'ApiServ', 'ngSanitize', 'btfor | @@ -20,8 +20,10 @@ angular.module('ForumConvCtrl', ['SessionsServ', 'ApiServ', 'ngSanitize', 'btfor | ||
20 | }); | 20 | }); |
21 | 21 | ||
22 | $scope.addMess = function () { | 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 | ApiServ("envoi du message", 'post', 'messs', data, function (err, mess) { | 27 | ApiServ("envoi du message", 'post', 'messs', data, function (err, mess) { |
26 | if (!err) { | 28 | if (!err) { |
27 | $scope.formData = {}; | 29 | $scope.formData = {}; |
@@ -37,4 +39,15 @@ angular.module('ForumConvCtrl', ['SessionsServ', 'ApiServ', 'ngSanitize', 'btfor | @@ -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 @@ | @@ -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 +24,28 @@ | ||
24 | <br/> {{ mess.auteur.role }} | 24 | <br/> {{ mess.auteur.role }} |
25 | <br/> {{ doss.date }} | 25 | <br/> {{ doss.date }} |
26 | </td> | 26 | </td> |
27 | - <td btf-markdown="mess.content"> | ||
28 | - </td> | 27 | + <!-- <td btf-markdown="mess.content"></td> --> |
28 | + <td mess-edit></td> | ||
29 | <td> | 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 | <button type="button" class="btn btn-danger" ng-show="session.canDelMess" ng-click="delMess($index)"> | 35 | <button type="button" class="btn btn-danger" ng-show="session.canDelMess" ng-click="delMess($index)"> |
31 | <span class="glyphicon glyphicon-remove" aria-hidden="true"></span> | 36 | <span class="glyphicon glyphicon-remove" aria-hidden="true"></span> |
32 | </button> | 37 | </button> |
33 | </td> | 38 | </td> |
34 | </tr> | 39 | </tr> |
35 | <tr ng-show="session.canAddMess"> | 40 | <tr ng-show="session.canAddMess"> |
36 | - <form> | 41 | + <form ng-init="mess = {content: '', editMode: true, viewSource: true}"> |
37 | <td> | 42 | <td> |
38 | <label for="nvMessTitre">Nouveau message</label> | 43 | <label for="nvMessTitre">Nouveau message</label> |
39 | </td> | 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 | <td> | 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 | <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> | 49 | <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> |
46 | </button> | 50 | </button> |
47 | </td> | 51 | </td> |
public/views/index.html
@@ -27,6 +27,7 @@ | @@ -27,6 +27,7 @@ | ||
27 | <script src="js/services/ApiServ.js"></script> | 27 | <script src="js/services/ApiServ.js"></script> |
28 | <script src="js/services/EncryptServ.js"></script> | 28 | <script src="js/services/EncryptServ.js"></script> |
29 | <script src="js/services/SessionServ.js"></script> | 29 | <script src="js/services/SessionServ.js"></script> |
30 | + <script src="js/directives/MessEditDrct.js"></script> | ||
30 | <script src="js/controllers/SessionCtrl.js"></script> | 31 | <script src="js/controllers/SessionCtrl.js"></script> |
31 | <script src="js/controllers/ConnectCtrl.js"></script> | 32 | <script src="js/controllers/ConnectCtrl.js"></script> |
32 | <script src="js/controllers/MembreCtrl.js"></script> | 33 | <script src="js/controllers/MembreCtrl.js"></script> |
@@ -0,0 +1,3 @@ | @@ -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 | \ No newline at end of file | 4 | \ No newline at end of file |
@@ -0,0 +1,4 @@ | @@ -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 | \ No newline at end of file | 5 | \ No newline at end of file |