Univention Bugzilla – Attachment 9558 Details for
Bug 47195
Use language sensitive sorting for tools.cmpObjects
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
47195.patch (text/plain), 2.98 KB, created by
Johannes Keiser
on 2018-06-14 17:25:38 CEST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Johannes Keiser
Created:
2018-06-14 17:25:38 CEST
Size:
2.98 KB
patch
obsolete
>diff --git a/management/univention-web/js/tools.js b/management/univention-web/js/tools.js >index 9bcb5d3..6952f84 100644 >--- a/management/univention-web/js/tools.js >+++ b/management/univention-web/js/tools.js >@@ -31,6 +31,7 @@ > define([ > "dojo/_base/lang", > "dojo/_base/array", >+ "dojo/_base/kernel", > "dojo/_base/window", > "dojo/request/xhr", > "dojo/_base/xhr", >@@ -50,7 +51,7 @@ define([ > "umc/widgets/Text", > "umc/i18n/tools", > "umc/i18n!" >-], function(lang, array, _window, xhr, basexhr, Deferred, all, json, string, topic, cookie, Dialog, TitlePane, timing, styles, entities, ContainerWidget, ConfirmDialog, Text, i18nTools, _) { >+], function(lang, array, kernel, _window, xhr, basexhr, Deferred, all, json, string, topic, cookie, Dialog, TitlePane, timing, styles, entities, ContainerWidget, ConfirmDialog, Text, i18nTools, _) { > // in order to break circular dependencies (umc.tools needs a Widget and > // the Widget needs umc/tools), we define umc/dialog as an empty object and > // require it explicitely >@@ -1130,7 +1131,12 @@ define([ > var o = { > attr: '', > desc: 1, >- ignCase: true >+ ignCase: true, >+ useCollator: true, >+ collatorLocales: kernel.locale, >+ collatorOptions: { >+ numeric: true >+ } > }; > > // entry for ordering can by a String or an Object >@@ -1141,6 +1147,10 @@ define([ > o.attr = args[i].attribute; > o.desc = (args[i].descending ? -1 : 1); > o.ignCase = undefined === args[i].ignoreCase ? true : args[i].ignoreCase; >+ >+ o.useCollator = undefined === args[i].useCollator ? o.useCollator : args[i].useCollator; >+ o.collatorLocales = undefined === args[i].collatorLocales ? o.collatorLocales : args[i].collatorLocales; >+ lang.mixin(o.collatorOptions, args[i].collatorOptions); > } > else { > // error case >@@ -1156,23 +1166,30 @@ define([ > for (var i = 0; i < order.length; ++i) { > var o = order[i]; > >- // check for lowercase (ignore not existing values!) > var a = _a[o.attr]; > var b = _b[o.attr]; >- if (o.ignCase && a && a.toLowerCase && b && b.toLowerCase) { >- a = a.toLowerCase(); >- b = b.toLowerCase(); >- } > > // check for lower/greater >- if (a < b) { >- return -1 * o.desc; >- } >- if (a > b) { >- return 1 * o.desc; >+ var hasCollator = typeof(Intl) === 'object' && Intl.hasOwnProperty('Collator') && typeof(Intl.Collator) === 'function'; >+ if (o.useCollator && hasCollator) { >+ // should we cache a collator for the same settings? >+ var collator = new Intl.Collator(o.collatorLocales, o.collatorOptions); >+ return collator.compare(a, b) * o.desc; >+ } else { >+ // check for lowercase (ignore not existing values!) >+ if (o.ignCase && a && a.toLowerCase && b && b.toLowerCase) { >+ a = a.toLowerCase(); >+ b = b.toLowerCase(); >+ } >+ if (a < b) { >+ return -1 * o.desc; >+ } >+ if (a > b) { >+ return 1 * o.desc; >+ } >+ return 0; > } > } >- return 0; > }; > }, >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 47195
: 9558