-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
073c61f
commit 9fa39be
Showing
15 changed files
with
299 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...Injection/CodehatTranslationExtension.php → ...Injection/PiotrmusTranslatorExtension.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace Piotrmus\Translator; | ||
|
||
use Symfony\Component\HttpKernel\Bundle\Bundle; | ||
|
||
class PiotrmusTranslatorBundle extends Bundle | ||
{ | ||
} |
13 changes: 13 additions & 0 deletions
13
src/Resources/config/form_extensions/mass_edit/product.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
extensions: | ||
piotrmus-mass-product-edit-configure-add-comment: | ||
module: piotrmus-translator/mass-edit/translate | ||
parent: pim-mass-product-edit | ||
position: 500 | ||
config: | ||
title: pim_enrich.mass_edit.product.title | ||
label: 'Translate Product' | ||
labelCount: "{1}Add comment to <span class=\"AknFullPage-title--highlight\">1 product</span>|]1, Inf[Add comment to <span class=\"AknFullPage-title--highlight\">{{ itemsCount }} products</span>" | ||
description: 'Add a comment for a set of products' | ||
code: update_product_translations | ||
jobInstanceCode: update_product_translations | ||
icon: icon-compare |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
config: | ||
paths: | ||
piotrmus-translator/mass-edit/translate: piotrmustranslator/js/mass-edit/translate | ||
piotrmus-translator/template/mass-edit/translate: piotrmustranslator/templates/mass-edit/translate.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,43 @@ | ||
services: | ||
Codehat\TranslationExtension\Translator\GoogleTranslator: | ||
Piotrmus\Translator\Translator\GoogleTranslator: | ||
arguments: | ||
- 'teste' | ||
- '%env(GOOGLE_API_KEY)%' | ||
|
||
Codehat\TranslationExtension\Connector\Processor\MassEdit\TranslateAttributesProcessor: | ||
Piotrmus\Translator\Connector\Processor\MassEdit\TranslateAttributesProcessor: | ||
arguments: | ||
- '@Codehat\TranslationExtension\Translator\GoogleTranslator' | ||
- '@pim_catalog.updater.property_setter' | ||
- '@Piotrmus\Translator\Translator\GoogleTranslator' | ||
|
||
codehat.job.translate: | ||
class: '%pim_connector.job.simple_job.class%' | ||
piotrmus.job.update_product_translations: | ||
class: Akeneo\Tool\Component\Batch\Job\Job | ||
arguments: | ||
- 'translate_attributes' | ||
- 'update_product_translations' | ||
- '@event_dispatcher' | ||
- '@akeneo_batch.job_repository' | ||
- [ '@codehat.job.translate_attributes.step' ] | ||
- [ '@piotrmus.step.update_product_translations.mass_edit' ] | ||
tags: | ||
- { name: akeneo_batch.job, connector: 'Codehat Translator', type: '%pim_enrich.job.mass_edit_type%' } ] | ||
- { name: akeneo_batch.job, connector: '%pim_enrich.connector_name.mass_edit%', type: '%pim_enrich.job.mass_edit_type%' } | ||
|
||
codehat.job.translate_attributes.step: | ||
class: '%pim_connector.step.item_step.class%' | ||
piotrmus.job.default_values_provider.translate_product: | ||
class: Akeneo\Pim\Enrichment\Component\Product\Connector\Job\JobParameters\DefaultValueProvider\ProductMassEdit | ||
arguments: | ||
- [ 'update_product_translations' ] | ||
tags: | ||
- { name: akeneo_batch.job.job_parameters.default_values_provider } | ||
|
||
piotrmus.job.constraint_collection_provider.translate_product: | ||
class: Akeneo\Pim\Enrichment\Component\Product\Connector\Job\JobParameters\ConstraintCollectionProvider\ProductMassEdit | ||
arguments: | ||
- [ 'update_product_translations' ] | ||
tags: | ||
- { name: akeneo_batch.job.job_parameters.constraint_collection_provider } | ||
|
||
piotrmus.step.update_product_translations.mass_edit: | ||
class: Akeneo\Tool\Component\Batch\Step\ItemStep | ||
arguments: | ||
- 'perform' | ||
- '@event_dispatcher' | ||
- '@akeneo_batch.job_repository' | ||
- '@pim_enrich.reader.database.product_and_product_model' | ||
- '@Codehat\TranslationExtension\Connector\Processor\MassEdit\TranslateAttributesProcessor' | ||
- '@pim_connector.writer.database.product' | ||
- '@pim_enrich.reader.database.products_and_variant_products_of_product_models' | ||
- '@Piotrmus\Translator\Connector\Processor\MassEdit\TranslateAttributesProcessor' | ||
- '@pim_connector.writer.database.product' | ||
- 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
'use strict'; | ||
|
||
define([ | ||
'jquery', | ||
'underscore', | ||
'pim/mass-edit-form/product/operation', | ||
'piotrmus-translator/template/mass-edit/translate', | ||
'pim/fetcher-registry', | ||
'pim/initselect2', | ||
'pim/user-context', | ||
], | ||
function ( | ||
$, | ||
_, | ||
BaseOperation, | ||
template, | ||
FetcherRegistry, | ||
initSelect2, | ||
UserContext | ||
) { | ||
return BaseOperation.extend({ | ||
template: _.template(template), | ||
events: { | ||
'change select.form-field': 'setValue', | ||
'change #translated-attributes': 'setAttributes', | ||
}, | ||
|
||
render: function () { | ||
let locales = FetcherRegistry.getFetcher('locale').fetchActivated(); | ||
let scopes = FetcherRegistry.getFetcher('channel').fetchAll(); | ||
let attributes = FetcherRegistry.getFetcher('attribute').search({ | ||
options: { | ||
locale: UserContext.get('catalogLocale'), | ||
limit: 1000 | ||
} | ||
}); | ||
Promise.all([locales, scopes, attributes]).then(function (values) { | ||
let locales = values[0]; | ||
let channels = values[1]; | ||
let attributes = values[2]; | ||
|
||
console.log(attributes.length); | ||
|
||
attributes = attributes.filter(function (attribute) { | ||
console.log(attribute); | ||
return attribute.localizable; | ||
}) | ||
|
||
let data = this.getFormData(); | ||
if (data.actions.length === 0) { | ||
data.actions[0] = { | ||
"sourceChannel": channels[0].code, | ||
"sourceLocale": locales[0].code, | ||
"targetChannel": channels[0].code, | ||
"targetLocale": locales[0].code, | ||
"translatedAttributes": [], | ||
}; | ||
this.setData(data); | ||
} | ||
|
||
let model = this.getFormData(); | ||
|
||
this.$el.html(this.template({ | ||
locales: locales, | ||
channels: channels, | ||
attributes: attributes, | ||
sourceChannel: model.actions[0].sourceChannel, | ||
sourceLocale: model.actions[0].sourceLocale, | ||
targetChannel: model.actions[0].targetChannel, | ||
targetLocale: model.actions[0].targetLocale, | ||
})); | ||
|
||
$('.select2').each(function (key, select) { | ||
$(select).select2(); | ||
if ($(select).attr('readonly')) { | ||
$(select).select2('readonly', true); | ||
} | ||
}) | ||
}.bind(this)); | ||
return this; | ||
}, | ||
|
||
setValue: function (event) { | ||
this.setFormValue(event.target.name, event.target.value); | ||
}, | ||
|
||
setAttributes: function (event) { | ||
let data = this.getFormData(); | ||
data.actions[0].translatedAttributes = $(event.target).val(); | ||
this.setData(data); | ||
}, | ||
|
||
setFormValue: function (key, value) { | ||
let data = this.getFormData(); | ||
data.actions[0][key] = value; | ||
console.log(data.actions[0]); | ||
this.setData(data); | ||
} | ||
}); | ||
} | ||
); |
Oops, something went wrong.