Skip to content

Commit 489a3bb

Browse files
authored
Merge pull request #233 from mapswipe/fix-manager-dashboard-change-status-button
improve manager dashboard from feedback
2 parents 95ffc59 + c2d31f7 commit 489a3bb

File tree

3 files changed

+17
-41
lines changed

3 files changed

+17
-41
lines changed

manager_dashboard/manager_dashboard/js/project-management.js

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1+
function addEventListeners(status) {
2+
$("#projectsTable-"+status).on('click', '.change-status', changeProjectStatus);
3+
$("#projectsTable-"+status).on('click', '.change-isFeatured', changeProjectIsFeatured);
4+
}
5+
16
function getProjects(status) {
7+
console.log('start get project status')
28
var ProjectsRef = firebase.database().ref("v2/projects").orderByChild("status").equalTo(status);
39

410
var tableRef = $("#projectsTable-"+status).DataTable();
@@ -21,9 +27,6 @@ function getProjects(status) {
2127
btn1 = addButton(data.key, data.val().status, "inactive")
2228
btn2 = addButton(data.key, data.val().status, "finished")
2329
row_array.push(btn1.outerHTML + btn2.outerHTML)
24-
} else if (data.val().status == "new") {
25-
btn = addButton(data.key, data.val().status, "active")
26-
row_array.push(btn.outerHTML)
2730
} else if (data.val().status == "finished") {
2831
btn = addButton(data.key, data.val().status, "inactive")
2932
row_array.push(btn.outerHTML)
@@ -55,22 +58,11 @@ function getProjects(status) {
5558
tableRef.row.add(row_array).draw( false )
5659
});
5760
};
58-
5961
$('.dataTables_length').addClass('bs-select');
6062
console.log('added data table styles')
61-
62-
var btns = document.getElementsByClassName('change-status')
63-
for (let item of btns) {
64-
item.addEventListener("click", changeProjectStatus)
65-
}
66-
67-
var btns = document.getElementsByClassName('change-isFeatured')
68-
for (let item of btns) {
69-
item.addEventListener("click", changeProjectIsFeatured)
70-
}
71-
7263
});
7364

65+
7466
}
7567

7668
function addButton(id, oldStatus, newStatus){
@@ -114,11 +106,12 @@ function updateTableView() {
114106
.draw();
115107
}
116108

117-
getProjects("new")
118109
getProjects("active")
119110
getProjects("inactive")
120111
getProjects("finished")
121112
getProjects("archived")
113+
114+
console.log('updated table view')
122115
}
123116

124117

@@ -154,8 +147,10 @@ function changeProjectIsFeatured() {
154147
}
155148

156149

157-
getProjects("new")
158-
getProjects("active")
159-
getProjects("inactive")
160-
getProjects("finished")
161-
getProjects("archived")
150+
status_array = ["active", "inactive", "finished", "archived"]
151+
152+
for (var i = 0; i < status_array.length; i++) {
153+
status = status_array[i]
154+
getProjects(status)
155+
addEventListeners(status)
156+
}

manager_dashboard/manager_dashboard/manage.html

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -91,25 +91,6 @@ <h3>Please <a href="index.html">log in</a> first.</h3>
9191

9292
<!-- manage existing projects -->
9393
<div class="row justify-content-center" id="project-management" style="display: block">
94-
<div class="col-md-12">
95-
<div id="new-projects" class="col-md-12 project-data">
96-
<h2>New Projects</h2>
97-
<p>These projects have just been created and no mapping has happened yet.</p>
98-
<table id="projectsTable-new" class="table table-striped table-bordered">
99-
<thead>
100-
<tr class="thead-inverse">
101-
<th>Project ID</th>
102-
<th>Name</th>
103-
<th>Project Type</th>
104-
<th>Progress</th>
105-
<th>Change Status</th>
106-
</tr>
107-
</thead>
108-
<tbody>
109-
<!-- will be added by function -->
110-
</tbody>
111-
</table>
112-
</div>
11394
<div id="active-projects" class="col-md-12 project-data">
11495
<h2>Active Projects</h2>
11596
<p>These projects are currently visible in the MapSwipe app.</p>

mapswipe_workers/mapswipe_workers/base/base_project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def __init__(self, project_draft):
6666
self.projectId = project_draft['projectDraftId']
6767
self.projectType = int(project_draft['projectType'])
6868
self.verificationNumber = project_draft['verificationNumber']
69-
self.status = 'new'
69+
self.status = 'inactive'
7070
self.projectTopic = project_draft.get('projectTopic', None)
7171
self.projectRegion = project_draft.get('projectRegion', None)
7272
self.projectNumber = project_draft.get('projectNumber', None)

0 commit comments

Comments
 (0)