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
dfb8d7dc
Commit
dfb8d7dc
authored
2 years ago
by
Tomáš
Browse files
Options
Downloads
Patches
Plain Diff
finish vote selecting, improve styles
parent
4bb42030
No related branches found
No related tags found
1 merge request
!1
Test release
Pipeline
#11231
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
+22
-17
22 additions, 17 deletions
rv_voting_calc/templates/rv_voting_calc/index.html
static_src/rv_voting_calc.js
+26
-14
26 additions, 14 deletions
static_src/rv_voting_calc.js
static_src/shared/utils.js
+5
-0
5 additions, 0 deletions
static_src/shared/utils.js
with
53 additions
and
31 deletions
rv_voting_calc/templates/rv_voting_calc/index.html
+
22
−
17
View file @
dfb8d7dc
...
@@ -14,25 +14,30 @@
...
@@ -14,25 +14,30 @@
<main>
<main>
<h1
class=
"text-6xl font-bebas mb-5"
>
Kalkulačka hlasování RV
</h1>
<h1
class=
"text-6xl font-bebas mb-5"
>
Kalkulačka hlasování RV
</h1>
<div
class=
"grid grid-cols-2 gap-4"
>
<div
class=
"grid grid-cols-2 gap-7 mb-5 items-center"
>
<div>
<div
class=
"flex items-center gap-3 justify-between"
>
<h2
class=
"text-2xl font-bebas mb-5"
>
Hlasy členů
</h2>
<h2
class=
"text-2xl font-bebas"
>
Hlasy členů
</h2>
<ul
class=
"flex flex-col gap-2"
>
<button
{% for member in rv_members %}
class=
"bg-black text-white px-5 py-3 duration-100 hover:bg-gray-800"
<li
class=
"flex gap-4 items-center"
>
id=
"count-votes"
<div
class=
"basis-56 flex items-center"
>
>
Vypočítat
</button>
<i
class=
"ico--user text-xl mr-2"
></i>
{{ member.displayName }}
</div>
<select
class=
"grow __vote-selection"
multiple=
"multiple"
></select>
</li>
{% endfor %}
</ul>
</div>
</div>
<div>
<h2
class=
"text-2xl font-bebas"
>
Výsledky
</h2>
<h2
class=
"text-2xl font-bebas mb-5"
>
Výsledky
</h2>
</div>
</div>
<div
class=
"grid grid-cols-2 gap-7"
>
<ul
class=
"flex flex-col gap-2"
>
{% for member in rv_members %}
<li
class=
"flex gap-4 items-center"
>
<div
class=
"basis-56 flex items-center"
>
<i
class=
"ico--user text-xl mr-2"
></i>
{{ member.displayName }}
</div>
<select
class=
"grow w-full __vote-selection"
multiple=
"multiple"
></select>
</li>
{% endfor %}
</ul>
</div>
</div>
</main>
</main>
...
...
This diff is collapsed.
Click to expand it.
static_src/rv_voting_calc.js
+
26
−
14
View file @
dfb8d7dc
...
@@ -21,6 +21,16 @@ $(window).ready(
...
@@ -21,6 +21,16 @@ $(window).ready(
}
}
});
});
$
(
"
.__vote-selection
"
).
on
(
"
select2:selecting
"
,
event
=>
{
// Prevent empty tags.
if
(
event
.
params
.
args
.
data
.
id
==
""
)
{
event
.
preventDefault
();
}
}
);
$
(
"
.__vote-selection
"
).
on
(
$
(
"
.__vote-selection
"
).
on
(
"
select2:select
"
,
"
select2:select
"
,
event
=>
{
event
=>
{
...
@@ -31,7 +41,7 @@ $(window).ready(
...
@@ -31,7 +41,7 @@ $(window).ready(
return
;
return
;
}
}
const
tagName
=
event
.
params
.
data
.
text
;
const
tagName
=
event
.
params
.
data
.
id
;
const
addedTag
=
new
Option
(
const
addedTag
=
new
Option
(
tagName
,
tagName
,
...
@@ -46,7 +56,11 @@ $(window).ready(
...
@@ -46,7 +56,11 @@ $(window).ready(
// Check if they contain the tag. If they do, ignore them.
// Check if they contain the tag. If they do, ignore them.
for
(
const
selection
of
unfilteredSelections
)
{
for
(
const
selection
of
unfilteredSelections
)
{
if
(
$
(
selection
).
children
(
`option[value=
${
tagName
}
]`
).
length
===
0
)
{
if
(
$
(
selection
).
children
(
`option[value=
${
$
.
escapeSelector
(
tagName
)}
]`
).
length
===
0
)
{
filteredSelections
.
push
(
selection
);
filteredSelections
.
push
(
selection
);
}
}
}
}
...
@@ -61,7 +75,7 @@ $(window).ready(
...
@@ -61,7 +75,7 @@ $(window).ready(
event
=>
{
event
=>
{
//// Remove the tag option if it's not selected anywhere.
//// Remove the tag option if it's not selected anywhere.
const
tagName
=
event
.
params
.
data
.
text
;
const
tagName
=
event
.
params
.
data
.
id
;
// Get all other selections.
// Get all other selections.
const
selections
=
$
(
"
.__vote-selection
"
);
const
selections
=
$
(
"
.__vote-selection
"
);
...
@@ -69,16 +83,9 @@ $(window).ready(
...
@@ -69,16 +83,9 @@ $(window).ready(
// Check if any of them have the tag selected. If they do, end the function.
// Check if any of them have the tag selected. If they do, end the function.
for
(
const
selection
of
selections
)
{
for
(
const
selection
of
selections
)
{
for
(
const
data
of
$
(
selection
).
select2
(
"
data
"
))
{
for
(
const
data
of
$
(
selection
).
select2
(
"
data
"
))
{
if
(
data
.
selected
&&
data
.
id
==
tagName
)
{
if
(
data
.
id
==
tagName
)
{
// Workaround - add the option back to this select (TODO - improve)
// TODO - Don't remove the tag from this select.
$
(
event
.
target
).
append
(
// I'm not sure select2 has a good way of doing this.
new
Option
(
tagName
,
tagName
,
false
,
false
)
).
trigger
(
"
change
"
);
return
;
return
;
}
}
...
@@ -87,7 +94,12 @@ $(window).ready(
...
@@ -87,7 +94,12 @@ $(window).ready(
// If the function has not ended by now, we can remove the tag.
// If the function has not ended by now, we can remove the tag.
for
(
const
selection
of
selections
)
{
for
(
const
selection
of
selections
)
{
$
(
selection
).
children
(
`option[value=
${
tagName
}
]`
).
remove
();
(
$
(
selection
).
children
(
`option[value=
${
$
.
escapeSelector
(
tagName
)}
]`
).
remove
()
);
$
(
selection
).
trigger
(
"
change
"
);
$
(
selection
).
trigger
(
"
change
"
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
static_src/shared/utils.js
0 → 100644
+
5
−
0
View file @
dfb8d7dc
const
escapeHTML
=
(
source
)
=>
{
return
new
Option
(
source
).
innerHTML
;
}
export
{
escapeHTML
};
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