From 18744c60574e33794f944b48773161d21905e09c Mon Sep 17 00:00:00 2001 From: Paul Isaris Date: Mon, 14 Oct 2024 10:43:45 +0300 Subject: [PATCH 1/7] - Added user creator id column in problems - Added Model Factories to Problems and Problem Solutions so that we can add tests --- .../Problem/CrowdSourcingProjectProblem.php | 2 ++ ...CrowdSourcingProjectProblemTranslation.php | 3 ++- .../CrowdSourcingProjectProblemFactory.php | 24 +++++++++++++++++++ ...urcingProjectProblemTranslationFactory.php | 20 ++++++++++++++++ ..._crowd_sourcing_project_problems_table.php | 24 +++++++++++++++++++ database/seeders/AirQualityProjectSeeder.php | 5 ++++ .../CrowdSourcingProjectProblemSeeder.php | 6 +++++ 7 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 database/factories/CrowdSourcingProject/Problem/CrowdSourcingProjectProblemFactory.php create mode 100644 database/factories/CrowdSourcingProject/Problem/CrowdSourcingProjectProblemTranslationFactory.php create mode 100644 database/migrations/2024_10_14_121805_add_user_creator_id_to_crowd_sourcing_project_problems_table.php diff --git a/app/Models/CrowdSourcingProject/Problem/CrowdSourcingProjectProblem.php b/app/Models/CrowdSourcingProject/Problem/CrowdSourcingProjectProblem.php index 446194d8..5ff1dd23 100644 --- a/app/Models/CrowdSourcingProject/Problem/CrowdSourcingProjectProblem.php +++ b/app/Models/CrowdSourcingProject/Problem/CrowdSourcingProjectProblem.php @@ -3,6 +3,7 @@ namespace App\Models\CrowdSourcingProject\Problem; use Awobaz\Compoships\Compoships; +use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasOne; @@ -11,6 +12,7 @@ class CrowdSourcingProjectProblem extends Model { use Compoships; use SoftDeletes; + use HasFactory; protected $table = 'crowd_sourcing_project_problems'; protected $fillable = ['id', 'project_id', 'slug', 'status_id', 'img_url', 'default_language_id']; diff --git a/app/Models/CrowdSourcingProject/Problem/CrowdSourcingProjectProblemTranslation.php b/app/Models/CrowdSourcingProject/Problem/CrowdSourcingProjectProblemTranslation.php index e63ee730..534ccfb1 100644 --- a/app/Models/CrowdSourcingProject/Problem/CrowdSourcingProjectProblemTranslation.php +++ b/app/Models/CrowdSourcingProject/Problem/CrowdSourcingProjectProblemTranslation.php @@ -5,10 +5,11 @@ use App\Models\CompositeKeysModel; use App\Models\Language; use Awobaz\Compoships\Compoships; +use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Relations\BelongsTo; class CrowdSourcingProjectProblemTranslation extends CompositeKeysModel { - use Compoships; + use Compoships, HasFactory; protected $table = 'crowd_sourcing_project_problem_translations'; protected $fillable = ['problem_id', 'language_id', 'title', 'description']; diff --git a/database/factories/CrowdSourcingProject/Problem/CrowdSourcingProjectProblemFactory.php b/database/factories/CrowdSourcingProject/Problem/CrowdSourcingProjectProblemFactory.php new file mode 100644 index 00000000..f29a831c --- /dev/null +++ b/database/factories/CrowdSourcingProject/Problem/CrowdSourcingProjectProblemFactory.php @@ -0,0 +1,24 @@ + 1, + 'slug' => $this->faker->slug, + 'status_id' => CrowdSourcingProjectProblemStatusLkp::DRAFT, + 'created_at' => now(), + 'updated_at' => now(), + 'user_creator_id' => 1, + 'default_language_id' => 6, + 'img_url' => $this->faker->imageUrl(), + ]; + } +} diff --git a/database/factories/CrowdSourcingProject/Problem/CrowdSourcingProjectProblemTranslationFactory.php b/database/factories/CrowdSourcingProject/Problem/CrowdSourcingProjectProblemTranslationFactory.php new file mode 100644 index 00000000..ff7ba3dc --- /dev/null +++ b/database/factories/CrowdSourcingProject/Problem/CrowdSourcingProjectProblemTranslationFactory.php @@ -0,0 +1,20 @@ + 1, + 'language_id' => 6, + 'title' => $this->faker->sentence, + 'description' => $this->faker->paragraph, + ]; + } + +} \ No newline at end of file diff --git a/database/migrations/2024_10_14_121805_add_user_creator_id_to_crowd_sourcing_project_problems_table.php b/database/migrations/2024_10_14_121805_add_user_creator_id_to_crowd_sourcing_project_problems_table.php new file mode 100644 index 00000000..f191f914 --- /dev/null +++ b/database/migrations/2024_10_14_121805_add_user_creator_id_to_crowd_sourcing_project_problems_table.php @@ -0,0 +1,24 @@ +unsignedInteger('user_creator_id')->after('project_id')->nullable(true); + $table->foreign('user_creator_id')->references('id')->on('users'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void { + Schema::table('crowd_sourcing_project_problems', function (Blueprint $table) {}); + } +}; diff --git a/database/seeders/AirQualityProjectSeeder.php b/database/seeders/AirQualityProjectSeeder.php index fbc6250b..910fc4da 100644 --- a/database/seeders/AirQualityProjectSeeder.php +++ b/database/seeders/AirQualityProjectSeeder.php @@ -111,6 +111,7 @@ public function run(): void { 'status_id' => CrowdSourcingProjectProblemStatusLkp::PUBLISHED, 'img_url' => '/images/projects/air-quality-europe/problem-1.png', 'default_language_id' => 6, + 'user_creator_id' => 1, 'translations' => [ [ 'language_id' => 6, @@ -168,6 +169,7 @@ public function run(): void { 'status_id' => CrowdSourcingProjectProblemStatusLkp::PUBLISHED, 'img_url' => '/images/projects/air-quality-europe/problem-2.png', 'default_language_id' => 12, + 'user_creator_id' => 1, 'translations' => [ [ 'language_id' => 6, @@ -225,6 +227,7 @@ public function run(): void { 'status_id' => CrowdSourcingProjectProblemStatusLkp::PUBLISHED, 'img_url' => null, 'default_language_id' => 12, + 'user_creator_id' => 1, 'translations' => [ [ 'language_id' => 6, @@ -244,6 +247,7 @@ public function run(): void { 'status_id' => CrowdSourcingProjectProblemStatusLkp::PUBLISHED, 'img_url' => '/images/projects/air-quality-europe/problem-4.png', 'default_language_id' => 6, + 'user_creator_id' => 1, 'translations' => [ [ 'language_id' => 6, @@ -266,6 +270,7 @@ public function run(): void { 'status_id' => $problem['status_id'], 'img_url' => $problem['img_url'], 'default_language_id' => $problem['default_language_id'], + 'user_creator_id' => $problem['user_creator_id'], ]); if (isset($problem['translations'])) { foreach ($problem['translations'] as $translation) { diff --git a/database/seeders/CrowdSourcingProjectProblemSeeder.php b/database/seeders/CrowdSourcingProjectProblemSeeder.php index 669e0a02..fd7832a1 100644 --- a/database/seeders/CrowdSourcingProjectProblemSeeder.php +++ b/database/seeders/CrowdSourcingProjectProblemSeeder.php @@ -20,6 +20,7 @@ public function run(): void { 'status_id' => CrowdSourcingProjectProblemStatusLkp::PUBLISHED, 'img_url' => 'https://placehold.co/600x400', 'default_language_id' => 6, + 'user_creator_id' => 1, 'translations' => [ [ 'language_id' => 6, @@ -40,6 +41,7 @@ public function run(): void { 'status_id' => CrowdSourcingProjectProblemStatusLkp::UNPUBLISHED, 'img_url' => 'https://placehold.co/600x400', 'default_language_id' => 6, + 'user_creator_id' => 1, 'translations' => [ [ 'language_id' => 6, @@ -60,6 +62,7 @@ public function run(): void { 'status_id' => CrowdSourcingProjectProblemStatusLkp::PUBLISHED, 'img_url' => 'https://placehold.co/600x400', 'default_language_id' => 12, + 'user_creator_id' => 1, 'translations' => [ [ 'language_id' => 6, @@ -80,6 +83,7 @@ public function run(): void { 'status_id' => CrowdSourcingProjectProblemStatusLkp::PUBLISHED, 'img_url' => 'https://placehold.co/600x400', 'default_language_id' => 12, + 'user_creator_id' => 1, 'translations' => [ [ 'language_id' => 6, @@ -100,6 +104,7 @@ public function run(): void { 'status_id' => CrowdSourcingProjectProblemStatusLkp::UNPUBLISHED, 'img_url' => 'https://placehold.co/600x400', 'default_language_id' => 6, + 'user_creator_id' => 1, 'translations' => [ [ 'language_id' => 6, @@ -123,6 +128,7 @@ public function run(): void { 'status_id' => $problem['status_id'], 'img_url' => $problem['img_url'], 'default_language_id' => $problem['default_language_id'], + 'user_creator_id' => $problem['user_creator_id'], ]); if (isset($problem['translations'])) { foreach ($problem['translations'] as $translation) { From 4af8b3d1fb5a48c6275746c38f8d57b7ecc7fe98 Mon Sep 17 00:00:00 2001 From: Kostas Papandreou Date: Fri, 11 Oct 2024 16:58:02 +0300 Subject: [PATCH 2/7] - moved design colors definitions to common.scss, removed them from project/problem/landing-page.scss - made utility classes for bg-color & bg-image in common.scss & switched over to using them instead of separate rules in project/problem/landing-page.scss - commented about bootstrap custom xxl breakpoint in project/problem/landing-page.scss - removed font imports from project/problem/landing-page.scss - replaced use of "--clr-primary-yellow" color to use "--project-primary-color" - changed "project-problem-page" class to be an id instead - on project-related pages, added "The Campaign" to top navbar - made "share-circle-btn" component use "currentColor" for color value of svg - small code syntax improvements --- resources/assets/sass/common.scss | 26 ++++++++++-- .../sass/project/problem/landing-page.scss | 42 ++++--------------- resources/lang/en/menu.php | 1 + .../components/share-circle-btn.blade.php | 2 +- .../partials/navbar.blade.php | 5 +++ .../problems/landing-page.blade.php | 8 ++-- 6 files changed, 43 insertions(+), 41 deletions(-) diff --git a/resources/assets/sass/common.scss b/resources/assets/sass/common.scss index 30f2b2a0..786d928d 100644 --- a/resources/assets/sass/common.scss +++ b/resources/assets/sass/common.scss @@ -9,10 +9,10 @@ @import "../../../node_modules/bootstrap-sweetalert/dist/sweetalert.css"; // Supports weights 100-900 -@import '@fontsource-variable/noto-sans'; +@import "@fontsource-variable/noto-sans"; // Supports weights 300-800 -@import '@fontsource-variable/open-sans'; +@import "@fontsource-variable/open-sans"; @import "sidebar"; @@ -25,6 +25,13 @@ @import "common/social"; @import "common/footer"; +:root { + --clr-primary-white: #fdfffc; + --clr-primary-black: #000000 ; + --clr-secondary-light-grey: #e8e9eb; + --clr-secondary-grey: #4d5359; +} + html, body { font-size: 16px; @@ -301,4 +308,17 @@ a.link { height: 35px; margin-right: 5px; } -} \ No newline at end of file +} + +.bg-clr-primary-white { + background-color: var(--clr-primary-white); +} + +.bg-clr-secondary-light-grey { + background-color: var(--clr-secondary-light-grey); +} + +.bg-image-noise { + background-image: url("/images/problems/bg-noise-sample.png"); + background-repeat: repeat; +} diff --git a/resources/assets/sass/project/problem/landing-page.scss b/resources/assets/sass/project/problem/landing-page.scss index bdc0b6c0..3e336d7d 100644 --- a/resources/assets/sass/project/problem/landing-page.scss +++ b/resources/assets/sass/project/problem/landing-page.scss @@ -1,34 +1,9 @@ -@import "bootstrap_4point6_custom_xxl"; - -// Supports weights 100-900 -@import '@fontsource-variable/noto-sans'; - -// Supports weights 300-800 -@import '@fontsource-variable/open-sans'; - -:root { - --clr-page-bg-clr-grey: #fdfffc; - --clr-primary-yellow: #f5ba16; - --primary-white: #fdfffc; - --primary-black: #000000 ; - --secondary-ochre: #b08307; - --clr-secondary-light-grey: #e8e9eb; - --clr-secondary-grey: #4d5359; -} - -#app { - background-color: var(--clr-page-bg-clr-grey); -} +@import "bootstrap_4point6_custom_xxl"; // this page uses custom styles to support one more bootstrap size: xxl from 1260px and UP -.project-problem-page { +#project-problem-page { #problems-overview { - margin-bottom: 3.25rem; - } - - #problems-list { - background-image: url("/images/problems/bg-noise-sample.png"); - background-repeat: repeat; + padding-bottom: 3.25rem; } .project-title { @@ -103,7 +78,7 @@ box-shadow: 0 4px 4px 0 #00000040, 0 4px 4px 0 #00000040; svg { - color: var(--clr-primary-yellow); + color: var(--project-primary-color); } } } @@ -194,6 +169,7 @@ top: 1rem; right: 2rem; background-color: transparent; + color: var(--project-primary-color); &:hover { box-shadow: 0 4px 4px 0 #00000040; @@ -207,7 +183,7 @@ button.cta-btn { width: auto; padding: 1.9rem 4.3rem; - background-color: var(--clr-primary-yellow); + background-color: var(--project-primary-color); border: none; border-radius: 1.5rem; // 21px box-shadow: 0 4px 4px 0 #00000040; @@ -232,10 +208,10 @@ // from "sm" and UP @media (min-width: 576px) { - .project-problem-page { + #project-problem-page { #problems-overview { - margin-bottom: 7.5rem; + padding-bottom: 7.5rem; } .project-title { @@ -263,7 +239,7 @@ // from "md" and UP @media (min-width: 768px) { - .project-problem-page #problems-list h2 { + #project-problem-page #problems-list h2 { margin-top: 7.5rem; } } diff --git a/resources/lang/en/menu.php b/resources/lang/en/menu.php index bbd15af7..a7c2f192 100644 --- a/resources/lang/en/menu.php +++ b/resources/lang/en/menu.php @@ -16,6 +16,7 @@ 'my_account' => 'My Account', 'my_history' => 'My history', 'sign_out' => 'Sign out', + 'the_campaign' => 'The Campaign', ]; diff --git a/resources/views/components/share-circle-btn.blade.php b/resources/views/components/share-circle-btn.blade.php index db6ba085..3be07719 100644 --- a/resources/views/components/share-circle-btn.blade.php +++ b/resources/views/components/share-circle-btn.blade.php @@ -1,6 +1,6 @@ \ No newline at end of file diff --git a/resources/views/crowdsourcing-project/partials/navbar.blade.php b/resources/views/crowdsourcing-project/partials/navbar.blade.php index 23567446..09e2d9af 100644 --- a/resources/views/crowdsourcing-project/partials/navbar.blade.php +++ b/resources/views/crowdsourcing-project/partials/navbar.blade.php @@ -19,6 +19,11 @@ +
+ +
+
+ +
+
+
@@ -202,7 +224,7 @@ class="icheck-input" type="checkbox" name="banner_title" class="form-control" value="{{ old('banner_title') ? old('banner_title') : - $viewModel->project->defaultTranslation->banner_title }}"/> + $viewModel->project->defaultTranslation->banner_title }}" /> {{ $errors->first('banner_title') }}
diff --git a/resources/views/crowdsourcing-project/landing-page.blade.php b/resources/views/crowdsourcing-project/landing-page.blade.php index 190bf96b..0893115d 100644 --- a/resources/views/crowdsourcing-project/landing-page.blade.php +++ b/resources/views/crowdsourcing-project/landing-page.blade.php @@ -2,8 +2,8 @@ @push('css') @endpush diff --git a/resources/views/crowdsourcing-project/problems/landing-page.blade.php b/resources/views/crowdsourcing-project/problems/landing-page.blade.php index f4103006..a3496f8a 100644 --- a/resources/views/crowdsourcing-project/problems/landing-page.blade.php +++ b/resources/views/crowdsourcing-project/problems/landing-page.blade.php @@ -4,7 +4,7 @@ @endpush diff --git a/resources/views/crowdsourcing-project/project-unavailable.blade.php b/resources/views/crowdsourcing-project/project-unavailable.blade.php index 12f6fa55..b493b41e 100644 --- a/resources/views/crowdsourcing-project/project-unavailable.blade.php +++ b/resources/views/crowdsourcing-project/project-unavailable.blade.php @@ -2,9 +2,8 @@ @push('css') @endpush diff --git a/resources/views/loggedin-environment/partials/menu.blade.php b/resources/views/loggedin-environment/partials/menu.blade.php index 2d21abc7..72e93204 100644 --- a/resources/views/loggedin-environment/partials/menu.blade.php +++ b/resources/views/loggedin-environment/partials/menu.blade.php @@ -33,12 +33,12 @@ class="nav-icon fa fa-question-circle "> @endcan @can("manage-platform") - + @endcan @can("manage-users") diff --git a/resources/views/questionnaire/questionnaire-page.blade.php b/resources/views/questionnaire/questionnaire-page.blade.php index 3698cb8f..bb53a2d6 100644 --- a/resources/views/questionnaire/questionnaire-page.blade.php +++ b/resources/views/questionnaire/questionnaire-page.blade.php @@ -6,6 +6,7 @@ @endpush diff --git a/resources/views/questionnaire/thanks_for_responding.blade.php b/resources/views/questionnaire/thanks_for_responding.blade.php index 773c9b08..4814cb2b 100644 --- a/resources/views/questionnaire/thanks_for_responding.blade.php +++ b/resources/views/questionnaire/thanks_for_responding.blade.php @@ -3,9 +3,8 @@ @push('css') @vite('resources/assets/sass/questionnaire/questionnaire-thanks.scss') diff --git a/vite.config.mjs b/vite.config.mjs index 3a47980f..083c0d01 100644 --- a/vite.config.mjs +++ b/vite.config.mjs @@ -14,6 +14,7 @@ export default defineConfig({ watch: { usePolling: true, // Useful for file changes in Docker }, + https: false, }, plugins: [ laravel({