Skip to content

Commit 4873a17

Browse files
committed
Added translation for custom group texts & layout improvemnets
1 parent 9ff48da commit 4873a17

File tree

10 files changed

+88
-15
lines changed

10 files changed

+88
-15
lines changed

client_app/src/yp-domain/yp-domain.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@
343343
}
344344

345345
if (!this.domain.only_admins_can_create_communities || this.checkDomainAccess(this.domain)) {
346-
this.set('createFabIcon', 'group-work');
346+
this.set('createFabIcon', 'add');
347347
}
348348

349349
window.appGlobals.setupGoogleAnalytics(this.domain);

client_app/src/yp-group/yp-group.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@
7575
height: 72px;
7676
--paper-fab-iron-icon: {
7777
color: var(--icon-general-color, #FFF);
78-
width: 72px;
79-
height: 72px;
78+
width: 50px;
79+
height: 50px;
8080
}
8181
}
8282

client_app/src/yp-magic-text/yp-magic-text.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,13 @@
226226
case 'communityContent':
227227
this.$.getTranslationAjax.url = "/api/communities/"+this.contentId+"/translatedText";
228228
break;
229+
case 'alternativeTextForNewIdeaButton':
230+
case 'alternativeTextForNewIdeaButtonClosed':
231+
case 'alternativeTextForNewIdeaButtonHeader':
232+
case 'alternativePointForHeader':
233+
case 'alternativePointAgainstHeader':
234+
case 'alternativePointForLabel':
235+
case 'alternativePointAgainstLabel':
229236
case 'groupName':
230237
case 'groupContent':
231238
this.$.getTranslationAjax.url = "/api/groups/"+this.contentId+"/translatedText";
@@ -256,6 +263,7 @@
256263
} else {
257264
console.error("No content for magic text");
258265
}
266+
this.dispatchEvent(new CustomEvent('new-translation', { bubbles: true, composed: true }));
259267
this._finalize();
260268
}
261269

client_app/src/yp-page/yp-page.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@
6363
height: 72px;
6464
--paper-fab-iron-icon: {
6565
color: var(--icon-general-color, #FFF);
66-
width: 72px;
67-
height: 72px;
66+
width: 60px;
67+
height: 60px;
6868
}
6969
}
7070

client_app/src/yp-post/yp-post-card-add.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,19 @@
143143
[[t('post.add_new')]]
144144
</template>
145145
<template is="dom-if" if="[[group.configuration.alternativeTextForNewIdeaButton]]">
146-
[[group.configuration.alternativeTextForNewIdeaButton]]
146+
<yp-magic-text content-id="[[group.id]]" extra-id="[[index]]" text-only content="[[group.configuration.alternativeTextForNewIdeaButton]]"
147+
content-language="[[group.language]]"
148+
class="ratingName" text-type="alternativeTextForNewIdeaButton"></yp-magic-text>
147149
</template>
148150
</div>
149151
<div class="flex addText closed" hidden$="[[!disabled]]">
150152
<template is="dom-if" if="[[!group.configuration.alternativeTextForNewIdeaButtonClosed]]">
151153
[[t('closedForNewPosts')]]
152154
</template>
153155
<template is="dom-if" if="[[group.configuration.alternativeTextForNewIdeaButtonClosed]]">
154-
[[group.configuration.alternativeTextForNewIdeaButtonClosed]]
156+
<yp-magic-text content-id="[[group.id]]" extra-id="[[index]]" text-only content="[[group.configuration.alternativeTextForNewIdeaButtonClosed]]"
157+
content-language="[[group.language]]"
158+
class="ratingName" text-type="alternativeTextForNewIdeaButtonClosed"></yp-magic-text>
155159
</template>
156160
</div>
157161
</div>

client_app/src/yp-post/yp-post-edit.html

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,11 @@ <h3 class="accessHeader">[[t('post.cover.media')]]</h3>
383383
<input type="hidden" name="structuredAnswers" value="[[structuredAnswers]]">
384384
</div>
385385
</yp-edit-dialog>
386+
387+
<yp-magic-text id="alternativeTextForNewIdeaButtonHeaderId" hidden content-id="[[group.id]]" text-only content="[[group.configuration.alternativeTextForNewIdeaButtonHeader]]"
388+
content-language="[[group.language]]" on-new-translation="_alternativeTextForNewIdeaButtonHeaderTranslation"
389+
text-type="alternativeTextForNewIdeaButtonHeader"></yp-magic-text>
390+
386391
</template>
387392

388393
</dom-module>
@@ -944,12 +949,23 @@ <h3 class="accessHeader">[[t('post.cover.media')]]</h3>
944949
}.bind(this), 250);
945950
},
946951

952+
_alternativeTextForNewIdeaButtonHeaderTranslation: function () {
953+
this.async(function () {
954+
var label = this.$$("#alternativeTextForNewIdeaButtonHeaderId");
955+
debugger;
956+
if (label && label.finalContent) {
957+
this.set('editHeaderText', label.finalContent);
958+
}
959+
});
960+
},
961+
947962
_setupTranslation: function () {
948963
this.async(function () {
949964
if (this.t) {
950965
if (this.newPost) {
951966
if (this.group && this.group.configuration && this.group.configuration.alternativeTextForNewIdeaButtonHeader) {
952-
this.editHeaderText = this.group.configuration.alternativeTextForNewIdeaButtonHeader;
967+
var label = this.$$("#alternativeTextForNewIdeaButtonHeaderId");
968+
this.editHeaderText = (label && label.finalContent) ? label.finalContent : this.group.configuration.alternativeTextForNewIdeaButtonHeader;
953969
} else {
954970
this.editHeaderText = this.t('post.new');
955971
}

client_app/src/yp-post/yp-post-points.html

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,11 @@
295295

296296
<template is="dom-if" if="[[post.Group.configuration.alternativePointForHeader]]">
297297
<div class="pointMainHeader layout horizontal center-center">
298-
[[post.Group.configuration.alternativePointForHeader]]
298+
299+
<yp-magic-text content-id="[[post.Group.id]]" text-only content="[[post.Group.configuration.alternativePointForHeader]]"
300+
content-language="[[post.Group.language]]"
301+
class="ratingName" text-type="alternativePointForHeader"></yp-magic-text>
302+
299303
</div>
300304
</template>
301305

@@ -392,10 +396,23 @@
392396

393397
<template is="dom-if" if="[[post.Group.configuration.alternativePointAgainstHeader]]">
394398
<div class="pointMainHeader layout horizontal center-center">
395-
[[post.Group.configuration.alternativePointAgainstHeader]]
399+
<yp-magic-text content-id="[[post.Group.id]]" text-only content="[[post.Group.configuration.alternativePointAgainstHeader]]"
400+
content-language="[[post.Group.language]]"
401+
class="ratingName" text-type="alternativePointAgainstHeader"></yp-magic-text>
396402
</div>
397403
</template>
398404

405+
<template is="dom-if" if="[[post.Group.configuration.alternativePointForLabel]]">
406+
<yp-magic-text id="alternativePointForLabelId" hidden content-id="[[post.Group.id]]" text-only content="[[post.Group.configuration.alternativePointForLabel]]"
407+
content-language="[[post.Group.language]]" on-new-translation="_updatePointLabels"
408+
text-type="alternativePointForLabel"></yp-magic-text>
409+
</template>
410+
411+
<template is="dom-if" if="[[post.Group.configuration.alternativePointAgainstLabel]]">
412+
<yp-magic-text id="alternativePointAgainstLabelId" hidden content-id="[[post.Group.id]]" text-only content="[[post.Group.configuration.alternativePointAgainstLabel]]"
413+
content-language="[[post.Group.language]]" on-new-translation="_updatePointLabels"
414+
text-type="alternativePointAgainstLabel"></yp-magic-text>
415+
</template>
399416

400417
<paper-material id="pointDownMaterial" elevation="1" class="pointInputMaterial layout vertical"
401418
animated hidden$="[[disableDebate]]">
@@ -1180,6 +1197,10 @@
11801197
this.set('labelDown', this.t('point.against'));
11811198
}
11821199
}
1200+
1201+
this.async(function () {
1202+
this._updatePointLabels();
1203+
});
11831204
},
11841205

11851206
removeElementsByClass: function (rootElement, className) {
@@ -1189,6 +1210,19 @@
11891210
}
11901211
},
11911212

1213+
_updatePointLabels: function () {
1214+
this.async(function () {
1215+
var forLabel = this.$$("#alternativePointForLabelId");
1216+
var againstLabel = this.$$("#alternativePointAgainstLabelId");
1217+
if (forLabel && forLabel.finalContent) {
1218+
this.set('labelUp', forLabel.finalContent);
1219+
}
1220+
if (againstLabel && againstLabel.finalContent) {
1221+
this.set('labelDown', againstLabel.finalContent);
1222+
}
1223+
});
1224+
},
1225+
11921226
_processStoredPoints: function () {
11931227
console.info("_processStoredPoints");
11941228
if (this.upPoints===null) {

client_app/src/yp-post/yp-post.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@
126126
height: 72px;
127127
--paper-fab-iron-icon: {
128128
color: var(--icon-general-color, #FFF);
129-
width: 72px;
130-
height: 72px;
129+
width: 50px;
130+
height: 50px;
131131
}
132132
}
133133

server_api/active-citizen

server_api/controllers/groups.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ var updateGroupConfigParamters = function (req, group) {
179179

180180
group.set('configuration.alternativePointForLabel', (req.body.alternativePointForLabel && req.body.alternativePointForLabel!="") ? req.body.alternativePointForLabel : null);
181181
group.set('configuration.alternativePointAgainstLabel', (req.body.alternativePointAgainstLabel && req.body.alternativePointAgainstLabel!="") ? req.body.alternativePointAgainstLabel : null);
182+
182183
group.set('configuration.disableFacebookLoginForGroup', truthValueFromBody(req.body.disableFacebookLoginForGroup));
183184
group.set('configuration.disableNameAutoTranslation', truthValueFromBody(req.body.disableNameAutoTranslation));
184185
group.set('configuration.externalGoalTriggerUrl', (req.body.externalGoalTriggerUrl && req.body.externalGoalTriggerUrl!="") ? req.body.externalGoalTriggerUrl : null);
@@ -1075,13 +1076,23 @@ router.get('/:id', auth.can('view group'), function(req, res) {
10751076
});
10761077
});
10771078

1079+
const allowedTextTypesForGroup = [
1080+
"alternativeTextForNewIdeaButton",
1081+
"alternativeTextForNewIdeaButtonClosed",
1082+
"alternativeTextForNewIdeaButtonHeader",
1083+
"alternativePointForHeader",
1084+
"alternativePointAgainstHeader",
1085+
"alternativePointForLabel",
1086+
"alternativePointAgainstLabel"
1087+
];
1088+
10781089
router.get('/:id/translatedText', auth.can('view group'), function(req, res) {
1079-
if (req.query.textType.indexOf("group") > -1) {
1090+
if (req.query.textType.indexOf("group") > -1 || allowedTextTypesForGroup.indexOf(req.query.textType) > -1) {
10801091
models.Group.findOne({
10811092
where: {
10821093
id: req.params.id
10831094
},
1084-
attributes: ['id','name','objectives']
1095+
attributes: ['id','name','objectives','configuration']
10851096
}).then(function(group) {
10861097
if (group) {
10871098
models.AcTranslationCache.getTranslation(req, group, function (error, translation) {

0 commit comments

Comments
 (0)