Commit 808b8a58 by aa.gusti

penambahan html_buttons

1 parent 9233327b
...@@ -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="")
......
...@@ -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"
...@@ -203,7 +210,6 @@ class DeTable(field.Field): ...@@ -203,7 +210,6 @@ class DeTable(field.Field):
""" """
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')
self.tableid = tableid self.tableid = tableid
...@@ -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>'
......
...@@ -68,10 +68,15 @@ ...@@ -68,10 +68,15 @@
<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">
<tal:block tal:condition="python:not hasattr(child, 'visible') or getattr(child, 'visible')==True">
<th <th
tal:condition="python:hasattr(child, 'action') and not getattr(child.condition)==False and False or True"> tal:condition="python:hasattr(child, 'action') and not getattr(child.condition)==False and False or True">
${child.title}</th> ${child.title} </th>
</tal:block>
</tal:block> </tal:block>
</tr> </tr>
...@@ -166,13 +171,9 @@ ...@@ -166,13 +171,9 @@
} }
} 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));
// }
// if (${tableid}Columns[co].hasOwnProperty("color_" + value)) {
//
// }
return ${tableid}Columns[co].wg_select_val[value]; return ${tableid}Columns[co].wg_select_val[value];
return "";
} }
} 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;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!