Datagrid clarity component with Firebase - firebase

I have a data grid which populates data from Firebase Cloudstore (sorted according to lastUpdated date from Firebase), when I edit the row I have modal dialog where I can edit the information, when save the entry I set the lastUpdated to sysdate. Editing works fine (and the timestamp is updated) but it picks the wrong row from the table. In the table I have a column which is the documentId from Firebase. To verify that it picks the wrong documentId I then console log the documentId which is passed to the edit method and it is not the same as the one on the row that I pick for editing in the view.
My code is exactly like the below code (taken from clarity documentation). What am I doing wrong ?
<clr-dg-row *clrDgItems="let user of users" [clrDgItem]="user">
<clr-dg-action-overflow>
<button class="action-item" (click)="onEdit(user)">Edit</button>
<button class="action-item" (click)="onDelete(user)">Delete</button>
</clr-dg-action-overflow>
<-- ... -->
</clr-dg-row>

You've got a few structure issues here.
First, the modals should be top level and not inside of the Datagrid. Basically, it is causing the last defined modal (of the same clrModalOpen binding) to be displayed and never the others.
Second, clicking on a record is not passing or setting any state about which row you are selecting. So your form has no knowledge of which row is being edited and your model is undefined.
The reason your modal would output the connection.id was you defined it inline of the datagrid rows itself, where the connection local variable was present. However, you'll have to pass it around to the modal since it must live outside of the datagrid itself.
See https://stackblitz.com/edit/angular-azbaxr?file=src%2Fapp%2Fapp.component.html

Related

jsViews sort - how to automatically update the sort when a property changes

Just looking at the live example code on the jsViews site:
https://www.jsviews.com/#jsvfortag#jsvsortfilterrange
If I modify this line to include a sort:
{^{for members sort='name' start=start-1 end=end}}
The array does not re-sort after observably adding an item to it.
$.observable(team.members).insert(0, {name: "zzz this should be last"})
Any ideas how to trigger the sort after an item is inserted?
The sorting does refresh when there is an array change event. Putting sort='name' will re-sort if you click on [Add], or on [x] to delete an item. But what you want it is to trigger a re-sort whenever you change the name property in an item.
But you don't want it to re-sort on character entry, so the first thing is to set:
<input data-link="name trigger=false" />
See docs here for the trigger setting (done above as local override of the global setting).
Next you can declaratively make your list of items depend on the name text on each of the items, by writing
{^{for members sort='name' depends='members.[]^name'}}
The depends='members.[]^name' feature has very little documentation, but is a wild card for responding to individual property changes (here, the name property) on any item in the array.
See https://www.jsviews.com/#samples/sort-filter#jsv-for for a sample which uses it.
You could also do depends='members.[]^*' for responding to changes on any array item property.
And depends='members.**' will work too, for listening to any change at all under the members array (See the docs here)
Here is a working sample which uses the depends='members.[]^name' approach above:
https://jsfiddle.net/BorisMoore/b51tu27n/

IN_VND_ITM_XLS Excel to CI - New field added to CI does not get inserted

I have added a new field into the IN_VND_ITM_XLS component interface, (BU_PRICE_STATUS), which is in a SQL View already part of the delivered template, ITM_VND_UMP_CVW. I modified the view (Record definition) in App Designer to pull in the BU_PRICE_STATUS field and then modified the component interface and added this field.
When I regenerate the template in Excel, it populates the additional field fine, I select it as an input cell (along with the others I originally had) and I submit the data and return back the green OK status.
When I look online in PeopleSoft I see that the vendor data was created for the item, however the BU_PRICE_STATUS field is populated with a different value than what I specified on the upload. The default value listed on the field definition in app designer was what was populated, instead of the value I had entered for the upload.
Is there something else I did to modify for this to work? I know that when you run the Item Loader process, it uses a Message definition (IN_MST_ITM_XLS) so I wasn't sure if the message needed to be updated to? Thanks in advance.
2/27 EDIT:
I've found that the Component (for this component interface) - IN_MST_ITM_XLS uses a function called PRCSITEM within a Function library record - FUNCLIB_INEIP and this populates data in a staging table called PS_ITM_VND_UMPR_EC. I see that this table does not contain the field BU_PRICE_STATUS (which I didn't believe it would) so I'm thinking if the code/table can be updated to capture this field it would work. Hoping someone can suggest if I'm in the right area and what would need to be changed.

Application Express: Anonymous PL/SQL Block and Bind Variables

I'm having an issue binding the value of a page item to a declared variable in an anonymous PL/SQL block process.
The problem is that the page item (:P4550_REQUESTOR) is not populated with a value until a conditional is met. It appears that the PL/SQL block process is binding the variable to an empty value as soon as the page is loaded, despite the fact that the process does not fire until a specific button has been clicked.
Here is my code:
DECLARE
v_email_to app_user.email%type;
v_requestor VARCHAR2(15);
BEGIN
v_requestor := :P4550_REQUESTOR;
BEGIN
SELECT email INTO v_email_to
FROM app_user
WHERE userid = v_requestor;
END;
SEND_APEX_MAIL (
v_email_to,
'Your vacancy request has been rejected.'
|| chr(10)
|| 'Emailed to: ' || v_email_to
|| chr(10)
|| 'Requestor: ' || v_requestor,
'Vacancy Request Rejected'
);
END;
Does anyone have any thoughts on this?
The block works just fine if I hard code a value to v_requestor. If I try to get the value of P4550_REQUESTOR after the page has loaded, it is empty. After clicking the edit button, P4550_REQUESTOR is populated.
** **MORE DETAIL** **
P4550_REQUESTOR is a page item that resides within the Vacancy Request region which is only displayed when a conditional is met. Specifically, the conditional is an edit button associated with a table row that is created on page load. Clicking the edit button causes the details region to display, and the associated page items to be populated.
The page item values in the Vacancy Request region are populated via an Automated Row Fetch which fires After Header.
P4550_REQUESTOR has a Source Type of DB Column.
The process that fires the code above is set to fire On Submit - After Computations and Validations
If I log the value of P4550_REQUESTOR when the page loads, it shows null. If I log the value after clicking the edit button, I get the expected string value.
Process Flow Control in Oracle APEX
(This is actually useful to think about in other programming disciplines and environments.)
Problem Defined
The problem is that the page item (:P4550_REQUESTOR) is not populated with a value until a conditional is met. It appears that the PL/SQL block process is binding the variable to an empty value as soon as the page is loaded, despite the fact that the process does not fire until a specific button has been clicked.
The problem statement reworded in Apex terminology and presented in the form of an actual question:
There is a REPORT REGION on the page which contains the result of a direct reference to a data table/view. This report is managed by an Apex process called "Automated Fetch" and is initiated automatically by the loading of the page headers.
There is a FORM ITEM on a page which which is populated conditionally by a BUTTON ITEM selection made by the user. The BUTTON ITEM is part of the report results.
There are multiple button items. Each is associated with a value for each report record.
If the user does not select the BUTTON ITEM from the REPORT REGION, the FORM ITEM remains unassigned and contains a "null" value.
There is a defined PL/SQL block of code which is set to execute when a SUBMIT BUTTON item is pressed (also on the same page). Why does my code block (defined page process) run with a null value when it is triggered without first pressing a BUTTON ITEM from the REPORT REGION first?
Event Driven Program Design for Procedural Programmers
The answer is not obvious if you think under the paradigm of a procedural language. Without diving into a lecture on the topic, here's a visual layout of the problem space of the OP that I cooked up to illustrate how the problem can be made more obvious:
This is my Apex page design in implementation. It's generic enough to use as a template for other Apex designs. There are no flow arrows on this diagram because it's a stateful system. One thing causes another thing to happen and so on... but not always and not all at the same time.
Use Cases for Apex UI Page Designs
Try walking through a few use cases to understand how the elements broken down in the diagram operate together. Each user may take any number of click combinations and interactions, but there is a commonality:
They all enter the same initialized conditions on page load.
They all leave the page by: navigating elsewhere or through the SUBMIT button event.
Use Case #1
User chooses {MyPage:SQLReport:ThisButton} from one of the records in {MyPage:SQLReport}
According to {MyPage:SQLReport:ThisButton} #3, the value associated between the report record and the button item is passed to: {MyPage:HTML-Region:ThisItem}
The form item state has been updated and changed from the initial null value.
User selects {MyPage:HTML-Region:ThisSubmit} button to inform the system to continue on.
The submit button executes the defined PL/SQL procedure block: {MyPage:RunCodeBlock}
Use Case #2
User enters page and reviews results displayed in the {MyPage:SQLReport} region.
User decides no additional input is necessary and then selects the {MyPage:HTML-Region:ThisSubmit} button to inform the system to continue on.
(a note: the state of form item {MyPage:HTML-Region:ThisItem} has not been changed from the initial null value at this point... after the submit button has been selected)
The submit button executes the defined PL/SQL procedure block: {MyPage:RunCodeBlock}
Use Case #3
User chooses {MyPage:SQLReport:ThisButton} from one of the records in {MyPage:SQLReport}
According to {MyPage:SQLReport:ThisButton} #3, the value associated between the report record and the button item is passed to: {MyPage:HTML-Region:ThisItem}
The form item state has been updated and changed from the initial null value.
User chooses {MyPage:SQLReport:ThisButton} from a different selection from one of the records in {MyPage:SQLReport}.
According to {MyPage:SQLReport:ThisButton} #3, the value associated between the report record and the button item is passed to: {MyPage:HTML-Region:ThisItem}
The form item state has been updated and changed from the initial value stored in step (2).
User selects {MyPage:HTML-Region:ThisSubmit} button to inform the system to continue on.
The submit button executes the defined PL/SQL procedure block: {MyPage:RunCodeBlock}
The difference between each case should illustrate why the dependent value (ThisItem, or more specifically, page item P4550_REQUESTOR) is null in one use case vs. the other.
Building a Physical Implementation (An Apex Page)
The table I used is called STAR_EMPS. It is similar to the EMP table but has only three columns: ename, deptno and salary. Although it is not super important, this is the data set I used to populate STAR_EMPS:
I used a simple two-column table named STAR_EMPS_LOG for capturing the output of a successfully executed procedure call. You could accomplish the same with just one column, but I wanted a sequential id for tracking the order each event was recorded- for running multiple test cases. The procedure is one of several defined processes kept on this page:
contained in: {MyPage:RunCodeBlock} is below:
DECLARE
-- output from this procedure will be recorded in the star_emps_log
-- table. {MyPage:RunCodeBlock}
mycelebrity star_emps.ename%TYPE:= :P17_CELEBRITY_NAME;
mylogmessage star_emps_log.log_message%TYPE;
BEGIN
-- Conditional; changes message based on the value set for the
-- page item.
if mycelebrity is null then
mylogmessage:= 'No button was pressed on the previous page.';
else
mylogmessage:= 'The user selected: ' || mycelebrity ||
' from the report list.';
end if;
-- populate value from the page item.
INSERT INTO star_emps_log (log_message)
VALUES (mylogmessage);
commit;
END;
This is how the page layout was set up:
As in your example, I made a {MyPage:SQLReport} region with its supporting elements. The SQL Report represents a query directed at the source data table.
{MyPage:Form} has been renamed to {MyPage:HTML-Region}.
{MyPage:SQLReport} is defined by a SQL query, there is also a mock column to use as a place holder for placement of the "edit" buttons.
{MyPage:SQLReport:ThisButton} The button specifications are detailed through this:
The TWO Page processes: PROCESS and BRANCH need to be linked with the same settings referencing a BUTTON triggering Item.
User Interface Test Cases
Run through the three suggested scenarios to get started. Verify that the system is interpreting the requests correctly. This is what the page layout looks like:
The two processes on the system have a definition that wasn't mentioned in previous discussions may solve our original problem at hand:
Some Parting Thoughts
It is a good thing this turns out to be a trivial case once broken down. The diagramming method described here should scale to other Apex applications of varying complexity. There is considerable utility in stepping away from the code, locking down on terminology and trying to describe systems and processes without actual code. Please be sure to share any stories if this approach helps with your own Oracle Apex design challenges.
Onward!
The original, verbose answer seems to way overcomplicate the issue. The session state concepts manual covers this behaviour more succinctly.
Should P4550_REQUESTOR be a normal item created from a wizard, using :P4550_REQUESTOR will return a value in processes running post submit because the submit processes moves values in browser to session state.
If P4550_REQUESTOR is rendered conditionally, then it will always be null and I'm not sure what would happen if you tried to set it - probably depends how.
On a similar note, if you used &P4550_REQUESTOR. to parameterise the process, you would face the behaviour originally described (and made the code less secure)

Data copied between rows on form's datagrid

Within AX 2009, I have, through compare and compile, added two new controls within a datagrid on a form, a Real edit and a combobox. I have compiled with no issues. The Allow Edit property is set to Yes on both controls.
However, on the form, if I edit one row, whether typing a new number with Real edit or combobox, and don't hit Save but hit the Down Arrow key, the data I typed on the previous records is duplicate in the next record and so on until I release the Down Arrow key, rather than just setting the focus on a new record.
The table where these fields were created doesn't exhibit this behavior. The focus simply moves to the next record and what was typed will not carry over to the next record. Only the form does this...
Has anyone seen this behavior before with AX forms?
You may have omitted to specify the data source on the grid itself?
Or if the new controls are based on Edit methods on the data source, have you got the data source parameter in the method signature?
see http://msdn.microsoft.com/en-us/library/aa637541(AX.10).aspx

Checkboxes and View Based Table View

I am having some difficulty trying to use checkboxes as the selectedIndex in a view based table.
There is good documentation on view based table here:
[View Based Tables ]
However, I after searching and looking on Stackoverflow I can't seem to get my implementation for doing the following.
My view is a table that makes a callout to Yahoo Finance. The table is view based constructed with bindings.
When the table is populated I want to have a check box against each row so that when the user clicks the check box, that row will be updated from Yahoo. Currently this works using multi or single selection using the table view and an observer.. I want to do this with the checkboxes and a button that gets all the checked rows.
The IB setup is as follows:
What is the best way to get the rows where the checkbox is selected? Should I use the array controller or do I need to do something with the table?
Assuming that you use a NSArray of NSDictionaries as your data model, why not add a key/value pair to each "stock" dictionary as a flag? Then in your button action method, just iterate through the data model and trigger an update when the flag is set. Bindings do the rest!

Resources