perbailan data

1 parent 52ad5591
...@@ -6,8 +6,8 @@ def column_concat(*args): ...@@ -6,8 +6,8 @@ def column_concat(*args):
cols = [] cols = []
for arg in args: for arg in args:
if type(arg) == list: if type(arg) == list:
for a in arg: # for a in arg:
cols.append(a) cols.extend(arg)
else: else:
cols.append(arg) cols.append(arg)
...@@ -20,7 +20,7 @@ def column_concat(*args): ...@@ -20,7 +20,7 @@ def column_concat(*args):
# saat ini menggunakan recursive spertinya ada syntax pythonic # saat ini menggunakan recursive spertinya ada syntax pythonic
# func.concat(cols[i], for col in cols) # func.concat(cols[i], for col in cols)
# lambda_concat = lambda args: func.concat(x, y) for x, y in zip(args[:-1], args[1:]) # lambda_concat = lambda args: func.concat(x, y) for x, y in zip(args[:-1], args[1:])
return func.concat(cols[0], column_concat(*cols[1:])) return func.concat(cols[0], column_concat(*cols[1:])) # pylint: disable=not-callable
def column_date(field, dt_format='YYYY-MM-DD HH:MI:SS'): def column_date(field, dt_format='YYYY-MM-DD HH:MI:SS'):
......
...@@ -87,7 +87,13 @@ class BaseView(object): ...@@ -87,7 +87,13 @@ class BaseView(object):
self.allow_post = False self.allow_post = False
self.allow_unpost = False self.allow_unpost = False
self.allow_check = False self.allow_check = False
# Digunakan untuk menentukan operasi spesific check
self.check_sum = False
self.check_sum_field = ""
self.check_field = "" self.check_field = ""
self.check_value = ""
self.list_paging = True
self.list_info = True
self.state_save = False self.state_save = False
self.server_side = True self.server_side = True
self.scroll_y = False self.scroll_y = False
...@@ -380,8 +386,13 @@ class BaseView(object): ...@@ -380,8 +386,13 @@ class BaseView(object):
allow_post = kwargs.get("allow_post", self.allow_post) allow_post = kwargs.get("allow_post", self.allow_post)
allow_unpost = kwargs.get("allow_unpost", self.allow_unpost) allow_unpost = kwargs.get("allow_unpost", self.allow_unpost)
allow_check = kwargs.get("allow_check", self.allow_check) allow_check = kwargs.get("allow_check", self.allow_check)
check_sum = kwargs.get("check_sum", self.check_sum)
check_sum_field = kwargs.get("check_sum_field", self.check_sum_field)
check_field = kwargs.get("check_field", self.check_field) check_field = kwargs.get("check_field", self.check_field)
check_value = kwargs.get("check_value", self.check_value)
list_info = kwargs.get("list_info") or self.list_info
kwargs.pop("list_info", None)
state_save = kwargs.get("state_save", self.state_save) state_save = kwargs.get("state_save", self.state_save)
filter_columns = kwargs.get("filter_columns", self.filter_columns) filter_columns = kwargs.get("filter_columns", self.filter_columns)
if "server_side" in kwargs: if "server_side" in kwargs:
...@@ -398,6 +409,9 @@ class BaseView(object): ...@@ -398,6 +409,9 @@ class BaseView(object):
html_buttons = kwargs.get("html_buttons", self.html_buttons) html_buttons = kwargs.get("html_buttons", self.html_buttons)
parent = kwargs.get("parent") parent = kwargs.get("parent")
list_paging = kwargs.get("list_paging") or self.list_paging
kwargs.pop("allow_view", None) kwargs.pop("allow_view", None)
kwargs.pop("allow_edit", None) kwargs.pop("allow_edit", None)
kwargs.pop("allow_delete", None) kwargs.pop("allow_delete", None)
...@@ -405,6 +419,9 @@ class BaseView(object): ...@@ -405,6 +419,9 @@ class BaseView(object):
kwargs.pop("allow_unpost", None) kwargs.pop("allow_unpost", None)
kwargs.pop("allow_check", None) kwargs.pop("allow_check", None)
kwargs.pop("check_field", None) kwargs.pop("check_field", None)
kwargs.pop("list_paging", None)
kwargs.pop("list_filter", None)
kwargs.pop("state_save", None) kwargs.pop("state_save", None)
kwargs.pop("filter_columns", None) kwargs.pop("filter_columns", None)
kwargs.pop("server_side", None) kwargs.pop("server_side", None)
...@@ -453,7 +470,10 @@ class BaseView(object): ...@@ -453,7 +470,10 @@ class BaseView(object):
allow_post=allow_post, allow_post=allow_post,
allow_unpost=allow_unpost, allow_unpost=allow_unpost,
allow_check=allow_check, allow_check=allow_check,
check_sum=check_sum,
check_sum_field=check_sum_field,
check_field=check_field, check_field=check_field,
check_value=check_value,
state_save=state_save, state_save=state_save,
new_buttons=new_buttons, new_buttons=new_buttons,
filter_columns=filter_columns, filter_columns=filter_columns,
...@@ -461,6 +481,8 @@ class BaseView(object): ...@@ -461,6 +481,8 @@ class BaseView(object):
scroll_y=scroll_y, scroll_y=scroll_y,
scroll_x=scroll_x, scroll_x=scroll_x,
html_buttons=html_buttons, html_buttons=html_buttons,
list_paging=list_paging,
list_info=list_info,
**kwargs **kwargs
) )
resources = table.get_widget_resources() resources = table.get_widget_resources()
......
...@@ -49,6 +49,7 @@ class Views(BaseView): ...@@ -49,6 +49,7 @@ class Views(BaseView):
path = os.path.dirname(path) path = os.path.dirname(path)
self.report_file = os.path.join(path, 'reports', 'users.jrxml') self.report_file = os.path.join(path, 'reports', 'users.jrxml')
self.allow_check = True self.allow_check = True
self.check_field = "id"
self.list_view_field = 'email' self.list_view_field = 'email'
......
...@@ -174,13 +174,13 @@ class BlokKavNoWidget(Widget): ...@@ -174,13 +174,13 @@ class BlokKavNoWidget(Widget):
result = "|".join([blok_kav_no, rt, rw]) result = "|".join([blok_kav_no, rt, rw])
if not rt: if not rt or not rt.isdigit() or len(rt) < 3:
raise Invalid( raise Invalid(
field.schema, "RT harus diisi. Minimal 000", result) field.schema, "RT harus angka. Minimal 000", result)
if not rw: if not rw or not rw.isdigit() or len(rw) < 2:
raise Invalid( raise Invalid(
field.schema, "RW harus diisi. Minimal 00", result) field.schema, "RW harus angka. Minimal 00", result)
# if not blok_kav_no or not rt or not rw: # if not blok_kav_no or not rt or not rw:
# raise Invalid(field.schema, "Blok Kav No RT/RW tidak lengkap", # raise Invalid(field.schema, "Blok Kav No RT/RW tidak lengkap",
......
...@@ -116,9 +116,14 @@ class DeTable(field.Field): ...@@ -116,9 +116,14 @@ class DeTable(field.Field):
allow_unpost=False, allow_unpost=False,
allow_check=False, allow_check=False,
check_field=False, check_field=False,
check_value=False,
check_sum=False,
check_sum_field="",
filter_columns=False, filter_columns=False,
scroll_x=False, scroll_x=False,
scroll_y=False, scroll_y=False,
list_paging=True,
list_info=True,
**kw **kw
): ):
kw.pop("parent", None) kw.pop("parent", None)
...@@ -135,9 +140,14 @@ class DeTable(field.Field): ...@@ -135,9 +140,14 @@ class DeTable(field.Field):
self.allow_unpost = json.dumps(allow_unpost) self.allow_unpost = json.dumps(allow_unpost)
self.allow_check = json.dumps(allow_check) self.allow_check = json.dumps(allow_check)
self.check_field = json.dumps(check_field) self.check_field = json.dumps(check_field)
self.check_value = json.dumps(check_value)
self.check_sum = json.dumps(check_sum)
self.check_sum_field = json.dumps(check_sum_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.paging = json.dumps(list_paging)
self.list_info = json.dumps(list_info)
# self.widget = None # self.widget = None
# Button yang dikirim sebagai tambahan # Button yang dikirim sebagai tambahan
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
allow_unpost allow_unpost|field.allow_unpost; allow_unpost allow_unpost|field.allow_unpost;
allow_check allow_check|field.allow_check; allow_check allow_check|field.allow_check;
check_field check_field|field.check_field; check_field check_field|field.check_field;
check_value check_value|field.check_value;
state_save state_save|field.state_save; state_save state_save|field.state_save;
filter_columns filter_columns|field.filter_columns; filter_columns filter_columns|field.filter_columns;
filter_scripts filter_scripts|field.filter_scripts; filter_scripts filter_scripts|field.filter_scripts;
...@@ -63,7 +64,8 @@ ...@@ -63,7 +64,8 @@
<tr> <tr>
<tal:block tal:repeat="child field"> <tal:block tal:repeat="child field">
<th class="no-sort" tal:condition="child.name=='id'"> <th class="no-sort" tal:condition="child.name=='id'">
<input tal:condition="allow_check=='true'" type="checkbox" class="${tableid}checkAll" id="${tableid}checkAll"/> <input tal:condition="allow_check=='true'"
type="checkbox" class="${tableid}checkAll" id="${tableid}checkAll"/>
<span tal:condition="allow_check!='true'">${child.title}</span> <span tal:condition="allow_check!='true'">${child.title}</span>
</th> </th>
<th tal:condition="child.name!='id'"> <th tal:condition="child.name!='id'">
...@@ -88,6 +90,13 @@ ...@@ -88,6 +90,13 @@
.fa-check-square { .fa-check-square {
color: forestgreen; color: forestgreen;
} }
.checked-row {
background-color: yellow !important; /* or use box-shadow for newer DT versions */
}
/* For modern DataTables (v1.12+) */
table.dataTable tbody tr.checked-row > * {
box-shadow: inset 0 0 0 9999px rgb(255, 255, 0, 0.9) !important; /* Yellow with some opacity */
}
</style> </style>
<script type="text/javascript"> <script type="text/javascript">
var m${tableid}ID; var m${tableid}ID;
...@@ -96,7 +105,9 @@ ...@@ -96,7 +105,9 @@
var o${tableid}Url = o${tableid}Uri + "${url_suffix}"; var o${tableid}Url = o${tableid}Uri + "${url_suffix}";
var m${tableid}ID; var m${tableid}ID;
var m${tableid}CheckList = []; var m${tableid}CheckList = [];
var allow_check = ${allow_check};
var check_field = ${ check_field }; var check_field = ${ check_field };
var check_value = ${check_value};
deform.addCallback('${tableid}', function (oid) { deform.addCallback('${tableid}', function (oid) {
function displayEmptyID() { function displayEmptyID() {
$("#emptyID").show(); $("#emptyID").show();
...@@ -180,16 +191,14 @@ ...@@ -180,16 +191,14 @@
${tableid}Columns[co].render = function (id, typ, data, setting) { ${tableid}Columns[co].render = function (id, typ, data, setting) {
if (${tableid}Columns[co].action === false) return ""; if (${tableid}Columns[co].action === false) return "";
let result = ""; let result = "";
console.log("Render ID Column", "${check_field=='id'}", "${allow_check=='true'}", '${check_field}');
<tal:block tal:condition="allow_check=='true'"> <tal:block tal:condition="allow_check=='true'">
var checked = ""; var checked = "";
if (check_field !== "") { result = '<input type="checkbox" class="' + mtableId + '_check" id="' + mtableId + '_check_' + data.id +'" value="' + data.id + '" name="' + mtableId + '_check"/>&nbsp;';
//checked = data[check_field] !== null ? "checked" : ""; return result;
// m${tableid}CheckList.push(id);
}
result = '<input type="checkbox" class="' + mtableId + '_check" id="' + mtableId + '_check_' + id +'" value="' + id + '" name="' + mtableId + '_check"/>&nbsp;';
</tal:block> </tal:block>
<tal:block tal:condition="allow_check=='false'"> <tal:block tal:condition="allow_check=='false'">
id = data[${tableid}Columns[co].data];
<tal:block tal:condition="allow_view=='true'"> <tal:block tal:condition="allow_view=='true'">
result += '<a href="${url}/' + id + '/view"><i class="fas fa-eye" aria-hidden="true" title="View"></i></a>&nbsp;'; result += '<a href="${url}/' + id + '/view"><i class="fas fa-eye" aria-hidden="true" title="View"></i></a>&nbsp;';
</tal:block> </tal:block>
...@@ -208,7 +217,17 @@ ...@@ -208,7 +217,17 @@
</tal:block> </tal:block>
return result; return result;
} }
} }else if(${tableid}Columns[co].data==check_field){
${tableid}Columns[co].render = function (id, typ, data, setting) {
let result = "";
if(data[check_field] == check_value){
result = '<input type="checkbox" class="' + mtableId + '_check" id="' + mtableId + '_check_' + id + '" value="' + id + '" name="' + mtableId + '_check"/>&nbsp;';
}else{
result = '<span>'+data[check_field]+'</span>';
}
return result;
}
}
} }
//end column definition loop //end column definition loop
...@@ -220,24 +239,27 @@ ...@@ -220,24 +239,27 @@
else param_ajax = o${tableid}Url; else param_ajax = o${tableid}Url;
o${tableid} = $('#${tableid}').DataTable({ o${tableid} = $('#${tableid}').DataTable({
scrollX: ${ field.scroll_x }, scrollX: ${field.scroll_x},
//scrollY: ${field.scroll_y}, //scrollY: ${field.scroll_y},
//dom: '<"row"<"col-md-8"<"toolbar">Bl><"col-md-4"fr>>tip', //dom: '<"row"<"col-md-8"<"toolbar">Bl><"col-md-4"fr>>tip',
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"> <tal:block tal:condition="filter_columns">
deferLoading: 0, deferLoading: 0,
</tal:block> </tal:block>
data: param_data, data: param_data,
ajax: param_ajax, ajax: param_ajax,
stateSave: ${ state_save }, stateSave: ${state_save},
scrollCollapse: true, scrollCollapse: true,
sort: ${ sorts }, sort: ${sorts},
info: true, info: true,
filter: ${ filters }, filter: ${filters},
autoWidth: false, autoWidth: false,
paginate: ${ paginates }, paginate: ${paginates},
paging:${field.paging},
info: ${field.list_info},
//searching: ${field.list_info},
paginationType: "full_numbers", paginationType: "full_numbers",
order: [], order: [],
lengthMenu: [ lengthMenu: [
...@@ -271,11 +293,13 @@ ...@@ -271,11 +293,13 @@
var checkboxValue = $(this).val(); var checkboxValue = $(this).val();
if (this.checked) { if (this.checked) {
// Add to list if not already present // Add to list if not already present
$(this).closest("tr").addClass('checked-row');
if (m${tableid}CheckList.indexOf(checkboxValue) === -1) { if (m${tableid}CheckList.indexOf(checkboxValue) === -1) {
m${tableid}CheckList.push(checkboxValue); m${tableid}CheckList.push(checkboxValue);
} }
}else { }else {
// Remove from list // Remove from list
$(this).closest("tr").removeClass('checked-row');
var index = m${tableid}CheckList.indexOf(checkboxValue); var index = m${tableid}CheckList.indexOf(checkboxValue);
if (index > -1) { if (index > -1) {
m${tableid}CheckList.splice(index, 1); m${tableid}CheckList.splice(index, 1);
...@@ -288,12 +312,14 @@ ...@@ -288,12 +312,14 @@
var checkboxValue = $(this).val(); var checkboxValue = $(this).val();
if (this.checked) { if (this.checked) {
// Add to list if not already present // Add to list if not already present
$(this).closest("tr").addClass('checked-row');
if (m${tableid}CheckList.indexOf(checkboxValue) === -1) { if (m${tableid}CheckList.indexOf(checkboxValue) === -1) {
m${tableid}CheckList.push(checkboxValue); m${tableid}CheckList.push(checkboxValue);
} }
}else { }else {
// Remove from list // Remove from list
var index = m${tableid}CheckList.indexOf(checkboxValue); var index = m${tableid}CheckList.indexOf(checkboxValue);
$(this).closest("tr").removeClass('checked-row');
if (index > -1) { if (index > -1) {
m${tableid}CheckList.splice(index, 1); m${tableid}CheckList.splice(index, 1);
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!