From: Bill Erickson Date: Wed, 8 Nov 2017 20:20:38 +0000 (-0500) Subject: LP#1731046 grid translations WIP X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fcollab%2Fberick%2Flp1731046-grid-translate-dialog;p=working%2FEvergreen.git LP#1731046 grid translations WIP Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/templates/staff/share/t_autogrid.tt2 b/Open-ILS/src/templates/staff/share/t_autogrid.tt2 index e8f94d77bd..a43d7bd01e 100644 --- a/Open-ILS/src/templates/staff/share/t_autogrid.tt2 +++ b/Open-ILS/src/templates/staff/share/t_autogrid.tt2 @@ -189,6 +189,10 @@ [% l('Print Full Grid') %] +
  • + + [% l('Translate Rows') %] +
  • diff --git a/Open-ILS/src/templates/staff/share/t_grid_translate_dialog.tt2 b/Open-ILS/src/templates/staff/share/t_grid_translate_dialog.tt2 new file mode 100644 index 0000000000..0e4ba1b4d1 --- /dev/null +++ b/Open-ILS/src/templates/staff/share/t_grid_translate_dialog.tt2 @@ -0,0 +1,45 @@ +
    + + + +
    diff --git a/Open-ILS/web/js/ui/default/staff/cat/z3950/app.js b/Open-ILS/web/js/ui/default/staff/cat/z3950/app.js index 911e4f6ecb..04cb5d617b 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/z3950/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/z3950/app.js @@ -185,10 +185,11 @@ function($scope , $q , $location , $timeout , $window, egCore , egGridDataProvi $scope.local_overlay_target = egCore.hatch.getLocalItem('eg.cat.marked_overlay_record') || 0; $scope.mark_as_overlay_target = function() { var items = $scope.gridControls.selectedItems(); - if ($scope.local_overlay_target == items[0].tcn()) { + if ($scope.local_overlay_target == items[0].doc_id()) { $scope.local_overlay_target = 0; } else { - $scope.local_overlay_target = items[0].tcn(); + $scope.local_overlay_target = items[0].doc_id(); + $scope.local_overlay_target_tcn = items[0].tcn(); } egCore.hatch.setLocalItem('eg.cat.marked_overlay_record',$scope.local_overlay_target); } diff --git a/Open-ILS/web/js/ui/default/staff/services/grid.js b/Open-ILS/web/js/ui/default/staff/services/grid.js index fab8679d69..5def01310d 100644 --- a/Open-ILS/web/js/ui/default/staff/services/grid.js +++ b/Open-ILS/web/js/ui/default/staff/services/grid.js @@ -119,10 +119,10 @@ angular.module('egGridMod', controller : [ '$scope','$q','egCore','egGridFlatDataProvider','$location', 'egGridColumnsProvider','$filter','$window','$sce','$timeout', - 'egProgressDialog', + 'egProgressDialog','$uibModal', function($scope, $q , egCore, egGridFlatDataProvider , $location, egGridColumnsProvider , $filter , $window , $sce , $timeout, - egProgressDialog) { + egProgressDialog , $uibModal) { var grid = this; @@ -663,6 +663,83 @@ angular.module('egGridMod', return false; } + $scope.showTranslateDialog = function() { + return $uibModal.open({ + templateUrl: './share/t_grid_translate_dialog', + backdrop: 'static', + size : 'lg', + controller: ['$scope', '$uibModalInstance', 'locales', + function($dialogScope, $uibModalInstance , locales) { + + $dialogScope.locales = locales; + $dialogScope.locale = locales[0].code(); // TODO + + var columns = $dialogScope.columns = + $scope.columns.filter( + function(col) {return col.i18n}); + + var translations = + $dialogScope.applied_translations = {}; + + angular.forEach(locales, function(locale) { + if (!translations[locale.code()]) + translations[locale.code()] = {}; + angular.forEach(columns, function(col) { + translations[locale.code()][col.name] = {}; + }); + }); + + $dialogScope.items = $scope.items; + $dialogScope.item_index = 0; + $dialogScope.prev = function() { + $dialogScope.item_index--; + } + $dialogScope.next = function() { + $dialogScope.item_index++; + } + $dialogScope.pkey = function() { + return grid.indexValue( + $dialogScope.items[$dialogScope.item_index]); + } + + function compile_strings() { + var entriess = []; + angular.forEach(translations, function(locale_blob, locale_code) { + angular.forEach(locale_blob, function(col_blob, col_name) { + angular.forEach(col_blob, function(string, ident) { + if (!string) return; + var i18n = new egCore.idl.i18n(); + // TODO: field class may not be same as grid class !! + i18n.fq_field(grid.idlClass + '.' + col_name); + i18n.identity_value(ident); + i18n.translation(locale_code); + i18n.string(string); + entriess.push(i18n); + }); + }); + }); + + return entriess; + } + + $dialogScope.apply = function() { + var i18n_entries = compile_strings(); + console.log(i18n_entries); + $uibModalInstance.close() + } + $dialogScope.cancel = function() { + $uibModalInstance.dismiss(); + } + } + ], + resolve : { + locales : function() { + return egCore.pcrud.retrieveAll('i18n_l', {}, {atomic : true}); + } + } + }); + } + // returns the list of selected item objects grid.getSelectedItems = function() { return $scope.items.filter( @@ -1572,6 +1649,7 @@ angular.module('egGridMod', } column.datatype = idl_info.idl_field.datatype; + column.i18n = idl_info.idl_field.i18n; if (!column.label) { column.label = idl_info.idl_field.label || column.name;