Skip to content

Commit

Permalink
Multiple fixes and implementations.
Browse files Browse the repository at this point in the history
closed #94
closed #95
maybe also #90 and #91 but didn't test yet.
didn't implement actions parameters dialog yet.
partial implementation of #59
  • Loading branch information
Eitan Blumin committed Apr 7, 2019
1 parent 62a37b7 commit 76838b4
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 74 deletions.
106 changes: 58 additions & 48 deletions src/AdminLTE/datatable_respite_crud.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,15 @@ class respite_crud {
return data;
}

static actionUrl(url, isNewWindow, params, row, self) {
if (params != undefined) {
if (url.indexOf('?') == -1) url += '?';
url = url + $.param(params);
}
url = respite_crud.replaceRowPlaceholders(url, row, self);
window.open(url, (isNewWindow ? '_blank' : '_self'));
}

static renderAutomatic_ed(data, ed, row) {
var rv = "";
if (data != undefined && data != '' && ed != undefined) {
Expand Down Expand Up @@ -1722,58 +1731,59 @@ class respite_crud {
//console.log(respite_crud.respite_editor_options.dt_Options.dt_Selector);
respite_crud.dt = $(respite_crud.respite_editor_options.dt_Options.dt_Selector).DataTable(setOptions);

// If detail rows enabled
if (respite_crud.isDetailRowsAdded) {
// On each draw, loop over the `detailRows` array and show any child rows
respite_crud.dt.on('draw', function () {
//dt-dynamic-filter-details
$('body').find('.dt-dynamic-filter-details').empty();
var urlParams = { ViewID: respite_crud.getUrlParam('ViewID') };
var searchCols = respite_crud.dt.settings()[0].aoPreSearchCols; //setOptions.searchCols;
var body = $('<div class="panel-body"></div>');
var hasFilters = false;
for (var i = 0; i < searchCols.length; i++) {
if (searchCols[i]['sSearch']) {
var col = setOptions.columns[i];
var searchVal = searchCols[i]['sSearch'];
var grp = $('<span role="group" style="margin-right: 5px"></span>');
var meta = {
"settings": { "aoColumns": respite_crud.dt.settings()[0].aoColumns },
"col": i
};

grp
.append(
$('<span class="label label-primary"></span>')
.append($('<a class="badge" data-toggle="tooltip" title="Remove filter" href="javascript:void(0)" onclick="respite_crud.clearColSearch(' + i + ')"><i class="fas fa-times"></i></a>'))
.append($('<span></span>').text(' ' + (col['editor_data']['label'] || col['name']) + ':'))
)
.append($('<span class="label label-default"></span>').text(
col.mRender(searchVal, undefined, undefined, meta)
|| searchVal)
)
;
body.append(grp.clone());
urlParams[col.name + '[search]'] = searchVal;
hasFilters = true;
}
respite_crud.dt.on('draw', function () {
//dt-dynamic-filter-details
$('body').find('.dt-dynamic-filter-details').empty();
var urlParams = { ViewID: respite_crud.getUrlParam('ViewID') };
var searchCols = respite_crud.dt.settings()[0].aoPreSearchCols; //setOptions.searchCols;
var body = $('<div class="panel-body"></div>');
var hasFilters = false;
for (var i = 0; i < searchCols.length; i++) {
if (searchCols[i]['sSearch']) {
var col = setOptions.columns[i];
var searchVal = searchCols[i]['sSearch'];
var grp = $('<span role="group" style="margin-right: 5px"></span>');
var meta = {
"settings": { "aoColumns": respite_crud.dt.settings()[0].aoColumns },
"col": i
};

grp
.append(
$('<span class="label label-primary"></span>')
.append($('<a class="badge" data-toggle="tooltip" title="Remove filter" href="javascript:void(0)" onclick="respite_crud.clearColSearch(' + i + ')"><i class="fas fa-times"></i></a>'))
.append($('<span></span>').text(' ' + (col['editor_data']['label'] || col['name']) + ':'))
)
.append($('<span class="label label-default"></span>').text(
col.mRender(searchVal, undefined, undefined, meta)
|| searchVal)
)
;
body.append(grp.clone());
urlParams[col.name + '[search]'] = searchVal;
hasFilters = true;
}
if (hasFilters) {
var urlLink = window.location.pathname + '?' + $.param(urlParams);
$('body').find('.dt-dynamic-filter-details')
.append($('<div class="panel panel-info"></div>')
.append($('<div class="panel-heading"><span class="mr-auto"><i class="fas fa-filter"></i> Active Filters:</span></div>')
.append($('<a class="ml-auto float-right pull-right" data-toggle="tooltip" title="Get URL for this set of filters"><i class="fas fa-link"></i></a>').attr('href', urlLink))
)
.append(body)
);
}

}
if (hasFilters) {
var urlLink = window.location.pathname + '?' + $.param(urlParams);
$('body').find('.dt-dynamic-filter-details')
.append($('<div class="panel panel-info"></div>')
.append($('<div class="panel-heading"><span class="mr-auto"><i class="fas fa-filter"></i> Active Filters:</span></div>')
.append($('<a class="ml-auto float-right pull-right" data-toggle="tooltip" title="Get URL for this set of filters"><i class="fas fa-link"></i></a>').attr('href', urlLink))
)
.append(body)
);
}

// If detail rows enabled
if (respite_crud.isDetailRowsAdded) {
// On each draw, loop over the `detailRows` array and show any child rows
$.each(respite_crud.detailRows, function (i, id) {
$('#' + id + ' td a.details-control').trigger('click');
});
});
}
}
});


// Implement row reordering event
respite_crud.dt.on('row-reorder', function (e, diff, edit) {
Expand Down
71 changes: 45 additions & 26 deletions src/AdminLTE/dataview.asp
Original file line number Diff line number Diff line change
Expand Up @@ -543,33 +543,24 @@ IF strError <> "" THEN
.addToolbarActionButton(
{
text: '<i class="<%= Sanitizer.JSON(dvActionsToolbar(nIndex)("GlyphIcon")) %>"></i> <%= Sanitizer.JSON(dvActionsToolbar(nIndex)("ActionLabel")) %>',
className: "btn btn-primary btn-sm",
className: "<%= Sanitizer.JSON(dvActionsToolbar(nIndex)("CSSButton")) %>",
title: "<%= Sanitizer.JSON(dvActionsToolbar(nIndex)("ActionTooltip")) %>",
action: function (e, dt, node, config) {
<%= dvActionsToolbar(nIndex)("NgClickJSCode") %>
<%
Select Case dvActionsToolbar(nIndex)("ActionType")
Case "javascript"
Response.Write dvActionsToolbar(nIndex)("ActionExpression")
Case "url"
Response.Write "respite_crud.actionUrl(""" & Sanitizer.JSON(dvActionsToolbar(nIndex)("ActionExpression")) & """, " & LCase(dvActionsToolbar(nIndex)("OpenURLInNewWindow")) & ");"
Case "db_command", "db_procedure"
Response.Write "throw 'not yet implemented';"
Case Else
Response.Write "throw 'Action Type " & dvActionsToolbar(nIndex)("ActionType") & " unrecognized';"
End Select
%>
}
})<%
NEXT
END IF
%>
/*
// Custom toolbar buttons example
.addToolbarActionButton(
{
text: '<i class="fas fa-exclamation-triangle"></i> Select Reds',
className: "btn btn-danger btn-sm",
action: function (e, dt, node, config) {
dt.rows('.bg-danger').select();
}
})
.addToolbarActionButton({
text: '<i class="fas fa-info-circle"></i> Inspect Selected',
className: "btn btn-info btn-sm",
action: function (e, dt, node, config) {
var r = dt.rows({ selected: true }).data();
alert("Inspecting " + r.length + " rows (check the console)");
console.log(r);
}
})*/
NEXT %>
// Inline buttons
<% IF blnAllowRowDetails THEN %>
.addDetailsButton() //formatDetails)<% END IF
Expand All @@ -578,7 +569,33 @@ IF strError <> "" THEN
IF blnAllowUpdate THEN %>
.addEditButton("<%= GetWord("Edit") %>")<% END IF
IF blnAllowDelete THEN %>
.addDeleteButton("<%= GetWord("Delete") %>")<% END IF %>
.addDeleteButton("<%= GetWord("Delete") %>")<% END IF
FOR nIndex = 0 TO dvActionsInline.UBound %>
.addInlineActionButton(
{
href: "javascript:void(0)",
label: "<%= Sanitizer.JSON(dvActionsInline(nIndex)("ActionLabel")) %>",
glyph: "<%= Sanitizer.JSON(dvActionsInline(nIndex)("GlyphIcon")) %>",
"class": "<%= Sanitizer.JSON(dvActionsInline(nIndex)("CSSButton")) %>",
title: "<%= Sanitizer.JSON(dvActionsInline(nIndex)("ActionTooltip")) %>"
},
function (e, tr, r) {
<%
Select Case dvActionsInline(nIndex)("ActionType")
Case "javascript"
Response.Write dvActionsInline(nIndex)("ActionExpression")
Case "url"
Response.Write "respite_crud.actionUrl(""" & Sanitizer.JSON(dvActionsInline(nIndex)("ActionExpression")) & """, " & LCase(dvActionsInline(nIndex)("OpenURLInNewWindow")) & ", undefined, r, undefined);"
Case "db_command", "db_procedure"
Response.Write "throw 'not yet implemented';"
Case Else
Response.Write "throw 'Action Type " & dvActionsInline(nIndex)("ActionType") & " unrecognized';"
End Select
%>}
)<%
NEXT
END IF
%>
/*
// Custom inline buttons example
.addInlineActionButton(
Expand Down Expand Up @@ -614,7 +631,9 @@ IF strError <> "" THEN
scrollY: 390,
scrollX: 460,
scrollCollapse: true,
scroller: { loadingIndicator: true },<% END IF %><% IF blnDtStateSave THEN %>
scroller: { loadingIndicator: true },<% END IF %><% IF blnAllowRowSelection THEN %>
select: "os",<% ELSE %>
select: false,<% END IF %><% IF blnDtStateSave THEN %>
stateSave: true,<% END IF %><% IF strRowReorderCol <> "" AND Not IsNull(strRowReorderCol) THEN %>
rowReorder: { dataSrc: "<%= Sanitizer.JSON(strRowReorderColMasked) %>" },
columnDefs: [
Expand Down

0 comments on commit 76838b4

Please sign in to comment.