use of org.activityinfo.model.type.RecordRef in project activityinfo by bedatadriven.
the class TableToolBar method onNewRecord.
private void onNewRecord(SelectEvent event) {
ResourceId newRecordId = ResourceId.generateSubmissionId(viewModel.getFormId());
RecordRef newRecordRef = new RecordRef(viewModel.getFormId(), newRecordId);
FormDialog dialog = new FormDialog(formStore, newRecordRef);
dialog.show();
}
use of org.activityinfo.model.type.RecordRef in project activityinfo by bedatadriven.
the class TableView method updateGrid.
private void updateGrid(EffectiveTableModel effectiveTableModel) {
panel.setHeading(effectiveTableModel.getFormLabel());
// destorying everything
if (grid != null && grid.updateView(effectiveTableModel)) {
return;
}
if (grid != null) {
center.remove(grid);
}
grid = new TableGrid(effectiveTableModel, viewModel.getColumnSet(), viewModel);
grid.addSelectionChangedHandler(event -> {
if (!event.getSelection().isEmpty()) {
RecordRef ref = event.getSelection().get(0);
viewModel.select(ref);
}
});
center.add(grid, new VerticalLayoutContainer.VerticalLayoutData(1, 1));
center.forceLayout();
// grid and sidebars is set
if (!container.isAttached()) {
panel.setWidget(container);
}
panel.forceLayout();
}
use of org.activityinfo.model.type.RecordRef in project activityinfo by bedatadriven.
the class RecordStore method put.
public final void put(ResourceId formId, UpdatedRecord record) {
RecordRef ref = new RecordRef(formId, ResourceId.valueOf(record.getRecordId()));
impl.put(key(ref), RecordObject.from(record));
}
use of org.activityinfo.model.type.RecordRef in project activityinfo by bedatadriven.
the class RecordTreeLoaderTest method subforms.
@Test
public void subforms() {
IncidentForm incidentForm = setup.getCatalog().getIncidentForm();
RecordRef rootRecordRef = incidentForm.getRecordRef(0);
Observable<Maybe<RecordTree>> recordTree = setup.getFormStore().getRecordTree(rootRecordRef);
Connection<Maybe<RecordTree>> recordTreeView = setup.connect(recordTree);
Iterable<FormInstance> subRecords = recordTreeView.assertLoaded().get().getSubRecords(rootRecordRef, ReferralSubForm.FORM_ID);
assertThat(Iterables.size(subRecords), equalTo(4));
}
use of org.activityinfo.model.type.RecordRef in project activityinfo by bedatadriven.
the class RecordTreeLoaderTest method references.
@Test
public void references() {
BioDataForm bioDataForm = setup.getBioDataForm();
Observable<Maybe<RecordTree>> recordTree = setup.getFormStore().getRecordTree(bioDataForm.getRecordRef(0));
Connection<Maybe<RecordTree>> recordTreeView = setup.connect(recordTree);
RecordTree tree = recordTreeView.assertLoaded().get();
LookupKeySet lookupKeySet = new LookupKeySet(tree.getFormTree(), tree.getFormTree().getRootField(BioDataForm.PROTECTION_CODE_FIELD_ID).getField());
assertThat(lookupKeySet.getLookupKeys(), hasSize(1));
ReferenceValue referenceValue = (ReferenceValue) tree.getRoot().get(BioDataForm.PROTECTION_CODE_FIELD_ID);
RecordRef ref = referenceValue.getOnlyReference();
assertThat(lookupKeySet.label(tree, ref), equalTo(Maybe.of("00667")));
}
Aggregations