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
f26ccfe1
Commit
f26ccfe1
authored
Jun 11, 2020
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Table edit: validator routine to prevent empty fields working
parent
1c681ee3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
89 deletions
+21
-89
table.js
cps/static/js/table.js
+18
-86
book_table.html
cps/templates/book_table.html
+3
-3
No files found.
cps/static/js/table.js
View file @
f26ccfe1
...
...
@@ -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'; }*/
cps/templates/book_table.html
View file @
f26ccfe1
...
...
@@ -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>
...
...
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