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
b070ba14
Commit
b070ba14
authored
Mar 16, 2021
by
Ozzie Isaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Selects are working in user management with generic confirm dialog
parent
bd7c6828
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
100 additions
and
66 deletions
+100
-66
admin.py
cps/admin.py
+8
-0
main.js
cps/static/js/main.js
+9
-9
table.js
cps/static/js/table.js
+58
-51
layout.html
cps/templates/layout.html
+1
-1
modal_dialogs.html
cps/templates/modal_dialogs.html
+22
-4
user_table.html
cps/templates/user_table.html
+2
-1
No files found.
cps/admin.py
View file @
b070ba14
...
@@ -440,6 +440,14 @@ def load_dialogtexts(element_id):
...
@@ -440,6 +440,14 @@ def load_dialogtexts(element_id):
texts
[
"main"
]
=
_
(
'Do you really want to delete this user?'
)
texts
[
"main"
]
=
_
(
'Do you really want to delete this user?'
)
elif
element_id
==
"delete_shelf"
:
elif
element_id
==
"delete_shelf"
:
texts
[
"main"
]
=
_
(
'Are you sure you want to delete this shelf?'
)
texts
[
"main"
]
=
_
(
'Are you sure you want to delete this shelf?'
)
elif
element_id
==
"select_locale"
:
texts
[
"main"
]
=
_
(
'Are you sure you want to change locales of selected user(s)?'
)
elif
element_id
==
"select_default_language"
:
texts
[
"main"
]
=
_
(
'Are you sure you want to change visible book languages for selected user(s)?'
)
elif
element_id
==
"role"
:
texts
[
"main"
]
=
_
(
'Are you sure you want to change the selected role for the selected user(s)?'
)
elif
element_id
==
"sidebar_view"
:
texts
[
"main"
]
=
_
(
'Are you sure you want to change the selected visibility restrictions for the selected user(s)?'
)
return
json
.
dumps
(
texts
)
return
json
.
dumps
(
texts
)
...
...
cps/static/js/main.js
View file @
b070ba14
...
@@ -114,26 +114,23 @@ $(document).ready(function() {
...
@@ -114,26 +114,23 @@ $(document).ready(function() {
}
}
});
});
function
confirmDialog
(
id
,
dataValue
,
yesFn
,
noFn
)
{
function
confirmDialog
(
id
,
dialogid
,
dataValue
,
yesFn
,
noFn
)
{
var
$confirm
=
$
(
"#GeneralDeleteModal"
);
var
$confirm
=
$
(
"#"
+
dialogid
);
// var dataValue= e.data('value'); // target.data('value');
$confirm
.
modal
(
'show'
);
$confirm
.
modal
(
'show'
);
$
.
ajax
({
$
.
ajax
({
method
:
"get"
,
method
:
"get"
,
dataType
:
"json"
,
dataType
:
"json"
,
url
:
getPath
()
+
"/ajax/loaddialogtexts/"
+
id
,
url
:
getPath
()
+
"/ajax/loaddialogtexts/"
+
id
,
success
:
function
success
(
data
)
{
success
:
function
success
(
data
)
{
$
(
"#header
"
).
html
(
data
.
header
);
$
(
"#header
-"
+
dialogid
).
html
(
data
.
header
);
$
(
"#text
"
).
html
(
data
.
main
);
$
(
"#text
-"
+
dialogid
).
html
(
data
.
main
);
}
}
});
});
$
(
"#btnConfirmYes-"
+
dialogid
).
off
(
'click'
).
click
(
function
()
{
$
(
"#btnConfirmYes"
).
off
(
'click'
).
click
(
function
()
{
yesFn
(
dataValue
);
yesFn
(
dataValue
);
$confirm
.
modal
(
"hide"
);
$confirm
.
modal
(
"hide"
);
});
});
$
(
"#btnConfirmNo
"
).
off
(
'click'
).
click
(
function
()
{
$
(
"#btnConfirmNo
-"
+
dialogid
).
off
(
'click'
).
click
(
function
()
{
if
(
typeof
noFn
!==
'undefined'
)
{
if
(
typeof
noFn
!==
'undefined'
)
{
noFn
(
dataValue
);
noFn
(
dataValue
);
}
}
...
@@ -483,6 +480,7 @@ $(function() {
...
@@ -483,6 +480,7 @@ $(function() {
$
(
"#config_delete_kobo_token"
).
click
(
function
()
{
$
(
"#config_delete_kobo_token"
).
click
(
function
()
{
confirmDialog
(
confirmDialog
(
$
(
this
).
attr
(
'id'
),
$
(
this
).
attr
(
'id'
),
"GeneralDeleteModal"
,
$
(
this
).
data
(
'value'
),
$
(
this
).
data
(
'value'
),
function
(
value
)
{
function
(
value
)
{
$
.
ajax
({
$
.
ajax
({
...
@@ -511,6 +509,7 @@ $(function() {
...
@@ -511,6 +509,7 @@ $(function() {
$
(
"#btndeluser"
).
click
(
function
()
{
$
(
"#btndeluser"
).
click
(
function
()
{
confirmDialog
(
confirmDialog
(
$
(
this
).
attr
(
'id'
),
$
(
this
).
attr
(
'id'
),
"GeneralDeleteModal"
,
$
(
this
).
data
(
'value'
),
$
(
this
).
data
(
'value'
),
function
(
value
){
function
(
value
){
var
subform
=
$
(
'#user_submit'
).
closest
(
"form"
);
var
subform
=
$
(
'#user_submit'
).
closest
(
"form"
);
...
@@ -529,6 +528,7 @@ $(function() {
...
@@ -529,6 +528,7 @@ $(function() {
$
(
"#delete_shelf"
).
click
(
function
()
{
$
(
"#delete_shelf"
).
click
(
function
()
{
confirmDialog
(
confirmDialog
(
$
(
this
).
attr
(
'id'
),
$
(
this
).
attr
(
'id'
),
"GeneralDeleteModal"
,
$
(
this
).
data
(
'value'
),
$
(
this
).
data
(
'value'
),
function
(
value
){
function
(
value
){
window
.
location
.
href
=
window
.
location
.
pathname
+
"/../../shelf/delete/"
+
value
window
.
location
.
href
=
window
.
location
.
pathname
+
"/../../shelf/delete/"
+
value
...
...
cps/static/js/table.js
View file @
b070ba14
...
@@ -237,12 +237,12 @@ $(function() {
...
@@ -237,12 +237,12 @@ $(function() {
}
}
$
(
"#domain-allow-table"
).
on
(
"click-cell.bs.table"
,
function
(
field
,
value
,
row
,
$element
)
{
$
(
"#domain-allow-table"
).
on
(
"click-cell.bs.table"
,
function
(
field
,
value
,
row
,
$element
)
{
if
(
value
===
2
)
{
if
(
value
===
2
)
{
confirmDialog
(
"btndeletedomain"
,
$element
.
id
,
domainHandle
);
confirmDialog
(
"btndeletedomain"
,
"GeneralDeleteModal"
,
$element
.
id
,
domainHandle
);
}
}
});
});
$
(
"#domain-deny-table"
).
on
(
"click-cell.bs.table"
,
function
(
field
,
value
,
row
,
$element
)
{
$
(
"#domain-deny-table"
).
on
(
"click-cell.bs.table"
,
function
(
field
,
value
,
row
,
$element
)
{
if
(
value
===
2
)
{
if
(
value
===
2
)
{
confirmDialog
(
"btndeletedomain"
,
$element
.
id
,
domainHandle
);
confirmDialog
(
"btndeletedomain"
,
"GeneralDeleteModal"
,
$element
.
id
,
domainHandle
);
}
}
});
});
...
@@ -508,7 +508,7 @@ $(function() {
...
@@ -508,7 +508,7 @@ $(function() {
$
(
"#user-table"
).
on
(
"click-cell.bs.table"
,
function
(
field
,
value
,
row
,
$element
)
{
$
(
"#user-table"
).
on
(
"click-cell.bs.table"
,
function
(
field
,
value
,
row
,
$element
)
{
if
(
value
===
"denied_column_value"
)
{
if
(
value
===
"denied_column_value"
)
{
ConfirmDialog
(
"btndeluser"
,
$element
.
id
,
user_handle
);
ConfirmDialog
(
"btndeluser"
,
"GeneralDeleteModal"
,
$element
.
id
,
user_handle
);
}
}
});
});
...
@@ -621,62 +621,69 @@ function checkboxChange(checkbox, userId, field, field_index) {
...
@@ -621,62 +621,69 @@ function checkboxChange(checkbox, userId, field, field_index) {
}
}
});
});
}
}
function
deactivateHeaderButtons
(
e
)
{
$
(
"#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
);
}
function
selectHeader
(
element
,
field
)
{
function
selectHeader
(
element
,
field
)
{
var
result
=
$
(
'#user-table'
).
bootstrapTable
(
'getSelections'
).
map
(
a
=>
a
.
id
);
if
(
element
.
value
!==
"None"
)
{
$
.
ajax
({
confirmDialog
(
element
.
id
,
"GeneralChangeModal"
,
0
,
function
()
{
method
:
"post"
,
var
result
=
$
(
'#user-table'
).
bootstrapTable
(
'getSelections'
).
map
(
a
=>
a
.
id
);
url
:
window
.
location
.
pathname
+
"/../../ajax/editlistusers/"
+
field
,
data
:
{
"pk"
:
result
,
"value"
:
element
.
value
},
success
:
function
()
{
$
.
ajax
({
$
.
ajax
({
method
:
"ge
t"
,
method
:
"pos
t"
,
url
:
window
.
location
.
pathname
+
"/../../ajax/
listusers"
,
url
:
window
.
location
.
pathname
+
"/../../ajax/
editlistusers/"
+
field
,
async
:
true
,
data
:
{
"pk"
:
result
,
"value"
:
element
.
value
}
,
timeout
:
900
,
success
:
function
()
{
success
:
function
(
data
)
{
$
.
ajax
(
{
$
(
"#user-table"
).
bootstrapTable
(
"load"
,
data
);
method
:
"get"
,
$
(
"#user_delete_selection"
).
addClass
(
"disabled"
);
url
:
window
.
location
.
pathname
+
"/../../ajax/listusers"
,
$
(
"#user_delete_selection"
).
attr
(
"aria-disabled"
,
true
);
async
:
true
,
$
(
".check_head"
).
attr
(
"aria-disabled"
,
true
);
timeout
:
900
,
$
(
".check_head"
).
attr
(
"disabled"
,
true
);
success
:
function
(
data
)
{
$
(
".check_head"
).
prop
(
'checked'
,
false
);
$
(
"#user-table"
).
bootstrapTable
(
"load"
,
data
);
$
(
".button_head"
).
attr
(
"aria-disabled"
,
true
);
deactivateHeaderButtons
(
);
$
(
".button_head"
).
addClass
(
"disabled"
);
}
$
(
".header_select"
).
attr
(
"disabled"
,
true
);
}
);
}
}
});
});
}
});
});
}
console
.
log
(
"test"
);
}
}
function
checkboxHeader
(
CheckboxState
,
field
,
field_index
)
{
function
checkboxHeader
(
CheckboxState
,
field
,
field_index
)
{
var
result
=
$
(
'#user-table'
).
bootstrapTable
(
'getSelections'
).
map
(
a
=>
a
.
id
);
confirmDialog
(
field
,
"GeneralChangeModal"
,
0
,
function
()
{
$
.
ajax
({
var
result
=
$
(
'#user-table'
).
bootstrapTable
(
'getSelections'
).
map
(
a
=>
a
.
id
);
method
:
"post"
,
$
.
ajax
({
url
:
window
.
location
.
pathname
+
"/../../ajax/editlistusers/"
+
field
,
method
:
"post"
,
data
:
{
"pk"
:
result
,
"field_index"
:
field_index
,
"value"
:
CheckboxState
},
url
:
window
.
location
.
pathname
+
"/../../ajax/editlistusers/"
+
field
,
success
:
function
()
{
data
:
{
"pk"
:
result
,
"field_index"
:
field_index
,
"value"
:
CheckboxState
},
$
.
ajax
({
success
:
function
()
{
method
:
"get"
,
$
.
ajax
({
url
:
window
.
location
.
pathname
+
"/../../ajax/listusers"
,
method
:
"get"
,
async
:
true
,
url
:
window
.
location
.
pathname
+
"/../../ajax/listusers"
,
timeout
:
900
,
async
:
true
,
success
:
function
(
data
)
{
timeout
:
900
,
$
(
"#user-table"
).
bootstrapTable
(
"load"
,
data
);
success
:
function
(
data
)
{
$
(
"#user_delete_selection"
).
addClass
(
"disabled"
);
$
(
"#user-table"
).
bootstrapTable
(
"load"
,
data
);
$
(
"#user_delete_selection"
).
attr
(
"aria-disabled"
,
true
);
$
(
"#user_delete_selection"
).
addClass
(
"disabled"
);
$
(
".check_head"
).
attr
(
"aria-disabled"
,
true
);
$
(
"#user_delete_selection"
).
attr
(
"aria-disabled"
,
true
);
$
(
".check_head"
).
attr
(
"disabled"
,
true
);
$
(
".check_head"
).
attr
(
"aria-disabled"
,
true
);
$
(
".check_head"
).
prop
(
'checked'
,
false
);
$
(
".check_head"
).
attr
(
"disabled"
,
true
);
$
(
".button_head"
).
attr
(
"aria-disabled"
,
true
);
$
(
".check_head"
).
prop
(
'checked'
,
false
);
$
(
".button_head"
).
addClass
(
"disabled"
);
$
(
".button_head"
).
attr
(
"aria-disabled"
,
true
);
$
(
".header_select"
).
attr
(
"disabled"
,
true
);
$
(
".button_head"
).
addClass
(
"disabled"
);
}
$
(
".header_select"
).
attr
(
"disabled"
,
true
);
});
}
}
});
}
});
});
});
}
}
...
...
cps/templates/layout.html
View file @
b070ba14
{% from 'modal_dialogs.html' import restrict_modal, delete_book, filechooser_modal, delete_confirm_modal %}
{% from 'modal_dialogs.html' import restrict_modal, delete_book, filechooser_modal, delete_confirm_modal
, change_confirm_modal
%}
<!DOCTYPE html>
<!DOCTYPE html>
<html
lang=
"{{ g.user.locale }}"
>
<html
lang=
"{{ g.user.locale }}"
>
<head>
<head>
...
...
cps/templates/modal_dialogs.html
View file @
b070ba14
...
@@ -108,13 +108,31 @@
...
@@ -108,13 +108,31 @@
<div
class=
"modal-dialog modal-sm"
>
<div
class=
"modal-dialog modal-sm"
>
<div
class=
"modal-content"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header bg-danger text-center"
>
<div
class=
"modal-header bg-danger text-center"
>
<span
id=
"header"
></span>
<span
id=
"header
-GeneralDeleteModal
"
></span>
</div>
</div>
<div
class=
"modal-body text-center"
>
<div
class=
"modal-body text-center"
>
<span
id=
"text"
></span>
<span
id=
"text
-GeneralDeleteModal
"
></span>
<p></p>
<p></p>
<button
id=
"btnConfirmYes"
type=
"button"
class=
"btn btn btn-danger"
>
{{_('Delete')}}
</button>
<button
id=
"btnConfirmYes-GeneralDeleteModal"
type=
"button"
class=
"btn btn btn-danger"
>
{{_('Delete')}}
</button>
<button
id=
"btnConfirmNo"
type=
"button"
class=
"btn btn-default"
>
{{_('Cancel')}}
</button>
<button
id=
"btnConfirmNo-GeneralDeleteModal"
type=
"button"
class=
"btn btn-default"
>
{{_('Cancel')}}
</button>
</div>
</div>
</div>
</div>
{% endmacro %}
{% macro change_confirm_modal() %}
<div
id=
"GeneralChangeModal"
class=
"modal fade"
role=
"Dialog"
>
<div
class=
"modal-dialog modal-sm"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header bg-info text-center"
>
<span
id=
"header-GeneralChangeModal"
></span>
</div>
<div
class=
"modal-body text-center"
>
<span
id=
"text-GeneralChangeModal"
></span>
<p></p>
<button
id=
"btnConfirmYes-GeneralChangeModal"
type=
"button"
class=
"btn btn btn-default"
>
{{_('Ok')}}
</button>
<button
id=
"btnConfirmNo-GeneralChangeModal"
type=
"button"
class=
"btn btn-default"
>
{{_('Cancel')}}
</button>
</div>
</div>
</div>
</div>
</div>
</div>
...
...
cps/templates/user_table.html
View file @
b070ba14
...
@@ -70,7 +70,7 @@
...
@@ -70,7 +70,7 @@
{%
if
validate
%}
data-edit-validate=
"{{ _('This Field is Required') }}"
{%
endif
%}
>
{%
if
validate
%}
data-edit-validate=
"{{ _('This Field is Required') }}"
{%
endif
%}
>
<div>
<div>
<select
id=
"select_{{ parameter }}"
class=
"header_select"
onchange=
"selectHeader(this, '{{parameter}}')"
disabled=
""
>
<select
id=
"select_{{ parameter }}"
class=
"header_select"
onchange=
"selectHeader(this, '{{parameter}}')"
disabled=
""
>
<option>
{{_('Select...')}}
</option>
<option
value=
"None"
>
{{_('Select...')}}
</option>
{% for translation in translations %}
{% for translation in translations %}
<option
value=
"{{translation}}"
>
{{translation.display_name|capitalize}}
</option>
<option
value=
"{{translation}}"
>
{{translation.display_name|capitalize}}
</option>
{% endfor %}
{% endfor %}
...
@@ -137,6 +137,7 @@
...
@@ -137,6 +137,7 @@
{% endblock %}
{% endblock %}
{% block modal %}
{% block modal %}
{{ delete_confirm_modal() }}
{{ delete_confirm_modal() }}
{{ change_confirm_modal() }}
{{ restrict_modal() }}
{{ restrict_modal() }}
{% endblock %}
{% endblock %}
{% block js %}
{% block js %}
...
...
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