From 36a4ede86b249695ee28c3d46816ab2c56d840ee Mon Sep 17 00:00:00 2001
From: konradoboza <34310128+konradoboza@users.noreply.github.com>
Date: Fri, 30 Mar 2018 20:22:49 +0200
Subject: [PATCH] EZP-28966: Disable deleting main translation button (#960)
* EZP-28966 Disable deleting main translation button
* fixup
* fixup
* fixup
---
Resources/config/yui.yml | 4 ++++
Resources/public/js/helpers/ez-notequalhelper.js | 16 ++++++++++++++++
Resources/public/templates/translateaction.hbt | 6 +++---
3 files changed, 23 insertions(+), 3 deletions(-)
create mode 100644 Resources/public/js/helpers/ez-notequalhelper.js
diff --git a/Resources/config/yui.yml b/Resources/config/yui.yml
index 4af0e4c4e..725160f7c 100644
--- a/Resources/config/yui.yml
+++ b/Resources/config/yui.yml
@@ -1238,6 +1238,7 @@ system:
- 'translateactionview-ez-template'
- 'ez-translator'
- 'event-outside'
+ - 'ez-notequalhelper'
path: "%ez_platformui.public_dir%/js/views/actions/ez-translateactionview.js"
translateactionview-ez-template:
type: 'template'
@@ -1309,6 +1310,9 @@ system:
ez-strictcomparisonhelper:
requires: ['handlebars']
path: "%ez_platformui.public_dir%/js/helpers/ez-strictcomparisonhelper.js"
+ ez-notequalhelper:
+ requires: ['handlebars']
+ path: "%ez_platformui.public_dir%/js/helpers/ez-notequalhelper.js"
ez-getflagcodehelper:
requires: ['handlebars']
path: "%ez_platformui.public_dir%/js/helpers/ez-getflagcodehelper.js"
diff --git a/Resources/public/js/helpers/ez-notequalhelper.js b/Resources/public/js/helpers/ez-notequalhelper.js
new file mode 100644
index 000000000..60e18221d
--- /dev/null
+++ b/Resources/public/js/helpers/ez-notequalhelper.js
@@ -0,0 +1,16 @@
+/*
+ * Copyright (C) eZ Systems AS. All rights reserved.
+ * For full copyright and license information view LICENSE file distributed with this source code.
+ */
+YUI.add('ez-notequalhelper', function (Y) {
+ Y.Handlebars.registerHelper('notEqual', function (left, right, options) {
+ var result = left !== right;
+
+ if (result) {
+ return options.fn(this);
+ } else {
+ return options.inverse(this);
+ }
+ });
+
+});
diff --git a/Resources/public/templates/translateaction.hbt b/Resources/public/templates/translateaction.hbt
index b1ea0829d..8f20bb708 100644
--- a/Resources/public/templates/translateaction.hbt
+++ b/Resources/public/templates/translateaction.hbt
@@ -26,9 +26,9 @@
{{translate 'translateaction.edit' 'bar'}}
- {{#if ../canDeleteTranslations}}
-
- {{/if}}
+ {{#notEqual ../content.mainLanguageCode this }}
+
+ {{/notEqual}}
{{/each}}