Rimossi mutable live data sulle variabili interne della gestione Documenti Interni
This commit is contained in:
parent
fa413aba25
commit
6f2be2b459
@ -37,12 +37,12 @@ public class DocInterniViewModel {
|
||||
private List<DocumentoArtDTO> availableArts;
|
||||
private MutableLiveData<List<DocInternoWrapper>> mDocsList = new MutableLiveData<>();
|
||||
|
||||
public final MutableLiveData<TipoDocDTO> dtbTipi = new MutableLiveData<>();
|
||||
public final MutableLiveData<GruppoArticoloDTO> mtbGrup = new MutableLiveData<>();
|
||||
public final MutableLiveData<FornitoreDTO> fornitore = new MutableLiveData<>();
|
||||
public final MutableLiveData<Date> dataDoc = new MutableLiveData<>();
|
||||
public final MutableLiveData<String> numDoc = new MutableLiveData<>();
|
||||
public final MutableLiveData<String> note = new MutableLiveData<>();
|
||||
public TipoDocDTO dtbTipi;
|
||||
public GruppoArticoloDTO mtbGrup;
|
||||
public FornitoreDTO fornitore;
|
||||
public Date dataDoc;
|
||||
public String numDoc;
|
||||
public String note;
|
||||
public final BindableInteger artsSize = new BindableInteger(0);
|
||||
|
||||
@Inject
|
||||
@ -86,13 +86,13 @@ public class DocInterniViewModel {
|
||||
}
|
||||
|
||||
public void setSelectedDocDetails(DialogSelectDocInfoResponseDTO selection) {
|
||||
this.fornitore.postValue(selection.getFornitore());
|
||||
this.dtbTipi.postValue(selection.getTipoDoc());
|
||||
this.fornitore = selection.getFornitore();
|
||||
this.dtbTipi = selection.getTipoDoc();
|
||||
|
||||
this.mtbGrup.postValue(selection.getGruppoArt());
|
||||
this.dataDoc.postValue(selection.getDataDoc());
|
||||
this.numDoc.postValue(selection.getNumDoc() != null ? selection.getNumDoc().toString() : null);
|
||||
this.note.postValue(selection.getNote());
|
||||
this.mtbGrup = selection.getGruppoArt();
|
||||
this.dataDoc = selection.getDataDoc();
|
||||
this.numDoc = selection.getNumDoc() != null ? selection.getNumDoc().toString() : null;
|
||||
this.note = selection.getNote();
|
||||
|
||||
this.sendOnLoadingStarted();
|
||||
fetchProducts(() -> {
|
||||
@ -118,7 +118,7 @@ public class DocInterniViewModel {
|
||||
String codAnag = null;
|
||||
String codVdes = null;
|
||||
|
||||
FornitoreDTO fornitore = this.fornitore.getValue();
|
||||
FornitoreDTO fornitore = this.fornitore;
|
||||
if (fornitore != null) {
|
||||
codAnag = fornitore.getCodAnag();
|
||||
codVdes = fornitore.getCodVdes();
|
||||
@ -126,7 +126,7 @@ public class DocInterniViewModel {
|
||||
|
||||
|
||||
var docsList = documentRepository.getDocuments(this.getCodDtip(),
|
||||
codAnag, codVdes, dataDoc.getValue(), numDoc.getValue());
|
||||
codAnag, codVdes, dataDoc, numDoc);
|
||||
|
||||
docsList.observeForever(data -> {
|
||||
this.mDocsList.postValue(data);
|
||||
@ -145,31 +145,28 @@ public class DocInterniViewModel {
|
||||
}
|
||||
|
||||
private String getCodDtip() {
|
||||
if (this.dtbTipi.getValue() == null) {
|
||||
if (this.dtbTipi == null) {
|
||||
return null;
|
||||
}
|
||||
return this.dtbTipi.getValue().getCodDtip();
|
||||
return this.dtbTipi.getCodDtip();
|
||||
}
|
||||
|
||||
public TipoDocDTO getTipoDoc() {
|
||||
if (this.dtbTipi.getValue() == null) {
|
||||
return null;
|
||||
}
|
||||
return this.dtbTipi.getValue();
|
||||
return this.dtbTipi;
|
||||
}
|
||||
|
||||
private String getCodMgrp() {
|
||||
if (this.mtbGrup.getValue() == null) {
|
||||
if (this.mtbGrup == null) {
|
||||
return null;
|
||||
}
|
||||
return this.mtbGrup.getValue().getCodMgrp();
|
||||
return this.mtbGrup.getCodMgrp();
|
||||
}
|
||||
|
||||
private String getCodAnagForn() {
|
||||
if (this.fornitore.getValue() == null) {
|
||||
if (this.fornitore == null) {
|
||||
return null;
|
||||
}
|
||||
return this.fornitore.getValue().getCodAnag();
|
||||
return this.fornitore.getCodAnag();
|
||||
}
|
||||
|
||||
public void editDocument(SqlMtbColt document) {
|
||||
@ -178,7 +175,7 @@ public class DocInterniViewModel {
|
||||
|
||||
public void newDocument() {
|
||||
SqlMtbColt document = new SqlMtbColt();
|
||||
if (this.dtbTipi.getValue() == null) {
|
||||
if (this.dtbTipi == null) {
|
||||
this.sendError(new NoDocTypeSelectedException());
|
||||
return;
|
||||
}
|
||||
@ -186,18 +183,18 @@ public class DocInterniViewModel {
|
||||
document.setCodMgrp(this.getCodMgrp());
|
||||
document.setDataCollo(new Date());
|
||||
document.setCodMdep(SettingsManager.i().getUserSession().getDepo().getCodMdep());
|
||||
document.setAnnotazioni(this.note.getValue());
|
||||
document.setAnnotazioni(this.note);
|
||||
document.setSegno(-1);
|
||||
document.setSerCollo("/");
|
||||
document.setNumCollo(this.nextNumCollo);
|
||||
document.setGestione("L");
|
||||
document.setDataDoc(this.dataDoc.getValue());
|
||||
if (this.numDoc.getValue() != null) {
|
||||
document.setNumDoc(Integer.parseInt(this.numDoc.getValue()));
|
||||
document.setDataDoc(this.dataDoc);
|
||||
if (this.numDoc != null) {
|
||||
document.setNumDoc(Integer.parseInt(this.numDoc));
|
||||
}
|
||||
if (this.fornitore.getValue() != null) {
|
||||
document.setCodAnag(this.fornitore.getValue().getCodAnag());
|
||||
document.setCodVdes(this.fornitore.getValue().getCodVdes());
|
||||
if (this.fornitore != null) {
|
||||
document.setCodAnag(this.fornitore.getCodAnag());
|
||||
document.setCodVdes(this.fornitore.getCodVdes());
|
||||
}
|
||||
documentRepository.insert(document, id -> {
|
||||
document.setId(id);
|
||||
@ -206,7 +203,7 @@ public class DocInterniViewModel {
|
||||
}
|
||||
|
||||
public boolean hasDocDetails() {
|
||||
return this.dtbTipi.getValue() != null;
|
||||
return this.dtbTipi != null;
|
||||
}
|
||||
|
||||
public interface Listener extends ILoadingListener {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user