Search on worklist does not work in SAPUI5 Fiori Template Application - sapui5

Hi SAPUI5 developers,
I made a Firori Worklist project inside of WebIDE. I connected it to an OData server and selected SAPUI version 1.38 as default.
It shows the worklist correctly and I can press on items and move between views and visit the object especially.
So everything seems to work fine.
The only thing that is not working is the search box. Its event is triggered whenever I type something inside it and press enter, but it does not filter anything.
The functions that are called are as follow:
onSearch: function(oEvent) {
if (oEvent.getParameters().refreshButtonPressed) {
// Search field's 'refresh' button has been pressed.
// This is visible if you select any master list item.
// In this case no new search is triggered, we only
// refresh the list binding.
this.onRefresh();
} else {
var oTableSearchState = [];
var sQuery = oEvent.getParameter("query");
if (sQuery && sQuery.length > 0) {
oTableSearchState = [new Filter("ZBrandName", FilterOperator.Contains, sQuery)];
}
this._applySearch(oTableSearchState);
}
},
/**
* Internal helper method to apply both filter and search state together on the list binding
* #param {object} oTableSearchState an array of filters for the search
* #private
*/
_applySearch: function(oTableSearchState) {
var oTable = this.byId("table"),
oViewModel = this.getModel("worklistView");
console.log(oTable);
oTable.getBinding("items").filter(oTableSearchState, "Application");
// changes the noDataText of the list in case there are no filter results
if (oTableSearchState.length !== 0) {
oViewModel.setProperty("/tableNoDataText", this.getResourceBundle().getText("worklistNoDataWithSearchText"));
}
},
Thanks in advance.

var oFilter = new sap.ui.model.Filter(oTableSearchState, true);
oTable.getBinding("items").filter(oFilter, "Application");

The problem that I reported may happen for others also thus I replied to my question because I found the answer.
The story is that when I used NorthWind OData service the Fiori Worklist template of the SAP WebIDE works fine and I could see a list of items and search on them (filter).
But when I used our internal SAP ERP OData Service I could see the list of items but I couldn't filter them.
Thus I thought the problem is related to SAP and it can not update the view.
But in fact, SAPUI5 sends a new request to OData Server for each filtering, while I thought the filtering is something that is done inside of the browser.
Therefore, the problem was related to our OData Service implementation that ignored the request options. While we had to implement whole the functionality of the OData specifications in our OData service.
I hope this info works for other who encounter this problem.

Related

Need to show a card widget and after some delay automatically show another card widget regarding google workspace add-on creation

I need to show homeCard() and after I need to show settingsCard() automatically. Since I coudn't find a right method in app-script documentation I need some help for do this task.
Here I provided the code
function nevigateToUserSelectionPage(e) {
var navigation = CardService.newNavigation();
var builder = CardService.newActionResponseBuilder();
var userSelectionCardNavigation = navigation.pushCard(settingsCard());
return builder.setNavigation(userSelectionCardNavigation).build();
}
function homeCard() {
builder = CardService.newCardBuilder();
section = CardService.newCardSection();
let participantsText = CardService.newTextParagraph()
.setText("<u>Home card here</u>");
let blink = CardService
.newImage()
.setImageUrl('https://res.cloudinary.com/deez2bddk/image/upload/v1646709349/icons8-dots-loading_x9q7jv.gif');
section.addWidget(blink);
section.addWidget(participantsText);
section.addWidget(AddSplah);
builder.addSection(section);
console.log('home card triggered!!!');
return builder.build();
}
function settingsCard() {
//const myTimeout = setTimeout(5000);
Utilities.sleep(10000);
builder = CardService.newCardBuilder();
section = CardService.newCardSection();
console.log('Settings card triggered!!!');
let participantsText = CardService.newTextParagraph()
.setText("<u>This is Settings Page....</u>");
section.addWidget(participantsText);
section.addWidget(getAuthenticationStepperImage());
builder.addSection(section);
return builder.build();
}
in code.gs file
function mainController() {
return homeCard();
}
Above code blocks I need to execute homeCard() function and then , settingsCard() but I can`t find a proper solution in workspace add-on creation documentation provided by google.
After doing some research, I think the CardService does not provide a method for non-interactive updates.
You can update the view based on user click interaction, as you can see in the Cats Quickstart. When the user clicks the cat image changes the image updates due the URL has a new parameter via new Date().getTime().
Apart from this, you have the triggers provided by Google, such as: homepageTrigger for common use case or onItemsSelectedTrigger specifically for Drive. You can review the full list here.
In summary: I think that what are you trying to achieve actually is not currently feasible within CardService.
If you wish Google adds some kind of time driven trigger to Google Workspace Add-ons, request it via this form.
Remember that in the actual state, HTML/CSS is not allowed, maybe this would be another possible path for your Feature Request.

Typo3: Controller action with hidden record as its parameter

I am currently trying to get a extension working in Typo3 v10, which enables the user to show, edit, update, disable and enable other user accounts.
Unfortunately, I am running into the issue that I cannot use disabled users as arguments for the actions:
/**
* Save user changes
*
* #param \Company\MyExtension\Domain\FeUser $feuser
* #return void
*/
public function updateAction(\Company\MyExtension\Domain\FeUser $feuser): void {}
It would resulting in the error following error:
Object of type \Company\MyExtension\Domain\FeUser with identity "3" not found.
From what I have gathered, extbase does not rely on the repository's default query settings to create the objects but instead uses PersistenceManager::createQueryForType to get the query settings via QueryFactory::create. This is an issue also listed in a few bug reports.
There's a suggestions as to how to use a custom QueryFactory to set different default QuerySettings for my extension, however this does not seem to work in Typo3 v10 anymore, at least my custom QueryFactory isn't being used after registering it... Also, if this were to work, wouldn't it use the new QueryFactory for all objects instantiated through a controller action and not just this extension?
How can I properly handle hidden users my extension with Typo3 v10.4?
P.S. Another suggestion was to fetch object early through initializeAction, but this only works well if it is about the unmodified model and not when setting new values for the object, as it would just load the database values in the end...
Checkout the extension "news" how it is handled here:
if ($news === null || $this->settings['isShortcut']) {
$previewNewsId = ((int)$this->settings['singleNews'] > 0) ? $this->settings['singleNews'] : 0;
if ($this->request->hasArgument('news_preview')) {
$previewNewsId = (int)$this->request->getArgument('news_preview');
}
if ($previewNewsId > 0) {
if ($this->isPreviewOfHiddenRecordsEnabled()) {
$news = $this->newsRepository->findByUid($previewNewsId, false);
} else {
$news = $this->newsRepository->findByUid($previewNewsId);
}
}
}
https://github.com/georgringer/news/blob/master/Classes/Controller/NewsController.php#L338
I am assuming you need the URL as well. I gave an answer here if you wanna take a look.
Show, edit and update hidden records in FrontEnd (TYPO3)
You can adjust it to your own needs as well.
Best regards

How to do oData client filter in sap.m.SelectDialog? [duplicate]

This question already has answers here:
Filtering just a sap.m.List in Client Side SAPUI5
(2 answers)
Closed 4 years ago.
I'm using sap.m.SelectDialog with sap.ui.model.odata.v2.ODataModel, the implementation of search in SelectDialog follows the sample
handleSearch: function(oEvent) {
var sValue = oEvent.getParameter("value");
var oFilter = new Filter("Name", sap.ui.model.FilterOperator.Contains, sValue);
var oBinding = oEvent.getSource().getBinding("items");
oBinding.filter([oFilter]);
},
handleSearch will trigger substringof method of EntitySet, But our oData service did not implement substringof, skip, top.
So my question is since front-end has get the whole data, can I do filter in client side?
I tried to set DefaultOperationMode in handleSearch:
this._oModel.sDefaultOperationMode = "Client";
not working.
Also tried to operate data in model directly, but this._oModel.oData returned not the whole data. but when I scroll down, new items are added with no new GET is triggered. Feel very confused about this.
BTW, if this can be done, how to hide search box in SelectDialog, the corresponding method seems not provided.
Thanks to #Medera, found an elegant way:
items="{
path: '/PackageSet',
parameters: {operationMode: 'Client'}
}">
Also marked my questions as duplicate.
#Not recommend
Thanks to #Jorg, fixed this by changing oData model to JSON model:
this._oModel.read("/PackageSet", {
success: this.successGetPackgeCallback.bind(this),
error: this.errorCallback.bind(this)
});
successGetPackgeCallback: function(oResult) {
var oModel = new JSONModel(oResult.results);
this.selectDialog.setModel(oModel);
},
The OData model is a server-side model, meaning that the data set is only available on the server and the client only knows the currently visible (requested) data. Operations, such as sorting and filtering, are done on the server.
The JSON model is a client-side model and, therefore, intended for small data sets, which are completely available on the client.

Siebel Open UI - How to make a query over Business Component from Javascript

I'm struggling to a Siebel Open UI requirement which ask for running a query over the current Business Component upon a double click on a record.
I tried the following in PR js associated to my custom applet:
var pm = this.GetPM();
var recordSet = pm.Get("GetRecordSet");
for (record in recordSet) {
var row = $("#" + this.GetPM().Get("GetPlaceholder"))
.find("tr[id=" + (Number(record) + 1) + "]")
.dblclick({ctx:pm}, function(event) {
var bc = event.data.ctx.Get("GetBusComp");
bc.InvokeMethod("ClearToQuery");
bc.SetSearchSpec("Id","1-81OR");
bc.InvokeMethod("ExecuteQuery");
});
}
the "bc" variable seems to be corrected instantiated, but when I look in the method exposed (console web browser) I don't see any of interest for making a query apart from InvokeMethod("ExecuteQuery") which is not working (it does nothing when I look at the logs).
Do you know how can I make such query from PR or PM?
Vincenzo
There are limitations in earlier versions of OpenUi but after 15, it has exposure to many BC methods.
Try this:
http://www.askmesiebel.com/2014/04/siebel-open-ui-invoke-business-service-from-pm-file/
Finally i got it, Query itselft is not possible on browser side. Only way is to call a Business Service which performs the query (at that time, bs is executed on the servver side)

GXT (Ext-GWT) + Pagination + HTTP GET

I'm trying to populate a GXT Grid using data retrieved from an online API (for instance, going to www.example.com/documents returns a JSON array of documents). In addition, I need to paginate the result.
I've read all the various blogs and tutorials, but most of them populate the pagination proxy using something like TestData.GetDocuments(). However, I want to get that info using HTTP GET.
I've managed to populate a grid, but without pagination, using a RequestBuilder + proxy + reader + loader. But it seems as though the actual loading of the data is "put off" until some hidden stage deep inside the GXT code. Pagination requires that data from the start, so I'm not sure what to do.
Can someone provide a simple code example which does what I need?
Thank you.
I managed to get this going, here is what I did:
First I defined the proxy and loader for my data along with the paging toolbat:
private PagingModelMemoryProxy proxy;
private PagingLoader<PagingLoadResult<ModelData>> loader;
private PagingToolBar toolBar;
Next is the creation of each one, initializing with an empty ArrayList.
proxy = new PagingModelMemoryProxy(new ArrayList<EquipmentModel>());
loader = new BasePagingLoader<PagingLoadResult<ModelData>>(proxy);
loader.setRemoteSort(true);
toolBar = new PagingToolBar(100);
toolBar.bind(loader);
loader.load(0, 100);
Last, I have a set method in my view that gets called when the AJAX call is complete, but you could trigger it anywhere. Here is my entire set method, Equipment and EquipmentModel are my database and view models respectively.
public void setEquipmentData(List<Equipment> data)
{
Collections.sort(data);
// build a list of models to be loaded
List<EquipmentModel> models = new ArrayList<EquipmentModel>();
for (Equipment equipment : data)
{
EquipmentModel model = new EquipmentModel(equipment);
models.add(model);
}
// load the list of models into the proxy and reconfigure the grid to
// refresh display.
proxy.setData(models);
ListStore<EquipmentModel> equipmentStore = new ListStore<EquipmentModel>(loader);
equipmentGrid.reconfigure(equipmentStore, equipmentColumnModel);
loader.load(0, 100);
}
The key here for me was re-creating the store with the same loader, the column model was pre-created and gets reused.