React Admin - Get additional parameter from server and pass to List view props - react-admin

We get "total" and "data" from getList which is passed to List view. I want to show additional data Aside of list view, Eg. total sell, total amount etc. I can pass those data from server but it seems react admin ignore those parameters. How can i accept those parameters from server and pass to Aside props in List view?

If the API is RESTful, adding additional data to the response would break REST principles. You could expose a different endpoint for such "summary" information and call it form a custom component.

Related

How to update multiple entities in Cuba Platform Frontend UI

I have a function that returns data from many entities and puts them in a table. When the table is changed and the save button is clicked I need to send all the data to their entities. Is there a way to do this in one action?
If you mean that you need a REST API method which can update several entities at once - then there is no such built-in method in the CUBA REST addon.
However, backend developers can create and expose a "service method" for you that accepts list of entities or POJOs as parameter. Then you will be able to call it from the web page.
See https://doc.cuba-platform.com/restapi-7.2/#rest_api_v2_ex_service_post

Is it okay to return all data that related to the resource in one endpoint

We have a recipe in our mobile application, this recipe has a details screen and the details screen has a lot of information, for example:
Rating
Related recipes
Ingredients
Recipe info
Nutritional info
So is that right to return all this info in the same endpoint or create multiple endpoints for each section?
One endpoint example:
GET: https://www.example.com/api/v1/{recipeId}
Multiple endpoints example:
GET: https://www.example.com/api/v1/{recipeId}/info // this API will return all info including the ingredients
GET: https://www.example.com/api/v1/{recipeId}/rating
GET: https://www.example.com/api/v1/{recipeId}/related
GET: https://www.example.com/api/v1/{recipeId}/nutritional
It depends.
If a consumer of your API is say a web page where you want to display all the information at the same time in one click, you can just bring all information together and display in one go rather than calling APIs one by one and then aggregating, however if there is possibility that individual endpoints are also required to be called separately, then you can expose multiple endpoints.
Also,your resource uri should be like this :
/api/v1/recipes/{recipeId}
In this case, you can create a single API endpoint. And, can expose a query parameter which shows which are the fields user (rest client, web) is interested in.
/api/v1/recipes/{recipeId}/?fields=all
/api/v1/recipes/{recipeId}/?fields=info,rating,related
/api/v1/recipes/{recipeId}/?fields=info
In this way, you will be saved from the headache of writing multiple endpoints for a single serving type.
Also, the schema of output message or JSON will be the same.
Maybe in future, you want to add another field to your response. You just need to add another filter name. Your client (web/rest) doesn't need to use a new API for that. Just pass the new filter and done.

Vue.js Two Components share same data from service call

I have two Vue components. One is hooked to the Data Store to get the data necessary to bind. It is displaying n details (records). The other component needs to share the same data. It is displaying the count on the records. How do I share information from 1st component.
I tried creating a global variable and set it in 1st component and use it in second component.
Thanks.
If these components is not related to each other (like parent-child) then you should use a global state using a Vuex to store your records and access them from different components.

VueJS/ElementUI: Accessing the rows of an El-Table

I'm using Element-UI along with VueJS for a project, and I've recently hit a wall.
For the needs of a specific function, I need to access the individual rows of an el-table component, preferably using $refs, but for the life of me I can't figure out how to do it.
EDIT:
I have a set of rows rendered within the table depending on information that comes from the server in the form of an array of objects. When the application receives the data, it parses the objects and nests them into corresponding groups if certain values are repeated, such as a product's id or the manufacturer's id. If the data is not repeated, it is left as is.
In one of the methods defined in the Vue component that calls el-table, I need to loop through the rows rendered inside the table in order to access their data and process a set of information.
I can access the table itself pretty easily once I set the ref attribute on it and call this.$refs, but I can't figure out how to access the rows themselves. I haven't found any way to set the ref attribute on the rows, either. I tried using pure JavaScript and jQuery and I managed to access the group of rows, but doing it this way doesn't allow me to access the data stored in the Vue elements.

How to Collect dijit/form/combobox Selected Values in Repeat Control

An XPage is used to display the number of points a person has collected, and the number of points remaining (see below).
I have a repeat control which gets a collection of documents meeting a specific criteria. The last column in the control contains 5 digit/form/comboboxes, which are displayed or hidden, according to the number of fields on each document that contain data.
The layout contains gift cards worth a certain amount of points, and the person can select how many of each gift card they want. eg.
Company Available in Values of Points Required Quantity Requested
The Quantity Requested column contains the digit/form/comboboxes. As the person selects values in the checkbox, I want the number of points remaining to be recalculated.
The onChange event of the digit/form/comboboxes calls a function in an Output Script which calls an RPC, which in turn calls an SSJS function. The SSJS function cycles through the documents displayed in the repeat control, gathering the points required information. I then wanted it to also grab the Quantity Requested. I understand from a previous posting that because of the way the digit/form/combox is rendered, I can only get the value using CSJS with dijit.byId and perhaps putting the value in a hidden field and retrieving it from there.
I can't seem to wrap my head around how I will do this when the repeat control will make it possible for there to be many combobox1 and combobox2, etc.
The XPage is not bound to a form, because all the items are just calculated on the fly and then discarded.
What is the best way to do this?
The JSON RPC service can't interact with any changes made in the browser, see https://www.intec.co.uk/json-rpc-service-component-tree-manipulation-openlog/. This could be the cause of your problems.
You may be able to get around it by triggering a partial refresh (POST) before calling the JSON RPC. In theory that might work, because the component tree (server-side map of the XPage) would get updated by the partialRefreshPost and the updates picked up by the JSON RPC. It's possible though that the Restore View picks up a version of the XPage other than the one for the browser, I don't know. I've never investigated that.
It's been a while since I've worked with server java script, I have been doing it the managed bean way with ActionListeners. If you have the data in the UI, then can you avoid server side processing and do it client side?
You can also use the DOM XSP Object like XSP.setSubmittedValue to have a key value pair sent with your post request to the server side, you can only have one... it can be JSON or any other value you set it to from the client side javascript.
I figured out how to do this. If anyone wants the code, let me know and I'll provide it.