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

Feature: Top Companies #600

Open
wants to merge 1 commit into
base: master
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
23 changes: 21 additions & 2 deletions module/Organizations/config/module.config.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
<?php

/**
* @author Mathias Weitz <[email protected]>
* @author Mathias Gelhausen <[email protected]>
*/

declare(strict_types=1);

namespace Organizations;

use Laminas\ServiceManager\Factory\InvokableFactory;

return [
'doctrine' => [
'driver' => [
Expand Down Expand Up @@ -51,7 +58,8 @@
'factories' => [
'Organizations/InviteEmployee' => \Organizations\Factory\Controller\InviteEmployeeControllerFactory::class,
'Organizations/Index' => 'Organizations\Factory\Controller\IndexControllerFactory',
'Organizations/Profile' => 'Organizations\Factory\Controller\ProfileControllerFactory'
'Organizations/Profile' => 'Organizations\Factory\Controller\ProfileControllerFactory',
Controller\FeaturedCompaniesController::class => Controller\FeaturedCompaniesControllerFactory::class,
]
],

Expand All @@ -74,6 +82,7 @@
'organizations/error/invite' => __DIR__ . '/../view/error/invite.phtml',
'organizations/mail/invite-employee' => __DIR__ . '/../view/mail/invite-employee.phtml',
'organizations/form/workflow-fieldset' => __DIR__ . '/../view/form/workflow-fieldset.phtml',
'organizations/form/featured-companies-filter-radio' => __DIR__ . '/../view/form/featured-companies-filter-radio.phtml',
'organizations/profile/disabled' => __DIR__ . '/../view/organizations/profile/disabled.phtml',
],
// Where to look for view templates not mapped above
Expand Down Expand Up @@ -104,6 +113,7 @@
'Organizations/Image' => \Organizations\Form\LogoImageFactory::class,
'Organizations/EmployeesFieldset' => 'Organizations\Factory\Form\EmployeesFieldsetFactory',
'Organizations/EmployeeFieldset' => 'Organizations\Factory\Form\EmployeeFieldsetFactory',
Form\Element\FeaturedCompaniesFilterRadio::class => InvokableFactory::class,
]
],

Expand Down Expand Up @@ -175,6 +185,11 @@
'route/lang/organizations/profileDetail'
],
],
'admin' => [
'allow' => [
'route/lang/organizations/featured',
],
],
],
'assertions' => [
'invokables' => [
Expand Down Expand Up @@ -204,9 +219,13 @@
'label' => /*@translate*/ 'Insert',
'route' => 'lang/organizations/edit',
],
'featured' => [
'label' => /*@translate*/ 'Featured Companies',
'route' => 'lang/organizations/featured',
'resource' => 'route/lang/organizations/featured',
],
],
],

],
],

Expand Down
14 changes: 14 additions & 0 deletions module/Organizations/config/router.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
* @copyright https://yawik.org/COPYRIGHT.php
* @license MIT
*/

declare(strict_types=1);

namespace Organizations;

return array(
'router' => array(
'routes' => array(
Expand Down Expand Up @@ -112,6 +117,15 @@
),
),
),
'featured' => [
'type' => 'Literal',
'options' => [
'route' => '/featured',
'defaults' => [
'controller' => Controller\FeaturedCompaniesController::class
]
],
],
),
),
'my-organization' => array(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

/**
* YAWIK
*
* @see https://github.com/cross-solution/YAWIK for the canonical source repository
* @copyright https://github.com/cross-solution/YAWIK/blob/master/COPYRIGHT
* @license https://github.com/cross-solution/YAWIK/blob/master/LICENSE
*/

declare(strict_types=1);

namespace Organizations\Controller;

use Laminas\Mvc\Controller\AbstractActionController;
use Organizations\Repository\Organization;

/**
* TODO: description
*
* @author Mathias Gelhausen
* TODO: write tests
*/
class FeaturedCompaniesController extends AbstractActionController
{
private $repository;

public function __construct(Organization $repository)
{
$this->repository = $repository;
}

public function indexAction()
{

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

/**
* YAWIK
*
* @see https://github.com/cross-solution/YAWIK for the canonical source repository
* @copyright https://github.com/cross-solution/YAWIK/blob/master/COPYRIGHT
* @license https://github.com/cross-solution/YAWIK/blob/master/LICENSE
*/

declare(strict_types=1);

namespace Organizations\Controller;

use Psr\Container\ContainerInterface;

/**
* Factory for \Organizations\Controller\FeaturedCompaniesController
*
* @author Mathias Gelhausen
* TODO: write tests
*/
class FeaturedCompaniesControllerFactory
{
public function __invoke(
ContainerInterface $container,
string $requestedName,
?array $options = null
): FeaturedCompaniesController {
return new FeaturedCompaniesController(
$container->get('repositories')->get('Organizations')
);
}
}
4 changes: 3 additions & 1 deletion module/Organizations/src/Controller/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Laminas\I18n\Translator\TranslatorInterface;
use Laminas\Mvc\Controller\AbstractActionController;
use Laminas\View\Model\ViewModel;
use Organizations\Form\FeaturedCompaniesSearchForm;
use Organizations\ImageFileCache\Manager as ImageFileCacheManager;

/**
Expand Down Expand Up @@ -90,10 +91,11 @@ public function indexAction()
'as' => 'organizations',
'params' => [
'type' => 'profile',
'featured' => $this->auth()->isAdmin() && (bool) $this->params('featured'),
]
],
'form' => [
'Core/Search',
$this->auth()->isAdmin() ? FeaturedCompaniesSearchForm::class : 'Core/Search',
'as' => 'form',
]
]);
Expand Down
38 changes: 38 additions & 0 deletions module/Organizations/src/Entity/FeaturedCompanySettings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

/**
* YAWIK
*
* @see https://github.com/cross-solution/YAWIK for the canonical source repository
* @copyright https://github.com/cross-solution/YAWIK/blob/master/COPYRIGHT
* @license https://github.com/cross-solution/YAWIK/blob/master/LICENSE
*/

declare(strict_types=1);

namespace Organizations\Entity;

use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;

/**
* TODO: description
*
* @ODM\EmbeddedDocument
*
* @author Mathias Gelhausen
* TODO: write tests
*/
class FeaturedCompanySettings
{
/**
* @ODM\Field(type="bool")
* @var bool
*/
private $isFeaturedCompany = false;

/**
* @ODM\Field(type="int")
* @var int
*/
private $priority = 1;
}
27 changes: 27 additions & 0 deletions module/Organizations/src/Entity/Organization.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ class Organization extends BaseEntity implements
*/
protected $profileSetting;

/**
* @ODM\Field(type="bool")
* @var bool
*/
protected $isFeaturedCompany = false;


/**
* @return string
*/
Expand Down Expand Up @@ -858,4 +865,24 @@ public function setWorkflowSettings($workflowSettings)

return $this;
}

/**
* Get isFeaturedCompany
*
* @return bool
*/
public function isFeaturedCompany(): bool
{
return $this->isFeaturedCompany;
}

/**
* Set isFeaturedCompany
*
* @param bool $isFeaturedCompany
*/
public function setIsFeaturedCompany(bool $isFeaturedCompany): void
{
$this->isFeaturedCompany = $isFeaturedCompany;
}
}
30 changes: 30 additions & 0 deletions module/Organizations/src/Entity/ProfileSettings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/**
* YAWIK
*
* @see https://github.com/cross-solution/YAWIK for the canonical source repository
* @copyright https://github.com/cross-solution/YAWIK/blob/master/COPYRIGHT
* @license https://github.com/cross-solution/YAWIK/blob/master/LICENSE
*/

declare(strict_types=1);

namespace Organizations\Entity;

use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;

/**
* TODO: description
*
* @ODM\EmbeddedDocument
*
* @author Mathias Gelhausen
* TODO: write tests
*/
class ProfileSettings
{
private $type;

private $isPrimeCompany;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

/**
* YAWIK
*
* @see https://github.com/cross-solution/YAWIK for the canonical source repository
* @copyright https://github.com/cross-solution/YAWIK/blob/master/COPYRIGHT
* @license https://github.com/cross-solution/YAWIK/blob/master/LICENSE
*/

declare(strict_types=1);

namespace Organizations\Form\Element;

use Core\Form\ViewPartialProviderInterface;
use Core\Form\ViewPartialProviderTrait;
use Laminas\Form\Element\Radio;

/**
* TODO: description
*
* @author Mathias Gelhausen
* TODO: write tests
*/
class FeaturedCompaniesFilterRadio extends Radio implements ViewPartialProviderInterface
{
use ViewPartialProviderTrait;

private $defaultPartial = 'organizations/form/featured-companies-filter-radio';

public function init()
{
$this->setName('featured');
$this->setValueOptions([
'none' => /*@translate*/ 'All',
'on' => /*@translate*/ 'Featured',
'off' => /*@translate*/ 'Not Featured',
]);
$this->setAttributes([
'value' => 'none',
'data-submit-on-change' => 'true'
]);
}
}
49 changes: 49 additions & 0 deletions module/Organizations/src/Form/FeaturedCompaniesSearchForm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

/**
* YAWIK
*
* @see https://github.com/cross-solution/YAWIK for the canonical source repository
* @copyright https://github.com/cross-solution/YAWIK/blob/master/COPYRIGHT
* @license https://github.com/cross-solution/YAWIK/blob/master/LICENSE
*/

declare(strict_types=1);

namespace Organizations\Form;

use Core\Form\SearchForm;
use Organizations\Form\Element\FeaturedCompaniesFilterRadio;

/**
* TODO: description
*
* @author Mathias Gelhausen
* TODO: write tests
*/
class FeaturedCompaniesSearchForm extends SearchForm
{

public function init()
{
$this->setName($this->getOption('name') ?: 'searchform');

$this->addTextElement(
$this->getOption('text_name') ?: 'q',
$this->getOption('text_label') ?: /*@translate*/ 'Search',
$this->getOption('text_placeholder') ?: /*@translate*/ 'Search query',
$this->getOption('text_span') ?: 12,
50,
true
);

$this->add([
'type' => FeaturedCompaniesFilterRadio::class
]);

$this->addButton(/*@translate*/ 'Search', -1000, 'submit');
$this->addButton(/*@translate*/ 'Clear', -1001, 'reset');

$this->addElements();
}
}
Loading