|
1 | 1 | [[ define "discussListPage" ]] |
2 | 2 | <!doctype html> |
3 | | -<html ng-app="DBHub" ng-controller="discussListView"> |
| 3 | +<html> |
4 | 4 | [[ template "head" . ]] |
5 | 5 | <body> |
6 | 6 | [[ template "header" . ]] |
7 | 7 | <div> |
8 | 8 | <div id="db-header-root"></div> |
9 | | - <div class="row"> |
10 | | - <div class="col-md-12"> |
11 | | - <div style="text-align: center; margin-top: 1%; margin-bottom: 1%"> |
12 | | - <button class="btn btn-success" ng-click="createDiscussion()">Start a new discussion</button> |
13 | | - <div class="btn-group"> |
14 | | - <label class="btn btn-default" ng-model="radioOpen" ng-click="openClick('true')" uib-btn-radio="true">Open</label> |
15 | | - <label class="btn btn-default" ng-model="radioOpen" ng-click="openClick('false')" uib-btn-radio="false">Closed</label> |
16 | | - </div> |
17 | | - </div> |
18 | | - </div> |
19 | | - </div> |
20 | | - <div class="row"> |
21 | | - <div class="col-md-12" style="padding-bottom: 10px;"> |
22 | | - <table ng-if="(DiscussionList != '') && (((radioOpen === false) && (discussionCount.closed !== 0)) || ((radioOpen === true) && (discussionCount.open !== 0)))" class="table table-striped table-responsive settingsTable"> |
23 | | - <tbody> |
24 | | - <tr ng-repeat="row in DiscussionList" ng-if="row.open == radioOpen"> |
25 | | - <td style="border-style: none;" width="80px"> |
26 | | - <div class="pull-right" style="padding-top: 6px;"> |
27 | | - <i ng-if="row.open === true" class="fa fa-minus-square-o fa-lg text-success"></i> |
28 | | - <i ng-if="row.open === false" class="fa fa fa-check-square-o fa-lg text-danger"></i> |
29 | | - </div> |
30 | | - <div style="padding-top: 6px;"># {{ row.disc_id }}</div> |
31 | | - </td> |
32 | | - <td style="border-style: none;"> |
33 | | - <a href="/discuss/[[ .DB.Info.Owner ]]/[[ .DB.Info.Database ]]?id={{ row.disc_id }}" style="font-size: x-large; color: #333;">{{ row.title }}</a> |
34 | | - <div> |
35 | | - Created <span title="{{ row.creation_date | date : 'medium' }}" style="color: grey;">{{ getTimePeriodTxt(row.creation_date, true) }}</span> by <a class="blackLink" href="/{{ row.creator }}"><img ng-if="row.avatar_url != ''" ng-attr-src="{{ decodeAmp(row.avatar_url) }}" style="vertical-align: top; border: 1px solid #8c8c8c;" height="18" width="18"/> {{ row.creator }}</a>. Last modified <span title="{{ row.last_modified | date : 'medium' }}" style="color: grey;">{{ getTimePeriodTxt(row.last_modified, true) }}</span> |
36 | | - <span ng-if="row.comment_count > 0"><i class="fa fa-comment-o"></i> <a class="blackLink" href="/discuss/[[ .DB.Info.Owner ]]/[[ .DB.Info.Database ]]?id={{ row.disc_id }}">{{ row.comment_count }} comment<span ng-if="row.comment_count > 1">s</span></a></span> |
37 | | - </div> |
38 | | - </td> |
39 | | - </tr> |
40 | | - </tbody> |
41 | | - </table> |
42 | | - <div ng-if="DiscussionList === null" style="text-align: center; font-size:large;" data-cy="nodisc"><i>This database doesn't have any discussions yet</i></div> |
43 | | - <div ng-if="(radioOpen === false) && (DiscussionList !== null) && (discussionCount.closed === 0)" style="text-align: center; font-size:large;"><i>This database doesn't have any closed discussions</i></div> |
44 | | - <div ng-if="(radioOpen === true) && (DiscussionList !== null) && (discussionCount.open === 0)" style="text-align: center; font-size:large;"><i>This database doesn't have any open discussions</i></div> |
45 | | - </div> |
46 | | - </div> |
| 9 | + <div id="discussion-list"></div> |
47 | 10 | </div> |
48 | 11 | [[ template "script_db_header" . ]] |
49 | | -[[ template "footer" . ]] |
50 | 12 | <script> |
51 | | - let app = angular.module('DBHub', ['ui.bootstrap', 'ngSanitize']); |
52 | | - app.controller('discussListView', function($scope, $http) { |
53 | | - // Pre-filled data |
54 | | - $scope.meta = { |
55 | | - Database: "[[ .DB.Info.Database ]]", |
56 | | - Owner: "[[ .DB.Info.Owner ]]", |
57 | | - [[ if .PageMeta.LoggedInUser ]] |
58 | | - Loggedin: "true", |
59 | | - [[ else ]] |
60 | | - Loggedin: "false", |
61 | | - [[ end ]] |
62 | | - } |
63 | | - |
64 | | - $scope.DiscussionList = [[ .DiscussionList ]]; |
65 | | - |
66 | | - // Count the number of open and closed discussions, so we can display an appropriate placeholder when one of |
67 | | - // them has 0 (eg no open discussions, or no closed discussions) |
68 | | - $scope.discussionCount = {"open": 0, "closed": 0}; |
69 | | - if ($scope.DiscussionList !== null) { |
70 | | - let numDisc = $scope.DiscussionList.length; |
71 | | - for (let i = 0; i < numDisc; i++) { |
72 | | - if ($scope.DiscussionList[i].open) { |
73 | | - $scope.discussionCount.open += 1; |
74 | | - } else { |
75 | | - $scope.discussionCount.closed += 1; |
76 | | - } |
77 | | - } |
78 | | - } |
79 | | - |
80 | | - // Switch to the create discussion page |
81 | | - $scope.createDiscussion = function() { |
82 | | - if ($scope.meta.Loggedin !== "true") { |
83 | | - // User needs to be logged in |
84 | | - lock.show(); |
85 | | - } else { |
86 | | - window.location = '/creatediscuss/[[ .DB.Info.Owner ]]/[[ .DB.Info.Database ]]'; |
87 | | - } |
88 | | - }; |
89 | | - |
90 | | - // Change \u0026 to & |
91 | | - $scope.decodeAmp = function(str) { |
92 | | - return decodeURIComponent(str); |
93 | | - }; |
94 | | - |
95 | | - // Returns a nicely presented "time elapsed" string |
96 | | - $scope.getTimePeriodTxt = function(date1, includeOn) { |
97 | | - return getTimePeriod(date1, includeOn) |
98 | | - }; |
99 | | - |
100 | | - // Switch between showing open vs closed discussions |
101 | | - $scope.radioOpen = true; |
102 | | - $scope.openClick = function(newValue) { |
103 | | - if (newValue === "true") { |
104 | | - // Only display open discussions |
105 | | - $scope.radioOpen = true; |
106 | | - } else { |
107 | | - // Only display closed discussions |
108 | | - $scope.radioOpen = false; |
109 | | - } |
110 | | - }; |
111 | | - }); |
| 13 | + const discussionData = [[ .DiscussionList ]]; |
112 | 14 | </script> |
| 15 | +[[ template "footer" . ]] |
113 | 16 | </body> |
114 | 17 | </html> |
115 | 18 | [[ end ]] |
0 commit comments