Files

50 lines
1.3 KiB
Dart
Raw Permalink Normal View History

class Etiqueta {
final String hMaestro;
final String hGlobal;
final String? mrf;
final String? ref;
final String? nombreEs;
final String? nombreEn;
final String grupo;
final bool activo;
final int? bibliotecaId;
Etiqueta({
required this.hMaestro,
required this.hGlobal,
this.mrf,
this.ref,
this.nombreEs,
this.nombreEn,
required this.grupo,
this.activo = true,
this.bibliotecaId,
});
String get displayName => nombreEs ?? nombreEn ?? ref ?? hMaestro.substring(0, 8);
String? get imagenUrl => mrf != null ? 'https://tzrtech.org/$mrf.png' : null;
factory Etiqueta.fromJson(Map<String, dynamic> json) => Etiqueta(
hMaestro: json['h_maestro'] as String,
hGlobal: json['h_global'] as String,
mrf: json['mrf'] as String?,
ref: json['ref'] as String?,
nombreEs: json['nombre_es'] as String?,
nombreEn: json['nombre_en'] as String?,
grupo: json['grupo'] as String? ?? 'default',
activo: json['activo'] as bool? ?? true,
);
Map<String, dynamic> toMap() => {
'h_maestro': hMaestro,
'h_global': hGlobal,
'mrf': mrf,
'ref': ref,
'nombre_es': nombreEs,
'nombre_en': nombreEn,
'grupo': grupo,
'biblioteca_id': bibliotecaId,
};
}