Listing and updating records in db - database

I have an Angular 4 front end that retrieves a list of records from a db and displays them to a user. I allow the user to edit each item by opening a popup dialog, making changes to the data, and clicking a Save button.
There are multiple users but I'm told that it will mostly be one user updating a given record at any one time.
when I load the records each record has all the data required, so I don't retrieve the record when the user opens the popup dialog (as all the data is already there).
when I save the data I return a status 200 on successful update and close the dialog - I don't refresh the list of items.
Does anyone see any issues with this approach? One thing I'm thinking is that if they have the initial screen open for a while, some of the records may have been updated by another user.
should I retrieve the record from the db when the user opens it in the popup dialog?
should I refresh the list of records after the user updates one and closes the popup dialog?
is there an easy way to check if a record has been updated in the background while a user was editing the same record
Just looking for best practice or typical approaches to this scenario - tia.

Related

How do I dynamically indicate that a record is being edited by another user without refreshing the client

While I understand how to prevent a user from updating a record that is already being edited by another user (or is outdated since the last page refresh) - I want to dynamically indicate that a record is being edited by another user; maybe gray out the record or disable an edit feature, etc.
I'm envisioning this similar to how Google Sheets indicates that another user is editing a cell, etc.
Thanks

How to refresh UI-Grid layout after reloading data

I have a problem with Angular UI-Grid (http://ui-grid.info/). Grid is implemented in modal window that appears after user clicks button.
Service works that way: User selects data set to prepare and clicks button. After clicking button website sends request to rest service to receive data. After receiving data modal with table is shown. Columns count depends on data requested by user.
The problem is that after user changes columns width and close modal with this table UI-Grid 'remembers' this column width that user left. If then user will select another set of data I am cleaning GridOptions object and fill it once again after data is received. The problem is that row width stays in previous state.
I tried so far:
using apis core.refresh() method - while debugging I can see that this
method fires some event but no effect on my grid,
remove whole DOM node and append it again before receiving response with new data
various different hacks trying to use many methods found inside grid api - no success at all.
I am sorry that I am unable to reproduce this in any fiddle but it would be really difficult I am afraid to match my case.
Any help would be very appreciated. Thanks
ps. it also applies to my another table where user can pin and hide columns. Pinned/hidden columns remains hidden/pinned after receiving brand new data. And it is not cool.
Once you set the data to the grid, you should be calling this -
gridApi.core.notifyDataChange( uiGridConstants.dataChange.ALL)
From the docs,
Notifies us that a data change has occurred, used in the public api
for users to tell us when they've changed data or some other event
that our watches cannot pick up
notifyDataChange tells the framework that one of the options or columnDefs has been changed.
Checkout this thread

Sync up data in ADF table after update in DB table done outside ADF environment

I have a jsff page inside a bounded task flow. It displays a table. Each row of table has an edit icon. on click of which a new jsff page opens containing the information of the selected row ready to be edited.
Here user can update and save the information and check the information back on the first page by clicking a Done button on second page.Pretty much simple.
The problem is I have some complex implementation due to which I should not update the row information through ADF way. I take the information entered by the user and pass it to plane java file. There in the plane java file I instantiate an AM and update the information through this AM.
The problem with this approach is that when I click the Done button to come back on table page to check the saved data, the data on the table is stale.
This seems as If the table is being updated outside the ADF framework and so it is not aware of the underlying the data change hence the ADF UI table is not synced with physical table automatically.
JDev : 11.1.1.7.11
Options tried : Upon click of Done button I tried to requery the VO of ADF table by
1) Clearing the VO cache row and repopulating it
2) Re executing the iterator binding
3) Re executing the iterator binding programatically.
Thanks

Inline add/edit/delete data in views in Drupal 7

I am trying to create a content type (say Meter). Each Meter consists of a "Meter Reading". This meter reading content contains three fields, say title, date range and usage. I have a Panel page where I display all the Meter Readings related to a parent Meter. I have displayed the Meter Readings in a tabular format.
I want the user to be able to add new Meter Readings without going to the default Meter Readings creation page. Rather than the default form kind of page, the user should be able to enter the data in the table view provided and it should be automatically saved into the project itself.
So, I want the functionality to be like:-
Display all the meter readings with two links, i.e., Edit and Delete,
When the user clicks on Edit link, the meter reading row should become editable and the user should be able to make the changes inline in the same table,
In the footer there should be a link for adding a new meter reading and when the user clicks on it, a new blank row should be added dynamically to the table and the user should be able to make a new entry into it.
Is there a module in Drupal 7 for doing so?? I have already tried out several modules for this such as SlickGrid, jQGrid and jEditable
Any help would be great. Thanks in advance.
Am afraid am not aware about a module that does all that out of the box. But in case you carry on with custom coding you can have a look at the following:
Edit and Delete options per row in views
Use Views Megarow. For working example you can have a look at how its used in commerce backoffice. Please note that you need to write the form structure ( FORM api ) for the quick edit form in a custom module. The Views Megarow takes care of ajax populating the edit form, its submission in client side, and refreshing the original row after the response from server.
When the user clicks on Edit link, the meter reading row should become editable and the user should be able to make the changes inline
in the same table.
Views Megarow doesn't support inline editing. But another module as suggested by #nmc does it. Its editablefields. But it doesn't have any edit/delete button. You click on the text directly ( provided user has appropriate permission to edit the field data ) in view.
In case you are going to use editablefields, then you would have to add another delete button in view, which one confirmation would redirect to the page that triggered delete action.
Since delete button would redirect to a default confirmation page, you may want to code a custom delete action which may override this.
In the footer there should be a link for adding a new meter reading and when the user clicks on it, a new blank row should be
added dynamically to the table and the user should be able to make a
new entry into it.
I suggest creating a small ajax form. Create a "Add Meter Reading" button in it, which on submission would create a meter reading node in the server. The ajax form should have parent information in a hidden field ( i.e. the Meter id). The ajax response for this form could be another script to load/refresh the view on client side.
Client side code to refresh the view can be found in Views Autorefresh submodule in Views Hacks.
If using views megarow you would have to add another jquery function on ajax response after view is refreshed - Trigger edit button.
Otherwise you may have to add some classes or theme to newly created rows in view to bring them to focus.
It is important that the entire views refreshes, so that drupal behaviours are attached to the newly created entry in table.
I don't know if there is one module which will meet all your needs but you may be able to use some in combination.
Views Bulk Operations (VBO) - has Drupal 7 support
This module augments Views by allowing bulk operations to be executed
on the displayed rows. It does so by showing a checkbox in front of
each node, and adding a select box containing operations that can be
applied. Drupal Core or Rules actions can be used.
editablefields - Drupal 7 version in dev
This module allows CCK fields to be edited on a node's display (e.g.
at node/123), not just on the node edit pages (e.g. node/123/edit). It
also works within views etc. Anywhere a 'formatter' can be selected,
you can select editable (or click to edit).
editview - no Drupal 7 support yet but I thought I would mention it in case you're able to adapt the code yourself
Editview is a plugin for the Views module. It allows you to create a
view in which the nodes are editable, and new nodes can be created.

displaying data in textboxes based on

I'm not quite sure where to begin with this. This is basically how I'm trying to get it to work. I will enter the ID of a Hire Record in a textbox, hit the show hire record at which point it will materialise that hire records details in their associated textbox fields.
I attached a screenshot of the form in question. I can also create a new record as you may be able to see by typing in the details and hitting create record (this is not a problem, i already understand how to do this), but I also want to be able to display an existing records details in the textboxes again. Yes I just repeated myself but I just thought I'd try clarify my intentions further :P
http://imageshack.us/photo/my-images/189/hirerecord1.png/
Anyway, how should I go about doing this? Thank you so much for your help.
I do this slightly differently on most of my forms. First off, when a form opens, I bind it to the data (data set, or whatever). I display whatever record I define as the defaults (generally the last record entered. If I want a new record, I have a button that is clicked that creates a new record in the data set and moves my form to that record. Now you can enter your data and handle your edits, saves, etc.
As far as the pulling up a record by typing in a field I believe you could do this with one text box, but I took the easy way out and used two text boxes that are exactly the same size and location. When your form is displaying data, handle the OnClick event for the field bound to the ID. Hide the bound text box and display the duplicate that is unbound. For that text box, handle the OnValidate event and set it to validate on the enter key. The user can then type in the ID and hit enter. You then get the ID they want from the unbound text box, clear it and hide it and cause your form to navigate to the appropriate record.
Jim

Resources