Skip to content

Commit

Permalink
Implementing issue #14
Browse files Browse the repository at this point in the history
  • Loading branch information
zyxist committed Jan 23, 2016
1 parent 1b147b8 commit f6858d8
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/Cantiga/CoreBundle/CantigaCoreBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public function boot()
Workspaces::registerWorkspace('admin', 'Admin workspace', 'admin_dashboard', 'ROLE_ADMIN', 'red');

AppTexts::registerName(CoreTexts::AREA_REQUEST_CREATION_STEP1_TEXT);
AppTexts::registerName(CoreTexts::AREA_REQUEST_NEW_INFO_TEXT);
AppTexts::registerName(CoreTexts::AREA_REQUEST_VERIFICATION_INFO_TEXT);
AppTexts::registerName(CoreTexts::AREA_REQUEST_APPROVED_INFO_TEXT);
AppTexts::registerName(CoreTexts::AREA_REQUEST_REVOKED_INFO_TEXT);
AppTexts::registerName(CoreTexts::AREA_REQUEST_CREATION_STEP2_TEXT);
AppTexts::registerName(CoreTexts::TERMS_OF_USE_TEXT);
AppTexts::registerName(CoreTexts::LOGIN_TEXT);
Expand Down
25 changes: 23 additions & 2 deletions src/Cantiga/CoreBundle/Controller/ProjectAreaRequestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Cantiga\CoreBundle\Api\Controller\ProjectPageController;
use Cantiga\CoreBundle\CoreExtensions;
use Cantiga\CoreBundle\CoreSettings;
use Cantiga\CoreBundle\CoreTexts;
use Cantiga\CoreBundle\Entity\AreaRequest;
use Cantiga\CoreBundle\Entity\Message;
use Cantiga\Metamodel\Exception\ModelException;
Expand Down Expand Up @@ -114,14 +115,15 @@ public function ajaxListAction(Request $request)
/**
* @Route("/{id}/info", name="project_area_request_info")
*/
public function infoAction($id)
public function infoAction($id, Request $request)
{
$action = new InfoAction($this->crudInfo);
$action->slug($this->getSlug());
return $action->run($this, $id, function(AreaRequest $item) {
return $action->run($this, $id, function(AreaRequest $item) use ($request) {
$formModel = $this->extensionPointFromSettings(CoreExtensions::AREA_REQUEST_FORM, CoreSettings::AREA_REQUEST_FORM);
return [
'summary' => $formModel->createSummary(),
'text' => $this->chooseText($item, $request),
'actions' => $this->chooseActionsForState($item),
];
});
Expand Down Expand Up @@ -248,4 +250,23 @@ private function chooseActionsForState(AreaRequest $ar) {
return [];
}
}

private function chooseText(AreaRequest $ar, Request $request)
{
switch($ar->getStatus()) {
case AreaRequest::STATUS_NEW:
$textType = CoreTexts::AREA_REQUEST_NEW_INFO_TEXT;
break;
case AreaRequest::STATUS_VERIFICATION:
$textType = CoreTexts::AREA_REQUEST_VERIFICATION_INFO_TEXT;
break;
case AreaRequest::STATUS_APPROVED:
$textType = CoreTexts::AREA_REQUEST_APPROVED_INFO_TEXT;
break;
case AreaRequest::STATUS_REVOKED:
$textType = CoreTexts::AREA_REQUEST_REVOKED_INFO_TEXT;
break;
}
return $this->getTextRepository()->getTextOrFalse($textType, $request, $this->getActiveProject());
}
}
25 changes: 22 additions & 3 deletions src/Cantiga/CoreBundle/Controller/UserAreaRequestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,17 @@ public function indexAction(Request $request)
/**
* @Route("/{id}/info", name="user_area_request_info")
*/
public function infoAction($id)
public function infoAction($id, Request $request)
{
$action = new InfoAction($this->crudInfo);
return $action->run($this, $id, function(AreaRequest $item) {
return $action->run($this, $id, function(AreaRequest $item) use ($request) {
$settings = $this->getProjectSettings();
$settings->setProject($item->getProject());
$formModel = $this->getExtensionPoints()
->getImplementation(CoreExtensions::AREA_REQUEST_FORM,
$item->getProject()->createExtensionPointFilter()->fromSettings($settings, CoreSettings::AREA_REQUEST_FORM)
);
return ['summary' => $formModel->createSummary()];
return ['summary' => $formModel->createSummary(), 'text' => $this->chooseText($item, $request)];
});
}

Expand Down Expand Up @@ -249,4 +249,23 @@ public function removeAction($id, Request $request)
$action = new RemoveAction($this->crudInfo);
return $action->run($this, $id, $request);
}

private function chooseText(AreaRequest $ar, Request $request)
{
switch($ar->getStatus()) {
case AreaRequest::STATUS_NEW:
$textType = CoreTexts::AREA_REQUEST_NEW_INFO_TEXT;
break;
case AreaRequest::STATUS_VERIFICATION:
$textType = CoreTexts::AREA_REQUEST_VERIFICATION_INFO_TEXT;
break;
case AreaRequest::STATUS_APPROVED:
$textType = CoreTexts::AREA_REQUEST_APPROVED_INFO_TEXT;
break;
case AreaRequest::STATUS_REVOKED:
$textType = CoreTexts::AREA_REQUEST_REVOKED_INFO_TEXT;
break;
}
return $this->getTextRepository()->getTextOrFalse($textType, $request, $ar->getProject());
}
}
4 changes: 4 additions & 0 deletions src/Cantiga/CoreBundle/CoreTexts.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class CoreTexts
{
const AREA_REQUEST_CREATION_STEP1_TEXT = 'cantiga:area-request:step1';
const AREA_REQUEST_CREATION_STEP2_TEXT = 'cantiga:area-request-step2';
const AREA_REQUEST_NEW_INFO_TEXT = 'cantiga:area-request:new';
const AREA_REQUEST_VERIFICATION_INFO_TEXT = 'cantiga:area-request:verification';
const AREA_REQUEST_APPROVED_INFO_TEXT = 'cantiga:area-request:approved';
const AREA_REQUEST_REVOKED_INFO_TEXT = 'cantiga:area-request:revoked';
const TERMS_OF_USE_TEXT = 'cantiga:terms-of-use';
const LOGIN_TEXT = 'cantiga:login';
const DASHBOARD_USER_TEXT = 'cantiga:dashboard:user';
Expand Down
3 changes: 3 additions & 0 deletions src/Cantiga/CoreBundle/Resources/translations/messages.en.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
// Area profile editor
'AreaProfileSaved' => 'The profile of your area has been saved.',

// Project area request
'CustomTextDisplayedToThisRequest' => 'Text displayed under the feedback box in the requests with this status:',

// Project area
'GroupUnassigned' => 'Unassigned',
'CreateAreaText' => 'You can create a new area here, bypassing the area request process (if such a process is enabled in the project settings). No user will be assigned to the area after its creation. You have to do it manually, by choosing the menu option "Membership" in the area information page.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@
'The verification has been started.' => 'Weryfikacja została rozpoczęta.',
'Cannot start the verification for this request.' => 'Nie można zacząć weryfikacji dla tego zgłoszenia.',
'Verifier' => 'Weryfikujący',
'CustomTextDisplayedToThisRequest' => 'Tekst wyświetlany pod oknem rozmowy w zgłoszeniach z tym statusem:',

// Project area
'GroupUnassigned' => 'Nieprzypisana',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@
<div class="col-lg-5 col-xs-12">
{{ macro.chat_box('Feedback' | trans, 'feedback') }}
</div>
{% if custom.text %}
<div class="col-lg-5 col-xs-12">
<div class="box">
<div class="box-body">
<p class="lead">{{'CustomTextDisplayedToThisRequest' | trans }}
{{ custom.text.content | raw }}
</div>
</div>
</div>
{% endif %}
</div>
{% endblock %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@
<div class="col-md-6 col-xs-12">
{{ macro.chat_box('Feedback' | trans, 'feedback') }}
</div>
{% if custom.text %}
<div class="col-md-6 col-xs-12">
<div class="box">
<div class="box-body">
{{ custom.text.content | raw }}
</div>
</div>
</div>
{% endif %}
</div>
{% endblock %}

Expand Down

0 comments on commit f6858d8

Please sign in to comment.