refactor nomi tabelle
This commit is contained in:
@@ -306,6 +306,8 @@ class AttachmentsBloc extends Bloc<AttachmentsEvent, AttachmentsState> {
|
||||
return file.copyWith(operationId: event.targetId);
|
||||
case AttachmentParentType.shippingDocument:
|
||||
return file.copyWith(shippingDocumentId: event.targetId);
|
||||
case AttachmentParentType.note:
|
||||
return file.copyWith(noteId: event.targetId);
|
||||
}
|
||||
}
|
||||
return file;
|
||||
@@ -405,6 +407,8 @@ class AttachmentsBloc extends Bloc<AttachmentsEvent, AttachmentsState> {
|
||||
return Bucket.documents;
|
||||
case AttachmentParentType.shippingDocument:
|
||||
return Bucket.companyDocuments;
|
||||
case AttachmentParentType.note:
|
||||
return Bucket.documents;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ enum AttachmentParentType {
|
||||
operation('operation_id'),
|
||||
ticket('ticket_id'),
|
||||
customer('customer_id'),
|
||||
shippingDocument('shipping_document_id');
|
||||
shippingDocument('shipping_document_id'),
|
||||
note('note_id');
|
||||
|
||||
final String dbColumn;
|
||||
const AttachmentParentType(this.dbColumn);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:typed_data';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flux/core/enums_and_consts/consts.dart';
|
||||
import 'package:flux/features/attachments/models/attachment_model.dart';
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
import 'package:flux/features/attachments/blocs/attachments_bloc.dart';
|
||||
@@ -14,8 +15,7 @@ enum Bucket {
|
||||
|
||||
class AttachmentsRepository {
|
||||
final _supabase = Supabase.instance.client;
|
||||
static const String _tableName =
|
||||
'attachment'; // Cambia col vero nome della tua tabella se diverso!
|
||||
static const String _tableName = Tables.attachments;
|
||||
|
||||
/// Scarica i byte di un file direttamente da Supabase Storage
|
||||
Future<Uint8List> downloadAttachmentBytes({
|
||||
@@ -43,6 +43,8 @@ class AttachmentsRepository {
|
||||
return 'customer_id';
|
||||
case AttachmentParentType.shippingDocument:
|
||||
return 'shipping_document_id';
|
||||
case AttachmentParentType.note:
|
||||
return 'note_id';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ class AttachmentModel extends Equatable {
|
||||
final String? operationId;
|
||||
final String? ticketId;
|
||||
final String? shippingDocumentId;
|
||||
final String? noteId;
|
||||
final String name;
|
||||
final String extension;
|
||||
final String? storagePath;
|
||||
@@ -23,6 +24,7 @@ class AttachmentModel extends Equatable {
|
||||
this.operationId,
|
||||
this.ticketId,
|
||||
this.shippingDocumentId,
|
||||
this.noteId,
|
||||
required this.name,
|
||||
required this.extension,
|
||||
this.storagePath,
|
||||
@@ -39,6 +41,7 @@ class AttachmentModel extends Equatable {
|
||||
operationId,
|
||||
ticketId,
|
||||
shippingDocumentId,
|
||||
noteId,
|
||||
name,
|
||||
extension,
|
||||
storagePath,
|
||||
@@ -67,6 +70,7 @@ class AttachmentModel extends Equatable {
|
||||
String? operationId,
|
||||
String? ticketId,
|
||||
String? shippingDocumentId,
|
||||
String? noteId,
|
||||
String? name,
|
||||
String? extension,
|
||||
String? storagePath,
|
||||
@@ -80,6 +84,7 @@ class AttachmentModel extends Equatable {
|
||||
operationId: operationId ?? this.operationId,
|
||||
ticketId: ticketId ?? this.ticketId,
|
||||
shippingDocumentId: shippingDocumentId ?? this.shippingDocumentId,
|
||||
noteId: noteId ?? this.noteId,
|
||||
name: name ?? this.name,
|
||||
extension: extension ?? this.extension,
|
||||
storagePath: storagePath ?? this.storagePath,
|
||||
@@ -98,6 +103,7 @@ class AttachmentModel extends Equatable {
|
||||
operationId: map['operation_id'] as String?,
|
||||
ticketId: map['ticket_id'] as String?,
|
||||
shippingDocumentId: map['shipping_document_id'] as String?,
|
||||
noteId: map['note_id'] as String?,
|
||||
name: map['name'] as String,
|
||||
extension: map['extension'] as String,
|
||||
storagePath: map['storage_path'] as String?,
|
||||
@@ -118,6 +124,7 @@ class AttachmentModel extends Equatable {
|
||||
'operation_id': operationId,
|
||||
'ticket_id': ticketId,
|
||||
'shipping_document_id': shippingDocumentId,
|
||||
'note_id': noteId,
|
||||
'file_size': fileSize,
|
||||
'company_id': companyId,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user