Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
douban-api-proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
douban-api-proxy
Commits
bd7c6828
Commit
bd7c6828
authored
Mar 16, 2021
by
Ozzie Isaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Selects are working in user management
parent
da2c3e9e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
116 additions
and
32 deletions
+116
-32
table.js
cps/static/js/table.js
+103
-20
config_view_edit.html
cps/templates/config_view_edit.html
+2
-2
modal_dialogs.html
cps/templates/modal_dialogs.html
+1
-1
user_table.html
cps/templates/user_table.html
+10
-9
No files found.
cps/static/js/table.js
View file @
bd7c6828
...
...
@@ -246,7 +246,7 @@ $(function() {
}
});
$
(
"#restrictModal"
).
on
(
"hidden.bs.modal"
,
function
()
{
$
(
"#restrictModal"
).
on
(
"hidden.bs.modal"
,
function
(
e
)
{
// Destroy table and remove hooks for buttons
$
(
"#restrict-elements-table"
).
unbind
();
$
(
"#restrict-elements-table"
).
bootstrapTable
(
"destroy"
);
...
...
@@ -255,8 +255,54 @@ $(function() {
$
(
"#h2"
).
addClass
(
"hidden"
);
$
(
"#h3"
).
addClass
(
"hidden"
);
$
(
"#h4"
).
addClass
(
"hidden"
);
$
(
"#add_element"
).
val
(
""
);
});
function
startTable
(
type
,
userId
)
{
function
startTable
(
target
,
userId
)
{
var
type
=
0
;
switch
(
target
)
{
case
"get_column_values"
:
type
=
1
;
$
(
"#h2"
).
removeClass
(
"hidden"
);
break
;
case
"get_tags"
:
type
=
0
;
$
(
"#h1"
).
removeClass
(
"hidden"
);
break
;
case
"get_user_column_values"
:
type
=
3
;
$
(
"#h4"
).
removeClass
(
"hidden"
);
break
;
case
"get_user_tags"
:
type
=
2
;
$
(
"#h3"
).
removeClass
(
"hidden"
);
break
;
case
"denied_tags"
:
type
=
2
;
$
(
"#h2"
).
removeClass
(
"hidden"
);
$
(
"#submit_allow"
).
addClass
(
"hidden"
);
$
(
"#submit_restrict"
).
removeClass
(
"hidden"
);
break
;
case
"allowed_tags"
:
type
=
2
;
$
(
"#h2"
).
removeClass
(
"hidden"
);
$
(
"#submit_restrict"
).
addClass
(
"hidden"
);
$
(
"#submit_allow"
).
removeClass
(
"hidden"
);
break
;
case
"allowed_column_value"
:
type
=
3
;
$
(
"#h2"
).
removeClass
(
"hidden"
);
$
(
"#submit_restrict"
).
addClass
(
"hidden"
);
$
(
"#submit_allow"
).
removeClass
(
"hidden"
);
break
;
case
"denied_column_value"
:
type
=
3
;
$
(
"#h2"
).
removeClass
(
"hidden"
);
$
(
"#submit_allow"
).
addClass
(
"hidden"
);
$
(
"#submit_restrict"
).
removeClass
(
"hidden"
);
break
;
}
$
(
"#restrict-elements-table"
).
bootstrapTable
({
formatNoMatches
:
function
()
{
return
""
;
...
...
@@ -270,6 +316,10 @@ $(function() {
return
{
classes
:
"bg-dark-danger"
};
}
},
onLoadSuccess
:
function
()
{
$
(
".no-records-found"
).
addClass
(
"hidden"
);
$
(
".fixed-table-loading"
).
addClass
(
"hidden"
);
},
onClickCell
:
function
(
field
,
value
,
row
)
{
if
(
field
===
3
)
{
$
.
ajax
({
...
...
@@ -323,24 +373,18 @@ $(function() {
return
;
});
}
$
(
"#get_column_values"
).
on
(
"click"
,
function
()
{
startTable
(
1
,
0
);
$
(
"#h2"
).
removeClass
(
"hidden"
);
});
$
(
"#get_tags"
).
on
(
"click"
,
function
()
{
startTable
(
0
,
0
);
$
(
"#h1"
).
removeClass
(
"hidden"
);
});
$
(
"#get_user_column_values"
).
on
(
"click"
,
function
()
{
startTable
(
3
,
$
(
this
).
data
(
"id"
));
$
(
"#h4"
).
removeClass
(
"hidden"
);
});
$
(
"#get_user_tags"
).
on
(
"click"
,
function
()
{
startTable
(
2
,
$
(
this
).
data
(
"id"
));
$
(
this
)[
0
].
blur
();
$
(
"#h3"
).
removeClass
(
"hidden"
);
$
(
"#restrictModal"
).
on
(
"show.bs.modal"
,
function
(
e
)
{
var
target
=
$
(
e
.
relatedTarget
).
attr
(
'id'
);
var
dataId
;
$
(
e
.
relatedTarget
).
one
(
'focus'
,
function
(
e
){
$
(
this
).
blur
();});
//$(e.relatedTarget).blur();
if
(
$
(
e
.
relatedTarget
).
hasClass
(
"button_head"
))
{
dataId
=
$
(
'#user-table'
).
bootstrapTable
(
'getSelections'
).
map
(
a
=>
a
.
id
);
}
else
{
dataId
=
$
(
e
.
relatedTarget
).
data
(
"id"
);
}
startTable
(
target
,
dataId
);
});
// User table handling
...
...
@@ -487,17 +531,23 @@ $(function() {
$
(
".check_head"
).
attr
(
"aria-disabled"
,
true
);
$
(
".check_head"
).
attr
(
"disabled"
,
true
);
$
(
".check_head"
).
prop
(
'checked'
,
false
);
$
(
".button_head"
).
attr
(
"aria-disabled"
,
true
);
$
(
".button_head"
).
addClass
(
"disabled"
);
$
(
".header_select"
).
attr
(
"disabled"
,
true
);
}
else
{
$
(
"#user_delete_selection"
).
removeClass
(
"disabled"
);
$
(
"#user_delete_selection"
).
attr
(
"aria-disabled"
,
false
);
$
(
".check_head"
).
attr
(
"aria-disabled"
,
false
);
$
(
".check_head"
).
removeAttr
(
"disabled"
);
$
(
".button_head"
).
attr
(
"aria-disabled"
,
false
);
$
(
".button_head"
).
removeClass
(
"disabled"
);
$
(
".header_select"
).
removeAttr
(
"disabled"
);
}
});
});
/* Function for deleting domain restrictions */
function
TableActions
(
value
,
row
)
{
return
[
...
...
@@ -572,6 +622,36 @@ function checkboxChange(checkbox, userId, field, field_index) {
});
}
function
selectHeader
(
element
,
field
)
{
var
result
=
$
(
'#user-table'
).
bootstrapTable
(
'getSelections'
).
map
(
a
=>
a
.
id
);
$
.
ajax
({
method
:
"post"
,
url
:
window
.
location
.
pathname
+
"/../../ajax/editlistusers/"
+
field
,
data
:
{
"pk"
:
result
,
"value"
:
element
.
value
},
success
:
function
()
{
$
.
ajax
({
method
:
"get"
,
url
:
window
.
location
.
pathname
+
"/../../ajax/listusers"
,
async
:
true
,
timeout
:
900
,
success
:
function
(
data
)
{
$
(
"#user-table"
).
bootstrapTable
(
"load"
,
data
);
$
(
"#user_delete_selection"
).
addClass
(
"disabled"
);
$
(
"#user_delete_selection"
).
attr
(
"aria-disabled"
,
true
);
$
(
".check_head"
).
attr
(
"aria-disabled"
,
true
);
$
(
".check_head"
).
attr
(
"disabled"
,
true
);
$
(
".check_head"
).
prop
(
'checked'
,
false
);
$
(
".button_head"
).
attr
(
"aria-disabled"
,
true
);
$
(
".button_head"
).
addClass
(
"disabled"
);
$
(
".header_select"
).
attr
(
"disabled"
,
true
);
}
});
}
});
console
.
log
(
"test"
);
}
function
checkboxHeader
(
CheckboxState
,
field
,
field_index
)
{
var
result
=
$
(
'#user-table'
).
bootstrapTable
(
'getSelections'
).
map
(
a
=>
a
.
id
);
$
.
ajax
({
...
...
@@ -591,6 +671,9 @@ function checkboxHeader(CheckboxState, field, field_index) {
$
(
".check_head"
).
attr
(
"aria-disabled"
,
true
);
$
(
".check_head"
).
attr
(
"disabled"
,
true
);
$
(
".check_head"
).
prop
(
'checked'
,
false
);
$
(
".button_head"
).
attr
(
"aria-disabled"
,
true
);
$
(
".button_head"
).
addClass
(
"disabled"
);
$
(
".header_select"
).
attr
(
"disabled"
,
true
);
}
});
}
...
...
cps/templates/config_view_edit.html
View file @
bd7c6828
...
...
@@ -141,8 +141,8 @@
<input
type=
"checkbox"
name=
"Show_detail_random"
id=
"Show_detail_random"
{%
if
conf
.
show_detail_random
()
%}
checked
{%
endif
%}
>
<label
for=
"Show_detail_random"
>
{{_('Show Random Books in Detail View')}}
</label>
</div>
<a
href=
"#"
id=
"get_tags"
class=
"btn btn-default"
data-toggle=
"modal"
data-target=
"#restrictModal"
>
{{_('Add Allowed/Denied Tags')}}
</a>
<a
href=
"#"
id=
"get_column_values"
class=
"btn btn-default"
data-toggle=
"modal"
data-target=
"#restrictModal"
>
{{_('Add Allowed/Denied custom column values')}}
</a>
<a
href=
"#"
id=
"get_tags"
data-id=
"0"
class=
"btn btn-default"
data-toggle=
"modal"
data-target=
"#restrictModal"
>
{{_('Add Allowed/Denied Tags')}}
</a>
<a
href=
"#"
id=
"get_column_values"
data-id=
"0"
class=
"btn btn-default"
data-toggle=
"modal"
data-target=
"#restrictModal"
>
{{_('Add Allowed/Denied custom column values')}}
</a>
</div>
</div>
</div>
...
...
cps/templates/modal_dialogs.html
View file @
bd7c6828
...
...
@@ -22,7 +22,7 @@
<form
id=
"add_restriction"
action=
""
method=
"POST"
>
<div
class=
"form-group required"
>
<label
for=
"add_element"
>
{{_('Add View Restriction')}}
</label>
<input
type=
"text"
class=
"form-control"
name=
"add_element"
id=
"add_element"
>
<input
type=
"text"
class=
"form-control"
name=
"add_element"
id=
"add_element"
>
</div>
<div
class=
"form-group required"
>
<input
type=
"button"
class=
"btn btn-default"
value=
"{{_('Allow')}}"
name=
"submit_allow"
id=
"submit_allow"
data-dismiss=
"static"
>
...
...
cps/templates/user_table.html
View file @
bd7c6828
{% extends "layout.html" %}
{% macro user_table_row(parameter, edit_text, show_text, validate, button=False) -%}
{% macro user_table_row(parameter, edit_text, show_text, validate, button=False
, id=0
) -%}
<th
data-field=
"{{ parameter }}"
id=
"{{ parameter }}"
data-name=
"{{ parameter }}"
data-visible=
"{{visiblility.get(parameter)}}"
...
...
@@ -12,7 +12,7 @@
{%
endif
%}
{%
if
validate
%}
data-edit-validate=
"{{ _('This Field is Required') }}"
{%
endif
%}
>
{% if button %}
<div><div
class=
"btn btn-default
disabled"
aria-disabled=
"true"
>
{{edit_text}}
</div></div><br>
<div><div
data-id=
"{{id}}"
data-toggle=
"modal"
data-target=
"#restrictModal"
class=
"btn btn-default button_head
disabled"
aria-disabled=
"true"
>
{{edit_text}}
</div></div><br>
{% endif %}
{{ show_text }}
</th>
...
...
@@ -47,7 +47,7 @@
data-editable-source=
{{url}}
{%
if
validate
%}
data-edit-validate=
"{{ _('This Field is Required') }}"
{%
endif
%}
>
<div>
<select
id=
"select_{{ parameter }}"
disabled=
""
>
<select
id=
"select_{{ parameter }}"
class=
"header_select"
onchange=
"selectHeader(this, '{{parameter}}')"
disabled=
""
>
<option
value=
"all"
>
{{ _('Show All') }}
</option>
{% for language in languages %}
<option
value=
"{{language.lang_code}}"
>
{{language.name}}
</option>
...
...
@@ -69,7 +69,7 @@
data-editable-source=
{{url}}
{%
if
validate
%}
data-edit-validate=
"{{ _('This Field is Required') }}"
{%
endif
%}
>
<div>
<select
id=
"select_{{ parameter }}"
disabled=
""
>
<select
id=
"select_{{ parameter }}"
class=
"header_select"
onchange=
"selectHeader(this, '{{parameter}}')"
disabled=
""
>
<option>
{{_('Select...')}}
</option>
{% for translation in translations %}
<option
value=
"{{translation}}"
>
{{translation.display_name|capitalize}}
</option>
...
...
@@ -104,10 +104,10 @@
{{ user_table_row('kindle_mail', _('Enter Kindle E-mail Address'), _('Kindle E-mail'), true) }}
{{ user_select_translations('locale', url_for('admin.table_get_locale'), _('Locale'), true) }}
{{ user_select_languages('default_language', url_for('admin.table_get_default_lang'), _('Visible Book Languages'), true) }}
{{ user_table_row('denied_tags', _("Edit Denied Tags"), _("Denied Tags"),
true, true
) }}
{{ user_table_row('allowed_tags', _("Edit Allowed Tags"), _("Allowed Tags"),
true, true
) }}
{{ user_table_row('allowed_column_value', _("Edit Allowed Column Values"), _("Allowed Column Values"),
true, true
) }}
{{ user_table_row('denied_column_value', _("Edit Denied Column Values"), _("Denied Columns Values"),
true, true
) }}
{{ user_table_row('denied_tags', _("Edit Denied Tags"), _("Denied Tags"),
false, true, 0
) }}
{{ user_table_row('allowed_tags', _("Edit Allowed Tags"), _("Allowed Tags"),
false, true, 1
) }}
{{ user_table_row('allowed_column_value', _("Edit Allowed Column Values"), _("Allowed Column Values"),
false, true, 2
) }}
{{ user_table_row('denied_column_value', _("Edit Denied Column Values"), _("Denied Columns Values"),
false, true, 3
) }}
{{ user_checkbox_row("role", "admin_role", _('Admin'), visiblility, all_roles)}}
{{ user_checkbox_row("role", "download_role",_('Upload'), visiblility, all_roles)}}
{{ user_checkbox_row("role", "upload_role", _('Download'), visiblility, all_roles)}}
...
...
@@ -130,13 +130,14 @@
{{ user_checkbox_row("sidebar_view", "sidebar_archived", _('Show archived books'), visiblility, sidebar_settings)}}
{{ user_checkbox_row("sidebar_view", "sidebar_download", _('Show Downloaded Books'), visiblility, sidebar_settings)}}
{{ user_checkbox_row("sidebar_view", "sidebar_list", _('Show Books List'), visiblility, sidebar_settings)}}
<th
data-align=
"right"
data-formatter=
"UserActions"
data-switchable=
"false"
><div><div
class=
"btn btn-default disabled"
aria-disabled=
"true"
>
{{_('Delete User')}}
</div></div><br>
{{_('Delete User')}}
</th>
<th
data-align=
"right"
data-formatter=
"UserActions"
data-switchable=
"false"
><div><div
class=
"btn btn-default
button_head
disabled"
aria-disabled=
"true"
>
{{_('Delete User')}}
</div></div><br>
{{_('Delete User')}}
</th>
</tr>
</thead>
</table>
{% endblock %}
{% block modal %}
{{ delete_confirm_modal() }}
{{ restrict_modal() }}
{% endblock %}
{% block js %}
<script
src=
"{{ url_for('static', filename='js/libs/bootstrap-table/bootstrap-table.min.js') }}"
></script>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment