Skip to content

Commit

Permalink
Merge pull request #564 from AcclaroInc/release/4.0.7
Browse files Browse the repository at this point in the history
Release/4.0.7
  • Loading branch information
bhupeshappfoster authored Feb 11, 2025
2 parents 1814f59 + 4dafedd commit 20d8866
Show file tree
Hide file tree
Showing 11 changed files with 476 additions and 223 deletions.
2 changes: 1 addition & 1 deletion .craftplugin
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"pluginName": "Translations for Craft",
"pluginDescription": "Drive global growth with simplified translation workflows.",
"pluginVersion": "v4.0.6",
"pluginVersion": "v4.0.7",
"pluginAuthorName": "Acclaro",
"pluginVendorName": "Acclaro",
"pluginAuthorUrl": "http://www.acclaro.com/",
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## 4.0.7 - 2024-02-11

### Fixed
- Widget overlapping in tranlsation dashbaord. ([AcclaroInc#560](https://github.com/AcclaroInc/pm-craft-translations/issues/560))
- Deprecation warning issue. ([AcclaroInc#536](https://github.com/AcclaroInc/craft-translations/issues/536))
- Date time issue in activity logs. ([AcclaroInc#539](https://github.com/AcclaroInc/craft-translations/issues/539))
- Wrong event handler issue. ([AcclaroInc#550](https://github.com/AcclaroInc/craft-translations/issues/550))
- Database button UI glitch. ([AcclaroInc#556](https://github.com/AcclaroInc/craft-translations/issues/556))
- Error notification for character limit. ([AcclaroInc#576](https://github.com/AcclaroInc/pm-craft-translations/issues/576))
- UI issue where order details sidebar distorted due to change in craft's native css.

## 4.0.6 - 2024-01-20

### Added
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
}
],
"require": {
"craftcms/cms": "^5.0.0",
"craftcms/cms": "^5.6.0",
"guzzlehttp/guzzle": "^7.0",
"composer/composer": "^2.7.0",
"google/cloud-translate": "^1.15",
Expand Down
580 changes: 391 additions & 189 deletions composer.lock

Large diffs are not rendered by default.

35 changes: 26 additions & 9 deletions src/assetbundles/src/css/Translations.css
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,6 @@
align-self: center;
}

.utility-status .progressbar {
left: 50%;
width: 50%;
transform: translateX(-50%) translateY(-50%);
}

.translations-order-confirmation .readable{
margin: 30px auto;
max-width: 400px;
Expand Down Expand Up @@ -777,8 +771,8 @@ body.ltr .widget[data-type="acclaro\\translations\\widgets\\NewAndModifiedEntrie
padding-top: 10px !important;
}

.pt-5 {
padding-top: 5px !important;
.pt-7 {
padding-top: 7px !important;
}

.w-300 {
Expand Down Expand Up @@ -1044,4 +1038,27 @@ td.target{

.activity-log .bullets {
padding-inline-start: var(--padding);
}
}

.meta .field .heading {
border-inline-end: none;
}

#settings, #meta-details {
padding-right: 2.5rem;
}

#settings .input.ltr:not(.value) {
display: block;
align-self: center;
}

#settings .field.button {
align-items: center;
justify-content: space-between;
}

#meta-details .value {
display: flex;
align-items: center;
}
2 changes: 1 addition & 1 deletion src/assetbundles/src/js/OrderEntries.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
});

// Modal checkboxes behaviour script
$(document).on('click, change', '.clone:checkbox', function() {
$(document).on('click change', '.clone:checkbox', function () {
$value = $(this).val();
$selected = $('tbody .clone:checkbox:checked').length;
if ($selected == 0) {
Expand Down
8 changes: 4 additions & 4 deletions src/assetbundles/src/js/RecentlyModified.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
$('div.menu ul.padded li a[data-id="'+recent+'"]').removeClass('sel');
$('div.menu ul.padded li a[data-id="'+modified+'"]').addClass('sel');
$("#"+modified).removeClass('hidden');
$("#"+recent).addClass('hidden');
window.translationsdashboard.widgets[widgetId].updateContainerHeight();
$("#" + recent).addClass('hidden');
this.$container.updateContainerHeight();
window.translationsdashboard.grid.refreshCols(true, true);
});

Expand All @@ -60,8 +60,8 @@
$('div.menu ul.padded li a[data-id="'+recent+'"]').addClass('sel');
$('div.menu ul.padded li a[data-id="'+modified+'"]').removeClass('sel');
$("#"+modified).addClass('hidden');
$("#"+recent).removeClass('hidden');
window.translationsdashboard.widgets[widgetId].updateContainerHeight();
$("#" + recent).removeClass('hidden');
this.$container.updateContainerHeight();
window.translationsdashboard.grid.refreshCols(true, true);
});

Expand Down
2 changes: 1 addition & 1 deletion src/services/repository/ActivityLogRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function createActivityLog($message, $target)
$activityLog = $this->makeNewActivityLogModel();
$activityLog->targetId = $target->id;
$activityLog->message = $message;
$activityLog->created = date('Y-m-d H:i:s');
$activityLog->created = Craft::$app->getFormatter()->asDatetime('now', 'php:Y-m-d H:i:s');
$activityLog->targetClass = get_class($target);

return $this->saveActivityLog($activityLog);
Expand Down
39 changes: 33 additions & 6 deletions src/services/repository/DraftRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ public function getDraftById($draftId, $siteId)
public function saveDraft($element)
{
$element->validate();
if($element->getErrors()){
return $element->getErrors();
if($element->getErrors()) {
// Extract the error messages from the element's errors
$errorMessages = $this->extractErrorMessages($element->getErrors());
throw new Exception("Validation failed: " . $errorMessages);
}

return Craft::$app->elements->saveElement($element, true, true, false);
Expand Down Expand Up @@ -188,9 +190,12 @@ public function createOrderDrafts($orderId, $wordCounts, $publish, $fileIds, $qu
$currentElement = 0;

$createDrafts = new CreateDrafts();
$transaction = Craft::$app->db->beginTransaction();


foreach ($order->getFiles() as $file) {
/* Create transaction per file so that in case a file has validation error
only that will be rolledback and others can be processed */
$transaction = Craft::$app->db->beginTransaction();

if (! in_array($file->id, $fileIds)) {
continue;
}
Expand Down Expand Up @@ -231,12 +236,13 @@ public function createOrderDrafts($orderId, $wordCounts, $publish, $fileIds, $qu
if ($publish) {
$this->applyDrafts($order->id, [$element->id], [$file->id], $queue);
}
$transaction->commit();
} catch(Exception $e) {
$transaction->rollback();
throw $e;
$this->setError($e->getMessage());
continue;
}
}
$transaction->commit();

if ($isNewDraft)
$order->logActivity(Translations::$plugin->translator->translate('app', 'Drafts created'));
Expand Down Expand Up @@ -418,4 +424,25 @@ public function deleteDraft($draftId, $siteId)
throw $e;
}
}

/**
* Extract error messages from an error object in string format
*/
private function extractErrorMessages($errorObject)
{
$errorMessages = [];

// Iterate through each key in the error object
foreach ($errorObject as $field => $messages) {
if (is_array($messages)) {
// Iterate through each error message in the array
foreach ($messages as $message) {
$errorMessages[] = $message; // Add the message to the list
}
}
}

// Return the concatenated error messages as a string
return implode("\n", $errorMessages);
}
}
14 changes: 6 additions & 8 deletions src/templates/_components/orders/info-tab.twig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{% if isCancelable %}
<table class="data right"><thead><th id="cancel-order-link" class="bg-none icon ordered desc orderable"><button></button></th></thead></table>
{% endif %}
<a class="right pt-5 mr--10" href="{{translator_url}}" target="_blank">#{{ order.serviceOrderId }} </a>
<a class="right pt-7 mr--10" href="{{translator_url}}" target="_blank">#{{ order.serviceOrderId }} </a>
{% else %}
<label class="right">{{ 'N/A' }} </label>
{% endif %}
Expand Down Expand Up @@ -75,9 +75,7 @@
<div class="data field">
<h5 class="heading">{{ 'Author'|t('app') }}</h5>
<div class="value input ltr" style="justify-content:flex-end" id="uploader-element">
{% include '_elements/element' with {
element: author,
} %}
{{ elementChip(author) }}
</div>
{% js %}
new Craft.ElementThumbLoader().load($('#uploader-element'));
Expand Down Expand Up @@ -115,7 +113,7 @@
</div>

{# Export/Import And Sync Buttons #}
<div class="field" style="justify-content: space-between;">
<div class="field button">
<div class="heading">
<label id="source-files">Source files</label>
<form id="export-zip" class="utility" method="post" accept-charset="UTF-8">
Expand All @@ -137,7 +135,7 @@
</button>
</div>

<div class="field" style="justify-content: space-between;">
<div class="field button">
<div class="heading">
<label id="translated-files">Translated files</label>
<div class="hud-wrapper hidden">
Expand All @@ -157,7 +155,7 @@
</div>
{% js 'new Craft.Translations.ExportFiles(\'export-zip\',\'export-btn\');' %}
{% if order.hasTranslator('acclaro') %}
<div class="field" style="justify-content: space-between;">
<div class="field button">
<div class="heading">
<label>My Acclaro</label>
<form id="sync-order" class="utility" method="post" accept-charset="UTF-8">
Expand All @@ -181,7 +179,7 @@
{% endif %}
</div>
{% elseif order.hasTranslator('google') %}
<div class="field" style="justify-content: space-between;">
<div class="field button">
<div class="heading">
<label>Google</label>
<form id="sync-order" class="utility" method="post" accept-charset="UTF-8">
Expand Down
4 changes: 1 addition & 3 deletions src/templates/assets/_editDraft.twig
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@
<div class="data">
<dt class="heading">Uploaded by</dt>
<dd class="value">
{% include '_elements/element' with {
element: author,
} %}
{{ elementChip(author) }}
</dd>
</div>
<div class="data">
Expand Down

0 comments on commit 20d8866

Please sign in to comment.