feat: integrazione scalette comunità come playlist
- Aggiunto il parsing di lista_nome e lista_esecuzione dall'API parrocchiale in ComunitaService. - Le scalette vengono trasformate in ComunitaScaletta[] e persistite in localStorage. - PlaylistService espone comunitaPlaylists (computed) e allPlaylists (computed che unisce playlist personali e scalette comunità). - Le scalette della comunità appaiono nel dropdown Playlist SOLO quando il filtro comunità è attivo; scompaiono automaticamente alla disattivazione. - Le scalette sono read-only: i pulsanti Modifica e Elimina vengono nascosti per le playlist della comunità. - Icona people-outline e bordo sinistro secondario distinguono visivamente le scalette della comunità dalle playlist personali.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Injectable, signal, inject } from '@angular/core';
|
||||
import { Injectable, signal, inject, computed } from '@angular/core';
|
||||
import { Storage } from '@ionic/storage-angular';
|
||||
import { Canto, CantiService } from './canti.service';
|
||||
import { ComunitaService } from './comunita.service';
|
||||
import * as QRCode from 'qrcode';
|
||||
|
||||
@Injectable({
|
||||
@@ -9,6 +10,7 @@ import * as QRCode from 'qrcode';
|
||||
export class PlaylistService {
|
||||
private storage = inject(Storage);
|
||||
private cantiService = inject(CantiService);
|
||||
private comunitaService = inject(ComunitaService);
|
||||
|
||||
public selectionMode = signal<boolean>(false);
|
||||
public selectedIds = signal<Set<string>>(new Set());
|
||||
@@ -22,6 +24,30 @@ export class PlaylistService {
|
||||
|
||||
private _storage: Storage | null = null;
|
||||
|
||||
// Community scalette exposed as playlists (only when community filter is active)
|
||||
public comunitaPlaylists = computed(() => {
|
||||
if (!this.comunitaService.comunitaCode() || !this.comunitaService.isFilterActive()) {
|
||||
return [];
|
||||
}
|
||||
return this.comunitaService.comunitaScalette().map(s => ({
|
||||
id: s.id,
|
||||
name: s.name,
|
||||
ids: s.ids,
|
||||
createdAt: s.date,
|
||||
isComunita: true
|
||||
}));
|
||||
});
|
||||
|
||||
// Merged list: personal playlists + community scalette
|
||||
public allPlaylists = computed(() => {
|
||||
const community = this.comunitaPlaylists();
|
||||
const personal = this.playlists();
|
||||
if (community.length > 0) {
|
||||
return [...community, ...personal.map(p => ({ ...p, isComunita: false }))];
|
||||
}
|
||||
return personal.map(p => ({ ...p, isComunita: false }));
|
||||
});
|
||||
|
||||
constructor() {
|
||||
this.init();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user