mirror of
https://github.com/janeczku/calibre-web
synced 2024-11-28 12:30:00 +00:00
Table edit: validator routine to prevent empty fields working
This commit is contained in:
parent
1c681ee378
commit
f26ccfe16c
@ -56,49 +56,31 @@ $(function() {
|
||||
}
|
||||
});
|
||||
});
|
||||
/*$("#books-table").bootstrapTable({
|
||||
});
|
||||
test = $("#books-table").bootstrapTable('getOptions');
|
||||
var column = test.columns[0]
|
||||
column.forEach(function(item){
|
||||
if ('editableValidate' in item) {
|
||||
item.editable = {
|
||||
mode: 'inline',
|
||||
validate: function (value) { if($.trim(value) == '') return 'This field is required'; },
|
||||
}
|
||||
}
|
||||
});
|
||||
$("#books-table").bootstrapTable('refreshOptions', {columns: [column]});*/
|
||||
|
||||
var column = [];
|
||||
$('#table1 > thead > tr > th').each(function(){
|
||||
if ($(this).attr('data-edit')) {
|
||||
if ($(this).attr('data-edit-validate')) {
|
||||
column.push({
|
||||
editable: {
|
||||
mode: 'inline',
|
||||
emptytext: "<span class='glyphicon glyphicon-plus'></span>",
|
||||
validate: function (value) { if($.trim(value) == '') return 'This field is required'; },
|
||||
}
|
||||
});
|
||||
} else {
|
||||
column.push({
|
||||
editable: {
|
||||
mode: 'inline',
|
||||
emptytext: "<span class='glyphicon glyphicon-plus'></span>",
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
column.push({});
|
||||
$("#books-table > thead > tr > th").each(function() {
|
||||
var element = {};
|
||||
if ($(this).attr("data-edit")) {
|
||||
element = {
|
||||
editable: {
|
||||
mode: "inline",
|
||||
emptytext: "<span class='glyphicon glyphicon-plus'></span>",
|
||||
}
|
||||
};
|
||||
}
|
||||
var validateText = $(this).attr("data-edit-validate");
|
||||
if (validateText) {
|
||||
element.editable.validate = function (value) {
|
||||
if ($.trim(value) === "") return validateText;
|
||||
};
|
||||
}
|
||||
column.push(element);
|
||||
});
|
||||
$("#table1").bootstrapTable({
|
||||
$("#books-table").bootstrapTable({
|
||||
sidePagination: "server",
|
||||
pagination: true,
|
||||
paginationDetailHAlign: " hidden",
|
||||
paginationHAlign: "left",
|
||||
/*url: window.location.pathname + "/../../ajax/listbooks",*/
|
||||
idField: "id",
|
||||
search: true,
|
||||
showColumns: true,
|
||||
@ -109,56 +91,11 @@ $(function() {
|
||||
maintainMetaData: true,
|
||||
responseHandler: responseHandler,
|
||||
columns: column,
|
||||
/*editable-mode="inline"
|
||||
editable-emptytext="<span class='glyphicon glyphicon-plus'></span>">*/
|
||||
/*columns: [
|
||||
{},
|
||||
{}, {
|
||||
editable: {
|
||||
mode: 'inline',
|
||||
emptytext: "<span class='glyphicon glyphicon-plus'></span>",
|
||||
validate: function (value) { if($.trim(value) == '') return 'This field is required'; },
|
||||
},
|
||||
}, {
|
||||
editable: {
|
||||
mode: 'inline',
|
||||
validate: function (value) { if($.trim(value) == '') return 'This field is required'; },
|
||||
},
|
||||
}, {
|
||||
editable: {
|
||||
mode: 'inline',
|
||||
validate: function (value) { if($.trim(value) == '') return 'This field is required'; },
|
||||
}
|
||||
}, {
|
||||
editable: {
|
||||
mode: 'inline',
|
||||
emptytext: "<span class='glyphicon glyphicon-plus'></span>",
|
||||
validate: function (value) { if($.trim(value) == '') return 'This field is required'; },
|
||||
},
|
||||
}, {
|
||||
editable: {
|
||||
mode: 'inline',
|
||||
emptytext: "<span class='glyphicon glyphicon-plus'></span>",
|
||||
validate: function (value) { if($.trim(value) == '') return 'This field is required'; },
|
||||
},
|
||||
}, {
|
||||
editable: {
|
||||
mode: 'inline',
|
||||
emptytext: "<span class='glyphicon glyphicon-plus'></span>",
|
||||
validate: function (value) { if($.trim(value) == '') return 'This field is required'; },
|
||||
},
|
||||
}],*/
|
||||
formatNoMatches: function () {
|
||||
return "";
|
||||
},
|
||||
});
|
||||
|
||||
/*var $table = $('#books-table');
|
||||
$('#books-table').bootstrapTable('getOptions')*/
|
||||
/*$('#books-table').bootstrapTable('editable')*/
|
||||
/*{ field: 'aimValue', title: 'Aim<br>Value', class: 'danger',editable: { mode: 'inline', validate: function (v) { return validateData(this, v); }, }, },*/
|
||||
|
||||
|
||||
$("#domain_allow_submit").click(function(event) {
|
||||
event.preventDefault();
|
||||
$("#domain_add_allow").ajaxForm();
|
||||
@ -173,6 +110,7 @@ $(function() {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#domain-allow-table").bootstrapTable({
|
||||
formatNoMatches: function () {
|
||||
return "";
|
||||
@ -398,9 +336,3 @@ function responseHandler(res) {
|
||||
});
|
||||
return res;
|
||||
}
|
||||
|
||||
function validato(value) {
|
||||
if($.trim(value) == '') return 'This field is required';
|
||||
}
|
||||
|
||||
/*function validateVal(value) { if($.trim(value) == '') return 'This field is required'; }*/
|
||||
|
@ -6,7 +6,7 @@
|
||||
data-editable-url="{{ url_for('editbook.edit_list_book', param=parameter)}}"
|
||||
data-editable-title="{{ edit_text}}"
|
||||
data-edit="true"
|
||||
{% if validate %}data-edit-validate="true" {% endif %}
|
||||
{% if validate %}data-edit-validate="{{ _('This Field is Required') }}" {% endif %}
|
||||
{% endif %}
|
||||
>{{ show_text }}</th>
|
||||
{%- endmacro %}
|
||||
@ -38,7 +38,7 @@
|
||||
data-editable-emptytext="<span class='glyphicon glyphicon-plus'></span>"
|
||||
</a-->
|
||||
<div class="btn btn-default disabled" id="merge_books" aria-disabled="true">{{_('Merge selected books')}}</div>
|
||||
<table id="table1" class="table table-no-bordered table-striped"
|
||||
<table id="books-table" class="table table-no-bordered table-striped"
|
||||
data-url="{{url_for('web.list_books')}}">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -54,7 +54,7 @@
|
||||
{{ text_table_row('series', _('Enter Series'),_('Series'), false) }}
|
||||
<th data-field="series_index" id="series_index" data-sortable="true" {% if g.user.role_edit() %} data-editable-type="number" data-editable-placeholder="1" data-editable-step="0.01" data-editable-min="0" data-editable-url="{{ url_for('editbook.edit_list_book', param='series_index')}}" data-editable="true" data-editable-title="{{_('Enter title')}}"{% endif %}>{{_('Series Index')}}</th>
|
||||
{{ text_table_row('languages', _('Enter Languages'),_('Languages'), false) }}
|
||||
<th data-field="pubdate" data-type="date" data-viewformat="dd.mm.yyyy" id="pubdate" data-sortable="true">Publishing Date</th>
|
||||
<th data-field="pubdate" data-type="date" data-viewformat="dd.mm.yyyy" id="pubdate" data-sortable="true">_('Publishing Date')</th>
|
||||
{{ text_table_row('publishers', _('Enter Publishers'),_('Publishers'), false) }}
|
||||
{% if g.user.role_edit() %}
|
||||
<th data-align="right" data-formatter="EbookActions" data-switchable="false"></th>
|
||||
|
Loading…
Reference in New Issue
Block a user