| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- using System;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using System.Threading.Tasks;
- using InABox.Core;
- using Xamarin.Forms.Xaml;
- using XF.Material.Forms.UI.Dialogs;
- namespace comal.timesheets
- {
- [XamlCompilation(XamlCompilationOptions.Compile)]
- public partial class ExistingForms
- {
-
- private String _currentfilter = "";
- public IModel DataModel
- {
- get => _model.DataModel;
- set => _model.DataModel = value;
- }
- public String AppliesTo
- {
- get => _model.AppliesTo;
- set => _model.AppliesTo = value;
- }
- public Func<IModel, IDigitalFormInstanceShell[]> Property
- {
- get => _model.Property;
- set => _model.Property = value;
- }
-
- // Event to handle new / existing form selection
-
- public ExistingForms()
- {
- InitializeComponent();
- }
-
- public void RefreshData(bool force, bool async)
- {
- if (async)
- DataModel.Refresh(force, Refresh);
- else
- {
- DataModel.Refresh(true);
- Refresh();
- }
- }
-
- private void Refresh()
- {
- var forms = Property(DataModel);
- _forms.ItemsSource = forms.Where(FilterShell);
- }
-
- private bool FilterShell(IDigitalFormInstanceShell shell)
- {
- if (String.IsNullOrWhiteSpace(_currentfilter))
- return true;
- return shell.Code.ToUpper().Contains(_currentfilter.ToUpper())
- || shell.Description.ToUpper().Contains(_currentfilter.ToUpper());
- }
- private void _search_OnTextChanged(object sender, MobileSearchBarTextChangedArgs args)
- {
- _currentfilter = args.Text;
- Refresh();
- }
- private void _digitalforms_OnRefresh(object sender, MobileListRefreshEventArgs args)
- {
- RefreshData(true,false);
- }
-
- private void AddForm_Tapped(object sender, EventArgs e)
- {
- var selector = new NewForms() { AppliesTo = this.AppliesTo };
- selector.ItemSelected += CreateNewForm;
- Navigation.PushAsync(selector);
- }
- private async void CreateNewForm(object sender, NewFormSelectedArgs args)
- {
- await MaterialDialog.Instance.AlertAsync("Not Implemented Yet!");
- return;
- }
-
- private async void EditForm(object sender, MobileListItemTappedEventArgs args)
- {
- await MaterialDialog.Instance.AlertAsync("Not Implemented Yet!");
- return;
- }
- }
- }
|