Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Es/feat observation fields #211

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a9e5ad8
chore:created observationPreset docs
ErikSin Feb 20, 2024
28b1779
chore: name added as a tag property
ErikSin Mar 3, 2024
008abae
chore:create question label
ErikSin Feb 20, 2024
578f6d9
chore:created screen for user to input field values
ErikSin Feb 20, 2024
626049e
chore:translations
ErikSin Feb 20, 2024
619a2bc
feat: created observation fields
ErikSin Feb 20, 2024
136eb6e
chore:added observation fields to navigation
ErikSin Feb 20, 2024
f01fab7
chore: got rid of unused import
ErikSin Feb 20, 2024
c1a46db
chore: change navigation names
ErikSin Apr 1, 2024
7378982
chore:created observationPreset docs
ErikSin Feb 20, 2024
7310ff1
chore: name added as a tag property
ErikSin Mar 3, 2024
8bb4a92
chore:create question label
ErikSin Feb 20, 2024
c4b77f2
chore:created screen for user to input field values
ErikSin Feb 20, 2024
f7192d1
chore:translations
ErikSin Feb 20, 2024
47bcda2
feat: created observation fields
ErikSin Feb 20, 2024
ae20ba3
chore:added observation fields to navigation
ErikSin Feb 20, 2024
4729bfa
chore:added observation fields to navigation
ErikSin Feb 20, 2024
0612e88
chore: got rid of unused import
ErikSin Feb 20, 2024
bc17494
chore: change navigation names
ErikSin Apr 1, 2024
b3faff9
Merge branch 'es/feat-observation-fields' of https://github.com/digid…
ErikSin Apr 1, 2024
42a1f4c
chore: fix linting issues
ErikSin Apr 16, 2024
97bd388
chore: added default config
ErikSin Apr 16, 2024
49ca92b
chore: update from main
ErikSin Apr 16, 2024
9339e1a
chore: added default config for testing
ErikSin Apr 17, 2024
d32b9e3
chore: update from main
ErikSin Apr 22, 2024
09fdc9d
chore: added default config
ErikSin Apr 22, 2024
be0e33c
chore: try different import
ErikSin Apr 24, 2024
3be7e51
chore: update dependecies
ErikSin Apr 30, 2024
f58001d
core: add default config
ErikSin Apr 30, 2024
1758526
chore: update from main
ErikSin Apr 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions docs/ObservationPresets.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
## Relationship between presets, fields, and tags

### Tags:

An `Observation` has a tags property.

```ts
type tags = {
[k: string]:
| boolean
| number
| string
| null
| (boolean | number | string | null)[];
};
```

This is an open ended propery, that allows any key value pair descriptor to be associated with an observation. For example, any notes associated with a observation is simply saved as a tag, with the `key="notes"`

### Presets:

Presets have a set of predefined tags used to categorize an observation. These tags can have as little or as many descriptors, usually defined by how it is used.

In the following example, there are 2 different types of tags, defined by the presets, both describing bridges.

```ts
// This tag simply defines the observation as being a bridge
const tags = {
name: 'bridge',
};

// this tag defines the observation as an active suspension bridge over a river
const tags = {
name: 'bridge',
bridgeType: 'suspension',
bodyOfWater: 'river',
isActive: true,
};
```

In CoMapeo each preset represnts one type of observation (defined by the name tag). Preset also includes other meta data associated with an observation.

### Fields:

Fields are also saved to an observation as a tag. The difference is that they are editted by the user at the time of the observation. A `preset` has predefined `keys` and a predefined `values`, while a `tag` has predefined `keys` and user editted values. This is useful when there are descriptors that cannot be predetermined.

Using the bridge example:

```ts
const tags = {
// this is predefined by the preset
type: 'bridge',
// this is a field, where the user was prompted to input the length
lengthInMeter: 35,
};
```

### How to determine the fields associated with a preset

`Presets` have a `fieldsId` property of type `string[]`. For each value in the array, there is an associated field with a matching docId.

Each observation can have a several fields associated with it.

Each field has a `type`, where `type: "text" | "number" | "selectOne" | "selectMultiple" | "UNRECOGNIZED";`. This defines how the field is presented to the user,and how the user inputs the value of the field. If the type is `text` or `number` the user inputs a string or number. If the type is `selectOne` or `selectMultiple` the user types is given a list of options to select from which determines the value of the field

A field has a `tagKey` property. This defined the `key` of the tag saved in the observation

### Flow for saving an observation

1. User choses a preset. This preset has `tags` and `fieldIds`.
2. Based on the `fieldIds` the user is prompted to fill in several forms. This provides an another `tags` object where the `keys=Field['tagKeys']` and the value is the value inputted by the user.
3. The tags from the preset, and the tags from the fields are flattened into `tags` object of an observation.
24 changes: 12 additions & 12 deletions docs/ObservationPresets.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### Tags:

An `Observation` has a `tags` property.
An `Observation` has a tags property.

```ts
type tags = {
Expand All @@ -15,7 +15,7 @@ type tags = {
};
```

This is an open-ended property that allows any key-value pair descriptor to be associated with an observation. For example, any notes associated with an observation is simply saved as a tag, with the `key="notes"`
This is an open ended propery, that allows any key value pair descriptor to be associated with an observation. For example, any notes associated with a observation is simply saved as a tag, with the `key="notes"`

### Presets:

Expand All @@ -25,24 +25,24 @@ In the following example, there are 2 different types of tags, defined by the pr

```ts
// This tag simply defines the observation as being a bridge
const tag = {
const tags = {
name: 'bridge',
};

// this tag defines the observation as an active suspension bridge over a river
const tag = {
const tags = {
name: 'bridge',
bridgeType: 'suspension',
bodyOfWater: 'river',
isActive: true,
};
```

In CoMapeo each preset represents one type of observation (defined by the `name` tag). Preset also includes other metadata associated with an observation.
In CoMapeo each preset represnts one type of observation (defined by the name tag). Preset also includes other meta data associated with an observation.

### Fields:

Fields are also saved to an observation as a tag. The difference is that they are edited by the user at the time of the observation. A `preset` has predefined `keys` and a predefined `values`, while a `tag` has predefined `keys` and user-edited values. This is useful when there are descriptors that cannot be predetermined.
Fields are also saved to an observation as a tag. The difference is that they are editted by the user at the time of the observation. A `preset` has predefined `keys` and a predefined `values`, while a `tag` has predefined `keys` and user editted values. This is useful when there are descriptors that cannot be predetermined.

Using the bridge example:

Expand All @@ -57,16 +57,16 @@ const tags = {

### How to determine the fields associated with a preset

`Presets` have a `fieldsId` property of type `string[]`. For each value in the array, there is an associated field with a matching `docId`.
`Presets` have a `fieldsId` property of type `string[]`. For each value in the array, there is an associated field with a matching docId.

Each observation can have a several fields associated with it.

Each field has a `type`, where `type: "text" | "number" | "selectOne" | "selectMultiple" | "UNRECOGNIZED";`. This defines how the field is presented to the user, and how the user inputs the value of the field. If the type is `text` or `number` the user inputs a string or number. If the type is `selectOne` or `selectMultiple` the user is given a list of options to select from which determines the value of the field.
Each field has a `type`, where `type: "text" | "number" | "selectOne" | "selectMultiple" | "UNRECOGNIZED";`. This defines how the field is presented to the user,and how the user inputs the value of the field. If the type is `text` or `number` the user inputs a string or number. If the type is `selectOne` or `selectMultiple` the user types is given a list of options to select from which determines the value of the field

A field has a `tagKey` property. This defines the `key` of the tag saved in the observation.
A field has a `tagKey` property. This defined the `key` of the tag saved in the observation

### Flow for saving an observation

1. User chooses a preset. This preset has `tags` and `fieldIds`.
2. Based on the `fieldIds` the user is prompted to fill in several forms. This provides another `tags` object where the `keys=Field['tagKeys']` and the value is the value inputted by the user.
3. The tags from the preset and the tags from the fields are flattened into the `tags` object of an observation.
1. User choses a preset. This preset has `tags` and `fieldIds`.
2. Based on the `fieldIds` the user is prompted to fill in several forms. This provides an another `tags` object where the `keys=Field['tagKeys']` and the value is the value inputted by the user.
3. The tags from the preset, and the tags from the fields are flattened into `tags` object of an observation.
16 changes: 16 additions & 0 deletions messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,18 @@
"description": "Title of observation screen showing (non-editable) view of observation with map and answered questions",
"message": "Observation"
},
"screens.ObservationDetails.done": {
"description": "Button text when all questions are complete",
"message": "Done"
},
"screens.ObservationDetails.nextQuestion": {
"description": "Button text to navigate to next question",
"message": "Next"
},
"screens.ObservationDetails.title": {
"description": "Title of observation details screen showing question number and total",
"message": "Question {current} of {total}"
},
"screens.ObservationEdit.BottomSheet.addLabel": {
"description": "Label above keyboard that expands into bottom sheet of options to add (photo, details etc)",
"message": "Add…"
Expand All @@ -358,6 +370,10 @@
"description": "Placeholder for description/notes field",
"message": "What is happening here?"
},
"screens.ObservationEdit.ObservationEditView.detailsButton": {
"description": "Button label to add details",
"message": "Add Details"
},
"screens.ObservationEdit.ObservationEditView.photoButton": {
"description": "Button label for adding photo",
"message": "Add Photo"
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@formatjs/intl-pluralrules": "^5.2.4",
"@formatjs/intl-relativetimeformat": "^11.2.4",
"@gorhom/bottom-sheet": "^4.5.1",
"@mapeo/ipc": "0.3.0",
"@mapeo/ipc": "^0.4.0",
"@osm_borders/maritime_10000m": "^1.1.0",
"@react-native-community/hooks": "^2.8.0",
"@react-native-community/netinfo": "11.1.0",
Expand Down Expand Up @@ -95,7 +95,7 @@
"@babel/preset-env": "^7.20.0",
"@babel/runtime": "^7.20.0",
"@formatjs/cli": "^6.2.0",
"@mapeo/core": "9.0.0-alpha.7",
"@mapeo/core": "^9.0.0-alpha.8",
"@mapeo/schema": "3.0.0-next.15",
"@react-native-community/cli": "^12.3.6",
"@react-native/babel-preset": "^0.73.21",
Expand Down
1 change: 1 addition & 0 deletions scripts/build-backend.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const KEEP_THESE = [
'loader.js',
// Static folders referenced by @mapeo/core code
'node_modules/@mapeo/core/drizzle',
'node_modules/@mapeo/default-config'
];

for (const name of KEEP_THESE) {
Expand Down
6 changes: 6 additions & 0 deletions src/backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ const MIGRATIONS_FOLDER_PATH = new URL(
import.meta.url,
).pathname

const DEFAULT_CONFIG_PATH = new URL(
'./node_modules/@mapeo/default-config/dist/mapeo-default-config.mapeoconfig',
import.meta.url,
).pathname

try {
const { values } = parseArgs({
options: {
Expand All @@ -35,6 +40,7 @@ try {
rootKey: Buffer.from(values.rootKey, 'hex'),
migrationsFolderPath: MIGRATIONS_FOLDER_PATH,
sharedStoragePath: values.sharedStoragePath,
defaultConfigPath: DEFAULT_CONFIG_PATH,
}).catch((err) => {
console.error('Server startup error:', err)
})
Expand Down
Loading
Loading