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

Fix assos names #348

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions app/Admin/Controllers/Resource/AssoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ protected function getFields(): array
'shortname' => 'text',
'login' => 'text',
'image' => 'image',
'short_description' => 'text',
'description' => 'textarea',
'type' => AssoType::get(['id', 'name']),
'parent' => Asso::get(['id', 'name']),
Expand Down
4 changes: 2 additions & 2 deletions app/Models/Asso.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Asso extends Model implements CanBeOwner, CanHaveContacts, CanHaveCalendar
];

protected $fillable = [
'name', 'shortname', 'login', 'image', 'description', 'type_id', 'parent_id', 'in_cemetery_at'
'name', 'shortname', 'login', 'image', 'description', 'short_description', 'type_id', 'parent_id', 'in_cemetery_at'
];

protected $hidden = [
Expand All @@ -60,7 +60,7 @@ class Asso extends Model implements CanBeOwner, CanHaveContacts, CanHaveCalendar
];

protected $must = [
'name', 'shortname', 'login', 'image', 'in_cemetery_at', 'deleted_at',
'shortname', 'login', 'image', 'in_cemetery_at', 'deleted_at',
];

// Children in the case of a staged mode display.
Expand Down
6 changes: 6 additions & 0 deletions config/validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
],

// Short association description.
'short_description' => [
'min' => 0,
'max' => 255,
],

// Association description.
'description' => [
'min' => 0,
'max' => 8191,
Expand Down
6 changes: 4 additions & 2 deletions database/factories/AssosFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@

$assoTypeIdentifiers = explode(',', config("seeder.asso.type.identifiers"));
$assoParents = explode(',', config("seeder.asso.parents"));
$shortname = $faker->company();
return [
'id' => Uuid::generate()->string,
'type_id' => AssoType::where('type', $faker->randomElement($assoTypeIdentifiers))->first()->id,
'parent_id' => Asso::where('login', $faker->randomElement($assoParents))->first()->id,
'login' => $faker->regexify('\w{6,30}'),
'shortname' => $faker->company(),
'name' => $faker->catchPhrase(),
'shortname' => $shortname,
'name' => ($faker->boolean(50) ? $shortname.' '.$faker->companySuffix() : null),
'image' => config("seeder.asso.generate_images", false) ? '/images/assos/'.$faker->image('public/images/assos', config('seeder.asso.image_width'), config('seeder.asso.image_height'), null, false) : null ,
'short_description' => $faker->catchPhrase(),
'description' => $faker->realText(400, 2),
'in_cemetery_at' => $faker->boolean(20) ? $faker->dateTimeBetween('-5 years', 'now') : null,
];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

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

class AddShortDescriptionAndChangeNameOfAssosTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('assos', function (Blueprint $table) {
$table->string('name', validation_max('name'))->nullable()->change();
$table->string('short_description', validation_max("short_description"));
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('assos', function (Blueprint $table) {
$table->dropColumn('short_description');
$table->string('name', validation_max('name'))->nullable(false)->change();
});
}
}
16 changes: 13 additions & 3 deletions resources/assets/react/screens/Asso/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,20 @@ class AssoHomeScreen extends React.Component {
<div className="col-md-10" style={{ whiteSpace: 'pre-line' }}>
<h1 className={`title ${color}`} style={{ fontWeight: 'bold' }}>
{asso.shortname}{' '}
<small className="text-muted h4" style={{ fontStyle: 'italic' }}>
{asso.name}
</small>
{asso.name && (
<small className="text-muted h4" style={{ fontStyle: 'italic' }}>
{asso.name}
</small>
)}
</h1>
{asso.short_description && (
<p
className={`${color}`}
style={{ padding: '.5rem', margin: '1rem 0', fontWeight: 'bold' }}
>
{asso.short_description}
</p>
)}
<span className="mt-4">{asso.type && asso.type.description}</span>
<ReactMarkdown className="my-3 text-justify" source={asso.description} />
{asso.in_cemetery_at == null && (
Expand Down
13 changes: 7 additions & 6 deletions resources/assets/react/screens/AssoList.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,13 @@ class AssoListScreen extends React.Component {
.normalize('NFD')
.replace(/[\u0300-\u036f]/g, '')
) ||
regex.test(
name
.toLowerCase()
.normalize('NFD')
.replace(/[\u0300-\u036f]/g, '')
)) &&
(name &&
regex.test(
name
.toLowerCase()
.normalize('NFD')
.replace(/[\u0300-\u036f]/g, '')
))) &&
in_cemetery_at === null
);
}
Expand Down