Commit 808b8a58 by aa.gusti

penambahan html_buttons

1 parent 9233327b
......@@ -183,6 +183,7 @@ class BaseView(object):
self.report_file = ""
self.new_buttons = {}
self.is_object = False
self.html_buttons = {}
def query_register(self, **kwargs):
pass
......@@ -260,6 +261,7 @@ class BaseView(object):
new_buttons
list_url
action_suffix
html_buttons
"""
allow_view = kwargs.get("allow_view", self.allow_view)
allow_edit = kwargs.get("allow_edit", self.allow_edit)
......@@ -282,6 +284,7 @@ class BaseView(object):
list_schema = kwargs.get("list_schema", self.list_schema)
scroll_y = kwargs.get("scroll_y", self.scroll_y)
scroll_x = kwargs.get("scroll_x", self.scroll_x)
html_buttons = kwargs.get("html_buttons", self.html_buttons)
parent = kwargs.get("parent")
if list_schema:
if parent:
......@@ -317,8 +320,8 @@ class BaseView(object):
filter_columns=filter_columns,
server_side=server_side,
scroll_y=scroll_y,
scroll_x=scroll_x
scroll_x=scroll_x,
html_buttons=html_buttons
)
resources = table.get_widget_resources()
# resources=dict(css="", js="")
......
......@@ -137,8 +137,10 @@ class DeTable(field.Field):
self.filter_columns = filter_columns
self.scroll_x = json.dumps(scroll_x)
self.scroll_y = json.dumps(scroll_y)
# self.widget = None
# Button yang dikirim sebagai tambahan
html_buttons = kw.get("html_buttons", None)
new_buttons = kw.get("new_buttons") or {}
action_suffix = f"{action_suffix}{params}"
......@@ -189,6 +191,11 @@ class DeTable(field.Field):
_scripts.append(f'$("#{tableid + button.name}").click(function ()' +
dict_buttons[button.name] + ');')
if html_buttons:
for html in html_buttons:
header_buttons.append(html["obj"])
_scripts.append(html["js"])
if filter_columns:
button = f"""
<a href="#{tableid}-form-filter"
......@@ -196,13 +203,12 @@ class DeTable(field.Field):
class= "btn btn-warning dropdown">Filters</a>
"""
header_buttons.insert(0, button)
if allow_check:
button = f"""
<input type="checkbox" class="${tableid}checkAll">All</input>
"""
header_buttons.insert(0, button)
self.buttons = "','".join(header_buttons).replace('\n', ""). \
replace(';', ';\n')
......@@ -300,12 +306,12 @@ class DeTable(field.Field):
thousand = hasattr(f, 'thousand') and f.thousand or None
separator = thousand and "separator" in thousand \
and thousand["separator"] or ','
and thousand["separator"] or ','
decimal = thousand and "decimal" in thousand and thousand[
"decimal"] or '.'
point = thousand and "point" in thousand and thousand["point"] or 0
currency = thousand and "currency" in thousand and \
thousand["currency"] or ""
thousand["currency"] or ""
if thousand or isinstance(f.typ, colander.Float) or \
isinstance(f.typ, colander.Integer):
d["render"] = \
......@@ -400,7 +406,8 @@ class DeTable(field.Field):
html += '<div class="form-group">'
if isinstance(f.widget, deform_widget.CheckboxWidget):
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 += '<div class="input-group" id="' + col_id + '">'
for rdo in range(len(radio_val)):
......@@ -420,6 +427,9 @@ class DeTable(field.Field):
html += f'<select class="form-control {self.tableid}-control-filter"'
html += f'placeholder="{f.title}" {txt}/>'
html += '<option value="">Semua</option>'
if type(wg_select_val) == list:
wg_select_val = dict(list)
for key in wg_select_val:
html += f'<option value="{key}">{wg_select_val[key]}</option>'
html += '</select>'
......@@ -577,4 +587,4 @@ class Button(object):
self.disabled = disabled
self.css_class = css_class
self.icon = icon
self.attributes = attributes
\ No newline at end of file
self.attributes = attributes
......@@ -65,13 +65,18 @@
});
</script>
</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>
<tr>
<tr>
<tal:block tal:repeat="child field">
<th
tal:condition="python:hasattr(child, 'action') and not getattr(child.condition)==False and False or True">
${child.title}</th>
<tal:block tal:condition="python:not hasattr(child, 'visible') or getattr(child, 'visible')==True">
<th
tal:condition="python:hasattr(child, 'action') and not getattr(child.condition)==False and False or True">
${child.title} </th>
</tal:block>
</tal:block>
</tr>
......@@ -166,14 +171,10 @@
}
} else if (${tableid}Columns[co].wg_select === true) {
${tableid}Columns[co].render = function (value) {
// if (value === 0) {
// o${tableid}.$('tr.selected').bgColor(${tableid}Columns[co].get("color_" + value));
// }
// if (${tableid}Columns[co].hasOwnProperty("color_" + value)) {
//
// }
return ${tableid}Columns[co].wg_select_val[value];
}
if (value!=null)
return ${tableid}Columns[co].wg_select_val[value];
return "";
}
} else if (${tableid}Columns[co].hasOwnProperty("url")) {
let url = ${tableid}Columns[co].url;
${tableid}Columns[co].render = function (data) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!