1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using System;
- using System.Linq;
- using System.Threading.Tasks;
- using Comal.Classes;
- using InABox.Core;
- using InABox.Mobile.Shared;
- using Syncfusion.XForms.RichTextEditor;
- using Xamarin.Forms;
- using Xamarin.Forms.Xaml;
- using XF.Material.Forms.UI.Dialogs;
- namespace PRS.Mobile
- {
- [XamlCompilation(XamlCompilationOptions.Compile)]
- public partial class SiteForms
- {
- private JobFormModel _model;
-
- public SiteForms(JobShell job) : base(job)
- {
- _model = new JobFormModel(App.Data, () => new Filter<JobForm>(x => x.Parent.ID).IsEqualTo(Job.ID));
- InitializeComponent();
- ProgressVisible = true;
- _forms.DataModel = _model;
- _forms.AppliesTo = "Job";
- _forms.Property = model => _model.Items.OfType<IDigitalFormInstanceShell>().ToArray();
- RefreshData(false, true);
- }
- private void RefreshData(bool force, bool async)
- {
- if (async)
- _model.Refresh(force, () => Device.BeginInvokeOnMainThread(RefreshScreen));
- else
- {
- _model.Refresh(force);
- RefreshScreen();
- }
- }
- private void RefreshScreen()
- {
- _forms.Refresh();
- ProgressVisible = false;
- }
-
- private void AddForm_Clicked(object sender, EventArgs e)
- {
- var selector = new NewForms() { AppliesTo = _forms.AppliesTo };
- selector.ItemSelected += CreateNewForm;
- Navigation.PushAsync(selector);
- }
- private async void CreateNewForm(object sender, NewFormSelectedArgs args)
- {
- var instance = _model.AddItem();
- instance.ParentID = Job.ID;
- instance.FormID = args.Form.ID;
- instance.FormCode = args.Form.Code;
- instance.FormDescription = args.Form.Description;
- instance.Save("Created on Mobile Device");
- Device.BeginInvokeOnMainThread(() =>
- {
- _forms.RefreshData(false,false);
- _forms.EditForm<Job,JobLink,JobForm>(instance,Job.Entity);
- });
- }
- private void _forms_OnFormTapped(object sender, ExistingFormTappedEventArgs args)
- {
- ProgressVisible = true;
- _forms.EditForm<Job, JobLink, JobForm>(args.Shell, Job.Entity);
- ProgressVisible = false;
- }
- }
- }
|