Commit f36025c2 by Javier Piris

Modificado NewQuestionViewModel y la vista

parent b1ed00b5
......@@ -6,7 +6,7 @@ using System.Net.Http;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace inutralia.ViewModels.QuestionsSpecialist
namespace inutralia.ViewModels
{
public class NewQuestionViewModel : BaseNavigationViewModel
{
......@@ -71,7 +71,7 @@ namespace inutralia.ViewModels.QuestionsSpecialist
if (await App.API.RefreshItemAsync(QuestionSpecialist))
{
Title = QuestionSpecialist.StatusImg;
OnPropertyChanged("Status");
OnPropertyChanged("State");
}
IsBusy = false;
......@@ -86,7 +86,7 @@ namespace inutralia.ViewModels.QuestionsSpecialist
{
///Realiza el procesp de actualización si hay menos
///de un elemento en el listado
//if (QuestionSpecialist.Messages.Count() < 1)
if (QuestionSpecialist.Messages.Count() < 1)
await FetchQuestions();
}
......@@ -102,7 +102,7 @@ namespace inutralia.ViewModels.QuestionsSpecialist
/// <summary>
/// Proceso de ejecución del comando de actualización del listado
/// </summary>
async Task ExecuteRefreshQuestionMessagesCommand()
public async Task ExecuteRefreshQuestionMessagesCommand()
{
try
{
......@@ -142,6 +142,9 @@ namespace inutralia.ViewModels.QuestionsSpecialist
string err = e.Message;
NewQuestion.Clear();
}
// Indicamos que ya no estámos ocupados (provoca que desaparezca el indicador de carga)
IsBusy = false;
}
///<summary>
......@@ -205,7 +208,7 @@ namespace inutralia.ViewModels.QuestionsSpecialist
else
{
QuestionMessage msg;
if (q.State == QuestionSpecialist.Estatus.Pending)
if (q.State == QuestionSpecialist.Estatus.Closed)
{
//Edit last Message
msg = q.Messages.Last();
......
using Xamarin.Forms;
using System;
using System.Linq;
using inutralia.Models;
using inutralia.ViewModels;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace inutralia.Views.Question
......@@ -6,9 +10,80 @@ namespace inutralia.Views.Question
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class NewConsultationView : ContentPage
{
protected NewQuestionViewModel ViewModel => BindingContext as NewQuestionViewModel;
public NewConsultationView()
{
InitializeComponent();
newQuest.IsEnabled = true;
buttonNewQuestion.IsEnabled = false;
buttonNewQuestion.Clicked += ButtonNewQuestion_Clicked;
}
//protected override void OnBindingContextChanged()
//{
// base.OnBindingContextChanged();
// ViewModel.PropertyChanged += ViewModel_PropertyChanged;
//}
//private void ViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
//{
// OnDataRefreshed();
//}
private async void ButtonNewQuestion_Clicked(object sender, EventArgs e)
{
if (String.IsNullOrWhiteSpace(newQuest.Text))
{
newQuest.Text = "";
return;
}
await ViewModel.SaveQuestion(newQuest.Text);
listNewConsultation.SelectedItem = null;
//OnDataRefreshed();
}
///// <summary>
///// Método llamado cada vez que una página pasa a ser visible
///// </summary>
protected override async void OnAppearing()
{
base.OnAppearing();
//await ViewModel.RefreshData();
//OnDataRefreshed();
}
///// <summary>
///// Método llamado al hacer tap en un elemento de la lista. Navega a la página de detalle
///// de la notificación seleccionada
///// </summary>
///// <param name="sender">La ListiView</param>
///// <param name="e">Argumentos del evento</param>
void ItemTapped(object sender, ItemTappedEventArgs e)
{
if (e == null) return; // has been set to null, do not 'process' tapped event
QuestionMessage item = (QuestionMessage)e.Item;
if (ViewModel.NewQuestion.Last() == item && item.FromUser)
{
buttonNewQuestion.IsEnabled = true;
newQuest.IsEnabled = true;
newQuest.Text = item.Text;
}
else
{
((ListView)sender).SelectedItem = null; // de-select the row
}
}
//private void OnDataRefreshed()
//{
// newQuest.Text = "";
// newQuest.IsEnabled = !(ViewModel.IsCloseOrPending);
// newQuest.Placeholder = (ViewModel.IsCloseOrPending) ? ((ViewModel.QuestionSpecialist.State == QuestionSpecialist.Estatus.Closed) ? "La pregunta está cerrada" : "Esperando respuesta") : "Realiza una pregunta";
// buttonNewQuestion.IsEnabled = !(ViewModel.IsCloseOrPending);
//}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment