From ccff21c9b5bbf57d3a74ee781429ac20af638563 Mon Sep 17 00:00:00 2001 From: Joris Tirado Date: Thu, 28 May 2020 14:28:26 -0700 Subject: [PATCH] MSPB-104: Update German translation (#210) * Update German translation * Refactor key actions generation * Refactor key entries structure While key entries is provided as an object where the key corresponds to the entrie's number, this complexity does not have to make it to the template. We already fill up empty entries by generating an array of key entries length, hence no need to switch back to an object structure. * Render combo keys count by section title --- i18n/de-DE.json | 18 ++-- i18n/en-US.json | 7 +- i18n/ru-RU.json | 2 +- submodules/devices/devices.js | 93 ++++++++++++------- .../devices/views/devices-sip_device.html | 55 +++++------ 5 files changed, 99 insertions(+), 76 deletions(-) diff --git a/i18n/de-DE.json b/i18n/de-DE.json index 203d7c3..4a77425 100644 --- a/i18n/de-DE.json +++ b/i18n/de-DE.json @@ -290,19 +290,25 @@ "__version": "v3.20_s4", "keys": { "alert": { - "message": "In der Standardeinstellung wird diese Taste als Leitungstaste verwendet. Wir empfehlen, dies nicht zu ändern." + "message": "In der Standardeinstellung wird diese Taste als Leitungstaste verwendet. Wir empfehlen, dies nicht zu ändern.", + "title": "Taste 1 im Standart" }, "featureKeys": { - "title": "Funktionstasten", + "menuTitle": "Funktionstasten", + "sectionTitle": "Funktionstasten", "label": "Funktionstaste" }, "comboKeys": { - "title": "Kombitasten", - "label": "Kombitaste" + "menuTitle": "Funktionstaste", + "sectionTitle": "Funktionstaste {{range}}", + "range": "{{min}} - {{max}}", + "label": "Funktionstaste" }, "labels": { + "deviceLabel": "Beschriftung", + "function": "Aktion", "parkingSpot": "Halteposition", - "user": "Benutzer", + "user": "Aktionsdaten", "value": "Wert" }, "info": { @@ -320,7 +326,7 @@ "typeTitle": "{{variable}}: " }, "types": { - "line": "Zeile", + "line": "Leitung", "none": "Keine", "presence": "Anwesenheit", "parking": "Parken", diff --git a/i18n/en-US.json b/i18n/en-US.json index bafa738..82bfcd9 100644 --- a/i18n/en-US.json +++ b/i18n/en-US.json @@ -300,11 +300,14 @@ "title": "Key 1 Default" }, "featureKeys": { - "title": "Feature Keys", + "menuTitle": "Feature Keys", + "sectionTitle": "Feature Keys", "label": "Feature key" }, "comboKeys": { - "title": "Combo Keys", + "menuTitle": "Combo Keys", + "sectionTitle": "Combo Keys {{range}}", + "range": "{{min}} - {{max}}", "label": "Combo key" }, "labels": { diff --git a/i18n/ru-RU.json b/i18n/ru-RU.json index f847fdb..9a08f40 100644 --- a/i18n/ru-RU.json +++ b/i18n/ru-RU.json @@ -616,7 +616,7 @@ "6": "Управляете возможностями пользователей. Вы можете включить, выключить или настроить различные дополнительные возможности." } }, - "confirmMobileUnAssignment": "Вы собираетесь открепить мобильное устройство. Для информации, номер телефона ассоциированный с устройством ({{variable}}) также будет откреплен от данного пользователя. Вы уверены?", + "confirmMobileUnAssignment": "Вы собираетесь открепить мобильное устройство. Для информации, номер телефона ассоциированный с устройством ({{variable}}) также будет откреплен от данного пользователя. Вы уверены?" }, "strategy": { diff --git a/submodules/devices/devices.js b/submodules/devices/devices.js index f22e6a7..e0d0adb 100644 --- a/submodules/devices/devices.js +++ b/submodules/devices/devices.js @@ -1008,8 +1008,7 @@ define(function(require) { .chain(data.template) .get([type, 'iterate'], 0) .range() - .keyBy() - .mapValues(function(index) { + .map(function(index) { return _.get(data.device, ['provision', type, index], { type: 'none' }); @@ -1049,51 +1048,75 @@ define(function(require) { }; }), provision: { - keyActions: _.map([ - 'none', - 'presence', - 'parking', - 'personal_parking', - 'speed_dial' - ], function(action) { - var i18n = self.i18n.active().devices.popupSettings.keys; - - return { - id: action, - info: _.get(i18n, ['info', 'types', action]), - text: _.get(i18n, ['types', action]) - }; - }), keys: _ .chain(data.template) .thru(self.getKeyTypes) .map(function(type) { var camelCasedType = _.camelCase(type), - i18n = _.get(self.i18n.active().devices.popupSettings.keys, camelCasedType); + i18n = _.get(self.i18n.active().devices.popupSettings.keys, camelCasedType), + entries = _.get(mergedDevice, ['provision', type], []), + entriesCount = _.size(entries); return _.merge({ id: type, type: camelCasedType, - data: _ - .chain(mergedDevice) - .get(['provision', type], {}) - .mapValues(function(metadata) { - var value = _.get(metadata, 'value', {}); - - return _.merge({}, metadata, _.isPlainObject(value) - ? {} - : { - value: { - value: _.toString(value) - } - } - ); + actions: _ + .chain([ + 'none', + 'presence', + 'parking', + 'personal_parking', + 'speed_dial' + ]) + .concat( + type === 'combo_keys' ? ['line'] : [] + ) + .map(function(action) { + var i18n = self.i18n.active().devices.popupSettings.keys; + + return { + id: action, + info: _.get(i18n, ['info', 'types', action]), + label: _.get(i18n, ['types', action]) + }; + }) + // Sort alphabetically while keeping `none` as first item + .sort(function(a, b) { + return a.id === 'none' ? -1 + : b.id === 'none' ? 1 + : a.label.localeCompare(b.label, monster.config.whitelabel.language); }) - .value() + .value(), + data: _.map(entries, function(metadata) { + var value = _.get(metadata, 'value', {}); + + return _.merge({}, metadata, _.isPlainObject(value) + ? {} + : { + value: { + value: _.toString(value) + } + } + ); + }) }, _.pick(i18n, [ - 'title', + 'menuTitle', + 'sectionTitle', 'label' - ])); + ]), _.has(i18n, 'range') ? { + sectionTitle: self.getTemplate({ + name: '!' + i18n.sectionTitle, + data: { + range: entriesCount > 1 ? self.getTemplate({ + name: '!' + i18n.range, + data: { + min: 1, + max: entriesCount + } + }) : '' + } + }) + } : {}); }) .value(), parkingSpots: _.range(1, 11) diff --git a/submodules/devices/views/devices-sip_device.html b/submodules/devices/views/devices-sip_device.html index 6b19b0f..7b51393 100644 --- a/submodules/devices/views/devices-sip_device.html +++ b/submodules/devices/views/devices-sip_device.html @@ -73,7 +73,7 @@
  • - {{title}} + {{menuTitle}}
  • {{/each}} @@ -323,7 +323,7 @@
    - {{{title}}} + {{{sectionTitle}}}
    @@ -333,33 +333,25 @@ {{telicon 'question--circle'}}
    - {{#each @root.extra.provision.keyActions}} + {{#each actions}} {{#if info}}

    - {{replaceVar @root.i18n.devices.popupSettings.keys.info.typeTitle text}} + {{replaceVar @root.i18n.devices.popupSettings.keys.info.typeTitle label}} {{info}}

    {{/if}} {{/each}} - {{#compare id '===' 'combo_keys'}} -

    - - {{replaceVar @root.i18n.devices.popupSettings.keys.info.typeTitle @root.i18n.devices.popupSettings.keys.types.line}} - - {{@root.i18n.devices.popupSettings.keys.info.types.line}} -

    - {{/compare}}
    {{#each data}} -
    -