Angular DragAndDrop cdk nested cdkgrouplist

I am trying to make several nested drag and drop lists

I have questions that go into sections, which in turn go into modules, until now I was able to drag the modules and sections together correctly, but the questions do not fit into the sections , (But if I remove the dragging behavior of modules/sections the questions move correctly), i have tried several solutions i found here, but nothing seems to work
Code

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> <div cdkDropListGroup>
<div class="example-container" cdkDropList [cdkDropListData]="filteredQuestions" (cdkDropListDropped)="drop($event)">
<h2>Preguntas</h2>
<div class="example-list" id="questions">
<div class="example-box" *ngFor="let item of filteredQuestions" cdkDrag>{{ item.Pregunta }}</div>
</div>
</div>
<div class="example-container">
<h2>Ficha Generada</h2>
<div cdkDropList [cdkDropListData]="generatedCards" (cdkDropListDropped)="dropGeneratedCards($event)">
<mat-accordion *ngFor="let card of generatedCards" cdkDrag [cdkDragData]="card">
<div>
<span>{{ card.Modulo }}</span>
</div>
<div cdkDropList [cdkDropListData]="card.Sections" (cdkDropListDropped)="dropSections($event)">
<div *ngFor="let section of card.Sections">
<mat-expansion-panel hideToggle cdkDrag [cdkDragData]="section">
<mat-expansion-panel-header class="disable_ripple">
<mat-panel-title>
{{ section.Section }}
</mat-panel-title>
</mat-expansion-panel-header>
<div class="card mb-3 mt-3">
<div cdkDropList [cdkDropListData]="section.ListPreguntas" class="example-list" (cdkDropListDropped)="drop($event)">
<div
class="example-box {{ selectedCodSeccionModulo !== section.CodSeccionModulo ? 'bg-gray-400 opacity-75' : 'bg-white' }}"
*ngFor="let item of section.ListPreguntas" cdkDrag [cdkDragDisabled]="selectedCodSeccionModulo !== section.CodSeccionModulo">
{{ item.Pregunta }}
</div>
</div>
</div>
</mat-expansion-panel>
</div>
</div>
</mat-accordion>
</div>
</div>
</div>
drop(event: CdkDragDrop<any[]>) {
const isSameContainer = event.previousContainer === event.container;
const isSameCodSeccionModulo = event.container.data.every((item: any) =>
item.CodSeccionModulo === this.selectedCodSeccionModulo
);
if (isSameContainer) {
moveItemInArray(
event.container.data,
event.previousIndex,
event.currentIndex
);
} else {
if (isSameCodSeccionModulo) {
transferArrayItem(
event.previousContainer.data,
event.container.data,
event.previousIndex,
event.currentIndex
);
} else {
console.log('El CodSeccionModulo no coincide, no se puede mover el ítem');
}
}
}
dropGeneratedCards(event: CdkDragDrop<any[]>) {
moveItemInArray(this.generatedCards, event.previousIndex, event.currentIndex);
}
dropSections(event: CdkDragDrop<any[]>) {
const card = this.generatedCards.find(card => card.Sections.includes(event.item.data));
if (card) {
moveItemInArray(card.Sections, event.previousIndex, event.currentIndex);
}
}`
</code>
<code> <div cdkDropListGroup> <div class="example-container" cdkDropList [cdkDropListData]="filteredQuestions" (cdkDropListDropped)="drop($event)"> <h2>Preguntas</h2> <div class="example-list" id="questions"> <div class="example-box" *ngFor="let item of filteredQuestions" cdkDrag>{{ item.Pregunta }}</div> </div> </div> <div class="example-container"> <h2>Ficha Generada</h2> <div cdkDropList [cdkDropListData]="generatedCards" (cdkDropListDropped)="dropGeneratedCards($event)"> <mat-accordion *ngFor="let card of generatedCards" cdkDrag [cdkDragData]="card"> <div> <span>{{ card.Modulo }}</span> </div> <div cdkDropList [cdkDropListData]="card.Sections" (cdkDropListDropped)="dropSections($event)"> <div *ngFor="let section of card.Sections"> <mat-expansion-panel hideToggle cdkDrag [cdkDragData]="section"> <mat-expansion-panel-header class="disable_ripple"> <mat-panel-title> {{ section.Section }} </mat-panel-title> </mat-expansion-panel-header> <div class="card mb-3 mt-3"> <div cdkDropList [cdkDropListData]="section.ListPreguntas" class="example-list" (cdkDropListDropped)="drop($event)"> <div class="example-box {{ selectedCodSeccionModulo !== section.CodSeccionModulo ? 'bg-gray-400 opacity-75' : 'bg-white' }}" *ngFor="let item of section.ListPreguntas" cdkDrag [cdkDragDisabled]="selectedCodSeccionModulo !== section.CodSeccionModulo"> {{ item.Pregunta }} </div> </div> </div> </mat-expansion-panel> </div> </div> </mat-accordion> </div> </div> </div> drop(event: CdkDragDrop<any[]>) { const isSameContainer = event.previousContainer === event.container; const isSameCodSeccionModulo = event.container.data.every((item: any) => item.CodSeccionModulo === this.selectedCodSeccionModulo ); if (isSameContainer) { moveItemInArray( event.container.data, event.previousIndex, event.currentIndex ); } else { if (isSameCodSeccionModulo) { transferArrayItem( event.previousContainer.data, event.container.data, event.previousIndex, event.currentIndex ); } else { console.log('El CodSeccionModulo no coincide, no se puede mover el ítem'); } } } dropGeneratedCards(event: CdkDragDrop<any[]>) { moveItemInArray(this.generatedCards, event.previousIndex, event.currentIndex); } dropSections(event: CdkDragDrop<any[]>) { const card = this.generatedCards.find(card => card.Sections.includes(event.item.data)); if (card) { moveItemInArray(card.Sections, event.previousIndex, event.currentIndex); } }` </code>
 <div cdkDropListGroup>
    <div class="example-container" cdkDropList [cdkDropListData]="filteredQuestions" (cdkDropListDropped)="drop($event)">
      <h2>Preguntas</h2>
      <div  class="example-list"  id="questions">
        <div class="example-box" *ngFor="let item of filteredQuestions" cdkDrag>{{ item.Pregunta }}</div>
      </div>
    </div>
  
    <div class="example-container">
      <h2>Ficha Generada</h2>
      <div cdkDropList [cdkDropListData]="generatedCards" (cdkDropListDropped)="dropGeneratedCards($event)">
        <mat-accordion *ngFor="let card of generatedCards" cdkDrag [cdkDragData]="card">
          <div>
            <span>{{ card.Modulo }}</span>
          </div>
          <div cdkDropList [cdkDropListData]="card.Sections" (cdkDropListDropped)="dropSections($event)">
            <div *ngFor="let section of card.Sections">
              <mat-expansion-panel hideToggle cdkDrag [cdkDragData]="section">
                <mat-expansion-panel-header class="disable_ripple">
                  <mat-panel-title>
                    {{ section.Section }}
                  </mat-panel-title>
                </mat-expansion-panel-header>
                <div class="card mb-3 mt-3">
                  <div cdkDropList [cdkDropListData]="section.ListPreguntas" class="example-list" (cdkDropListDropped)="drop($event)">
                    <div
                      class="example-box {{ selectedCodSeccionModulo !== section.CodSeccionModulo ? 'bg-gray-400 opacity-75' : 'bg-white' }}"
                      *ngFor="let item of section.ListPreguntas" cdkDrag [cdkDragDisabled]="selectedCodSeccionModulo !== section.CodSeccionModulo">
                      {{ item.Pregunta }}
                    </div>
                  </div>
                </div>
              </mat-expansion-panel>
            </div>
          </div>
        </mat-accordion>
      </div>
    </div>
  </div>

drop(event: CdkDragDrop<any[]>) {
    const isSameContainer = event.previousContainer === event.container;
    const isSameCodSeccionModulo = event.container.data.every((item: any) =>
      item.CodSeccionModulo === this.selectedCodSeccionModulo
    );
  
    if (isSameContainer) {
      moveItemInArray(
        event.container.data,
        event.previousIndex,
        event.currentIndex
      );
    } else {
      if (isSameCodSeccionModulo) {
        transferArrayItem(
          event.previousContainer.data,
          event.container.data,
          event.previousIndex,
          event.currentIndex
        );
      } else {
        console.log('El CodSeccionModulo no coincide, no se puede mover el ítem');
      }
    }
  }
  
  dropGeneratedCards(event: CdkDragDrop<any[]>) {
    moveItemInArray(this.generatedCards, event.previousIndex, event.currentIndex);
  }
  
  dropSections(event: CdkDragDrop<any[]>) {
    const card = this.generatedCards.find(card => card.Sections.includes(event.item.data));
    if (card) {
      moveItemInArray(card.Sections, event.previousIndex, event.currentIndex);
    }
  }`

New contributor

patricio paz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật