From 5c2b7be143403fe90e9bb05faee863821c95bc08 Mon Sep 17 00:00:00 2001 From: Nathan Curtis Date: Fri, 21 Jun 2024 14:52:07 -0700 Subject: [PATCH 1/2] [TM-971] Add a set of new fields for project establishment. --- .../CreateProjectWithFormController.php | 5 ++ app/Models/V2/Projects/Project.php | 5 ++ config/wri/linked-fields.php | 10 ++++ ...21015_add_fields_project_establishment.php | 47 +++++++++++++++++++ 4 files changed, 67 insertions(+) create mode 100644 database/migrations/2024_06_20_221015_add_fields_project_establishment.php diff --git a/app/Http/Controllers/V2/Projects/CreateProjectWithFormController.php b/app/Http/Controllers/V2/Projects/CreateProjectWithFormController.php index 6f9580fd0..00af8ff4a 100644 --- a/app/Http/Controllers/V2/Projects/CreateProjectWithFormController.php +++ b/app/Http/Controllers/V2/Projects/CreateProjectWithFormController.php @@ -90,6 +90,11 @@ public function __invoke(Request $request): EntityWithSchemaResource 'proj_boundary' => $projectPitch->proj_boundary, 'states' => $projectPitch->states, 'proj_impact_biodiv' => $projectPitch->biodiversity_impact, + 'water_source' => $projectPitch->water_source, + 'baseline_biodiversity' => $projectPitch->baseline_biodiversity, + 'goal_trees_restored_planting' => $projectPitch->goal_trees_restored_planting, + 'goal_trees_restored_anr' => $projectPitch->goal_trees_restored_anr, + 'goal_trees_restored_direct_seeding' => $projectPitch->goal_trees_restored_direct_seeding, ]); foreach ($projectPitch->treeSpecies()->get() as $treeSpecies) { diff --git a/app/Models/V2/Projects/Project.php b/app/Models/V2/Projects/Project.php index 5952a5e91..15eeb9caa 100644 --- a/app/Models/V2/Projects/Project.php +++ b/app/Models/V2/Projects/Project.php @@ -134,6 +134,11 @@ class Project extends Model implements MediaModel, AuditableContract, EntityMode 'proj_boundary', 'states', 'proj_impact_biodiv', + 'water_source', + 'baseline_biodiversity', + 'goal_trees_restored_planting', + 'goal_trees_restored_anr', + 'goal_trees_restored_direct_seeding', ]; public $fileConfiguration = [ diff --git a/config/wri/linked-fields.php b/config/wri/linked-fields.php index cd25da2c6..ca3e9c328 100644 --- a/config/wri/linked-fields.php +++ b/config/wri/linked-fields.php @@ -258,6 +258,10 @@ 'pro-soil-health' => ['property' => 'soil_health', 'label' => 'Soil Health (project)', 'input_type' => 'long-text'], 'pro-pit-land-use-types' => ['property' => 'land_use_types', 'label' => 'Land use types', 'input_type' => 'select-image', 'multichoice' => true, 'option_list_key' => 'restoration-systems'], 'pro-pit-restoration_strategy' => ['property' => 'restoration_strategy', 'label' => 'Restoration strategy', 'input_type' => 'select-image', 'multichoice' => true, 'option_list_key' => 'restoration-practices'], + 'pro-pit-baseline-biodiversity' => ['property' => 'baseline_biodiversity', 'label' => 'Baseline Biodiversity Conditions', 'input_type' => 'long-text'], + 'pro-pit-goal-trees-restored-planting' => ['property' => 'goal_trees_restored_planting', 'label' => 'Trees Restored Goal - Planting', 'input_type' => 'number'], + 'pro-pit-goal-trees-restored-anr' => ['property' => 'goal_trees_restored_anr', 'label' => 'Trees Restored Goal - ANR', 'input_type' => 'number'], + 'pro-pit-goal-trees-restored-direct-seeding' => ['property' => 'goal_trees_restored_direct_seeding', 'label' => 'Trees Restored Goal - Direct Seeding', 'input_type' => 'number'], ], 'file-collections' => [ 'pro-pit-fcol-cover' => ['property' => 'cover', 'label' => 'Cover Image', 'input_type' => 'file', 'multichoice' => false], @@ -333,6 +337,12 @@ 'pro-proj-boundary' => ['property' => 'proj_boundary', 'label' => 'Project Boundary', 'input_type' => 'mapInput'], 'pro-states' => ['property' => 'states', 'label' => 'States', 'input_type' => 'select', 'multichoice' => true, 'option_list_key' => 'states'], 'pro-impact-biodiv' => ['property' => 'proj_impact_biodiv', 'label' => 'Biodiversity Impact (project)', 'input_type' => 'long-text'], + // This is breaking convention for linked field keys because project pitch was already using pro-water-source. + 'project-water-source' => ['property' => 'water_source', 'label' => 'Water Source', 'input_type' => 'long-text'], + 'pro-baseline-biodiversity' => ['property' => 'baseline_biodiversity', 'label' => 'Baseline Biodiversity Conditions', 'input_type' => 'long-text'], + 'pro-goal-trees-restored-planting' => ['property' => 'goal_trees_restored_planting', 'label' => 'Trees Restored Goal - Planting', 'input_type' => 'number'], + 'pro-goal-trees-restored-anr' => ['property' => 'goal_trees_restored_anr', 'label' => 'Trees Restored Goal - ANR', 'input_type' => 'number'], + 'pro-goal-trees-restored-direct-seeding' => ['property' => 'goal_trees_restored_direct_seeding', 'label' => 'Trees Restored Goal - Direct Seeding', 'input_type' => 'number'], ], 'file-collections' => [ 'pro-col-media' => ['property' => 'media', 'label' => 'Media', 'input_type' => 'file', 'multichoice' => true], diff --git a/database/migrations/2024_06_20_221015_add_fields_project_establishment.php b/database/migrations/2024_06_20_221015_add_fields_project_establishment.php new file mode 100644 index 000000000..3e26d2523 --- /dev/null +++ b/database/migrations/2024_06_20_221015_add_fields_project_establishment.php @@ -0,0 +1,47 @@ +text('water_source')->nullable(); + $table->text('baseline_biodiversity')->nullable(); + $table->integer('goal_trees_restored_planting')->nullable(); + $table->integer('goal_trees_restored_anr')->nullable(); + $table->integer('goal_trees_restored_direct_seeding')->nullable(); + }); + Schema::table('project_pitches', function (Blueprint $table) { + $table->text('baseline_biodiversity')->nullable(); + $table->integer('goal_trees_restored_planting')->nullable(); + $table->integer('goal_trees_restored_anr')->nullable(); + $table->integer('goal_trees_restored_direct_seeding')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('v2_projects', function (Blueprint $table) { + $table->dropColumn('water_source'); + $table->dropColumn('baseline_biodiversity'); + $table->dropColumn('goal_trees_restored_planting'); + $table->dropColumn('goal_trees_restored_anr'); + $table->dropColumn('goal_trees_restored_direct_seeding'); + }); + Schema::table('project_pitches', function (Blueprint $table) { + $table->dropColumn('baseline_biodiversity'); + $table->dropColumn('goal_trees_restored_planting'); + $table->dropColumn('goal_trees_restored_anr'); + $table->dropColumn('goal_trees_restored_direct_seeding'); + }); + } +}; From c435ba4c2f78eeaab1a9601ee9505457f577c768 Mon Sep 17 00:00:00 2001 From: Nathan Curtis Date: Thu, 20 Jun 2024 15:07:50 -0700 Subject: [PATCH 2/2] [TM-975] Add three new fields to project report. --- config/wri/linked-fields.php | 3 ++ ...06_20_215908_add_project_report_fields.php | 31 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 database/migrations/2024_06_20_215908_add_project_report_fields.php diff --git a/config/wri/linked-fields.php b/config/wri/linked-fields.php index cd25da2c6..13ddbdf54 100644 --- a/config/wri/linked-fields.php +++ b/config/wri/linked-fields.php @@ -431,6 +431,9 @@ // TODO (TM-912) Deprecated, to be removed. 'pro-rep-paid-other-activity-description' => ['property' => 'paid_other_activity_description', 'label' => 'Paid Other Activities Description', 'input_type' => 'long-text'], 'pro-rep-other-workdays-description' => ['property' => 'other_workdays_description', 'label' => 'Other Activities Description', 'input_type' => 'long-text'], + 'pro-rep-local-engagement-description' => ['property' => 'local_engagement_description', 'label' => 'Response to Local Priorities', 'input_type' => 'long-text'], + 'pro-rep-indirect-beneficiaries' => ['property' => 'indirect_beneficiaries', 'label' => 'Number of Indirect Beneficiaries', 'input_type' => 'number'], + 'pro-rep-indirect-beneficiaries-description' => ['property' => 'indirect_beneficiaries_description', 'label' => 'Indirect Beneficiaries Description', 'input_type' => 'long-text'], ], 'relations' => [ 'pro-rep-rel-tree-species' => [ diff --git a/database/migrations/2024_06_20_215908_add_project_report_fields.php b/database/migrations/2024_06_20_215908_add_project_report_fields.php new file mode 100644 index 000000000..4cb1fc0ef --- /dev/null +++ b/database/migrations/2024_06_20_215908_add_project_report_fields.php @@ -0,0 +1,31 @@ +text('local_engagement_description')->nullable(); + $table->integer('indirect_beneficiaries')->nullable(); + $table->text('indirect_beneficiaries_description')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('v2_project_reports', function (Blueprint $table) { + $table->dropColumn('local_engagement_description'); + $table->dropColumn('indirect_beneficiaries'); + $table->dropColumn('indirect_beneficiaries_description'); + }); + } +};