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 87ad06b5
authored
Sep 03, 2024
by
aagusti
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
perbaikan render list act
1 parent
462a00fc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
11 deletions
opensipkd/base/views/base_views.py
opensipkd/base/views/widget_os.py
opensipkd/base/views/widgets/autocomplete_input.pt
opensipkd/base/views/base_views.py
View file @
87ad06b
...
...
@@ -8,6 +8,7 @@ import colander
from
datatables
import
ColumnDT
from
dateutil.relativedelta
import
relativedelta
from
deform
import
(
widget
,
Form
,
ValidationFailure
,
FileData
,
)
from
deform.widget
import
SelectWidget
from
opensipkd.base.views.upload
import
tmpstore
from
opensipkd.tools
import
dmy
,
get_settings
,
get_ext
,
\
date_from_str
,
get_random_string
...
...
@@ -274,7 +275,8 @@ class BaseView(object):
def
returned_form
(
self
,
form
,
table
,
**
kwargs
):
resources
=
form
.
get_widget_resources
()
readonly
=
"readonly"
in
kwargs
and
kwargs
[
"readonly"
]
readonly
=
"readonly"
in
kwargs
and
kwargs
[
"readonly"
]
or
False
kwargs
[
"readonly"
]
=
readonly
is_object
=
kwargs
.
get
(
"is_object"
)
if
is_object
:
return
dict
(
form
=
form
,
...
...
@@ -433,6 +435,7 @@ class BaseView(object):
def
get_list
(
self
):
url
=
[]
select_list
=
{}
if
not
self
.
columns
:
columns
=
[]
for
d
in
self
.
list_schema
():
...
...
@@ -456,6 +459,12 @@ class BaseView(object):
columns
.
append
(
ColumnDT
(
getattr
(
self
.
table
,
d
.
name
),
mData
=
d
.
name
,
global_search
=
global_search
))
if
hasattr
(
d
,
"widget"
):
if
d
.
widget
:
log
.
debug
(
d
.
widget
)
if
type
(
d
.
widget
)
is
SelectWidget
:
select_list
[
d
.
name
]
=
d
.
widget
.
values
if
hasattr
(
d
,
"url"
):
url
.
append
(
d
.
name
)
else
:
...
...
@@ -470,6 +479,15 @@ class BaseView(object):
query
=
self
.
list_filter
(
query
)
row_table
=
DataTables
(
self
.
req
.
GET
,
query
,
columns
)
result
=
row_table
.
output_result
()
data
=
result
and
"data"
in
result
and
result
[
"data"
]
or
{}
for
res
in
data
:
for
k
in
res
:
if
k
in
select_list
.
keys
():
vals
=
select_list
[
k
]
for
r
in
vals
:
if
r
[
0
]
==
res
[
k
]:
res
[
k
]
=
r
[
1
]
""
# for k, v in d.items():
# if k in url and v:
# link = "/".join([self.home, nik_url, v])
...
...
opensipkd/base/views/widget_os.py
View file @
87ad06b
...
...
@@ -715,3 +715,33 @@ class TextInputWidget(widget.TextInputWidget):
class
DateInputWidget
(
WidgetDateInputWidget
):
type_name
=
"text"
# class AutocompleteInputWidget(widget.AutocompleteInputWidget):
# targets = None
# def serialize(self, field, cstruct, **kw):
# item_id = kw.get("item_id", None)
# super().serialize(field, cstruct, **kw)
# if "delay" in kw or getattr(self, "delay", None):
# raise ValueError(
# "AutocompleteWidget does not support *delay* parameter "
# "any longer."
# )
# if cstruct in (null, None):
# cstruct = ""
# self.values = self.values or []
# readonly = kw.get("readonly", self.readonly)
#
# options = {}
# if isinstance(self.values, string_types):
# options["remote"] = "%s?term=%%QUERY" % self.values
# else:
# options["local"] = self.values
#
# options["minLength"] = kw.pop("min_length", self.min_length)
# options["limit"] = kw.pop("items", self.items)
# kw["options"] = json.dumps(options)
# tmpl_values = self.get_template_values(field, cstruct, kw)
# template = readonly and self.readonly_template or self.template
# return field.renderer(template, **tmpl_values)
#
opensipkd/base/views/widgets/autocomplete_input.pt
View file @
87ad06b
<span tal:define="name name|field.name;
css_class css_class|field.widget.css_class;
oid oid|field.oid;
style style|field.widget.style"
tal:omit-tag="">
css_class css_class|field.widget.css_class;
oid oid|field.oid;
style style|field.widget.style;
js js|field.widget.js"
tal:omit-tag="">
<input type="text"
name="${name}"
value="${cstruct}"
data-provide="typeahead"
tal:attributes="class string: form-control ${css_class or ''};
style style;
attributes|field.widget.attributes|{};"
tal:attributes="class string: form-control ${css_class or ''};
style style;
attributes|field.widget.attributes|{};"
id="${oid}"/>
<script tal:condition="field.widget.values" type="text/javascript">
deform.addCallback(
'${field.oid}',
function (oid) {
'${field.oid}',
function (oid) {
$('#' + oid).typeahead(${options});
}
${structure:js}
}
);
</script>
</span>
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