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

Feat/hkd 6/integration #661

Draft
wants to merge 46 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
0199630
feat: create Translator role
gabrielfs7 Sep 4, 2024
556b01c
chore: add metadata for translations
shpran Sep 5, 2024
40a4b58
chore: move props to tao-core
shpran Sep 5, 2024
e9f3c54
chore: add domains for new proprs
shpran Sep 5, 2024
5db6376
feat: hide translations buttons based on feature flag
gabrielfs7 Sep 9, 2024
89df5ec
chore: use form modifiers for edit instance form
shpran Sep 9, 2024
261be7a
chore: rename modifiers
shpran Sep 10, 2024
8ab8e3a
chore: use proxies instead of manager
shpran Sep 10, 2024
ffd0fbf
chore: fix cs
shpran Sep 10, 2024
260e993
chore: add composer dependency
gabrielfs7 Sep 11, 2024
8fcde3c
chore: add event listener to set translation type
shpran Sep 11, 2024
b292ede
chore: register listener
shpran Sep 11, 2024
f79dfd5
chore: add missing dependency for clone
gabrielfs7 Sep 12, 2024
0f0ef05
chore: only do translations over tao-core extension
gabrielfs7 Sep 12, 2024
6ff36eb
chore: use direct event class, add unit test
shpran Sep 12, 2024
dc18c3f
chore: fix cs
shpran Sep 13, 2024
62fd7a0
chore: default values during item creation
shpran Sep 13, 2024
6a84eae
Merge pull request #660 from oat-sa/feat/ADF-1779/add-translator-role
gabrielfs7 Sep 13, 2024
d6ccd11
chore: convert values to string
shpran Sep 13, 2024
298d0fa
chore: update dependencies
gabrielfs7 Sep 16, 2024
af98194
chore: use standard feature flag name
gabrielfs7 Sep 16, 2024
d35d335
chore: add proper endpoint
gabrielfs7 Sep 16, 2024
d0255db
chore: add new metadata to link original resource
gabrielfs7 Sep 18, 2024
5b86766
fix: set the right icon for the Translate button
jsconan Sep 18, 2024
7378a93
chore: add new form modifier, remove type from props
shpran Sep 18, 2024
07b5a9d
Merge pull request #662 from oat-sa/feature/ADF-1787/translatable-test
gabrielfs7 Sep 19, 2024
a594419
chore: fix unit tests
shpran Sep 19, 2024
59fb43f
chore: fix unit tests
shpran Sep 19, 2024
9e22161
feat: implement the translateItem action
jsconan Sep 19, 2024
d6d4e9d
Merge branch 'feat/HKD-6/integration' into feature/ADF-1782/translati…
jsconan Sep 19, 2024
1247942
chore: attach event manager
gabrielfs7 Sep 19, 2024
06e3ea4
chore: fixed test
gabrielfs7 Sep 19, 2024
d1aeb24
feat: add action to open the authoring from a translation
jsconan Sep 19, 2024
f94d4fb
chore: add missing ontology mapping
gabrielfs7 Sep 20, 2024
9ab2384
Merge branch 'feat/HKD-6/integration' into feature/ADF-1782/translati…
jsconan Sep 23, 2024
3ead0d7
Merge pull request #663 from oat-sa/feature/ADF-1782/translation-list-ui
jsconan Sep 24, 2024
dd5cfe0
feat: add extra parameters to the launchEditor action when editing a …
jsconan Sep 24, 2024
29e51f5
Merge branch 'feat/HKD-6/integration' into feature/ADF-1784/side-by-s…
jsconan Sep 24, 2024
b44e32a
feat: add translation parameters for the authoring
jsconan Sep 25, 2024
0c110d8
feat: add the delete action for the translation (error 500 to be fixed)
jsconan Sep 25, 2024
3db7ec8
chore: replace item created listener to new item listener relates to …
shpran Sep 30, 2024
a35d3ca
Merge branch 'feat/HKD-6/integration' into feature/ADF-1784/side-by-s…
jsconan Oct 8, 2024
f521f70
fix: correct the delete translation action
jsconan Oct 10, 2024
c4405f5
refactor: use a better construction for the authoring forwarding URL
jsconan Oct 14, 2024
6b86f3f
Merge pull request #664 from oat-sa/feature/ADF-1784/side-by-side-aut…
jsconan Oct 14, 2024
480e01d
chore: bundle the assets
jsconan Oct 15, 2024
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
16 changes: 15 additions & 1 deletion actions/class.Items.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use oat\generis\model\OntologyRdfs;
use oat\tao\model\lock\LockManager;
use oat\tao\model\TaoOntology;
use oat\taoItems\model\Form\Modifier\FormModifierProxy;
use oat\taoItems\model\ItemModelStatus;
use oat\tao\model\accessControl\Context;
use oat\generis\model\OntologyAwareTrait;
Expand All @@ -38,6 +39,7 @@
use oat\taoItems\model\event\ItemUpdatedEvent;
use oat\tao\model\controller\SignedFormInstance;
use oat\taoItems\model\event\ItemRdfUpdatedEvent;
use oat\taoItems\model\Translation\Form\Modifier\TranslationFormModifierProxy;
use tao_helpers_form_FormContainer as FormContainer;
use oat\tao\model\Lists\Business\Validation\DependsOnPropertyValidator;

Expand Down Expand Up @@ -185,6 +187,10 @@ public function editItem(): void
$this->getDependsOnPropertyValidator(),
],
],
FormContainer::FORM_MODIFIERS => [
FormModifierProxy::class,
TranslationFormModifierProxy::class,
],
]
);
$myForm = $formContainer->getForm();
Expand Down Expand Up @@ -353,6 +359,14 @@ public function authoring()
LockManager::getImplementation()
->setLock($item, $this->getSession()->getUser()->getIdentifier());

// Add support for the translation and the side-by-side authoring tool
if ($this->getRequestParameter('translation') !== null) {
$authoringUrl = sprintf('%s&translation=%s', $authoringUrl, $this->getRequestParameter('translation'));
}
if ($this->getRequestParameter('originResourceUri') !== null) {
$authoringUrl = sprintf('%s&originResourceUri=%s', $authoringUrl, $this->getRequestParameter('originResourceUri'));
}

return $this->forwardUrl($authoringUrl);
}
}
Expand All @@ -366,7 +380,7 @@ public function authoring()
if (!empty($itemModel) && $itemModel instanceof core_kernel_classes_Resource) {
$errorMsg = __(
'No item authoring tool available for the selected type of item: %s'
. $itemModel->getLabel()
. $itemModel->getLabel()
);
} else {
$errorMsg = __('No item type selected for the current item.')
Expand Down
3 changes: 3 additions & 0 deletions actions/structures.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
<action id="item-move-all" name="Move To" url="/taoItems/Items/moveAll" context="resource" multiple="true" group="tree" binding="moveTo">
<icon id="icon-move-item"/>
</action>
<action id="item-translate" name="Translate" url="/tao/Translation/translate" context="instance" group="tree" binding="translateItem">
<icon id="icon-replace"/>
</action>
</actions>
</section>
</sections>
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"require": {
"oat-sa/oatbox-extension-installer": "~1.1||dev-master",
"oat-sa/generis": ">=15.36.1",
"oat-sa/tao-core": ">=53.0.0",
"oat-sa/tao-core": "dev-feat/HKD-6/integration as 99",
"oat-sa/extension-tao-backoffice": ">=6.0.0"
},
"autoload": {
Expand Down
17 changes: 15 additions & 2 deletions manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@

use oat\tao\model\user\TaoRoles;
use oat\taoBackOffice\controller\Lists;
use oat\taoItems\model\search\ItemClassListService;
use oat\taoItems\model\Form\ServiceProvider\FormServiceProvider;
use oat\taoItems\model\search\ItemClassListServiceProvider;
use oat\taoItems\model\Translation\ServiceProvider\TranslationServiceProvider;
use oat\taoItems\model\user\TaoItemsRoles;
use oat\tao\model\accessControl\func\AccessRule;
use oat\taoItems\scripts\install\RegisterNpmPaths;
Expand All @@ -37,6 +38,7 @@
use oat\taoItems\scripts\install\RegisterCategoryService;
use oat\taoItems\scripts\install\RegisterAssetTreeBuilder;
use oat\taoItems\scripts\install\RegisterItemPreviewerRegistryService;
use oat\taoItems\scripts\install\SetupEventListeners;

/*
* @author CRP Henri Tudor - TAO Team - {@link http://www.tao.lu}
Expand Down Expand Up @@ -67,6 +69,7 @@
RegisterItemPreviewerRegistryService::class,
RegisterAssetTreeBuilder::class,
SetRolesPermissions::class,
SetupEventListeners::class,
],
],
'update' => taoItems_scripts_update_Updater::class,
Expand Down Expand Up @@ -227,6 +230,14 @@
TaoItemsRoles::RESTRICTED_ITEM_AUTHOR,
['ext' => 'taoItems', 'mod' => 'ItemExport']
],
[
AccessRule::GRANT,
TaoItemsRoles::ITEM_TRANSLATOR,
[
'ext' => 'tao',
'mod' => 'Translation'
]
]
],
'optimizableClasses' => [
'http://www.tao.lu/Ontologies/TAOItem.rdf#Item',
Expand Down Expand Up @@ -254,6 +265,8 @@
],
'containerServiceProviders' => [
CopierServiceProvider::class,
ItemClassListServiceProvider::class
ItemClassListServiceProvider::class,
TranslationServiceProvider::class,
FormServiceProvider::class,
],
];
98 changes: 98 additions & 0 deletions migrations/Version202409060743452141_taoItems.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?php

declare(strict_types=1);

namespace oat\taoItems\migrations;

use Doctrine\DBAL\Schema\Schema;
use oat\oatbox\event\EventManager;
use oat\oatbox\reporting\Report;
use oat\tao\model\accessControl\func\AccessRule;
use oat\tao\model\accessControl\func\AclProxy;
use oat\tao\model\menu\SectionVisibilityFilter;
use oat\tao\scripts\tools\migrations\AbstractMigration;
use oat\tao\scripts\update\OntologyUpdater;
use oat\taoItems\model\event\ItemCreatedEvent;
use oat\taoItems\model\event\ItemUpdatedEvent;
use oat\taoItems\model\Translation\Listener\TranslationItemEventListener;
use oat\taoItems\model\user\TaoItemsRoles;

final class Version202409060743452141_taoItems extends AbstractMigration
{
public function getDescription(): string
{
return 'Add new Item Translator Role, sync models and add new listener';
}

public function up(Schema $schema): void
{
OntologyUpdater::syncModels();

AclProxy::applyRule($this->getRule());

$this->addReport(Report::createSuccess('Applied rules for role ' . TaoItemsRoles::ITEM_TRANSLATOR));

/** @var SectionVisibilityFilter $sectionVisibilityFilter */
$sectionVisibilityFilter = $this->getServiceManager()->get(SectionVisibilityFilter::SERVICE_ID);

$sectionVisibilityFilter->showSectionByFeatureFlag(
$sectionVisibilityFilter->createSectionPath(
[
'manage_items',
'item-translate'
]
),
'FEATURE_FLAG_TRANSLATION_ENABLED'
);
$this->getServiceManager()->register(SectionVisibilityFilter::SERVICE_ID, $sectionVisibilityFilter);

$this->addReport(
Report::createSuccess('Hide item section for feature flag FEATURE_FLAG_TRANSLATION_ENABLED')
);

/** @var EventManager $eventManager */
$eventManager = $this->getServiceManager()->get(EventManager::SERVICE_ID);
$eventManager->attach(
ItemCreatedEvent::class,
[TranslationItemEventListener::class, 'populateTranslationProperties']
);
$eventManager->attach(
ItemUpdatedEvent::class,
[TranslationItemEventListener::class, 'populateTranslationProperties']
);
$this->getServiceManager()->register(EventManager::SERVICE_ID, $eventManager);

$this->addReport(
Report::createSuccess('Listen to ' . ItemCreatedEvent::class . ' at ' . TranslationItemEventListener::class)
);
}

public function down(Schema $schema): void
{
AclProxy::revokeRule($this->getRule());

/** @var EventManager $eventManager */
$eventManager = $this->getServiceManager()->get(EventManager::SERVICE_ID);
$eventManager->detach(
ItemCreatedEvent::class,
[TranslationItemEventListener::class, 'populateTranslationProperties']
);
$eventManager->detach(
ItemUpdatedEvent::class,
[TranslationItemEventListener::class, 'populateTranslationProperties']
);
$this->getServiceManager()->register(EventManager::SERVICE_ID, $eventManager);
}

private function getRule(): AccessRule
{
return new AccessRule(
AccessRule::GRANT,
TaoItemsRoles::ITEM_TRANSLATOR,
[
'ext' => 'tao',
'mod' => 'Translation'
]
);
}
}
29 changes: 29 additions & 0 deletions models/classes/Form/Modifier/FormModifierProxy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2024 (original work) Open Assessment Technologies SA.
*/

declare(strict_types=1);

namespace oat\taoItems\model\Form\Modifier;

use oat\tao\model\form\Modifier\AbstractFormModifier;

final class FormModifierProxy extends AbstractFormModifier
{
}
51 changes: 51 additions & 0 deletions models/classes/Form/ServiceProvider/FormServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2024 (original work) Open Assessment Technologies SA.
*/

declare(strict_types=1);

namespace oat\taoItems\model\Form\ServiceProvider;

use oat\generis\model\DependencyInjection\ContainerServiceProviderInterface;
use oat\tao\model\form\Modifier\UniqueIdFormModifier;
use oat\taoItems\model\Form\Modifier\FormModifierProxy;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

use function Symfony\Component\DependencyInjection\Loader\Configurator\service;

class FormServiceProvider implements ContainerServiceProviderInterface
{
public function __invoke(ContainerConfigurator $configurator): void
{
$services = $configurator->services();

$services
->set(FormModifierProxy::class, FormModifierProxy::class)
->public();

$services
->get(FormModifierProxy::class)
->call(
'addModifier',
[
service(UniqueIdFormModifier::class),
]
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2024 (original work) Open Assessment Technologies SA.
*/

declare(strict_types=1);

namespace oat\taoItems\model\Translation\Form\Modifier;

use oat\tao\model\form\Modifier\AbstractFormModifier;

final class TranslationFormModifierProxy extends AbstractFormModifier
{
}
Loading
Loading