ng2 Dragula and the magic of Angular pipes

I have successfully implemented Dragula to make a table of values from a database sortable. Everything functions as intended, with the ability to drag and drop table rows. However, I encounter an issue when I apply a custom pipe to three of the cell values in each row to convert them from database values to human-readable ones (such as changing 'N' to 'Normal' and 'O' to 'Offline'). The table loads and displays correctly with the pipes applied, but upon dragging and dropping, the table breaks and the piped values become blank.

If I remove the pipes, the table behaves normally, although the values are not easily readable for humans.

Here is a snippet of my HTML code with the dragula directive:

<tbody class='wrapper' dragula='RIDRAG' id="left">
  <tr class='container' *ngFor="let ri of this.riRow; let i = index">
    <td><img src="./assets/images/Hamburger_icon.svg.png" style="width: 15px; padding-left: 5px;"></td>
    <td>{{i + 1}}</td>
    <td>{{ri.ri}}</td>
    <td>{{ri.classification}}</td>
    <td>{{ri.type}}</td>
    <td>{{ri.shd}}</td>
    <td>
      <app-edit-ri-row [noGroupFlag]="this.noGroupFlag || disabledCheck()"  (editEmit)="receiveEditEmit($event)" [riRow]="ri"></app-edit-ri-row>
      <button style="width:50%;" type="submit" name="delete" [disabled]="this.noGroupFlag || disabledCheck() === true"
        class="btn btn-danger rounded-0" (click)="removeRiRow(i)">
        <fa-icon [icon]="['fas', 'trash-alt']" size="med"></fa-icon>&nbsp;
      </button>
    </td>
  </tr>
</tbody>

This snippet shows how I create a Dragula instance and parse the data it returns:

this.dragula.createGroup('RIDRAG', {
  removeOnSpill: false,
  revertOnSpill: true
});
this.subs.add(this.dragula.drop('RIDRAG')
  .pipe(map(data => {
    // Data parsing logic 
  }))
  .subscribe()
);

My main question is: Can Angular pipes be used effectively with Dragula?

Answer №1

Utilizing Angular Pipes in conjunction with Dragula is indeed feasible. It's crucial to understand that the Angular Pipe processes the data provided by the Dragula object, which gets updated and converted upon each drop action. Hence, the issue I encountered was directly related to the state of the data during the drop event.

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

Guidelines for converting an array into checkboxes using React Native with TypeScript

As I embark on my React Native journey, I have chosen to use TypeScript in my project. Currently, I am faced with the challenge of mapping an array into a checkbox. Enclosed below is a snippet from my JSON file: { "stud_name": "Adam", "sex": "male" ...

I'm receiving an error code 500 when attempting a patch request on my Express backend - what's causing this issue

Whenever my angular frontend sends a patch request to my express backend, all routes work smoothly except for the patch routes. The specific error message that pops up is: Error: No default engine was specified and no extension was provided. Should I be ...

Is it possible to reach my Node.js server within the container using localhost?

Currently, I am in the process of learning how to develop a website using Angular. In addition, we are also exploring Docker by containerizing our project. Our objective is to have Angular exclusively installed within the container, with our code located o ...

I am currently unable to retrieve any results for my fullcalendar tooltip

I am currently working on setting tooltips for events using Primeng's fullcalendar. Despite initializing the tooltip in the web console, I am unable to see it when hovering over an event. My development environment includes Typescript, Primeng 7.0.5, ...

Having trouble accessing / encountering an error in Angular 6 and .NET Core 2.1 integration

While working on my Angular form in the Visual Studio .NET Core 2.1 template, I encountered an issue with displaying toast notifications. When running localhost, I received a "Cannot GET /" error. Additionally, after running ng build, various errors appear ...

ngx-emoji mart - The error message "Type 'string' is not assignable" is being displayed

While working on a project involving the @ctrl/ngx-emoji-mart package, I encountered a perplexing issue. The code functioned flawlessly in Stackblitz but when I attempted to run it on my local system, an error surfaced: Type 'string' is not assig ...

Switching from a Promise to an Observable using React-Redux and TypeScript

I am struggling to grasp the concept of storing a Promise response into Redux. I believe finding a solution to this issue would greatly benefit me. Currently, I am utilizing a library that returns a Promise, and I wish to save this response - whether it i ...

The Angular Material Nav Sidebar is specifically designed to appear only when resizing the screen to

I am currently following a tutorial on setting up Angular Material Sidenav with a toolbar from this video (https://www.youtube.com/watch?v=Q6qhzG7mObU). However, I am encountering an issue where the layout only takes effect after resizing the page. I am no ...

How can a default value be assigned to an ag-Grid filter?

Is there a way to set a default value in ag-grid filter text that is displayed to the user but not applied to the actual results? this.columnDefs = [ { headerName: this.pageData["tbm.line.list.grid.phonenumber"], field: 'tn', /*sor ...

Is there a way to change an ISO 8601 date into the format '/Date(1525687010053)/' using JavaScript?

Is there a way to convert a date value that is formatted as 9999-12-31T00:00:00Z to the format /Date(1525687010053)/ using javascript? I tried implementing the following code, but it doesn't seem to be working: var datevalue = '9999-12-31T00:00 ...

An issue with event listeners in Vue 3 and Pixi.js arises when working with DisplayObjects that are either created as properties of classes or inherited from parent classes

Utilizing PIXI js in conjunction with Vue 3 (see code snippet below) Due to the consistent pattern of most graphics with varying behaviors and properties, we opted for an OOP approach with TypeScript to prevent code duplication. However, following this app ...

Exploring the functionality of maximizing and minimizing logic in an Angular Bootstrap modal popup

I'm currently utilizing Angular Bootstrap Modal Popup and I'd like to include options for Maximize and Minimize in addition to the close button. By clicking on the maximize option, the popup should expand to full screen, and by clicking on minimi ...

The formgroup label is currently displayed in uppercase, but I would prefer it to be in title case

In the angular template below, I have noticed that even though the labels are in titlecase, they appear in uppercase when the page is rendered. This wasn't the desired outcome so I attempted to use the titlecase pipe and enclose the label text within ...

Teach Typescript to recognize a specific union type within a React component

Imagine I have an object of type: type BulkItem = { id: number; type: 'bulk'; tonnage: number } type RegularItem = { id: number; type: 'regular'; weight: number } export type CartItem = BulkItem | RegularItem // there could be more item ...

Unlock the potential of Angular $http by leveraging TypeScript generics in your web development projects

I have been attempting to implement a generic promise return in my code: public getUserData: () => ng.IPromise <string> = () => { var promise = this.makeRequest<string>('http://someurl.com',null) .then((resp ...

Embed a dynamically generated SVG into an element in Angular without triggering any security warnings

Currently, in my angular 10 application, I am utilizing a library called svg.js to generate an SVG within the client. However, the specific library I am using is irrelevant for the question at hand. let svg = SVG().size(this.widthpx, this.heightpx).svg ...

Using Angular: A guide to setting individual values for select dropdowns with form controls

I am working on a project that involves organizing food items into categories. Each item has a corresponding table entry, with a field indicating which category it belongs to. The category is represented by a Guid but displayed in a user-friendly format. C ...

A result of the array's elements' index will form an object

Here is a straightforward example for you to work with. I am trying to retrieve the index of each Test component. However, the key value is returning an object. Since I'm not very well-versed in Reactjs, could someone guide me on how to get the index ...

Hiding a div after three clicks using HTML

What is the best way to hide a div tag containing an input tag after clicking on the input tag three times using HTML and angular? ...

Warning: The use of the ngModel input property and ngModelChange event with reactive form directives has been marked as obsolete

https://i.sstatic.net/EAWSR.png Encountered the following error: It seems that the usage of ngModel alongside formControlName on the same field is deprecated in Angular v6 and will be removed in Angular v7. After attempting to address this issue by remo ...