diff --git a/.github/workflows/deliver.yml b/.github/workflows/deliver.yml new file mode 100644 index 000000000..bbcae84a8 --- /dev/null +++ b/.github/workflows/deliver.yml @@ -0,0 +1,155 @@ +name: Run tests and delivery workflow +on: + schedule: + - cron: '0 8 * * *' # Run at 8AM UTC. + push: + branches: + - '2.x' + - '2.x-**' + tags: + - '2.*' + pull_request: + branches: + - '2.x' + +jobs: + build: + name: Build Docker images + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@v2 + - name: Set default FARMOS_REPO and FARMOS_VERSION. + run: | + echo "FARMOS_REPO=${GITHUB_REPOSITORY}" >> $GITHUB_ENV + echo "FARMOS_VERSION=2.x" >> $GITHUB_ENV + - name: Set FARMOS_VERSION for branch push event. + if: github.event_name == 'push' && github.ref_type == 'branch' + run: echo "FARMOS_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV + - name: Set FARMOS_VERSION for tag push event. + if: github.event_name == 'push' && github.ref_type == 'tag' + run: echo "FARMOS_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV + - name: Set FARMOS_VERSION and FARMOS_REPO for pull request event. + if: github.event_name == 'pull_request' + run: | + echo "FARMOS_VERSION=${GITHUB_HEAD_REF}" >> $GITHUB_ENV + echo "FARMOS_REPO=${{ github.event.pull_request.head.repo.full_name }}" >> $GITHUB_ENV + - name: Build and save farmOS 2.x Docker image + run: | + docker build --build-arg FARMOS_REPO=https://github.com/${FARMOS_REPO} --build-arg FARMOS_VERSION=${FARMOS_VERSION} -t farmos/farmos:2.x docker + docker save farmos/farmos:2.x > /tmp/farmos-2x.tar + - name: Cache farmOS 2.x Docker image + uses: actions/cache@v3 + with: + path: /tmp/farmos-2x.tar + key: farmos-2x-${{ github.run_id }} + # This builds the dev Docker image using the specified FARMOS_VERSION, + # but notably it does NOT override the default PROJECT_VERSION, so the + # farmOS Composer project 2.x branch is always used. + - name: Build and save farmOS 2.x-dev Docker image + run: | + docker build --build-arg FARMOS_REPO=https://github.com/${FARMOS_REPO} --build-arg FARMOS_VERSION=${FARMOS_VERSION} -t farmos/farmos:2.x-dev docker/dev + docker save farmos/farmos:2.x-dev > /tmp/farmos-2x-dev.tar + - name: Cache farmOS 2.x-dev Docker image + uses: actions/cache@v3 + with: + path: /tmp/farmos-2x-dev.tar + key: farmos-2x-dev-${{ github.run_id }} + outputs: + farmos_version: ${{ env.FARMOS_VERSION }} + sniff: + name: Run PHP Codesniffer + runs-on: ubuntu-latest + needs: build + steps: + - name: Checkout the repository + uses: actions/checkout@v2 + - name: Restore farmOS 2.x-dev Docker image from cache + uses: actions/cache@v3 + with: + path: /tmp/farmos-2x-dev.tar + key: farmos-2x-dev-${{ github.run_id }} + - name: Load farmos/farmos:2.x-dev image + run: docker load < /tmp/farmos-2x-dev.tar + - name: Run PHP CodeSniffer + run: docker run farmos/farmos:2.x-dev phpcs /opt/drupal/web/profiles/farm + test: + name: Run PHPUnit tests + runs-on: ubuntu-latest + needs: build + strategy: + matrix: + dbms: + - pgsql + - mariadb + - sqlite + include: + - dbms: pgsql + DB_URL: pgsql://farm:farm@db/farm + processes: auto + - dbms: mariadb + DB_URL: mysql://farm:farm@db/farm + processes: auto + - dbms: sqlite + DB_URL: sqlite://localhost/sites/default/files/db.sqlite + processes: 1 + steps: + - name: Print test matrix variables + run: echo "matrix.dbms=${{ matrix.dbms }}, matrix.DB_URL=${{ matrix.DB_URL }}" + - name: Checkout the repository + uses: actions/checkout@v2 + - name: Restore farmOS 2.x-dev Docker image from cache + uses: actions/cache@v3 + with: + path: /tmp/farmos-2x-dev.tar + key: farmos-2x-dev-${{ github.run_id }} + - name: Load farmos/farmos:2.x-dev image + run: docker load < /tmp/farmos-2x-dev.tar + # Build a new docker-compose.yml file from docker-compose.testing.common + docker-compose.testing.{dbms}.yml. + # Copy to the current directory so that farmOS volume mounts don't change to the docker/www folder. + - name: Create docker-compose.yml + env: + DB_URL: ${{ matrix.DB_URL }} + run: | + cp docker/docker-compose.testing.* . + docker-compose -f docker-compose.testing.common.yml -f docker-compose.testing.${{ matrix.dbms }}.yml config > docker-compose.yml + - name: Start containers + run: docker-compose up -d + - name: Wait until www container is ready + # The www-container-fs-ready file is only created once we expect the containers to be online + # so waiting for that lets us know it is safe to start the tests + run: until [ -f ./www/www-container-fs-ready ]; do sleep 0.1; done + - name: Run PHPUnit tests + run: docker-compose exec -u www-data -T www paratest --verbose=1 --processes=${{ matrix.processes }} /opt/drupal/web/profiles/farm + - name: Test Drush site install with all modules + run: docker-compose exec -u www-data -T www drush site-install --db-url=${{ matrix.DB_URL }} farm farm.modules='all' + release: + name: Create GitHub release + if: github.event_name == 'push' && github.ref_type == 'tag' + runs-on: ubuntu-latest + needs: + - build + - sniff + - test + steps: + - name: Set FARMOS_VERSION from previous output. + run: echo "FARMOS_VERSION=${{ needs.build.outputs.farmos_version }}" >> $GITHUB_ENV + - name: Restore farmOS 2.x Docker image from cache + uses: actions/cache@v3 + with: + path: /tmp/farmos-2x.tar + key: farmos-2x-${{ github.run_id }} + - name: Load farmos/farmos:2.x image + run: docker load < /tmp/farmos-2x.tar + - name: Run farmOS Docker container + run: docker run --rm -v /tmp/farmOS:/opt/drupal farmos/farmos:2.x true + - name: Create artifact + run: cd /tmp && tar -czf farmOS-${FARMOS_VERSION}.tar.gz farmOS + - name: Create GitHub release + uses: softprops/action-gh-release@6034af24fba4e5a8e975aaa6056554efe4c794d0 #0.1.13 + with: + body: | + For full release notes, see [CHANGELOG.md](https://github.com/farmOS/farmOS/blob/${{ env.FARMOS_VERSION }}/CHANGELOG.md). + files: /tmp/farmOS-${{ env.FARMOS_VERSION }}.tar.gz + draft: false + prerelease: false diff --git a/.github/workflows/package-release.yml b/.github/workflows/package-release.yml deleted file mode 100644 index 09208baf8..000000000 --- a/.github/workflows/package-release.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Create 2.x release -on: - push: - tags: - - '2.*' - -jobs: - build: - name: Create Release - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@master - - name: Set FARMOS_VERSION environment variable - run: echo "FARMOS_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV - # This builds the Docker image using the specified FARMOS_VERSION, - # but notably it does NOT override the default PROJECT_VERSION, so the - # farmOS Composer project 2.x branch is always used. - - name: Build farmOS Docker image - run: docker build --build-arg FARMOS_REPO=https://github.com/${GITHUB_REPOSITORY} --build-arg FARMOS_VERSION=${FARMOS_VERSION} -t farmos docker - - name: Run farmOS Docker container - run: docker run --rm -v /tmp/farmOS:/opt/drupal farmos true - - name: Create artifact - run: cd /tmp && tar -czf farmOS-${FARMOS_VERSION}.tar.gz farmOS - - name: Create GitHub release - uses: softprops/action-gh-release@6034af24fba4e5a8e975aaa6056554efe4c794d0 #0.1.13 - with: - body: | - For full release notes, see [CHANGELOG.md](https://github.com/farmOS/farmOS/blob/${{ env.FARMOS_VERSION }}/CHANGELOG.md). - files: /tmp/farmOS-${{ env.FARMOS_VERSION }}.tar.gz - draft: false - prerelease: false diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml deleted file mode 100644 index cffe399f3..000000000 --- a/.github/workflows/run-tests.yml +++ /dev/null @@ -1,80 +0,0 @@ -name: Run 2.x PHPUnit tests -on: - schedule: - - cron: '0 8 * * *' # Run at 8AM UTC. - push: - branches: - - '2.x' - - '2.x-**' - pull_request: - branches: - - '2.x' - -jobs: - build: - name: Run PHPUnit tests - runs-on: ubuntu-latest - strategy: - matrix: - dbms: - - pgsql - - mariadb - - sqlite - include: - - dbms: pgsql - DB_URL: pgsql://farm:farm@db/farm - processes: auto - - dbms: mariadb - DB_URL: mysql://farm:farm@db/farm - processes: auto - - dbms: sqlite - DB_URL: sqlite://localhost/sites/default/files/db.sqlite - processes: 1 - # Allow all three database tests to run even when one fails. - # This is a temporary workaround for Issue #3241653: Occasional test - # failures with SQLite: SQLSTATE[HY000]: General error: 5 database is - # locked - # @todo https://www.drupal.org/project/farm/issues/3241653 - fail-fast: false - steps: - - name: Print test matrix variables - run: echo "matrix.dbms=${{ matrix.dbms }}, matrix.DB_URL=${{ matrix.DB_URL }}" - - name: Checkout the repository - uses: actions/checkout@v2 - - name: Set FARMOS_VERSION for push event. - if: ${{ !github.event.pull_request }} - run: | - echo "FARMOS_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV - echo "FARMOS_REPO=${GITHUB_REPOSITORY}" >> $GITHUB_ENV - - name: Set FARMOS_VERSION for pull request event. - if: ${{ github.event.pull_request }} - run: | - echo "FARMOS_VERSION=${GITHUB_HEAD_REF}" >> $GITHUB_ENV - echo "FARMOS_REPO=${{ github.event.pull_request.head.repo.full_name }}" >> $GITHUB_ENV - - name: Build farmOS 2.x Docker image - run: docker build --build-arg FARMOS_REPO=https://github.com/${FARMOS_REPO} --build-arg FARMOS_VERSION=${FARMOS_VERSION} -t farmos/farmos:2.x docker - # This builds the dev Docker image using the specified FARMOS_VERSION, - # but notably it does NOT override the default PROJECT_VERSION, so the - # farmOS Composer project 2.x branch is always used. - - name: Build farmOS 2.x-dev Docker image - run: docker build --build-arg FARMOS_REPO=https://github.com/${FARMOS_REPO} --build-arg FARMOS_VERSION=${FARMOS_VERSION} -t farmos/farmos:2.x-dev docker/dev - # Build a new docker-compose.yml file from docker-compose.testing.common + docker-compose.testing.{dbms}.yml. - # Copy to the current directory so that farmOS volume mounts don't change to the docker/www folder. - - name: Create docker-compose.yml - env: - DB_URL: ${{ matrix.DB_URL }} - run: | - cp docker/docker-compose.testing.* . - docker-compose -f docker-compose.testing.common.yml -f docker-compose.testing.${{ matrix.dbms }}.yml config > docker-compose.yml - - name: Start containers - run: docker-compose up -d - - name: Wait until www container is ready - # The www-container-fs-ready file is only created once we expect the containers to be online - # so waiting for that lets us know it is safe to start the tests - run: until [ -f ./www/www-container-fs-ready ]; do sleep 0.1; done - - name: Run PHP CodeSniffer - run: docker-compose exec -u www-data -T www phpcs /opt/drupal/web/profiles/farm - - name: Run PHPUnit tests - run: docker-compose exec -u www-data -T www paratest --verbose=1 --processes=${{ matrix.processes }} /opt/drupal/web/profiles/farm - - name: Test Drush site install with all modules - run: docker-compose exec -u www-data -T www drush site-install --db-url=${{ matrix.DB_URL }} farm farm.modules='all' diff --git a/CHANGELOG.md b/CHANGELOG.md index 9df725a9e..b57278371 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,35 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- [Issue #3275161: Allow IMG tags in default text format](https://www.drupal.org/project/farm/issues/3275161) +- [Update toolbar logo spacing for gin beta #527](https://github.com/farmOS/farmOS/pull/527) + +### Fixed + +- [Do not check php-geos requirement in the update phase #526](https://github.com/farmOS/farmOS/pull/526) + +### Security + +- Update Drupal core to 9.3.12 for [SA-CORE-2022-008](https://www.drupal.org/sa-core-2022-008) and + [SA-CORE-2022-009](https://www.drupal.org/sa-core-2022-009). + +## [2.0.0-beta4] 2022-04-13 + +### Added + +- [Link from entities to their referenced terms and show entity views on taxonomy terms #458](https://github.com/farmOS/farmOS/pull/458). +- [Encourage GEOS PHP extension use #521](https://github.com/farmOS/farmOS/pull/521) + +### Changed + +- Update [farmOS-map](https://github.com/farmOS/farmOS-map) to [v2.0.4](https://github.com/farmOS/farmOS-map/releases/tag/v2.0.4). +- [Issue #3270561: Upgrade to gin beta](https://www.drupal.org/project/farm/issues/3270561) +- [Separate Docker image build from testing jobs in run-test.yml workflow #522](https://github.com/farmOS/farmOS/pull/522) +- [Merge test and release workflows into a unified delivery workflow #523](https://github.com/farmOS/farmOS/pull/523) +- [Improve fields documentation #505](https://github.com/farmOS/farmOS/pull/505) + ### Fixed - [Only require a name to build map popups #515](https://github.com/farmOS/farmOS/pull/515) @@ -160,7 +189,8 @@ moving forward. Drupal 7, which required a complete refactor of the codebase. By comparison, updating from Drupal 9 to 10 will simply involve updating deprecated code. -[Unreleased]: https://github.com/farmOS/farmOS/compare/2.0.0-beta3...HEAD +[Unreleased]: https://github.com/farmOS/farmOS/compare/2.0.0-beta4...HEAD +[2.0.0-beta4]: https://github.com/farmOS/farmOS/releases/tag/2.0.0-beta4 [2.0.0-beta3]: https://github.com/farmOS/farmOS/releases/tag/2.0.0-beta3 [2.0.0-beta2]: https://github.com/farmOS/farmOS/releases/tag/2.0.0-beta2 [2.0.0-beta1]: https://github.com/farmOS/farmOS/releases/tag/2.0.0-beta1 diff --git a/composer.json b/composer.json index 691994a2c..27efef2a0 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "require": { "cweagans/composer-patches": "^1.6", "drupal/admin_toolbar": "^2.4", - "drupal/core": "9.3.9", + "drupal/core": "9.3.12", "drupal/config_update": "^1.7", "drupal/csv_serialization": "^2.0", "drupal/date_popup": "^1.1", @@ -30,7 +30,7 @@ "drupal/exif_orientation": "^1.1", "drupal/fraction": "^2.0", "drupal/geofield": "^1.33", - "drupal/gin": "3.0-alpha37", + "drupal/gin": "^3.0@beta", "drupal/inline_entity_form": "^1.0@RC", "drupal/inspire_tree": "^1.0", "drupal/jsonapi_extras": "^3.15", @@ -60,9 +60,6 @@ "drupal/entity": { "Issue #3206703: Provide reverse relationships for bundle plugin entity_reference fields.": "https://www.drupal.org/files/issues/2021-05-18/3206703-7.patch" }, - "drupal/gin": { - "Issue #3245203: Sticky region has inconsistent z-index.": "https://www.drupal.org/files/issues/2021-10-21/3245203-alpha37-3.patch" - }, "drupal/jsonapi_schema": { "Issue #3256795: Float fields have a null schema": "https://www.drupal.org/files/issues/2022-01-03/3256795-4.patch", "Issue #3246251: Change format utc-millisec to date-time": "https://www.drupal.org/files/issues/2021-10-27/3246251-2.patch" diff --git a/composer.libraries.json b/composer.libraries.json index c530d7e8f..8aa6a9a9a 100644 --- a/composer.libraries.json +++ b/composer.libraries.json @@ -7,10 +7,10 @@ "type": "package", "package": { "name": "farmos/farmos-map", - "version": "2.0.3", + "version": "2.0.4", "type": "drupal-library", "dist": { - "url": "https://github.com/farmOS/farmOS-map/releases/download/v2.0.2/v2.0.2-dist.zip", + "url": "https://github.com/farmOS/farmOS-map/releases/download/v2.0.4/v2.0.4-dist.zip", "type": "zip" }, "extra": { diff --git a/composer.project.json b/composer.project.json index 2723ee089..ab427c46d 100644 --- a/composer.project.json +++ b/composer.project.json @@ -1,11 +1,11 @@ { "require": { "cweagans/composer-patches": "^1.7", - "drupal/core-composer-scaffold": "9.3.9" + "drupal/core-composer-scaffold": "9.3.12" }, "require-dev": { "brianium/paratest": "^4", - "drupal/core-dev": "9.3.9", + "drupal/core-dev": "9.3.12", "phpspec/prophecy-phpunit": "^2", "symfony/finder": "^4.0" }, diff --git a/docker/docker-compose.development.yml b/docker/docker-compose.development.yml index 273b03783..d20c07961 100644 --- a/docker/docker-compose.development.yml +++ b/docker/docker-compose.development.yml @@ -28,4 +28,7 @@ services: # Enable this service when executing javascript tests. # chrome: -# image: selenium/standalone-chrome:latest + + # Tests are failing on later versions of this image. + # See https://github.com/farmOS/farmOS/issues/514 +# image: selenium/standalone-chrome:4.1.2-20220217 diff --git a/docker/docker-compose.testing.common.yml b/docker/docker-compose.testing.common.yml index fd57d3785..7f2aa2ab5 100644 --- a/docker/docker-compose.testing.common.yml +++ b/docker/docker-compose.testing.common.yml @@ -10,4 +10,6 @@ services: XDEBUG_MODE: 'off' chrome: - image: selenium/standalone-chrome:latest + # Tests are failing on later versions of this image. + # See https://github.com/farmOS/farmOS/issues/514 + image: selenium/standalone-chrome:4.1.2-20220217 diff --git a/docs/development/environment/tests.md b/docs/development/environment/tests.md index 03ca7b4f4..e679a7afd 100644 --- a/docs/development/environment/tests.md +++ b/docs/development/environment/tests.md @@ -26,7 +26,9 @@ by adding the following container: ```yml chrome: - image: selenium/standalone-chrome:latest + # Tests are failing on later versions of this image. + # See https://github.com/farmOS/farmOS/issues/514 + image: selenium/standalone-chrome:4.1.2-20220217 ``` ## Faster testing without XDebug diff --git a/docs/development/module/fields.md b/docs/development/module/fields.md index ce87e9524..9dbce09ba 100644 --- a/docs/development/module/fields.md +++ b/docs/development/module/fields.md @@ -15,7 +15,10 @@ If the field should be added to all bundles of a given entity type (eg: all log types), then they should be added as "base fields" via `hook_entity_base_field_info()`. -A `farm_field.factory` helper service is provided to make this easier: +A `farm_field.factory` helper service is provided to make this easier. For more +information on how this works, see [Field factory service](/development/module/services/#field-factory-service). + +To get started, place the following in the `[modulename].module` file: ```php id() == 'log') { + // Options for the new field. See Field options below. $options = [ 'type' => 'string', 'label' => t('My new field'), @@ -39,6 +44,7 @@ function mymodule_entity_base_field_info(EntityTypeInterface $entity_type) { 'view' => 10, ], ]; + // NOTE: Replace 'myfield' with the internal name of the field. $fields['myfield'] = \Drupal::service('farm_field.factory')->baseFieldDefinition($options); } @@ -56,10 +62,15 @@ then they should be added as "bundle fields" via deprecated in favor of a core Drupal hook in the future. See core issue: [https://www.drupal.org/node/2346347](https://www.drupal.org/node/2346347) +A `farm_field.factory` helper service is provided to make this easier. For more +information on how this works, see [Field factory service](/development/module/services/#field-factory-service). + The format for bundle field definitions is identical to base field definitions (above), but the `bundleFieldDefinition()` method must be used instead of `baseFieldDefinition()`. +To get started, place the following in the `[modulename].module` file: + ```php id() == 'log' && $bundle == 'input') { + // Options for the new field. See Field options below. $options = [ 'type' => 'string', 'label' => t('My new field'), @@ -82,6 +96,7 @@ function mymodule_farm_entity_bundle_field_info(EntityTypeInterface $entity_type 'view' => 10, ], ]; + // NOTE: Replace 'myfield' with the internal name of the field. $fields['myfield'] = \Drupal::service('farm_field.factory')->bundleFieldDefinition($options); } @@ -126,6 +141,10 @@ Existing options can be overridden or removed by editing/deleting the entities in the active configuration of the site. (**Warning** changing core types runs the risk of conflicting with future farmOS updates). +Note that the file name is important and must follow a specific pattern. This +is generally in the form `[select_module_name].[select_field].[id].yml`. See +the examples for more info. + ### Examples: #### Flag @@ -140,11 +159,13 @@ dependencies: enforced: module: - my_module -id: monitor -label: Monitor +id: organic +label: Organic entity_types: null ``` +Note that the file name is in the form `farm_flag.flag.[id].yml`. + The most important parts are the `id`, which is a unique machine name for the flag, `label`, which is the human readable/translatable label that will be shown in the select field and other parts of the UI, and `entity_types`, which @@ -194,6 +215,8 @@ id: field label: Field ``` +Note that the file name is in the form `farm_land.land_type.[id].yml`. + #### Structure type The "Structure" module in farmOS provides a "Building" type like this: @@ -211,6 +234,8 @@ id: building label: Building ``` +Note that the file name is in the form `farm_structure.structure_type.[id].yml`. + #### Lab test type The "Lab test" module in farmOS provides a "Soil test" type like this: @@ -228,6 +253,8 @@ id: soil label: Soil test ``` +Note that the file name is in the form `farm_lab_test.lab_test_type.[id].yml`. + #### ID tag type ID tag types are similar to Flags, in that they have an `id` and `label`. They @@ -237,7 +264,7 @@ certain types of assets. For example, an "Ear tag" type, provided by the "Animal asset" module, only applies to "Animal" assets: -`animal/config/install/farm_flag.flag.ear_tag.yml` +`animal/config/install/farm_id_tag.id_tag.ear_tag.yml` ```yaml langcode: en @@ -253,5 +280,7 @@ bundles: - animal ``` +Note that the file name is in the form `farm_flag.flag.ear_tag.[id].yml`. + If you want the tag type to apply to all assets, set `bundles: null`. (or can it just be omitted?) diff --git a/docs/development/module/services.md b/docs/development/module/services.md index 58690db6a..23090f19f 100644 --- a/docs/development/module/services.md +++ b/docs/development/module/services.md @@ -74,6 +74,80 @@ $all_inventory = \Drupal::service('asset.inventory')->getInventory($asset); $gallons_of_fertilizer = \Drupal::service('asset.inventory')->getInventory($asset, 'volume', 'gallons'); ``` +## Field factory service + +**Service name**: `farm_field.factory` + +The field factory service provides two methods to make the process of creating +Drupal entity base and bundle field definitions easier and more consistent in +farmOS. This is used by modules that add [fields](/development/module/fields) +to [entity types](/development/module/entities). + +Base fields are added to *all* bundles of a given entity type (eg: all logs). +Bundle fields are only added to *specific* bundles (eg: only "Input" logs). + +Using this service is optional. It simply generates instances of Drupal core's +`BaseFieldDefinition` class or the Entity API module's `BundleFieldDefinition` +class, with farmOS-specific opinions to help enforce some consistency among +farmOS core and contrib modules. You can create instances of these field +definition classes directly instead of using the farmOS field factory service. +Or you can take the object produced by the service and customize it further +using standard Drupal field definition methods. This service is provided only +as a shortcut. + +For more information on Drupal core's field definition API, see +[Drupal FieldTypes, FieldWidgets and FieldFormatters](https://www.drupal.org/docs/drupal-apis/entity-api/fieldtypes-fieldwidgets-and-fieldformatters) + +**Methods**: + +`baseFieldDefinition($options)` - Generates a base field definition, given an +array of options (see below). + +`bundleFieldDefinition($options)` - Generates a bundle field definition, given +an array of options (see below). + +**Options**: + +Both methods expect an array of field definition options. These include: + +- `type` (required) - The field data type. Each type may require additional + options. Supported types include: + - `boolean` - True/false checkbox. + - `entity_reference` - Reference other entities. Additional options: + - `target_type` (required) - The entity type to reference (eg: `asset`, + `log`, `plan`) + - `target_bundle` (optional) - The allowed target bundle. For example, + a `target_type` of `asset` and a `target_bundle` of `animal` would + limit references to animal assets. + - `auto_create` (optional) Only used when `target_type` is set to + `taxonomy_term`. If `auto_create` is set, term references will be + created automatically if the term does not exist. + - `file` - File upload. + - `fraction` - High-precision decimal number storage. + - `geofield` - Geometry on a map. + - `image` - Image upload. + - `list_string` - Select list with allowed values. Additional options: + - `allowed_values` - An associative array of allowed values. + - `allowed_values_function` - The name of a function that returns an + associative array of allowed values. + - `string_long` - Unformatted text field of unlimited length. + - `text_long` - Formatted text field of unlimited length. + - `timestamp` - Date and time. +- `label` - The field label. +- `description` - The field description. +- `required` - Whether the field is required. +- `multiple` - Whether the field should allow multiple values. Defaults to + `FALSE`. +- `cardinality` - How many values are allowed (eg: `1` for single value + fields, `-1` for unlimited values). This is an alternative to `multiple`, + and will take precedence if it is set. Defaults to `1`. + +Other options are available for more advanced use-cases. Refer to the +[FarmFieldFactory](https://github.com/farmOS/farmOS/blob/2.x/modules/core/field/src/FarmFieldFactory.php) +class to understand how they work. + +For more information and example code, see [Adding fields](/development/module/fields). + ## Group membership service **Service name**: `group.membership` diff --git a/docs/guide/mapping.md b/docs/guide/mapping.md index b6b4e1020..21b8e021e 100644 --- a/docs/guide/mapping.md +++ b/docs/guide/mapping.md @@ -29,7 +29,7 @@ There are three ways to zoom in/out: - On touch screens, you can "pinch zoom" using two fingers. - With a computer mouse, you can use the scroll wheel to zoom in/out (click on the map first to enable scroll zoom). -- The plus (+) and minus (+) buttons in the top left of the map control zoom. +- The plus (+) and minus (-) buttons in the top left of the map control zoom. ### Geolocating diff --git a/docs/hosting/install.md b/docs/hosting/install.md index 4ae598e86..13051e1f3 100644 --- a/docs/hosting/install.md +++ b/docs/hosting/install.md @@ -23,8 +23,9 @@ dependencies. The [farmOS Docker images](#farmos-in-docker) include these. - `realpath_cache_size=4096K` - `realpath_cache_ttl=3600` - **[PHP BCMath extension](https://www.php.net/manual/en/book.bc.php)** and - **[GEOS](https://trac.osgeo.org/geos)** are recommended for more accurate - geometric calculations. + **[GEOS](https://trac.osgeo.org/geos)** are required for accurate geometric + calculations. farmOS can be installed without these, but production usage + without them is strongly discouraged. ### Database server diff --git a/farm.profile b/farm.profile index 589ca7aad..ffead1031 100644 --- a/farm.profile +++ b/farm.profile @@ -30,7 +30,6 @@ function farm_modules() { 'farm_plant' => t('Plant assets'), 'farm_animal' => t('Animal assets'), 'farm_equipment' => t('Equipment assets'), - 'farm_material' => t('Material assets'), 'farm_structure' => t('Structure assets'), 'farm_water' => t('Water assets'), 'farm_activity' => t('Activity logs'), @@ -46,6 +45,7 @@ function farm_modules() { ], 'optional' => [ 'farm_inventory' => t('Inventory management'), + 'farm_material' => t('Material assets'), 'farm_seed' => t('Seed assets'), 'farm_sensor' => t('Sensor assets'), 'farm_compost' => t('Compost assets'), diff --git a/modules/core/field/src/FarmFieldFactory.php b/modules/core/field/src/FarmFieldFactory.php index e8750b304..9ebe3a397 100644 --- a/modules/core/field/src/FarmFieldFactory.php +++ b/modules/core/field/src/FarmFieldFactory.php @@ -351,7 +351,7 @@ class FarmFieldFactory implements FarmFieldFactoryInterface { 'type' => 'entity_reference_label', 'weight' => $options['weight']['view'] ?? 0, 'settings' => [ - 'link' => FALSE, + 'link' => TRUE, ], ]; break; diff --git a/modules/core/format/config/install/filter.format.default.yml b/modules/core/format/config/install/filter.format.default.yml index 7955f8535..70e9e97ce 100644 --- a/modules/core/format/config/install/filter.format.default.yml +++ b/modules/core/format/config/install/filter.format.default.yml @@ -11,7 +11,7 @@ filters: status: true weight: -10 settings: - allowed_html: '