Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
aa.gusti
/
opensipkd-base
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 17a61332
authored
Feb 04, 2026
by
aa.gustiana@gmail.com
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat: Enhance DeTable widget with number range filtering and update BaseView for…
… session flash messages
1 parent
d8e70b04
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
29 deletions
opensipkd/base/views/base_views.py
opensipkd/detable/detable.py
opensipkd/detable/templates/detable.pt
opensipkd/base/views/base_views.py
View file @
17a6133
...
@@ -1152,6 +1152,7 @@ class BaseView(object):
...
@@ -1152,6 +1152,7 @@ class BaseView(object):
q
.
delete
()
q
.
delete
()
self
.
db_session
.
flush
()
self
.
db_session
.
flush
()
request
.
session
.
flash
(
msg
)
request
.
session
.
flash
(
msg
)
return
self
.
route_list
()
return
self
.
route_list
()
form
=
self
.
get_form
(
form
=
self
.
get_form
(
self
.
edit_schema
,
buttons
=
(
btn_delete
,
btn_cancel
))
self
.
edit_schema
,
buttons
=
(
btn_delete
,
btn_cancel
))
...
...
opensipkd/detable/detable.py
View file @
17a6133
...
@@ -95,7 +95,6 @@ class DeTable(field.Field):
...
@@ -95,7 +95,6 @@ class DeTable(field.Field):
css_class
=
"deform"
# bw compat only; pass a widget to override
css_class
=
"deform"
# bw compat only; pass a widget to override
def
__init__
(
def
__init__
(
self
,
self
,
schema
,
schema
,
...
@@ -485,37 +484,20 @@ class DeTable(field.Field):
...
@@ -485,37 +484,20 @@ class DeTable(field.Field):
html
+=
f
'name="{col_id}" id="{col_id}-max" /></span>'
html
+=
f
'name="{col_id}" id="{col_id}-max" /></span>'
html
+=
f
'</div>'
html
+=
f
'</div>'
html
+=
f
'</div>'
html
+=
f
'</div>'
"""
elif
getattr
(
f
,
"search_method"
,
None
)
==
"yadcf_range_number"
:
awal
html
+=
f
'<div class="form-group" {txt}>'
html
+=
f
'<div class="form-group" {txt}>'
html += f'<div class="input-group">'
html
+=
f
'<label class="form-label" style="font-size:12px">{f.title}</label>'
html += f'<span class="input-group-addon">{f.title}</span>'
html
+=
f
'<div class="input-group" style="padding: 3px 0px 7px !important;">'
html += f'<span class="input-group-addon"><input type="date" class="form-control {self.tableid}-control-filter hasDatePicker"'
html
+=
f
'<input type="number" class="form-control {self.tableid}-control-filter"'
html += f'data-index={field_index} placeholder="{f.title} Awal" '
html
+=
f
'data-index={field_index} placeholder="{f.title} Min" '
html += f'name="{col_id}" id="{col_id}-min"/></span>'
html
+=
f
'name="{col_id}" id="{col_id}-min"/>'
html += f'<span class="input-group-addon"><input type="date" class="form-control {self.tableid}-control-filter hasDatePicker"'
html
+=
f
'<div class="input-group-addon">-</div>'
html += f'data-index={field_index} placeholder="{f.title} Akhir" '
html
+=
f
'<input type="number" class="form-control {self.tableid}-control-filter"'
html
+=
f
'data-index={field_index} placeholder="{f.title} Max" '
html
+=
f
'name="{col_id}" id="{col_id}-max" /></span>'
html
+=
f
'name="{col_id}" id="{col_id}-max" /></span>'
html
+=
f
'</div>'
html
+=
f
'</div>'
html
+=
f
'</div>'
html
+=
f
'</div>'
"""
# html += """
# <script type="text/javascript">
# deform.addCallback(
# '%s',
# function deform_cb(oid) {
# $('#'+oid).datepicker();
# }
# );
# </script>
# """ % self.tableid
# requirements = f.widget.requirements
# for requirement in requirements:
# if type(requirement) == dict and "js" in requirement:
# for req in requirement:
#
else
:
else
:
html
+=
f
'<input type="text" class="form-control {self.tableid}-control-filter"'
html
+=
f
'<input type="text" class="form-control {self.tableid}-control-filter"'
html
+=
f
'placeholder="{f.title}" {txt}/>'
html
+=
f
'placeholder="{f.title}" {txt}/>'
...
...
opensipkd/detable/templates/detable.pt
View file @
17a6133
...
@@ -226,6 +226,9 @@
...
@@ -226,6 +226,9 @@
dom: '<"row"<"col-md-8"<"toolbar">>><"row"<"col-md-8"Bl><"col-md-4"fr>>t<"row dt-footer"<"col-md-8 sub-foot" i><"col-md-4"p>>',
dom: '<"row"<"col-md-8"<"toolbar">>><"row"<"col-md-8"Bl><"col-md-4"fr>>t<"row dt-footer"<"col-md-8 sub-foot" i><"col-md-4"p>>',
processing: true,
processing: true,
serverSide: ${ server_side },
serverSide: ${ server_side },
<tal:block tal:condition="filter_columns">
deferLoading: 0,
</tal:block>
data: param_data,
data: param_data,
ajax: param_ajax,
ajax: param_ajax,
stateSave: ${ state_save },
stateSave: ${ state_save },
...
@@ -422,6 +425,37 @@
...
@@ -422,6 +425,37 @@
//&& min_val !== "" && max_val !== ""
//&& min_val !== "" && max_val !== ""
}
}
}
}
else if ($(this).attr("type") === 'number') {
value = this.value;
localStorage.setItem(col_id, value);
var splitted = col_id.split('-');
if (splitted[splitted.length - 1] !== "min" && splitted[splitted.length - 1] !== "max"){
o${tableid}.column($(this).data('index')).search(value)
}
else{
var min_val = undefined;
var max_val = undefined;
if (splitted[splitted.length - 1] === "min") {
min_val = this.value;
splitted.length = splitted.length - 1;
col_id = splitted.join("-");
max_val = $("#" + col_id + '-max').val()
}
else {
max_val = this.value;
splitted.length = splitted.length - 1;
col_id = splitted.join("-");
min_val = $("#" + col_id + '-min').val();
}
if (min_val === undefined && max_val !== undefined) min_val = max_val;
if (max_val === undefined && min_val !== undefined) max_val = min_val;
if (max_val !== undefined && min_val !== undefined && min_val !== null && max_val !== null)
o${tableid}
.column($(this).data('index'))
.search(min_val + '-yadcf_delim-' + max_val, true);
//&& min_val !== "" && max_val !== ""
}
}
else {
else {
col_id = this.id;
col_id = this.id;
value = this.value;
value = this.value;
...
@@ -448,7 +482,7 @@
...
@@ -448,7 +482,7 @@
if (typ === "select") filter_table();
if (typ === "select") filter_table();
var typ = $(this).attr("type").toLowerCase();
var typ = $(this).attr("type").toLowerCase();
if (typ
=== "date"
) filter_table();
if (typ
in ("date", "number")
) filter_table();
});
});
console.log("Read Data");
console.log("Read Data");
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment