Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1671 from ojs/hotfix/author-grid-translation
Browse files Browse the repository at this point in the history
Author grid translation
behram authored Nov 25, 2016
2 parents f0548bd + 74eece3 commit 89e5019
Showing 17 changed files with 215 additions and 8 deletions.
4 changes: 3 additions & 1 deletion app/Resources/translations/messages.en.yml
Original file line number Diff line number Diff line change
@@ -1304,6 +1304,8 @@ title.workflow_review_form_edit: 'Edit Review Form'
title.workflow_review_form_new: 'New Review Form'
title.workflow_review_form_show: 'Show Review Form'
title.search_advanced: "Advanced Search"
title.page_sort: 'Sort Pages'
sort.pages: 'Sort Pages'
titleTransliterated: 'Transliterated Title'
titleabbr: 'Abbreviated Title'
titletransliterated: 'Transliterated Title'
@@ -1674,7 +1676,7 @@ deletion.section: 'The section has been removed successfully but its articles pr
review_form.missing_label: 'Label field of one of the elements is missing.'
delete.journal_user: 'Are you sure you want to remove the user from the journal?'
delete.journal_user_role: 'ATTENTION: Are you sure you want to remove this role from yourself?'

upload.full.file.to.issue.fullfile.field: 'Upload issue full file to issue form full file input'

doiRequestTime: 'DOI Request Time'
otherId: 'Other ID'
3 changes: 3 additions & 0 deletions app/Resources/translations/messages.tr.yml
Original file line number Diff line number Diff line change
@@ -1299,6 +1299,8 @@ title.workflow_review_form_edit: 'Değerlendirme Formunu Düzenle'
title.workflow_review_form_new: 'Yeni Değerlendirme Formu'
title.workflow_review_form_show: 'Değerlendirme Formunu Göster'
title.search_advanced: "Gelişmiş Arama"
title.page_sort: 'Sayfaları Sırala'
sort.pages: 'Sayfaları Sırala'
titleTransliterated: 'Başka Alfabede Yazılmış Başlık'
titleabbr: 'Kısaltılmış Başlık'
titletransliterated: 'Başka Alfabede Yazılmış Başlık'
@@ -1674,6 +1676,7 @@ deletion.section: 'Bölüm başarıyla silindi lakin makaleleri bölümlere say
review_form.missing_label: 'Form elemanlarından birisinin etiket alanı boş.'
delete.journal_user: 'Kullanıcıyı dergiden silmek istediğinize emin misiniz?'
delete.journal_user_role: 'DİKKAT: Dergideki bu rolünüz silinecek, emin misiniz?'
upload.full.file.to.issue.fullfile.field: 'Lütfen sayı tam metin dosyasını sayı düzenleme formunda tam metin alanına yükleyin.'

doiRequestTime: 'DOI Talep Tarihi'
otherId: 'Diğer No'
48 changes: 48 additions & 0 deletions src/Ojs/CoreBundle/Params/IssueFileParams.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace Ojs\CoreBundle\Params;

class IssueFileParams
{
const OTHER = 0;
const SUPPLEMENTARY_FILE = 1;
const RESEARCH_METARIALS = 2;
const RESEARCH_RESULTS = 3;
const TRANSCRIPTS = 4;
const DATA_ANALYSIS = 5;
const DATA_SET = 6;
const SOURCE_TEXT = 7;
const PICTURES = 8;
const TABLES = 9;
const COPYRIGHT_TRANSFER_FORM = 10;
const COMPETING_OF_INSTEREST_FILE = 11;

/**
*
* @var array
*/
public static $FILE_TYPES = array(
self::OTHER => 'other',
self::SUPPLEMENTARY_FILE => 'workflow.supp_file',
self::RESEARCH_METARIALS => 'workflow.research_materials',
self::RESEARCH_RESULTS => 'workflow.research_results',
self::TRANSCRIPTS => 'transcripts',
self::DATA_ANALYSIS => 'article.data.analysis',
self::DATA_SET => 'dataset',
self::SOURCE_TEXT => 'source.text',
self::PICTURES => 'pictures',
self::TABLES => 'tables',
self::COPYRIGHT_TRANSFER_FORM => 'copyright.transfer.form',
self::COMPETING_OF_INSTEREST_FILE => 'competing.of.interest.file',
);

/**
*
* @param integer $typeNum
* @return string
*/
public static function fileType($typeNum)
{
return isset(self::$FILE_TYPES[$typeNum]) ? self::$FILE_TYPES[$typeNum] : null;
}
}
9 changes: 7 additions & 2 deletions src/Ojs/JournalBundle/Controller/BoardController.php
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@
use Ojs\JournalBundle\Event\ListEvent;
use Ojs\JournalBundle\Form\Type\BoardMemberType;
use Ojs\JournalBundle\Form\Type\BoardType;
use Ojs\UserBundle\Entity\User;
use Symfony\Component\Form\Form;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
@@ -468,10 +469,14 @@ public function otoGenerateAction(Request $request)
$em = $this->getDoctrine()->getManager();
$translator = $this->get('translator');

$getEditorUsers = $em->getRepository('OjsUserBundle:User')->findUsersByJournalRole(
['ROLE_EDITOR']
$getEditorUsers = $em->getRepository(User::class)->findUsersByJournalRole(
['ROLE_EDITOR', 'ROLE_CO_EDITOR', 'ROLE_SECTION_EDITOR']
);

usort($getEditorUsers, function ($a, $b){
return strcmp($a->getLastName(), $b->getLastName());
});

$board = new Board();
$board->setJournal($journal);
foreach($this->getParameter('locale_support') as $localeCode){
43 changes: 43 additions & 0 deletions src/Ojs/JournalBundle/Controller/JournalPageController.php
Original file line number Diff line number Diff line change
@@ -51,6 +51,49 @@ public function indexAction(Request $request)
return $grid->getGridResponse('OjsJournalBundle:JournalPage:index.html.twig');
}

/**
* @param Request $request
* @return Response
*/
public function sortAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$journal = $this->get('ojs.journal_service')->getSelectedJournal();
$pages = $em->getRepository(JournalPage::class)->findAll();
usort($pages, function($a, $b){
return $a->getPageOrder() > $b->getPageOrder();
});

$sortData = [];
foreach ($pages as $page){
$sortData[$page->getId()] = $page->getPageOrder();
}

if($request->getMethod() == 'POST' && $request->request->has('sortData')){
$sortData = json_decode($request->request->get('sortData'));
foreach ($sortData as $pageId => $order){
foreach ($pages as $page){
if($page->getId() == $pageId){
$page->setPageOrder($order);
$em->persist($page);
}
}
}
$em->flush();
$this->successFlashBag('successful.update');

return $this->redirectToRoute('ojs_journal_page_sort', [
'journalId' => $journal->getId(),
]);
}

return $this->render('OjsJournalBundle:JournalPage:sort.html.twig', [
'pages' => $pages,
'jsonSortData' => json_encode($sortData),
]
);
}

/**
* Displays a form to create a new JournalPage entity.
*/
5 changes: 3 additions & 2 deletions src/Ojs/JournalBundle/Entity/ArticleAuthor.php
Original file line number Diff line number Diff line change
@@ -29,14 +29,15 @@ class ArticleAuthor implements Translatable
/**
* @var integer
* @Expose
* @GRID\Column(title="author.order",field="authorOrder")
*/
private $authorOrder;

/**
* @var Author
* @Expose
* @GRID\Column(title="firstName",field="author.firstName")
* @GRID\Column(title="lastName",field="author.lastName")
* @GRID\Column(title="author.firstname",field="author.firstName")
* @GRID\Column(title="author.lastname",field="author.lastName")
* @Expose
*/
private $author;
7 changes: 7 additions & 0 deletions src/Ojs/JournalBundle/Entity/IssueFile.php
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
use Ojs\CoreBundle\Entity\GenericEntityTrait;
use Prezent\Doctrine\Translatable\Annotation as Prezent;
use Prezent\Doctrine\Translatable\Entity\AbstractTranslatable;
use Ojs\CoreBundle\Annotation\Display;

/**
* IssueFile
@@ -22,18 +23,23 @@ class IssueFile extends AbstractTranslatable
/**
* @var integer
* @GRID\Column(title="id")
* @JMS\Expose
*/
protected $id;
/**
* @Prezent\Translations(targetEntity="Ojs\JournalBundle\Entity\IssueFileTranslation")
* @JMS\Expose
*/
protected $translations;
/**
* @var integer
* @JMS\Expose
*/
private $type;
/**
* @var string
* @JMS\Expose
* @Display\File(path="issuefiles")
*/
private $file;
/**
@@ -56,6 +62,7 @@ class IssueFile extends AbstractTranslatable
/**
* @var string
* @GRID\Column(title="issuefile.langcode")
* @JMS\Expose
*/
private $langCode;
/**
24 changes: 24 additions & 0 deletions src/Ojs/JournalBundle/Entity/JournalPage.php
Original file line number Diff line number Diff line change
@@ -53,6 +53,11 @@ class JournalPage extends AbstractTranslatable implements JournalItemInterface
*/
private $visible;

/**
* @var int
*/
private $pageOrder = 0;

/**
* Constructor
*/
@@ -226,6 +231,25 @@ public function setJournal(Journal $journal)
return $this;
}

/**
* @return int
*/
public function getPageOrder(): int
{
return $this->pageOrder;
}

/**
* @param int $pageOrder
* @return $this
*/
public function setPageOrder(int $pageOrder)
{
$this->pageOrder = $pageOrder;

return $this;
}

/**
* @return string
*/
3 changes: 2 additions & 1 deletion src/Ojs/JournalBundle/Form/Type/IssueFileType.php
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@

use Ojs\CoreBundle\Form\Type\JournalBasedTranslationsType;
use Ojs\CoreBundle\Params\ArticleFileParams;
use Ojs\CoreBundle\Params\IssueFileParams;
use Ojs\JournalBundle\Entity\IssueFile;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
@@ -27,7 +28,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'choice',
[
'label' => 'issuefile.type',
'choices' => ArticleFileParams::$FILE_TYPES,
'choices' => IssueFileParams::$FILE_TYPES,
])
->add('version', null, ['label' => 'issuefile.version'])
->add('langCode', JournalLangCodeType::class,
Original file line number Diff line number Diff line change
@@ -21,6 +21,11 @@ Ojs\JournalBundle\Entity\JournalPage:
visible:
type: boolean
nullable: true
pageOrder:
type: integer
nullable: false
options:
default: 0
slug:
type: string
length: 255
Original file line number Diff line number Diff line change
@@ -2,6 +2,10 @@ ojs_journal_page_index:
path: /{journalId}/page
defaults: { _controller: "OjsJournalBundle:JournalPage:index" }

ojs_journal_page_sort:
path: /{journalId}/page/sort
defaults: { _controller: "OjsJournalBundle:JournalPage:sort" }

ojs_journal_page_new:
path: /{journalId}/page/new
defaults: { _controller: "OjsJournalBundle:JournalPage:new" }
@@ -27,4 +31,4 @@ ojs_journal_page_update:
ojs_journal_page_delete:
path: /{journalId}/page/{id}/delete
defaults: { _controller: "OjsJournalBundle:JournalPage:delete" }
methods: [DELETE]
methods: [DELETE]
Original file line number Diff line number Diff line change
@@ -18,6 +18,9 @@
</ul>

<h1>{{ 'title.issue_files'|trans }}</h1>
<div class="alert alert-warning">
{{ 'upload.full.file.to.issue.fullfile.field'|trans }}
</div>
{% if is_granted('CREATE', selectedJournal(), 'issues') %}
<a href="{{ path('ojs_journal_issue_file_new', {'issueId': issue.id, 'journalId': selectedJournal().id}) }}" class="btn btn-success">
{{ "c"|trans }}
Original file line number Diff line number Diff line change
@@ -18,6 +18,9 @@
{{ "create"|trans }}
</a>
{% endif %}
<a href="{{ path('ojs_journal_page_sort', {'journalId': selectedJournal().id}) }}" class="btn btn-primary">
{{ "sort.pages"|trans }}
</a>

<hr>
{{ grid(grid) }}
38 changes: 38 additions & 0 deletions src/Ojs/JournalBundle/Resources/views/JournalPage/sort.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{% extends '::ojsbase.html.twig' %}
{% block title %}{{ 'title.page_sort'|trans }} {{ parent() }}{% endblock %}

{% block breadcrumb %}
{% set list = [
{'link': path('ojs_journal_dashboard_index', {journalId: selectedJournal().id}), 'title': 'dashboard'|trans},
{'link': path('ojs_journal_page_index', {'journalId': selectedJournal().id}),'title': 'title.pages'|trans},
{'title': 'title.page_sort'|trans}
] %}
{{ breadcrumb(list) }}
{% endblock %}

{% block body -%}
<h1>{{ 'sort.pages'|trans }}</h1>
{{ include('::flashbag.html.twig') }}
<div class="row">
<form method="post" action="{{ path('ojs_journal_page_sort', {'journalId': selectedJournal().id}) }}">
<div class="col-sm-4 col-sm-push-4 well">
<ul id="sortable" class="list-group">
<input type="hidden" value='{{ jsonSortData|raw }}' name="sortData"/>
{% for page in pages %}
<li class="list-group-item" data-id="{{ page.id }}">
<h5>
<i class="fa fa-arrows-v" aria-hidden="true"></i>
{{ page.title }}
</h5>
</li>
{% endfor %}
</ul>
<button class="btn btn-primary pull-right">
{{ 'update'|trans }}
</button>
</div>
</form>
</div>

{{ actions({'back': {'href': path('ojs_journal_page_index', {'journalId': selectedJournal().id})}}) }}
{% endblock %}
4 changes: 3 additions & 1 deletion src/Ojs/SiteBundle/Controller/JournalController.php
Original file line number Diff line number Diff line change
@@ -244,7 +244,9 @@ public function journalIndexAction(Request $request, $slug, $isJournalHosting=fa
}

$data['posts'] = $em->getRepository('OjsJournalBundle:JournalPost')->findBy(['journal' => $journal]);
$data['journalPages'] = $em->getRepository('OjsJournalBundle:JournalPage')->findBy(['journal' => $journal]);
$data['journalPages'] = $em->getRepository('OjsJournalBundle:JournalPage')->findBy([
'journal' => $journal
], ['pageOrder' => 'ASC']);

if($isJournalHosting){
$data['years'] = $this->setupIssuesURIsByYear(array_slice($issueRepo->getByYear($journal), 0, 5, true),true);
4 changes: 4 additions & 0 deletions web/assets/app/css/app.css
Original file line number Diff line number Diff line change
@@ -914,4 +914,8 @@ label.required:before {

.isJournalHosting .language_selector{
list-style:none;
}

#sortable li{
cursor: move;
}
14 changes: 14 additions & 0 deletions web/assets/app/js/common.js
Original file line number Diff line number Diff line change
@@ -251,6 +251,20 @@ $(document).ready(function () {
});

$('.grid-search-reset').parent().remove();

$( "#sortable" ).sortable({
update: function(event, ui) {
var item = ui.item;
var jsonData = {};
$.each(ui.item.parent().find('li'), function(index, value){
var id = $(value).data('id');
jsonData[id] = index+1;
});
var jsonDataInput = item.parent().find('input');
jsonDataInput.val(JSON.stringify(jsonData));
}
});
$( "#sortable" ).disableSelection();
});
// Returns a random integer between min (included) and max (included)
// Using Math.round() will give you a non-uniform distribution!

0 comments on commit 89e5019

Please sign in to comment.