Skip to content

Commit f7c43b3

Browse files
committed
UX update (run admin)
1 parent c7ed524 commit f7c43b3

File tree

6 files changed

+252
-48
lines changed

6 files changed

+252
-48
lines changed

public/javascripts/line_run_admin.js

Lines changed: 88 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ var app = angular.module("RunAdmin", ['ngAnimate', 'ui.bootstrap', 'ui.bootstrap
103103

104104
$scope.selectAll = function () {
105105
angular.forEach($scope.runs, function (run) {
106-
run.checked = true;
106+
if($scope.list_filter(run)) run.checked = true;
107107
});
108108
}
109109

@@ -115,30 +115,105 @@ var app = angular.module("RunAdmin", ['ngAnimate', 'ui.bootstrap', 'ui.bootstrap
115115
$scope.removeRun(chk.join(","));
116116
}
117117

118-
$scope.removeRun = function (runIds) {
119-
swal({
118+
$scope.removeRun = async function (runIds) {
119+
const {
120+
value: operation
121+
} = await swal({
120122
title: "Delete Run?",
121123
text: "Are you sure you want to remove the run?",
122124
type: "warning",
123125
showCancelButton: true,
124126
confirmButtonText: "Yes, delete it!",
125-
confirmButtonColor: "#ec6c62"
126-
}).then((result) => {
127-
if (result.value) {
128-
$http.delete("/api/runs/line/" + runIds).then(function (response) {
129-
console.log(response)
130-
updateRunList()
131-
}, function (error) {
132-
console.log(error)
133-
})
127+
confirmButtonColor: "#ec6c62",
128+
input: 'text',
129+
inputPlaceholder: 'Enter "DELETE" here',
130+
inputValidator: (value) => {
131+
return value != 'DELETE' && 'You need to write "DELETE" !'
134132
}
135133
})
134+
135+
if (operation) {
136+
$http.delete("/api/runs/line/" + runIds).then(function (response) {
137+
console.log(response)
138+
updateRunList()
139+
}, function (error) {
140+
console.log(error)
141+
})
142+
}
143+
144+
145+
}
146+
var showAllRounds = true
147+
var showAllFields = true
148+
var showAllTeams = true
149+
$scope.teamName = ""
150+
151+
$scope.$watch('Rrounds', function (newValue, oldValue) {
152+
showAllRounds = true
153+
//console.log(newValue)
154+
for (let round in newValue) {
155+
if (newValue.hasOwnProperty(round)) {
156+
if (newValue[round]) {
157+
showAllRounds = false
158+
return
159+
}
160+
}
161+
}
162+
}, true)
163+
$scope.$watch('Rfields', function (newValue, oldValue) {
164+
//console.log(newValue)
165+
showAllFields = true
166+
for (let field in newValue) {
167+
if (newValue.hasOwnProperty(field)) {
168+
if (newValue[field]) {
169+
showAllFields = false
170+
return
171+
}
172+
}
173+
}
174+
}, true)
175+
$scope.$watch('teamName', function (newValue, oldValue) {
176+
if (newValue == '') showAllTeams = true
177+
else showAllTeams = false
178+
return
179+
}, true)
180+
181+
$scope.list_filter = function (value, index, array) {
182+
return (showAllRounds || $scope.Rrounds[value.round.name]) &&
183+
(showAllFields || $scope.Rfields[value.field.name]) && (showAllTeams || ~value.team.name.indexOf($scope.teamName))
136184
}
137185

138186
function updateRunList() {
139187
$http.get("/api/competitions/" + competitionId +
140188
"/line/runs?populate=true").then(function (response) {
141189
$scope.runs = response.data
190+
var rounds = {}
191+
var fields = {}
192+
for (var i = 0; i < $scope.runs.length; i++) {
193+
try {
194+
var round = $scope.runs[i].round.name
195+
if (!rounds.hasOwnProperty(round)) {
196+
rounds[round] = false
197+
}
198+
} catch (e) {
199+
200+
}
201+
202+
try {
203+
var field = $scope.runs[i].field.name
204+
205+
if (!fields.hasOwnProperty(field)) {
206+
fields[field] = false
207+
}
208+
} catch (e) {
209+
210+
}
211+
212+
213+
}
214+
215+
$scope.Rrounds = rounds
216+
$scope.Rfields = fields
142217
})
143218
}
144219

@@ -187,6 +262,7 @@ var app = angular.module("RunAdmin", ['ngAnimate', 'ui.bootstrap', 'ui.bootstrap
187262
})
188263
}
189264

265+
190266
$scope.go = function (path) {
191267
path = path + '?return=' + window.location.pathname;
192268
window.location = path

public/javascripts/maze_run_admin.js

Lines changed: 89 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ var app = angular.module("RunAdmin", ['ngAnimate', 'ui.bootstrap', 'ui.bootstrap
9393

9494
$scope.selectAll = function () {
9595
angular.forEach($scope.runs, function (run) {
96-
run.checked = true;
96+
if($scope.list_filter(run)) run.checked = true;
9797
});
9898
}
9999

@@ -105,30 +105,107 @@ var app = angular.module("RunAdmin", ['ngAnimate', 'ui.bootstrap', 'ui.bootstrap
105105
if (chk) $scope.removeRun(chk.join(","));
106106
}
107107

108-
$scope.removeRun = function (runid) {
109-
swal({
108+
$scope.removeRun = async function (runIds) {
109+
const {
110+
value: operation
111+
} = await swal({
110112
title: "Delete Run?",
111113
text: "Are you sure you want to remove the run?",
112114
type: "warning",
113115
showCancelButton: true,
114116
confirmButtonText: "Yes, delete it!",
115-
confirmButtonColor: "#ec6c62"
116-
}).then((result) => {
117-
if (result.value) {
118-
$http.delete("/api/runs/maze/" + runid).then(function (response) {
119-
console.log(response)
120-
updateRunList()
121-
}, function (error) {
122-
console.log(error)
123-
})
117+
confirmButtonColor: "#ec6c62",
118+
input: 'text',
119+
inputPlaceholder: 'Enter "DELETE" here',
120+
inputValidator: (value) => {
121+
return value != 'DELETE' && 'You need to write "DELETE" !'
124122
}
125123
})
124+
125+
if (operation) {
126+
$http.delete("/api/runs/maze/" + runIds).then(function (response) {
127+
console.log(response)
128+
updateRunList()
129+
}, function (error) {
130+
console.log(error)
131+
})
132+
}
133+
134+
135+
}
136+
var showAllRounds = true
137+
var showAllFields = true
138+
var showAllTeams = true
139+
$scope.teamName = ""
140+
141+
$scope.$watch('Rrounds', function (newValue, oldValue) {
142+
showAllRounds = true
143+
//console.log(newValue)
144+
for (let round in newValue) {
145+
if (newValue.hasOwnProperty(round)) {
146+
if (newValue[round]) {
147+
showAllRounds = false
148+
return
149+
}
150+
}
151+
}
152+
}, true)
153+
$scope.$watch('Rfields', function (newValue, oldValue) {
154+
//console.log(newValue)
155+
showAllFields = true
156+
for (let field in newValue) {
157+
if (newValue.hasOwnProperty(field)) {
158+
if (newValue[field]) {
159+
showAllFields = false
160+
return
161+
}
162+
}
163+
}
164+
}, true)
165+
$scope.$watch('teamName', function (newValue, oldValue) {
166+
if (newValue == '') showAllTeams = true
167+
else showAllTeams = false
168+
return
169+
}, true)
170+
171+
$scope.list_filter = function (value, index, array) {
172+
return (showAllRounds || $scope.Rrounds[value.round.name]) &&
173+
(showAllFields || $scope.Rfields[value.field.name]) && (showAllTeams || ~value.team.name.indexOf($scope.teamName))
126174
}
127175

176+
128177
function updateRunList() {
129178
$http.get("/api/competitions/" + competitionId +
130179
"/maze/runs?populate=true").then(function (response) {
131180
$scope.runs = response.data
181+
182+
var rounds = {}
183+
var fields = {}
184+
for (var i = 0; i < $scope.runs.length; i++) {
185+
try {
186+
var round = $scope.runs[i].round.name
187+
if (!rounds.hasOwnProperty(round)) {
188+
rounds[round] = false
189+
}
190+
} catch (e) {
191+
192+
}
193+
194+
try {
195+
var field = $scope.runs[i].field.name
196+
197+
if (!fields.hasOwnProperty(field)) {
198+
fields[field] = false
199+
}
200+
} catch (e) {
201+
202+
}
203+
204+
205+
}
206+
207+
$scope.Rrounds = rounds
208+
$scope.Rfields = fields
132209
})
133210
}
134211

public/lang/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
"view": "View",
4343
"sign": "Sign",
4444
"judge": "Judge",
45+
"approval": "Approval",
46+
"action": "Action",
4547
"point": "points",
4648
"league": "League",
4749
"competition": "Competiton",

public/lang/ja.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
"view": "表示",
4949
"sign": "署名",
5050
"judge": "審判",
51+
"approval": "承認",
52+
"action": "操作",
5153
"point": "",
5254
"league": "リーグ",
5355
"competition": "大会名",

views/line_run_admin.jade

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,28 @@ block content
6767
td
6868
button(ng-click='addRun()') {{"admin.lineRun.add" | translate}}
6969
a(ng-href='/admin/{{competitionId}}/line/runs/bulk') {{"admin.lineRun.bulk" | translate}}
70-
70+
71+
.refine
72+
.card.border-dark.mb-3(style='width:100%;')
73+
.card-header.bg-transparent.border-dark.fa-2x
74+
i.fas.fa-search(aria-hidden='true') {{'line.competition.refine.filter' | translate}}
75+
.card-body.text-dark
76+
h6.card-title {{'line.competition.refine.round' | translate}}
77+
span(ng-repeat='(key, value) in Rrounds track by key')
78+
input(type='checkbox' ng-model='Rrounds[key]' id="checkR_{{key}}")
79+
label.checkbox(for="checkR_{{key}}") {{key}}
80+
hr
81+
h6.card-title {{'line.competition.refine.field' | translate}}
82+
span(ng-repeat='(key, value) in Rfields track by key')
83+
input(type='checkbox' ng-model='Rfields[key]' id="checkF_{{key}}")
84+
label.checkbox(for="checkF_{{key}}") {{key}}
85+
hr
86+
h6.card-title {{'line.competition.refine.team' | translate}}
87+
.input-group
88+
span#basic-addon1.input-group-addon
89+
i.fas.fa-users(aria-hidden='true')
90+
input.form-control(type='text', placeholder='Team name', aria-label='Username', aria-describedby='basic-addon1' ng-model='teamName')
91+
7192
div
7293
button(ng-click="selectAll()" class='btn btn-primary' style="margin: 5px 5px 5px 5px;") {{"admin.lineRun.selectAll" | translate}}
7394
button(ng-click="removeSelectedRun()" class='btn btn-danger' style="margin: 5px 5px 5px 5px;") {{"admin.lineRun.delS" | translate}}
@@ -88,13 +109,9 @@ block content
88109
th {{"common.time" | translate}}
89110
th {{"admin.lineRun.status" | translate}}
90111
th {{"common.comment" | translate}}
91-
th
92-
th
93-
th
94-
//th
95112
th {{"common.operation" | translate}}
96113
tbody
97-
tr(ng-repeat='run in runs | orderBy:"[startTime,round.name,field.name,team.name]"' runs-read-finished='')
114+
tr(ng-repeat='run in runs | filter:list_filter | orderBy:"[startTime,round.name,field.name,team.name]"' runs-read-finished='')
98115
td
99116
input(type='checkbox' ng-model='run.checked' style="display:initial;")
100117
td(ng-bind='run.startTime | date:"dd EEE HH:mm"' ng-style="{'background-color':run.status==5?'#bdafdb':''}" )
@@ -112,13 +129,23 @@ block content
112129
span(ng-if="run.status==5") {{"admin.lineRun.st5" | translate}}
113130
td(ng-style="{'background-color':run.status==5?'#bdafdb':''}")
114131
button(uib-popover="{{run.comment}}" popover-trigger="'outsideClick'" type="button" class="btn btn-default" ng-disabled="run.comment==''") {{"common.comment" | translate}}
115-
td(ng-style="{'background-color':run.status==5?'#bdafdb':''}")
132+
//td(ng-style="{'background-color':run.status==5?'#bdafdb':''}")
116133
button(ng-click="go('/line/view/' + run._id)" class='btn btn-info') {{"common.view" | translate}}
117-
td(ng-style="{'background-color':run.status==5?'#bdafdb':''}")
134+
//td(ng-style="{'background-color':run.status==5?'#bdafdb':''}")
118135
button(ng-click="go_sign(run._id)" class='btn btn-warning') {{"common.sign" | translate}}
119-
td(ng-style="{'background-color':run.status==5?'#bdafdb':''}")
136+
//td(ng-style="{'background-color':run.status==5?'#bdafdb':''}")
120137
button(ng-click="go_judge(run._id)" class='btn btn-danger') {{"common.judge" | translate}}
121138
//td(ng-style="{'background-color':run.status==5?'#bdafdb':''}")
122-
button(ng-click="go_approval(run._id)" class='btn btn-secondary') Approval
139+
button(ng-click="go_approval(run._id)" class='btn btn-secondary') {{"common.approval" | translate}}
123140
td(ng-style="{'background-color':run.status==5?'#bdafdb':''}")
124-
a(href="" ng-click='removeRun(run._id)') {{"common.delete" | translate}}
141+
//a(href="" ng-click='removeRun(run._id)') {{"common.delete" | translate}}
142+
.dropdown
143+
button#dropdownMenu.btn.btn-secondary.dropdown-toggle(type='button', data-toggle='dropdown', aria-haspopup='true', aria-expanded='false') {{"common.action" | translate}}
144+
.dropdown-menu(aria-labelledby='dropdownMenu')
145+
button.dropdown-item(type='button' ng-click="go('/line/view/' + run._id)") Kioskにチェクポイント設定画面を表示
146+
button.dropdown-item(type='button' ng-click="go('/line/view/' + run._id)") {{"common.view" | translate}}
147+
button.dropdown-item(type='button' ng-click="go_judge(run._id)") {{"common.judge" | translate}}
148+
button.dropdown-item(type='button' ng-click="go_sign(run._id)") {{"common.sign" | translate}}
149+
button.dropdown-item(type='button' ng-click="go_approval(run._id)") {{"common.approval" | translate}}
150+
.dropdown-divider
151+
button.dropdown-item(type='button' ng-click='removeRun(run._id)') {{"common.delete" | translate}}

0 commit comments

Comments
 (0)