mirror of
https://github.com/janeczku/calibre-web
synced 2025-01-13 19:00:30 +00:00
Selects are working in user management
This commit is contained in:
parent
da2c3e9ed7
commit
bd7c6828bf
@ -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
|
// Destroy table and remove hooks for buttons
|
||||||
$("#restrict-elements-table").unbind();
|
$("#restrict-elements-table").unbind();
|
||||||
$("#restrict-elements-table").bootstrapTable("destroy");
|
$("#restrict-elements-table").bootstrapTable("destroy");
|
||||||
@ -255,8 +255,54 @@ $(function() {
|
|||||||
$("#h2").addClass("hidden");
|
$("#h2").addClass("hidden");
|
||||||
$("#h3").addClass("hidden");
|
$("#h3").addClass("hidden");
|
||||||
$("#h4").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({
|
$("#restrict-elements-table").bootstrapTable({
|
||||||
formatNoMatches: function () {
|
formatNoMatches: function () {
|
||||||
return "";
|
return "";
|
||||||
@ -270,6 +316,10 @@ $(function() {
|
|||||||
return {classes: "bg-dark-danger"};
|
return {classes: "bg-dark-danger"};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
onLoadSuccess: function () {
|
||||||
|
$(".no-records-found").addClass("hidden");
|
||||||
|
$(".fixed-table-loading").addClass("hidden");
|
||||||
|
},
|
||||||
onClickCell: function (field, value, row) {
|
onClickCell: function (field, value, row) {
|
||||||
if (field === 3) {
|
if (field === 3) {
|
||||||
$.ajax ({
|
$.ajax ({
|
||||||
@ -323,24 +373,18 @@ $(function() {
|
|||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$("#get_column_values").on("click", function() {
|
|
||||||
startTable(1, 0);
|
|
||||||
$("#h2").removeClass("hidden");
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#get_tags").on("click", function() {
|
$("#restrictModal").on("show.bs.modal", function(e) {
|
||||||
startTable(0, 0);
|
var target = $(e.relatedTarget).attr('id');
|
||||||
$("#h1").removeClass("hidden");
|
var dataId;
|
||||||
});
|
$(e.relatedTarget).one('focus', function(e){$(this).blur();});
|
||||||
$("#get_user_column_values").on("click", function() {
|
//$(e.relatedTarget).blur();
|
||||||
startTable(3, $(this).data("id"));
|
if ($(e.relatedTarget).hasClass("button_head")) {
|
||||||
$("#h4").removeClass("hidden");
|
dataId = $('#user-table').bootstrapTable('getSelections').map(a => a.id);
|
||||||
});
|
} else {
|
||||||
|
dataId = $(e.relatedTarget).data("id");
|
||||||
$("#get_user_tags").on("click", function() {
|
}
|
||||||
startTable(2, $(this).data("id"));
|
startTable(target, dataId);
|
||||||
$(this)[0].blur();
|
|
||||||
$("#h3").removeClass("hidden");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// User table handling
|
// User table handling
|
||||||
@ -487,17 +531,23 @@ $(function() {
|
|||||||
$(".check_head").attr("aria-disabled", true);
|
$(".check_head").attr("aria-disabled", true);
|
||||||
$(".check_head").attr("disabled", true);
|
$(".check_head").attr("disabled", true);
|
||||||
$(".check_head").prop('checked', false);
|
$(".check_head").prop('checked', false);
|
||||||
|
$(".button_head").attr("aria-disabled", true);
|
||||||
|
$(".button_head").addClass("disabled");
|
||||||
|
$(".header_select").attr("disabled", true);
|
||||||
} else {
|
} else {
|
||||||
$("#user_delete_selection").removeClass("disabled");
|
$("#user_delete_selection").removeClass("disabled");
|
||||||
$("#user_delete_selection").attr("aria-disabled", false);
|
$("#user_delete_selection").attr("aria-disabled", false);
|
||||||
$(".check_head").attr("aria-disabled", false);
|
$(".check_head").attr("aria-disabled", false);
|
||||||
$(".check_head").removeAttr("disabled");
|
$(".check_head").removeAttr("disabled");
|
||||||
|
$(".button_head").attr("aria-disabled", false);
|
||||||
|
$(".button_head").removeClass("disabled");
|
||||||
|
$(".header_select").removeAttr("disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/* Function for deleting domain restrictions */
|
/* Function for deleting domain restrictions */
|
||||||
function TableActions (value, row) {
|
function TableActions (value, row) {
|
||||||
return [
|
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) {
|
function checkboxHeader(CheckboxState, field, field_index) {
|
||||||
var result = $('#user-table').bootstrapTable('getSelections').map(a => a.id);
|
var result = $('#user-table').bootstrapTable('getSelections').map(a => a.id);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -591,6 +671,9 @@ function checkboxHeader(CheckboxState, field, field_index) {
|
|||||||
$(".check_head").attr("aria-disabled", true);
|
$(".check_head").attr("aria-disabled", true);
|
||||||
$(".check_head").attr("disabled", true);
|
$(".check_head").attr("disabled", true);
|
||||||
$(".check_head").prop('checked', false);
|
$(".check_head").prop('checked', false);
|
||||||
|
$(".button_head").attr("aria-disabled", true);
|
||||||
|
$(".button_head").addClass("disabled");
|
||||||
|
$(".header_select").attr("disabled", true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -141,8 +141,8 @@
|
|||||||
<input type="checkbox" name="Show_detail_random" id="Show_detail_random" {% if conf.show_detail_random() %}checked{% endif %}>
|
<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>
|
<label for="Show_detail_random">{{_('Show Random Books in Detail View')}}</label>
|
||||||
</div>
|
</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_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" class="btn btn-default" data-toggle="modal" data-target="#restrictModal">{{_('Add Allowed/Denied custom column values')}}</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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
<form id="add_restriction" action="" method="POST">
|
<form id="add_restriction" action="" method="POST">
|
||||||
<div class="form-group required">
|
<div class="form-group required">
|
||||||
<label for="add_element">{{_('Add View Restriction')}}</label>
|
<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>
|
||||||
<div class="form-group required">
|
<div class="form-group required">
|
||||||
<input type="button" class="btn btn-default" value="{{_('Allow')}}" name="submit_allow" id="submit_allow" data-dismiss="static">
|
<input type="button" class="btn btn-default" value="{{_('Allow')}}" name="submit_allow" id="submit_allow" data-dismiss="static">
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{% extends "layout.html" %}
|
{% 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 }}"
|
<th data-field="{{ parameter }}" id="{{ parameter }}"
|
||||||
data-name="{{ parameter }}"
|
data-name="{{ parameter }}"
|
||||||
data-visible="{{visiblility.get(parameter)}}"
|
data-visible="{{visiblility.get(parameter)}}"
|
||||||
@ -12,7 +12,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% if validate %}data-edit-validate="{{ _('This Field is Required') }}"{% endif %}>
|
{% if validate %}data-edit-validate="{{ _('This Field is Required') }}"{% endif %}>
|
||||||
{% if button %}
|
{% 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 %}
|
{% endif %}
|
||||||
{{ show_text }}
|
{{ show_text }}
|
||||||
</th>
|
</th>
|
||||||
@ -47,7 +47,7 @@
|
|||||||
data-editable-source={{url}}
|
data-editable-source={{url}}
|
||||||
{% 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 }}" disabled="">
|
<select id="select_{{ parameter }}" class="header_select" onchange="selectHeader(this, '{{parameter}}')" disabled="">
|
||||||
<option value="all">{{ _('Show All') }}</option>
|
<option value="all">{{ _('Show All') }}</option>
|
||||||
{% for language in languages %}
|
{% for language in languages %}
|
||||||
<option value="{{language.lang_code}}">{{language.name}}</option>
|
<option value="{{language.lang_code}}">{{language.name}}</option>
|
||||||
@ -69,7 +69,7 @@
|
|||||||
data-editable-source={{url}}
|
data-editable-source={{url}}
|
||||||
{% 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 }}" disabled="">
|
<select id="select_{{ parameter }}" class="header_select" onchange="selectHeader(this, '{{parameter}}')" disabled="">
|
||||||
<option>{{_('Select...')}}</option>
|
<option>{{_('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>
|
||||||
@ -104,10 +104,10 @@
|
|||||||
{{ user_table_row('kindle_mail', _('Enter Kindle E-mail Address'), _('Kindle E-mail'), true) }}
|
{{ 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_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_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('denied_tags', _("Edit Denied Tags"), _("Denied Tags"), false, true, 0) }}
|
||||||
{{ user_table_row('allowed_tags', _("Edit Allowed Tags"), _("Allowed Tags"), true, true) }}
|
{{ 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"), true, true) }}
|
{{ 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"), true, true) }}
|
{{ 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", "admin_role", _('Admin'), visiblility, all_roles)}}
|
||||||
{{ user_checkbox_row("role", "download_role",_('Upload'), visiblility, all_roles)}}
|
{{ user_checkbox_row("role", "download_role",_('Upload'), visiblility, all_roles)}}
|
||||||
{{ user_checkbox_row("role", "upload_role", _('Download'), 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_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_download", _('Show Downloaded Books'), visiblility, sidebar_settings)}}
|
||||||
{{ user_checkbox_row("sidebar_view", "sidebar_list", _('Show Books List'), 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>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
</table>
|
</table>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block modal %}
|
{% block modal %}
|
||||||
{{ delete_confirm_modal() }}
|
{{ delete_confirm_modal() }}
|
||||||
|
{{ restrict_modal() }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block js %}
|
{% block js %}
|
||||||
<script src="{{ url_for('static', filename='js/libs/bootstrap-table/bootstrap-table.min.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/libs/bootstrap-table/bootstrap-table.min.js') }}"></script>
|
||||||
|
Loading…
Reference in New Issue
Block a user