Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
irul
/
opensipkd-base
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 808b8a58
authored
Jan 06, 2025
by
aa.gusti
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
penambahan html_buttons
1 parent
9233327b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
20 deletions
opensipkd/base/views/base_views.py
opensipkd/detable/detable.py
opensipkd/detable/templates/detable.pt
opensipkd/base/views/base_views.py
View file @
808b8a5
...
@@ -183,6 +183,7 @@ class BaseView(object):
...
@@ -183,6 +183,7 @@ class BaseView(object):
self
.
report_file
=
""
self
.
report_file
=
""
self
.
new_buttons
=
{}
self
.
new_buttons
=
{}
self
.
is_object
=
False
self
.
is_object
=
False
self
.
html_buttons
=
{}
def
query_register
(
self
,
**
kwargs
):
def
query_register
(
self
,
**
kwargs
):
pass
pass
...
@@ -260,6 +261,7 @@ class BaseView(object):
...
@@ -260,6 +261,7 @@ class BaseView(object):
new_buttons
new_buttons
list_url
list_url
action_suffix
action_suffix
html_buttons
"""
"""
allow_view
=
kwargs
.
get
(
"allow_view"
,
self
.
allow_view
)
allow_view
=
kwargs
.
get
(
"allow_view"
,
self
.
allow_view
)
allow_edit
=
kwargs
.
get
(
"allow_edit"
,
self
.
allow_edit
)
allow_edit
=
kwargs
.
get
(
"allow_edit"
,
self
.
allow_edit
)
...
@@ -282,6 +284,7 @@ class BaseView(object):
...
@@ -282,6 +284,7 @@ class BaseView(object):
list_schema
=
kwargs
.
get
(
"list_schema"
,
self
.
list_schema
)
list_schema
=
kwargs
.
get
(
"list_schema"
,
self
.
list_schema
)
scroll_y
=
kwargs
.
get
(
"scroll_y"
,
self
.
scroll_y
)
scroll_y
=
kwargs
.
get
(
"scroll_y"
,
self
.
scroll_y
)
scroll_x
=
kwargs
.
get
(
"scroll_x"
,
self
.
scroll_x
)
scroll_x
=
kwargs
.
get
(
"scroll_x"
,
self
.
scroll_x
)
html_buttons
=
kwargs
.
get
(
"html_buttons"
,
self
.
html_buttons
)
parent
=
kwargs
.
get
(
"parent"
)
parent
=
kwargs
.
get
(
"parent"
)
if
list_schema
:
if
list_schema
:
if
parent
:
if
parent
:
...
@@ -317,8 +320,8 @@ class BaseView(object):
...
@@ -317,8 +320,8 @@ class BaseView(object):
filter_columns
=
filter_columns
,
filter_columns
=
filter_columns
,
server_side
=
server_side
,
server_side
=
server_side
,
scroll_y
=
scroll_y
,
scroll_y
=
scroll_y
,
scroll_x
=
scroll_x
scroll_x
=
scroll_x
,
html_buttons
=
html_buttons
)
)
resources
=
table
.
get_widget_resources
()
resources
=
table
.
get_widget_resources
()
# resources=dict(css="", js="")
# resources=dict(css="", js="")
...
...
opensipkd/detable/detable.py
View file @
808b8a5
...
@@ -137,8 +137,10 @@ class DeTable(field.Field):
...
@@ -137,8 +137,10 @@ class DeTable(field.Field):
self
.
filter_columns
=
filter_columns
self
.
filter_columns
=
filter_columns
self
.
scroll_x
=
json
.
dumps
(
scroll_x
)
self
.
scroll_x
=
json
.
dumps
(
scroll_x
)
self
.
scroll_y
=
json
.
dumps
(
scroll_y
)
self
.
scroll_y
=
json
.
dumps
(
scroll_y
)
# self.widget = None
# self.widget = None
# Button yang dikirim sebagai tambahan
# Button yang dikirim sebagai tambahan
html_buttons
=
kw
.
get
(
"html_buttons"
,
None
)
new_buttons
=
kw
.
get
(
"new_buttons"
)
or
{}
new_buttons
=
kw
.
get
(
"new_buttons"
)
or
{}
action_suffix
=
f
"{action_suffix}{params}"
action_suffix
=
f
"{action_suffix}{params}"
...
@@ -189,6 +191,11 @@ class DeTable(field.Field):
...
@@ -189,6 +191,11 @@ class DeTable(field.Field):
_scripts
.
append
(
f
'$("#{tableid + button.name}").click(function ()'
+
_scripts
.
append
(
f
'$("#{tableid + button.name}").click(function ()'
+
dict_buttons
[
button
.
name
]
+
');'
)
dict_buttons
[
button
.
name
]
+
');'
)
if
html_buttons
:
for
html
in
html_buttons
:
header_buttons
.
append
(
html
[
"obj"
])
_scripts
.
append
(
html
[
"js"
])
if
filter_columns
:
if
filter_columns
:
button
=
f
"""
button
=
f
"""
<a href="#{tableid}-form-filter"
<a href="#{tableid}-form-filter"
...
@@ -196,13 +203,12 @@ class DeTable(field.Field):
...
@@ -196,13 +203,12 @@ class DeTable(field.Field):
class= "btn btn-warning dropdown">Filters</a>
class= "btn btn-warning dropdown">Filters</a>
"""
"""
header_buttons
.
insert
(
0
,
button
)
header_buttons
.
insert
(
0
,
button
)
if
allow_check
:
if
allow_check
:
button
=
f
"""
button
=
f
"""
<input type="checkbox" class="${tableid}checkAll">All</input>
<input type="checkbox" class="${tableid}checkAll">All</input>
"""
"""
header_buttons
.
insert
(
0
,
button
)
header_buttons
.
insert
(
0
,
button
)
self
.
buttons
=
"','"
.
join
(
header_buttons
)
.
replace
(
'
\n
'
,
""
)
.
\
self
.
buttons
=
"','"
.
join
(
header_buttons
)
.
replace
(
'
\n
'
,
""
)
.
\
replace
(
';'
,
';
\n
'
)
replace
(
';'
,
';
\n
'
)
...
@@ -300,12 +306,12 @@ class DeTable(field.Field):
...
@@ -300,12 +306,12 @@ class DeTable(field.Field):
thousand
=
hasattr
(
f
,
'thousand'
)
and
f
.
thousand
or
None
thousand
=
hasattr
(
f
,
'thousand'
)
and
f
.
thousand
or
None
separator
=
thousand
and
"separator"
in
thousand
\
separator
=
thousand
and
"separator"
in
thousand
\
and
thousand
[
"separator"
]
or
','
and
thousand
[
"separator"
]
or
','
decimal
=
thousand
and
"decimal"
in
thousand
and
thousand
[
decimal
=
thousand
and
"decimal"
in
thousand
and
thousand
[
"decimal"
]
or
'.'
"decimal"
]
or
'.'
point
=
thousand
and
"point"
in
thousand
and
thousand
[
"point"
]
or
0
point
=
thousand
and
"point"
in
thousand
and
thousand
[
"point"
]
or
0
currency
=
thousand
and
"currency"
in
thousand
and
\
currency
=
thousand
and
"currency"
in
thousand
and
\
thousand
[
"currency"
]
or
""
thousand
[
"currency"
]
or
""
if
thousand
or
isinstance
(
f
.
typ
,
colander
.
Float
)
or
\
if
thousand
or
isinstance
(
f
.
typ
,
colander
.
Float
)
or
\
isinstance
(
f
.
typ
,
colander
.
Integer
):
isinstance
(
f
.
typ
,
colander
.
Integer
):
d
[
"render"
]
=
\
d
[
"render"
]
=
\
...
@@ -400,7 +406,8 @@ class DeTable(field.Field):
...
@@ -400,7 +406,8 @@ class DeTable(field.Field):
html
+=
'<div class="form-group">'
html
+=
'<div class="form-group">'
if
isinstance
(
f
.
widget
,
deform_widget
.
CheckboxWidget
):
if
isinstance
(
f
.
widget
,
deform_widget
.
CheckboxWidget
):
wg_check_val
=
[
f
.
widget
.
true_val
,
f
.
widget
.
false_val
]
wg_check_val
=
[
f
.
widget
.
true_val
,
f
.
widget
.
false_val
]
radio_val
=
[[
""
,
'Semua'
],
[
wg_check_val
[
0
],
'Aktif'
],
[
wg_check_val
[
1
],
'Pasif'
]]
radio_val
=
[[
""
,
'Semua'
],
[
wg_check_val
[
0
],
'Aktif'
],
[
wg_check_val
[
1
],
'Pasif'
]]
html
+=
'<label class="" for="'
+
col_id
+
'">'
+
f
.
title
+
'</label>'
html
+=
'<label class="" for="'
+
col_id
+
'">'
+
f
.
title
+
'</label>'
html
+=
'<div class="input-group" id="'
+
col_id
+
'">'
html
+=
'<div class="input-group" id="'
+
col_id
+
'">'
for
rdo
in
range
(
len
(
radio_val
)):
for
rdo
in
range
(
len
(
radio_val
)):
...
@@ -420,6 +427,9 @@ class DeTable(field.Field):
...
@@ -420,6 +427,9 @@ class DeTable(field.Field):
html
+=
f
'<select class="form-control {self.tableid}-control-filter"'
html
+=
f
'<select class="form-control {self.tableid}-control-filter"'
html
+=
f
'placeholder="{f.title}" {txt}/>'
html
+=
f
'placeholder="{f.title}" {txt}/>'
html
+=
'<option value="">Semua</option>'
html
+=
'<option value="">Semua</option>'
if
type
(
wg_select_val
)
==
list
:
wg_select_val
=
dict
(
list
)
for
key
in
wg_select_val
:
for
key
in
wg_select_val
:
html
+=
f
'<option value="{key}">{wg_select_val[key]}</option>'
html
+=
f
'<option value="{key}">{wg_select_val[key]}</option>'
html
+=
'</select>'
html
+=
'</select>'
...
@@ -577,4 +587,4 @@ class Button(object):
...
@@ -577,4 +587,4 @@ class Button(object):
self
.
disabled
=
disabled
self
.
disabled
=
disabled
self
.
css_class
=
css_class
self
.
css_class
=
css_class
self
.
icon
=
icon
self
.
icon
=
icon
self
.
attributes
=
attributes
\ No newline at end of file
\ No newline at end of file
self
.
attributes
=
attributes
opensipkd/detable/templates/detable.pt
View file @
808b8a5
...
@@ -65,13 +65,18 @@
...
@@ -65,13 +65,18 @@
});
});
</script>
</script>
</div>
</div>
<table id="${tableid}" class="table table-bordered table-hover table-condensed dataTable no-footer">
<table id="${tableid}" class="table table-bordered table-hover table-condensed dataTable no-footer">
<thead>
<thead>
<tr>
<tr>
<tr>
<tal:block tal:repeat="child field">
<tal:block tal:repeat="child field">
<th
tal:condition="python:hasattr(child, 'action') and not getattr(child.condition)==False and False or True">
<tal:block tal:condition="python:not hasattr(child, 'visible') or getattr(child, 'visible')==True">
${child.title}</th>
<th
tal:condition="python:hasattr(child, 'action') and not getattr(child.condition)==False and False or True">
${child.title} </th>
</tal:block>
</tal:block>
</tal:block>
</tr>
</tr>
...
@@ -166,14 +171,10 @@
...
@@ -166,14 +171,10 @@
}
}
} else if (${tableid}Columns[co].wg_select === true) {
} else if (${tableid}Columns[co].wg_select === true) {
${tableid}Columns[co].render = function (value) {
${tableid}Columns[co].render = function (value) {
// if (value === 0) {
if (value!=null)
// o${tableid}.$('tr.selected').bgColor(${tableid}Columns[co].get("color_" + value));
return ${tableid}Columns[co].wg_select_val[value];
// }
return "";
// if (${tableid}Columns[co].hasOwnProperty("color_" + value)) {
}
//
// }
return ${tableid}Columns[co].wg_select_val[value];
}
} else if (${tableid}Columns[co].hasOwnProperty("url")) {
} else if (${tableid}Columns[co].hasOwnProperty("url")) {
let url = ${tableid}Columns[co].url;
let url = ${tableid}Columns[co].url;
${tableid}Columns[co].render = function (data) {
${tableid}Columns[co].render = function (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