Search in sources :

Example 11 with FormMapViewModel

use of org.odk.collect.android.activities.viewmodels.FormMapViewModel in project collect by opendatakit.

the class FormMapViewModelTest method unfinalizedInstance_hasEditableStatus.

@Test
public void unfinalizedInstance_hasEditableStatus() {
    FormMapViewModel viewModel = new FormMapViewModel(TEST_FORM_1, testInstancesRepository);
    List<FormMapViewModel.MappableFormInstance> instances = viewModel.getMappableFormInstances();
    assertThat(instances.get(2).getClickAction(), is(FormMapViewModel.ClickAction.OPEN_EDIT));
}
Also used : FormMapViewModel(org.odk.collect.android.activities.viewmodels.FormMapViewModel) Test(org.junit.Test)

Example 12 with FormMapViewModel

use of org.odk.collect.android.activities.viewmodels.FormMapViewModel in project collect by opendatakit.

the class FormMapViewModelTest method instanceThatFailedToSend_thatCanBeEdited_hasViewableStatus.

// Instances that failed to send are not editable starting in v2021.2
@Test
public void instanceThatFailedToSend_thatCanBeEdited_hasViewableStatus() {
    FormMapViewModel viewModel = new FormMapViewModel(TEST_FORM_1, testInstancesRepository);
    List<FormMapViewModel.MappableFormInstance> instances = viewModel.getMappableFormInstances();
    assertThat(instances.get(3).getClickAction(), is(FormMapViewModel.ClickAction.OPEN_READ_ONLY));
}
Also used : FormMapViewModel(org.odk.collect.android.activities.viewmodels.FormMapViewModel) Test(org.junit.Test)

Example 13 with FormMapViewModel

use of org.odk.collect.android.activities.viewmodels.FormMapViewModel in project collect by opendatakit.

the class FormMapActivity method loadForm.

@Nullable
private Form loadForm() {
    Form form = formsRepositoryProvider.get().get(getIntent().getLongExtra(EXTRA_FORM_ID, -1));
    FormMapViewModelFactory viewModelFactory = new FormMapViewModelFactory(form, instancesRepositoryProvider.get());
    formMapViewModel = new ViewModelProvider(this, viewModelFactory).get(FormMapViewModel.class);
    return form;
}
Also used : Form(org.odk.collect.forms.Form) FormMapViewModel(org.odk.collect.android.activities.viewmodels.FormMapViewModel) ViewModelProvider(androidx.lifecycle.ViewModelProvider) Nullable(androidx.annotation.Nullable)

Aggregations

FormMapViewModel (org.odk.collect.android.activities.viewmodels.FormMapViewModel)13 Test (org.junit.Test)12 Instance (org.odk.collect.forms.instances.Instance)2 InMemInstancesRepository (org.odk.collect.formstest.InMemInstancesRepository)2 Nullable (androidx.annotation.Nullable)1 ViewModelProvider (androidx.lifecycle.ViewModelProvider)1 Form (org.odk.collect.forms.Form)1