Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nk20
Manage
Activity
Members
Labels
Plan
Issues
31
Issue boards
Milestones
Wiki
Code
Merge requests
5
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package 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
BDE
nk20
Commits
aa98c484
Commit
aa98c484
authored
4 years ago
by
me5na7qbjqbrp
Browse files
Options
Downloads
Patches
Plain Diff
Create base template for search page
parent
00b07147
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!104
Beta
,
!98
Morefront
,
!95
Unified search
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/member/templates/member/user_list.html
+4
-63
4 additions, 63 deletions
apps/member/templates/member/user_list.html
note_kfet/templates/base_search.html
+69
-0
69 additions, 0 deletions
note_kfet/templates/base_search.html
with
73 additions
and
63 deletions
apps/member/templates/member/user_list.html
+
4
−
63
View file @
aa98c484
{% extends "base.html" %}
{% extends "base
_search
.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load render_table from django_tables2 %}
{% load i18n crispy_forms_tags perms %}
{% block contenttitle %}{% endblock %}
{% load i18n perms %}
{% block content %}
{% if "member.change_profile_registration_valid"|has_perm:user %}
...
...
@@ -13,63 +11,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
</a>
{% endif %}
<div
class=
"card bg-light"
>
<h3
class=
"card-header text-center"
>
{{ title }}
</h3>
<div
class=
"card-body"
>
<input
id=
"searchbar"
type=
"text"
class=
"form-control"
placeholder=
"Nom/prénom/note/section..."
>
</div>
<div
class=
"card-body"
>
<div
id=
"user_table"
>
{% if table.data %}
{% render_table table %}
{% else %}
<div
class=
"alert alert-warning"
>
{% trans "There is no user with this pattern." %}
</div>
{% endif %}
</div>
</div>
</div>
{# Search panel #}
{{ block.super }}
{% endblock %}
{% block extrajavascript %}
<script
type=
"text/javascript"
>
let
pattern
=
''
;
function
reloadTable
()
{
pattern
=
$
(
"
#searchbar
"
).
val
();
if
(
pattern
.
length
>
2
)
$
(
"
#user_table
"
).
load
(
location
.
pathname
+
"
?search=
"
+
pattern
.
replace
(
"
"
,
"
%20
"
)
+
"
#user_table
"
,
init_table
);
}
function
init_table
()
{
// On row click, go to object
$
(
"
.table-row
"
).
click
(
function
()
{
window
.
document
.
location
=
$
(
this
).
data
(
"
href
"
);
});
// Highlight searched terms
$
(
"
tr
"
).
each
(
function
()
{
$
(
this
).
find
(
"
td:eq(0), td:eq(1), td:eq(2), td:eq(3), td:eq(5)
"
).
each
(
function
()
{
$
(
this
).
html
(
$
(
this
).
text
().
replace
(
new
RegExp
(
pattern
,
'
i
'
),
"
<mark>$&</mark>
"
));
});
});
}
$
(
document
).
ready
(
function
()
{
// Recover last search from url
let
searchParams
=
new
URLSearchParams
(
window
.
location
.
search
)
if
(
searchParams
.
has
(
'
search
'
))
pattern
=
searchParams
.
get
(
'
search
'
);
// On search, refresh table
$
(
"
#searchbar
"
).
keyup
(
debounce
(
reloadTable
,
300
));
// First init
init_table
();
});
</script>
{% endblock %}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
note_kfet/templates/base_search.html
0 → 100644
+
69
−
0
View file @
aa98c484
{% extends "base.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load render_table from django_tables2 %}
{% load i18n perms %}
{% block contenttitle %}{% endblock %}
{% block content %}
<div
class=
"card bg-light"
>
<h3
class=
"card-header text-center"
>
{{ title }}
</h3>
<div
class=
"card-body"
>
<input
id=
"searchbar"
type=
"text"
class=
"form-control"
placeholder=
"{% trans "
Search
by
attribute
such
as
name
…"
%}"
>
</div>
<div
id=
"dynamic-table"
>
{% if table.data %}
{% render_table table %}
{% else %}
<div
class=
"card-body"
>
<div
class=
"alert alert-warning"
>
{% trans "There is no results." %}
</div>
</div>
{% endif %}
</div>
</div>
{% endblock %}
{% block extrajavascript %}
<script
type=
"text/javascript"
>
let
pattern
=
''
;
function
reloadTable
()
{
pattern
=
$
(
"
#searchbar
"
).
val
();
if
(
pattern
.
length
>
2
)
$
(
"
#dynamic-table
"
).
load
(
location
.
pathname
+
"
?search=
"
+
pattern
.
replace
(
"
"
,
"
%20
"
)
+
"
#dynamic-table
"
,
init_table
);
}
function
init_table
()
{
// On row click, go to object
$
(
"
.table-row
"
).
click
(
function
()
{
window
.
document
.
location
=
$
(
this
).
data
(
"
href
"
);
});
// Highlight searched terms
$
(
"
tr
"
).
each
(
function
()
{
$
(
this
).
find
(
"
td:eq(0), td:eq(1), td:eq(2), td:eq(3), td:eq(5)
"
).
each
(
function
()
{
$
(
this
).
html
(
$
(
this
).
text
().
replace
(
new
RegExp
(
pattern
,
'
i
'
),
"
<mark>$&</mark>
"
));
});
});
}
$
(
document
).
ready
(
function
()
{
// Recover last search from url
let
searchParams
=
new
URLSearchParams
(
window
.
location
.
search
)
if
(
searchParams
.
has
(
'
search
'
))
pattern
=
searchParams
.
get
(
'
search
'
);
// On search, refresh table
$
(
"
#searchbar
"
).
keyup
(
debounce
(
reloadTable
,
300
));
// First init
init_table
();
});
</script>
{% endblock %}
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