| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- using System;
- using System.Linq;
- using System.Linq.Expressions;
- using Comal.Classes;
- using InABox.Clients;
- using InABox.Core;
- using Xamarin.Forms;
- using Xamarin.Forms.Xaml;
- using XF.Material.Forms.UI;
- using XF.Material.Forms.UI.Dialogs;
- namespace PRS.Mobile
- {
- [XamlCompilation(XamlCompilationOptions.Compile)]
- public partial class AssignmentEditFormsView : AssignmentEditView
- {
-
- public AssignmentEditFormsView()
- {
- InitializeComponent();
- }
- public override void Refresh()
- {
- _forms.DataModel = ViewModel?.Forms;
- _forms.AppliesTo = "Assignment";
- _forms.Property = model => ViewModel?.Forms.Items.OfType<IDigitalFormInstanceShell>().ToArray();
- _forms.RefreshData(true,false);
- NoForms.IsVisible = ViewModel?.Forms.Any() != true;
- _forms.IsVisible = ViewModel?.Forms.Any() == true;
-
- }
- private async void _forms_OnFormTapped(object sender, ExistingFormTappedEventArgs args)
- {
- if (args.Shell is AssignmentFormShell instance)
- {
- using (await MaterialDialog.Instance.LoadingDialogAsync(message: "Loading"))
- {
- // Pretty sure this can be replaced with _forms.EditFormAsync<>(instance, ViewModel.Item.Entity)
- // Only difference is that calls RefreshData(true, true)
- var form = new Client<AssignmentForm>()
- .Query(
- new Filter<AssignmentForm>(x => x.ID).IsEqualTo(instance.ID),
- new Columns<AssignmentForm>(ColumnTypeFlags.None).Add(x=>x.ID).Add(x=>x.Form.ID)
- )
- .Rows
- .Select(x => x.ToObject<AssignmentForm>())
- .FirstOrDefault();
-
- var model = new DigitalFormHostModel<Assignment, AssignmentLink, AssignmentForm>();
- model.LoadItems(ViewModel.Item.Entity, form.Form.ID, form.ID, null);
- var host = new DigitalFormHost(model);
- host.OnClosing += (o, args) =>
- {
- if (args.Changed)
- {
- //instance.Completed = !model.DigitalFormDataModel.Instance.FormCompleted.IsEmpty();
- }
- };
- Navigation.PushAsync(host);
- }
- }
- }
-
- }
- }
|