Managing simultaneous edits to shared data among multiple users using Angular 4

Is it possible to handle multiple users editing the same information, such as editing a patient using two browsers or users simultaneously? One browser starts the edit process, makes changes and saves them. Meanwhile, another browser attempts to make different changes and save them, but they should be rejected. How can this functionality be achieved?

HTML File

<ng-template #content>
<form
role="form"
#createPatientForm="ngForm"
(ngSubmit)="onLogin(createPatientForm.value)"
novalidate>
<div class="modal-body" *ngIf="!editMode || !confirm">
  <div class="form-content">
    <div class="form-group">
      <div class="row">
        <div id="fName" class="col-8">
          <label for="firstName">First Name*</label>
          <input
            #fName="ngModel"
            type="text"
            [(ngModel)]="patient.FirstName"
            name="firstName"
            class="form-control input-underline input-lg"
            [ngClass]="{ invalid: !fName.valid && fName.touched }"
            id="firstName"
            autocomplete="off"
            minlength="2"
            maxlength="20"
            required
          />
        </div>

      <div *ngIf="!fName.valid && fName.touched" class="error">
        <div *ngIf="fName.errors.required">First Name is required.  </div>
        <div *ngIf="fName.errors.minlength">Minimum of 2 characters.</div>
      </div>

      <div *ngIf="!mName.valid && mName.touched" class="error">
        <div *ngIf="mName.errors.pattern">
          Numbers not allowed for initials.
        </div>
        <div *ngIf="mName.errors.minlength">Minimum of 2 characters.</div>
      </div>
    </div>
    <div class="form-group">
      <label for="lastName">Last Name*</label>
      <input
        #lName="ngModel"
        type="text"
        [(ngModel)]="patient.LastName"
        name="lastName"
        class="form-control input-underline input-lg"
        [ngClass]="{ invalid: !lName.valid && lName.touched }"
        id="lastName"
        autocomplete="off"
        minlength="2"
        maxlength="50"
        inputName
        required
      />

      <div *ngIf="!lName.valid && lName.touched" class="error">
        <div *ngIf="lName.errors.required">Last Name is required.</div>
        <div *ngIf="lName.errors.minlength">Minimum of 2 characters.</div>
      </div>
    </div>
        <div class="col-6">
          <label for="Gender">Gender*</label>
          <select
            #gender="ngModel"
            [(ngModel)]="patient.Gender"
            [class.text-dimmed]="!patient.Gender"
            name="gender"
            id="Gender"
            class="form-control input-underline input-lg"
            [ngClass]="{ invalid: gender.value === null && gender.touched }"
            required
          >
            <option [ngValue]="null">Select</option>
            <option value="Male">Male</option>
            <option value="Female">Female</option>
          </select>
          <div *ngIf="gender.value === null && gender.touched">
            <div class="error">Gender required.</div>
          </div>
        </div>
      </div>
    </div>

    <div class="form-group">
      <label for="patientEmail">Email</label>
      <input
        type="email"
        #email="ngModel"
        [(ngModel)]="patient.Email"
        name="patientEmail"
        class="form-control input-underline input-lg"
        [ngClass]="{ invalid: !email.valid && email.touched }"
        id="patientEmail"
        minlength="5"
        maxlength="100"
        pattern="^(?!.*(?:''|\.\.))[\w-\.\']{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$"
      />
      <div class="error" *ngIf="!email.valid && email.touched">
        <div *ngIf="email.errors.pattern">
          Please enter a valid email address.
        </div>
        <div *ngIf="email.errors.minlength">
          minimum of 5 characters required.
        </div>
      </div>
    </div>
    <div class="hint-section">
      <p class="address-header text-center">
        * Required
      </p>
    </div>
  </div>
</div>
<div class="modal-footer">
  <span (click)="cancel()" class="clickable">CANCEL</span>
  <button
    [disabled]="
      checkFormValidity(createPatientForm) || !createPatientForm.form.valid
    "
    type="button"
    class="btn square-btn"
    (click)="editMode && confirm ? setConfirm() : createUpdatePatient()"
  >
    {{ editMode && confirm ? "YES" : "NEXT" }}
  </button>
</div>

TypeScript File

 createUpdatePatient() {
this.duplicateFinderService.confirmDuplicatePatient(
  this.dateOfBirth,
  this.patient,
  this.mode,
  this.patientId
);
this.router.navigate(["../additional-details"], {
  relativeTo: this.route
  });
}

Additional Detail TypeScript File

  update() {
this.requestPending = true;
this.patientService.updatePatientProfile(this.patient).subscribe(
  () => {
    this.store.dispatch(
      new SetPatientAction(this.patient, this.utilService)
    );
    this.requestPending = false;
    if (this.isAdminEdit) {
      this.router.navigate(["../billing"], { relativeTo: this.route });
    } else {
      this.router.navigate(["../"], { relativeTo: this.route });
    }
  },
  error => {
    this.requestPending = false;
     }
   );
 }

Billing Detail TypeScript File

  update() {
this.requestPending = true;
this.patientService.updatePatientBilling(this.patient).subscribe(() => {
  this.requestPending = false;
  this.store.dispatch(new SetPatientAction(this.patient, this.utilService));
  this.cancel();
  });
}

Is achieving this functionality in the frontend feasible? Thank you.

Answer №1

To reach your goal, consider utilizing the user's ID to track their activity and make adjustments as needed.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

JS Issues with generating accurate dates in JS/JS Date perplexities

Creating a custom datepicker has been a challenging task for me. I'm facing difficulties in understanding how JS Date works and need some assistance to bridge this knowledge gap. The issue arises when I attempt to generate dates using a for loop, resu ...

Navigating through each element of an array individually by using the onClick function in React

I'm currently working on a project that involves creating a button to cycle through different themes when pressed. The goal is for the button to display each theme in sequence and loop back to the beginning after reaching the last one. I've imple ...

PHP sending only a single space in an email

My HTML form works perfectly fine, except for one field! The issue arises with a particular text field that I fill out using a button and a short JavaScript function. Could this be causing a conflict with the PHP code? The problematic text field is: inpu ...

Retrieve the id within the parentheses for each checkbox that is checked and re-check each time a checkbox is selected using Kendo UI

Working with the tricky kendo-ui has made adding selectors quite challenging; however, my current task involves simply obtaining the inner contents of the id selector upon clicking an input checkbox element. Specifically, I need to extract the text between ...

Resize a division to fill the window while maintaining original proportions

Is there a way to resize a div so that it fills the entire browser viewport while maintaining its aspect ratio? How can I achieve this using CSS, JQuery, or both? ...

React Navigation ran into an issue with the specified location

It seems that I am encountering an issue where it is displaying a message stating "no routes matched for location '/'". However, the Header file clearly shows that there is a home component defined for this URL. https://i.sstatic.net/26516LfM.jpg ...

Ways to dynamically update the state of a mat-button-toggle-group programmatically

I'm currently working on implementing a confirmation dialog to change the state of MatButtonToggleGroup. However, I am facing an issue where I need to prevent the default behavior unless I revert to the previous state upon cancellation. Here's t ...

What is the best way to use regular expressions in JavaScript to pull out a date value from a string?

I am working with a string in this format: var value = "/Date(1454187600000+0300)/". From this, I need to extract a date format like 1/30/2016. Currently, I have the following code snippet: var value = "/Date(1454187600000+0300)/"; // I need to extract f ...

React select and react modal cannot be overlaid on top of each other

I am facing an issue with my React modal that contains a react-select component. Some of the options at the bottom of the modal are not visible. How can I ensure that the select overlay appears on top of the modal to display all options? https://i.sstatic. ...

What is the process for creating a line using points in three.js?

Can anyone provide a solution for creating a straight line using new THREE.Points()? I attempted to place particles and set their positions with an array and for loop, but the spacing was inconsistent. ...

Transferring data between components in Ionic 2: Service to Page

My service code includes two functions - one for creating a native storage with IP and port, and the other for retrieving values from the native storage. DatabaseService export class DatabaseService { ... public ip: string; public port: string; . ...

The `diff` command is causing issues in `execSync`, resulting in errors when the files do not

Why am I getting an error with the diff command when my files don't match? let {stdout,stderr,err} = execSync(`diff output.txt answer.txt`, { cwd: "/home", encoding: 'utf8' }); if (err) { console.log(err); } console.log(stdout); The ...

How to make changes to the state in Vue.js while using v-for loop

Currently, I am retrieving comments from an API and attempting to modify a specific comment from the list. Upon clicking the edit button, a text area appears within the comment box along with a save button, functioning as expected. The issue arises when ...

Executing a php function on input onchange event

Hey there! I have a input field named result. I am trying to trigger a function whenever something changes in this input. So, I attempted the following: <input onchange="maFonction" id="result" readonly="readonly" type="text" value="0" size = "10" /&g ...

Injecting resolve values from UI router into Angular Jasmine tests

I am facing an issue in my Angular application where UI router resolves a promise into the controller. However, when attempting to test this controller using Karma, I receive an error about an unknown provider. How can I inject a mock object into the test ...

Using NgFor to duplicate a div containing a form and link the inputs to NgModel

Working on a form using Angular to store datasets with inputs for name and description. Users can add multiple datasets by clicking the "Add" button. To achieve this, I initialized a dataset list with one element in app.component.ts. Using NgFor, it dynam ...

Exploring AngularJS to search for and present data in a tabular layout

Can anyone guide me on searching for data within a JSON file and presenting it in a table format? I want the table to be visible only when I click the search button. I would really appreciate it if someone could provide me with instructions or a helpful ...

Is it possible to update table cell content depending on selected option?

Displayed here is the select block: <form> <select id="select"> <option disabled selected value="choose"> CHOOSE </option> <option value="i2g" id="i ...

Harvesting Angular information using Selenium

Here is some HTML code that can be extracted using a Selenium driver: <td colspan="2"><strong>Owner</strong> <div ng-class="{'owner-overflow' : property.ownersInfo.length > 4}"> ...

Retrieving routing information from directives within angular2

const APP_ROUTES: RouterConfig = [ { path: 'app/home', component: HomeComponent, data: { name: 'Home' } } ] Assuming the route configuration is set as displayed above, how can one ...