I have come across a problem with I am having a edit form, so what I want to achieve is if user edits an item it gets locked so other user can not edit this item at the same time. I want something that when user clicks on other link it unlocks the item. Please don't suggest on unload because it will not not work on iOS Safari.
If anyone can give me steps/concept that would help a lot.
Thanks.
You could add a couple columns to your table such as 'locked' and locking_timestamp.
If a record is currently "locked" you can make it inaccessible by others and you can use the locking_timestamp column to only allow a particular record to be locked for a specified duration.
You can use the same method used by drupal :
compare the date of last change before saving the row to detect if the row has been changed by an other user
see :http://www.drupalcoder.com/blog/node-editing-concurrency-in-drupal.html
Related
I'm using mui-datatable to implement table in my app. I've every feature I need up and running, and I'm using server side data and pagination.
The problem is that I need to persist selection of rows when the user change the current page.
I can store the ids of the rows that where selected in an external array using onRowSelected.. but I'm not sure how to make the table render those rows as selected when user changes the page.
Bare in mind i'm using server side data, so the idea would be that in page 1, when I select row 1, a take the id of that record and add it to the array of selected ids. Then I need to check if the ids of rows that are currently displayed in the page are included in the selected array, and if so then check it as selected in the table. That way when I change the page, the same logic would run and all rows would be cleared since none of the row in the new page are selected.. I think you get the point.
I dont know where should i check if the row's id is included y my selected array and if so, how to check it in the datatable.
Thanks in advance for the help.
You can wrap your entire MUI datatable in another component which maintains the state of all selected rows
I'm stupid... I just needed some sleep xD
My problem was solved once I realized that I just needed to pass the rowsSelected option like this:
rowsSelected: this.state.pictures.filter(p=>this.state.selectedIds.includes(p.id)).map((p,i)=>i)
where this.state.picture will change when the user changes the page and rowsSelected will also changed.
Never mind... It's a rookie mistake.
I'm working with a hospital where we are implementing a web-application that is triggered from their own hospital information system (HIS).
The way the app works is that in their HIS, they select a patient and call the web-app with the patientId in the url.
Regarding patient safety, they want only one of those tabs open at the same time.
So if a second patient-tab is opened, the first one should be closed ..
Is this possible? And if it is, how?
Edit following danday74's answer
The url from the HIS is triggered via command line arguments (SAP system).
Firefox "http://url_to_webpage/"
when you link to the patient tab do this ...
<a ng-href="/your/patient/url" target="patientTab">open new patient tab</a>
When the link is clicked it should open the page in a new tab called "patientTab" - if another link is clicked with the target patientTab then it will use the existing "patientTab" - just make sure all your anchor tags that use the patientTab have the target set.
hope that does the job for you :)
So for the people that have a similar problem, the way we fixed it was the following:
On the init script for the page, we check if a session variable tab-token is found and if it contains a UUID
If the variable is not found, it means that no other open tab is found and we leave the tab active + create the variable and store a generated UUID in it
If a UUID is found, that means another tab is also active and we show a screen overlay with the message that another active tab was found
We watch on every change in the session variable and update the screen overlay whenever and wherever it needs to.
It is not a fool-proof solution, but in the context and usage of the application, it is sufficient ..
In system I am developing, user can access particular page which is used to make DML operation on custom object. I want to fulfill following business case :
User A opens a Page made changes on page but did not click Save.
At the same time User B opens a page made changes and click Save. User B data got saved in record.
Now user A came and click Save. But as data is outdated I want to prompt user that "you are over righting the latest update. Do you want to continue."
Is there any faster out-of-box way available to achieve it ?
Assuming this is in a VisualForce page, you could check if the value has changed inside your Save method.
Query for the LastModifiedDate of all records you may change, and save that in your controller. This should be done in your controller's constructor and/or anywhere you re-load the record(s).
In the save method, first query the record(s) again to check if the LastModifiedDate has been changed. If it has been changed, prompt the user.
Assuming you are trying to insert a record into an object.
You can write a validation rule on that object. Check if that record is already inserted or not and show an error message.
Regards,
Naveen
autorabit
When a user 'Saves' a Contact (for example), whether it's new or just updated, I need to:
Do an external callout using one of the Contact field values as a lookup
Display the results of the callout, so the user can make a selection
Update the Contact based on the user's selection display the updated Contact
I have found two aproaches, but have reached a point in both that I need to resolve.
Trigger Based Method
In the 'after' trigger pass the lookup string to a callback.
Update the Contact with the selection
Issues
How do you pass the lookup string or results to a visualforce page to display the lookup results?
When the user makes the selection and the update has been done, how do I move back to the updated contact?
Override Base Method
I found a discussion here that seems to suggests using overriding & redirection to someone asking about 'Edit'. I think this could also be done with the 'Save' button.
Issue
This is meant to be a deployable sollution, so I think that the override has to be set in code (I'm using the IDE) and not via Setup (or am I wrong?). I can't find out if this is possible or how to do it
Sorry for detailed question. Didn't want to just ask the wrong question (i.e. assume I know the best approach).
Thanks...
For the trigger-based method, you cannot change the built-in Save functionality, but (per your second solution) you can override the Edit button and recreate the Edit page with Visualforce, which would give you full control over the Save button and how you handle the callout and redirecting.
The release notes for Spring '10 indicate that standard-button overrides are now available for packaging, as they can be created through the Metadata API.
I have a button that when clicked, will create a JSONstore using a url provided. The store is then loaded into a grid. If the button is clicked again, it adds all the information again (so it is listed twice). I want it so that when the user clicks the button, it clears the store/grid and then adds everything.
Any ideas on how to accomplish this?
Thanks,
EDIT
ExtJS 3
datasetStore.removeAll();
datasetStore.loadData(datasetsArray);
It will be useful to see some code examples (and extjs version), but you can simply use loadRecords method (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.JsonStore-method-loadRecords):
grid.store.loadRecords([array of your new records here], {addRecords: false});
{addRecords: false} indicates that existing records will be removed first.
for ExtJs4: simply doe store.loadRecords([ array ]). In version 4.2.2 the store.proxy has NO clear() method so that doesn't work (was proposed in other examples elsewhere...)
If you want to to totally clear store and proxy, pass an empty array. This is handy because in some cases you want to clear the store and removeAll only moves the data to an array managed internally in the store so when later doing a sync on a gridStore which shows only 1 record, you may see your controller flooded with a bunch of records marked for removal!!