Determine the list of IR filter's functions/operators in Oracle APEX 19.1 - oracle

Is there a way to hide some Functions/Operators in the Row Filter of APEX 19.1's Interactive Report? Some end-users get confused with as many functions/operators that they do not used.
Thanks for any considerations.

While APEX doesn't support this out of the box, it is doable with JavaScript. Every time the filter dialog is displayed, content is brought from the server to the client and injected into the DOM. You just need to modify the content before the user can see it. One way to achieve this is by using the MutationObserver interface: https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
Here are some steps you could follow to do it (tested in APEX 19.2):
Go to the Interactive Report and set the Static ID to my-irr.
Go to the page level attributes and add the following code to the Function and Global Variable Declaration field:
function removeIRFilterOperators() {
var irRegId = 'my-irr';
var filterOperatorsToRemove = ['!=', 'ABS'];
var observer;
function detectFilterDialog(mutationsList) {
for (var mIdx = 0; mIdx < mutationsList.length; mIdx++) {
if (mutationsList[mIdx].addedNodes.length &&
mutationsList[mIdx].addedNodes[0].classList &&
mutationsList[mIdx].addedNodes[0].classList.contains('a-IRR-dialog--filter')) {
removeOperators();
}
}
}
function removeOperators() {
var anchors = document.querySelectorAll('#' + irRegId + '_row_filter_operators a');
for (var aIdx = 0; aIdx < anchors.length; aIdx++) {
if (filterOperatorsToRemove.includes(anchors[aIdx].textContent)) {
anchors[aIdx].parentElement.parentElement.removeChild(anchors[aIdx].parentElement);
}
}
}
observer = new MutationObserver(detectFilterDialog);
observer.observe(
document,
{
attributes: false,
childList: true,
subtree: true
}
);
}
removeIRFilterOperators();
The MutationObverver uses the detectFilterDialog function to detect when the filter dialog is added to the DOM. When that happens, the removeOperators function removes the specified options from the operator's list. All you need to do is update the filterOperatorsToRemove array to include the list of operators you want to remove.

If you're talking about the "Actions" menu, then yes - go to IR's attributes and enable/disable any option you want:

Related

Dynamic menu configuration section with conditional inputs on Magento custom module

I've followed this tutorial to create a custom dynamic backend configuration with serialized data, and everything is working as expected. yay
But now I want to take another step and only show some inputs when a specific value is selected in a select box. I know that I can use when doing this with system.xml, but how can I accomplish the same thing via code with dynamics serialized tables?
I ended up doing some kind of Javascript workaround to enable/disable a certain input.
function togleSelect(element)
{
var val = element.value;
var name = element.name;
if (val == 0) // select value to be triggered
{
name = name.substr(0, name.lastIndexOf("[")) + "[name_of_my_input]";
var target = document.getElementsByName(name);
target[0].disabled = false;
}
else
{
name = name.substr(0, name.lastIndexOf("[")) + "[name_of_my_input]";
var target = document.getElementsByName(name);
target[0].disabled = true;
}
}
It's not the best solution but it's working.

Getting lightswitch HTML client to load related entities

I am trying to load an entity based on a Query and allow the user to edit it. The entity loads without issues from the query, however it does not load its related entities, leaving detail pickers unfilled when loading the edit screen.
This is the code that I have:
myapp.BrowseCOAMissingHoldingCompanies.VW_ChartOfAccountsWithMissingHoldingCompanies_ItemTap_execute = function (screen) {
var accountName = screen.VW_ChartOfAccountsWithMissingHoldingCompanies.selectedItem.AccountFullName;
return myapp.activeDataWorkspace.Accounting360Data.FindChartOfAccountsMappingByAccountName(accountName)
.execute().then(function (query) {
var coa = query.results[0];
return myapp.showAddEditChartOfAccountsMapping(coa, {
beforeShown: function (addEditScreen) {
addEditScreen.ChartOfAccountsMapping = coa;
},
afterClosed: function () {
screen.VW_ChartOfAccountsWithMissingHoldingCompanies.refresh();
}
});
});
};
Interestingly if I open the browse screen (and nothing else) of that entity type first (which does retrieve the entity), then the related entities load correctly and everything works, but I can't figure out how to make that level of load happen in this code.
One method of tackling this (and to avoid the extra query execution of a follow on refresh) is to use the expand method to include any additional navigation properties as follows:
myapp.BrowseCOAMissingHoldingCompanies.VW_ChartOfAccountsWithMissingHoldingCompanies_ItemTap_execute = function (screen) {
var accountName = screen.VW_ChartOfAccountsWithMissingHoldingCompanies.selectedItem.AccountFullName;
return myapp.activeDataWorkspace.Accounting360Data.FindChartOfAccountsMappingByAccountName(
accountName
).expand(
"RelatedEntity," +
"AnotherRelatedEntity," +
"AnotherRelatedEntity/SubEntity"
).execute().then(function (query) {
var coa = query.results[0];
return myapp.showAddEditChartOfAccountsMapping(coa, {
beforeShown: function (addEditScreen) {
addEditScreen.ChartOfAccountsMapping = coa;
},
afterClosed: function () {
screen.VW_ChartOfAccountsWithMissingHoldingCompanies.refresh();
}
});
});
}
As you've not mentioned the name of your entity's navigational properties, I've used coa.RelatedEntity, coa.AnotherRelatedEntity and coa.AnotherRelatedEntity.SubEntity in the above example.
As covered by LightSwitch's intellisense (in msls-?.?.?-vsdoc.js) this method 'Expands results by including additional navigation properties using an expression defined by the OData $expand system query option' and it accepts a single parameter of 'An OData expand expression (a comma-separated list of names of navigation properties)'.
The reason your forced refresh of coa also populates the navigational properties is that LightSwitch's refresh method implicitly expands all navigation properties (provided you don't specify the navigationPropertyNames parameter when calling the refresh). The following shows the internal implementation of the LightSwitch refresh method (with the implicit expand behaviour executing if the navigationPropertyNames parameter is null):
function refresh(navigationPropertyNames) {
var details = this,
properties = details.properties.all(),
i, l = properties.length,
property,
propertyEntry,
query;
if (details.entityState !== _EntityState.unchanged) {
return WinJS.Promise.as();
}
if (!navigationPropertyNames) {
navigationPropertyNames = [];
for (i = 0; i < l; i++) {
property = properties[i];
propertyEntry = property._entry;
if (isReferenceNavigationProperty(propertyEntry) &&
!isVirtualNavigationProperty(propertyEntry)) {
navigationPropertyNames.push(propertyEntry.serviceName);
}
}
}
query = new _DataServiceQuery(
{
_entitySet: details.entitySet
},
details._.__metadata.uri);
if (navigationPropertyNames.length > 0) {
query = query.expand(navigationPropertyNames.join(","));
}
return query.merge(msls.MergeOption.unchangedOnly).execute();
}
However, if you take the refresh approach, you'll be performing an additional unnecessary query operation.
Entity Framework uses lazy loading by default, so related data will be loaded on demand, but in your case that's too late because the entity is already client-side a that point.
Try using the Include method in your query if you want eager loading.
Calling refresh on the details of the entity seems to do it:
return coa.details.refresh().then(function() {
return myapp.showAddEditChartOfAccountsMapping(coa, {
beforeShown: function (addEditScreen) {
addEditScreen.ChartOfAccountsMapping = coa;
},
afterClosed: function () {
screen.VW_ChartOfAccountsWithMissingHoldingCompanies.refresh();
}
});
});
You should use load method to fetch related data from Server. At this time we don't have any ways to force msls load related data.

Firefox Addon bookmarks group (subfolder) search: discriminating between bookmarks and groups

I'm trying to make my first firefox addon.
For this I want to get all the groups directly under the TOOLBAR group.
I started here, but didn't manage to discriminate between groups and bookmarks.
Here is the relevant part of my code:
var { search, TOOLBAR } = require("sdk/places/bookmarks");
search(
{ group: TOOLBAR, type: "group" },
{ sort: "title" }
).on("end", function (results) {
var arrayLength = results.length;
console.log(arrayLength);
for (var i = 0; i < arrayLength; i++) {
console.log(results[i]);
//Do something
}
});
I would be interested in how to do this using the linked API.
If this wouldn't work for some reason, I would also be interested in workarounds, older methods, more complicated or direct methods. In this case, please direct me to information that is roocky-proof :)

CouchDb - Access replication filters in view

is it possible to use the replication filter feature of couchdb (http://wiki.apache.org/couchdb/Replication#Filtered_Replication) by requesting a view, f.e.:
.../_view/candidates?filter=hrtool/myfilter
This would be nice to filter the documents based on the usersession or userrole
Thanks in advance
fadh
That is possible with a _list function.
List functions are Javascript code which pre-process the view output before sending it to the client. You can modify the view output in any way, such as by filtering some rows.
function(head, req) {
// lists.filtered: filter view output by using a replication filter.
var ddoc = this; // A common trick to explicitly identify the design document.
function error(reason) {
start({"code":400, "headers":{"content-type":"application/json"}});
send(JSON.stringify({"error":reason}));
}
var filter_name = req.query.filter;
if(!filter_name)
return error("Need filter_name parameter");
var filter_src = ddoc.filters[filter_name];
if(!filter_src)
return error("Invalid filter_name: " + filter_name);
// Not 100% sure on this, you could also use new Function(args, src);
// In the worst-case, the couchapp tool has the !code tool to copy code.
var filter = eval(filter_src); // Not 100% sure on this
var row;
start({"headers":{"content-type":"application/json"}});
send('{"rows":[\r\n');
var first = true;
while(row = getRow()) {
if(filter(row)) { // Or perhaps use include_docs=true and filter(row.doc)
if(! first)
send(",\r\n");
first = false;
send(JSON.stringify(row));
}
}
send("]}\r\n");
}
Use this list "filter" like any filter function:
GET /db/_design/example/_list/filtered/candidates?filter=myfilter&include_docs=true

Cascading to a auto completing text box

I have a web page where the user will enter their address. They will select their country and region in cascading drop down lists. I would like to provide an auto completing textbox for their city, but I want to be context sensitive to the country and region selections. I would have just used another cascading drop down list, however the number of cities exceeds the maximum number of list items.
Any suggestions or cool code spinets out there that may help me out?
I just found the following blog post that looks at least close to what you want.
They manage it using the following javascript functions:
function initCascadingAutoComplete() {
var moviesAutoComplete = $find('autoCompleteBehavior1');
var actorsAutoComplete = $find('autoCompleteBehavior2');
actorsAutoComplete.set_contextKey(moviesAutoComplete.get_element().value);
moviesAutoComplete.add_itemSelected(cascade);
// setup initial state of second flyout
if (moviesAutoComplete.get_element().value) {
actorsAutoComplete.get_element().disabled = false;
} else {
actorsAutoComplete.get_element().disabled = true;
actorsAutoComplete.get_element().value = "";
}
}
function cascade(sender, ev) {
var actorsAutoComplete = $find('autoCompleteBehavior2');
actorsAutoComplete.set_contextKey(ev.get_text());
actorsAutoComplete.get_element().value = '';
if (actorsAutoComplete.get_element().disabled) {
actorsAutoComplete.get_element().disabled = false;
}
}
Sys.Application.add_load(initCascadingAutoComplete);
Calling the cascade function on the add_itemSelected method of the parent control for the cascading behaviour.
They cascade the contents of one auto complete extender into another, rather than taking a cascading drop down list, but hopefully you can reuse some of the ideas.

Resources