Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Rybička
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
Rybička
Commits
b71027dd
Commit
b71027dd
authored
2 years ago
by
Tomáš
Browse files
Options
Downloads
Patches
Plain Diff
nicer UI, loading info & disabling button when calculating
parent
e599315a
No related branches found
No related tags found
1 merge request
!1
Test release
Pipeline
#11274
failed
2 years ago
Stage: build
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
rv_voting_calc/templates/rv_voting_calc/index.html
+18
-2
18 additions, 2 deletions
rv_voting_calc/templates/rv_voting_calc/index.html
rv_voting_calc/views.py
+2
-1
2 additions, 1 deletion
rv_voting_calc/views.py
static_src/rv_voting_calc.js
+13
-63
13 additions, 63 deletions
static_src/rv_voting_calc.js
with
33 additions
and
66 deletions
rv_voting_calc/templates/rv_voting_calc/index.html
+
18
−
2
View file @
b71027dd
...
...
@@ -8,6 +8,17 @@
{% block head %}
{% render_bundle "rv_voting_calc" %}
<link
href=
"https://styleguide.pirati.cz/2.11.x/css/styles.css"
rel=
"stylesheet"
media=
"all"
>
<link
href=
"https://styleguide.pirati.cz/2.11.x/css/pattern-scaffolding.css"
rel=
"stylesheet"
media=
"all"
>
{% endblock %}
{% block content %}
...
...
@@ -20,9 +31,14 @@
<div
class=
"flex items-center gap-3 justify-between"
>
<h2
class=
"text-2xl font-bebas"
>
Výsledky
</h2>
<button
class=
"b
g-black text-white px-5 py-3 duration-100 hover:bg-gray-800
"
class=
"b
tn disabled:cursor-progress
"
id=
"count-votes"
>
Vypočítat
</button>
disabled
>
<div
class=
"btn__body"
>
Vypočítat
</div>
</button>
</div>
</div>
...
...
This diff is collapsed.
Click to expand it.
rv_voting_calc/views.py
+
2
−
1
View file @
b71027dd
...
...
@@ -22,7 +22,8 @@ def get_options_by_member(source, rv_members) -> dict:
try
:
options_by_member
=
json
.
loads
(
source
)
if
not
isinstance
(
options_by_member
,
dict
):
# The provided votes must be a dictionary with at least 1 key.
if
not
isinstance
(
options_by_member
,
dict
)
or
len
(
options_by_member
)
==
0
:
raise
ValueError
except
ValueError
:
raise
HTTPExceptions
.
BAD_REQUEST
...
...
This diff is collapsed.
Click to expand it.
static_src/rv_voting_calc.js
+
13
−
63
View file @
b71027dd
...
...
@@ -38,39 +38,7 @@ $(window).ready(
$
(
"
.__vote-selection
"
).
on
(
"
select2:select
"
,
event
=>
{
// //// Sync the tag option with other selectors.
//
// // If the tag isn't new for this selection, do nothing.
// if (!event.params.data.isNew) {
// return;
// }
//
// const tagName = event.params.data.id;
//
// const addedTag = new Option(
// tagName,
// tagName,
// false,
// false
// );
//
// // Get all other selections.
// const unfilteredSelections = $(".__vote-selection").not(event.target);
// let filteredSelections = [];
//
// // Check if they contain the tag. If they do, ignore them.
// for (const selection of unfilteredSelections) {
// if (
// $(selection).
// children(`option[value=${$.escapeSelector(tagName)}]`).
// length === 0
// ) {
// filteredSelections.push(selection);
// }
// }
//
// // Add the new tag to all selections that don't have it yet.
// $(filteredSelections).append(addedTag).trigger("change");
$
(
"
#count-votes
"
).
prop
(
"
disabled
"
,
false
);
// Keep user-defined ordering. This is imperative!
// http://github.com/select2/select2/issues/3106 - Thanks to kevin-brown!
...
...
@@ -85,41 +53,21 @@ $(window).ready(
$
(
"
.__vote-selection
"
).
on
(
"
select2:unselect
"
,
event
=>
{
//// Remove the tag option if it's not selected anywhere.
// const tagName = event.params.data.id;
//
// // Get all other selections.
// const selections = $(".__vote-selection");
//
// // Check if any of them have the tag selected. If they do, end the function.
// for (const selection of selections) {
// for (const data of $(selection).select2("data")) {
// if (data.id == tagName) {
// // TODO - Don't remove the tag from this select.
// // I'm not sure select2 has a good way of doing this.
//
// return;
// }
// }
// }
//
// // If the function has not ended by now, we can remove the tag.
// for (const selection of selections) {
// (
// $(selection).
// children(`option[value=${$.escapeSelector(tagName)}]`).
// remove()
// );
//
// $(selection).trigger("change");
// }
for
(
const
selection
of
$
(
"
.__vote-selection
"
))
{
if
(
$
(
selection
).
select2
(
"
data
"
).
length
!==
0
)
{
return
;
}
}
$
(
"
#count-votes
"
).
prop
(
"
disabled
"
,
true
);
}
);
$
(
"
#count-votes
"
).
on
(
"
click
"
,
async
(
event
)
=>
{
$
(
event
.
currentTarget
).
addClass
(
"
btn--loading
"
).
prop
(
"
disabled
"
,
true
);
let
votes
=
{};
for
(
const
username
of
Object
.
keys
(
RV_MEMBERS
))
{
...
...
@@ -139,7 +87,7 @@ $(window).ready(
const
urlParams
=
new
URL
(
window
.
location
).
searchParams
;
const
rvGid
=
urlParams
.
get
(
"
rv_gid
"
);
const
seed
=
urlParams
.
get
(
"
seed
"
);
let
response
=
await
fetch
(
VOTE_CALCULATION_ENDPOINT
+
`?votes=
${
encodeURIComponent
(
JSON
.
stringify
(
votes
))}
`
...
...
@@ -171,6 +119,8 @@ $(window).ready(
+
`&seed=
${
Cookies
.
get
(
"
seed
"
)}
`
)
);
$
(
event
.
currentTarget
).
removeClass
(
"
btn--loading
"
).
prop
(
"
disabled
"
,
false
);
}
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment