Skip to content

Commit

Permalink
Merge pull request #106 from scify/master
Browse files Browse the repository at this point in the history
Project landing page button text color
  • Loading branch information
PavlosIsaris authored Oct 15, 2024
2 parents 0cd38a7 + 6a7026c commit 0d6b1d3
Show file tree
Hide file tree
Showing 37 changed files with 1,042 additions and 171 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,10 @@ public function populateInitialValuesForProjectIfNotSet(CrowdSourcingProject $pr

public function populateInitialColorValuesForProjectIfNotSet(CrowdSourcingProject $project): CrowdSourcingProject {
if (!$project->lp_primary_color) {
$project->lp_primary_color = '#707070';
$project->lp_primary_color = '#0069d9';
}
if (!$project->lp_btn_text_color_theme) {
$project->lp_btn_text_color_theme = 'light';
}

return $project;
Expand Down
15 changes: 15 additions & 0 deletions app/BusinessLogicLayer/lkp/QuestionnaireTypeLkp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace App\BusinessLogicLayer\lkp;

class QuestionnaireTypeLkp {
public const MAIN_QUESTIONNAIRE = 1;
public const FEEDBACK_QUESTIONNAIRE = 2;

public static function GetAllTypeIds(): array {
return [
self::MAIN_QUESTIONNAIRE,
self::FEEDBACK_QUESTIONNAIRE,
];
}
}
5 changes: 4 additions & 1 deletion app/Models/CrowdSourcingProject/CrowdSourcingProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* @property string $lp_questionnaire_img_path
* @property int $lp_show_speak_up_btn
* @property string $lp_primary_color
* @property string $lp_btn_text_color_theme
* @property int $should_send_email_after_questionnaire_response
* @property int $display_landing_page_banner
*/
Expand All @@ -49,13 +50,15 @@ class CrowdSourcingProject extends Model {
/**
* The attributes that are mass assignable.
*
* Note: in the lp_* fields, lp stands for landing page
*
* @var array
*/
protected $fillable = [
'slug', 'external_url', 'img_path',
'logo_path', 'user_creator_id', 'language_id', 'status_id',
'sm_featured_img_path', 'lp_questionnaire_img_path',
'lp_show_speak_up_btn', 'lp_primary_color',
'lp_show_speak_up_btn', 'lp_primary_color', 'lp_btn_text_color_theme',
'should_send_email_after_questionnaire_response',
'display_landing_page_banner',
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
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;
use Illuminate\Database\Eloquent\SoftDeletes;

class CrowdSourcingProjectProblem extends Model {
use Compoships;
use HasFactory;
use SoftDeletes;

protected $table = 'crowd_sourcing_project_problems';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function definition() {
'lp_questionnaire_img_path' => $this->faker->imageUrl(),
'lp_show_speak_up_btn' => $this->faker->boolean,
'lp_primary_color' => $this->faker->hexColor,
'lp_btn_text_color_theme' => $this->faker->hexColor,
'should_send_email_after_questionnaire_response' => $this->faker->boolean,
'display_landing_page_banner' => $this->faker->boolean,
'img_path' => $this->faker->imageUrl(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Database\Factories\CrowdSourcingProject\Problem;

use App\BusinessLogicLayer\lkp\CrowdSourcingProjectProblemStatusLkp;
use App\Models\CrowdSourcingProject\Problem\CrowdSourcingProjectProblem;
use Illuminate\Database\Eloquent\Factories\Factory;

class CrowdSourcingProjectProblemFactory extends Factory {
protected $model = CrowdSourcingProjectProblem::class;

public function definition() {
return [
'project_id' => 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(),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Database\Factories\CrowdSourcingProject\Problem;

use App\Models\CrowdSourcingProject\Problem\CrowdSourcingProjectProblemTranslation;
use Illuminate\Database\Eloquent\Factories\Factory;

class CrowdSourcingProjectProblemTranslationFactory extends Factory {
protected $model = CrowdSourcingProjectProblemTranslation::class;

public function definition() {
return [
'problem_id' => 1,
'language_id' => 6,
'title' => $this->faker->sentence,
'description' => $this->faker->paragraph,
];
}
}
6 changes: 4 additions & 2 deletions database/factories/Questionnaire/QuestionnaireFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Database\Factories\Questionnaire;

use App\BusinessLogicLayer\lkp\QuestionnaireStatusLkp;
use App\BusinessLogicLayer\lkp\QuestionnaireTypeLkp;
use App\Models\Questionnaire\Questionnaire;
use Illuminate\Database\Eloquent\Factories\Factory;

Expand All @@ -12,8 +14,8 @@ public function definition() {
return [
'project_id' => 1,
'prerequisite_order' => 1,
'status_id' => 1,
'type_id' => 1,
'status_id' => QuestionnaireStatusLkp::DRAFT,
'type_id' => QuestionnaireTypeLkp::MAIN_QUESTIONNAIRE,
'default_language_id' => 1,
'goal' => 10,
'questionnaire_json' => json_encode([
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void {
Schema::table('crowd_sourcing_project_problems', function (Blueprint $table) {
$table->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) {});
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void {
Schema::table('crowd_sourcing_projects', function (Blueprint $table) {
$table->string('lp_btn_text_color_theme')->after('lp_primary_color')->default('light')->nullable(false);
});
}

/**
* Reverse the migrations.
*/
public function down(): void {
Schema::table('crowd_sourcing_projects', function (Blueprint $table) {
//
});
}
};
5 changes: 5 additions & 0 deletions database/seeders/AirQualityProjectSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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) {
Expand Down
9 changes: 1 addition & 8 deletions database/seeders/CrowdSourcingProjectColorsSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

namespace Database\Seeders;

use App\Models\CrowdSourcingProject\CrowdSourcingProject;
use App\Repository\CrowdSourcingProject\CrowdSourcingProjectColorsRepository;
use Illuminate\Database\Seeder;

class CrowdSourcingProjectColorsSeeder extends Seeder {
protected $crowdSourcingProjectColorsRepository;
protected CrowdSourcingProjectColorsRepository $crowdSourcingProjectColorsRepository;

public function __construct(CrowdSourcingProjectColorsRepository $crowdSourcingProjectColorsRepository) {
$this->crowdSourcingProjectColorsRepository = $crowdSourcingProjectColorsRepository;
Expand Down Expand Up @@ -76,11 +75,5 @@ public function run() {
if (app()->environment() !== 'testing') {
echo "\nDefault colors were created.\n";
}

$projects = CrowdSourcingProject::all();
foreach ($projects as $project) {
$project->lp_primary_color = '#707070';
$project->save();
}
}
}
6 changes: 6 additions & 0 deletions database/seeders/CrowdSourcingProjectProblemSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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) {
Expand Down
9 changes: 6 additions & 3 deletions database/seeders/DefaultProjectSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public function run() {
'user_creator_id' => 1,
'language_id' => 6,
'should_send_email_after_questionnaire_response' => 1,
'lp_primary_color' => '#707070',
'lp_primary_color' => '#0069d9',
'lp_btn_text_color_theme' => '#212529',
'lp_questionnaire_image_path' => '/images/projects/european-elections/logo.webp',
'lp_show_speak_up_btn' => 1,
'sm_featured_img_path' => '/images/projects/european-elections/logo.webp',
Expand All @@ -52,7 +53,8 @@ public function run() {
'user_creator_id' => 1,
'language_id' => 6,
'should_send_email_after_questionnaire_response' => 1,
'lp_primary_color' => '#707070',
'lp_primary_color' => '#0069d9',
'lp_btn_text_color_theme' => '#212529',
'lp_questionnaire_image_path' => '/images/projects/european-democracy/logo.webp',
'lp_show_speak_up_btn' => 1,
'sm_featured_img_path' => '/images/projects/european-democracy/logo.webp',
Expand All @@ -68,7 +70,8 @@ public function run() {
'user_creator_id' => 1,
'language_id' => 6,
'should_send_email_after_questionnaire_response' => 1,
'lp_primary_color' => '#707070',
'lp_primary_color' => '#0069d9',
'lp_btn_text_color_theme' => '#212529',
'lp_questionnaire_image_path' => '/images/projects/european-democracy/logo.webp',
'lp_show_speak_up_btn' => 1,
'sm_featured_img_path' => '/images/projects/european-democracy/logo.webp',
Expand Down
5 changes: 3 additions & 2 deletions database/seeders/QuestionnaireSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Database\Seeders;

use App\BusinessLogicLayer\lkp\QuestionnaireTypeLkp;
use App\Repository\CrowdSourcingProject\CrowdSourcingProjectQuestionnaireRepository;
use App\Repository\Questionnaire\QuestionnaireLanguageRepository;
use App\Repository\Questionnaire\QuestionnaireRepository;
Expand Down Expand Up @@ -30,7 +31,7 @@ public function run() {
'id' => 1,
'project_id' => 1,
'type_id' => 1,
'status_id' => 2,
'status_id' => QuestionnaireTypeLkp::MAIN_QUESTIONNAIRE,
'default_language_id' => 6,
'goal' => 100,
'max_votes_num' => 10,
Expand All @@ -44,7 +45,7 @@ public function run() {
'id' => 2,
'project_id' => 2,
'type_id' => 1,
'status_id' => 2,
'status_id' => QuestionnaireTypeLkp::MAIN_QUESTIONNAIRE,
'default_language_id' => 6,
'goal' => 50,
'max_votes_num' => 5,
Expand Down
5 changes: 3 additions & 2 deletions database/seeders/QuestionnaireTypesSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

namespace Database\Seeders;

use App\BusinessLogicLayer\lkp\QuestionnaireTypeLkp;
use App\Models\Questionnaire\QuestionnaireType;
use Illuminate\Database\Seeder;

class QuestionnaireTypesSeeder extends Seeder {
public function run() {
$questionnaire_types = [
['id' => 1, 'name' => 'Main Questionnaire | The questionnaire the users are asked to respond for a project'],
['id' => 2, 'name' => 'Feedback Questionnaire | The quality assessment questionnaire. User are invited to respond after they have responded to the Main questionnaire'],
['id' => QuestionnaireTypeLkp::MAIN_QUESTIONNAIRE, 'name' => 'Main Questionnaire | The questionnaire the users are asked to respond for a project'],
['id' => QuestionnaireTypeLkp::FEEDBACK_QUESTIONNAIRE, 'name' => 'Feedback Questionnaire | The quality assessment questionnaire. User are invited to respond after they have responded to the Main questionnaire'],
];

foreach ($questionnaire_types as $questionnaire_type) {
Expand Down
Loading

0 comments on commit 0d6b1d3

Please sign in to comment.