mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Performance: Standardize lodash imports to use destructured members Changes lodash imports of the form `import x from 'lodash/x'` to `import { x } from 'lodash'` to reduce bundle size. * Remove unnecessary _ import from Graph component * Enforce lodash import style * Fix remaining lodash imports
30 lines
663 B
TypeScript
30 lines
663 B
TypeScript
import { isArray } from 'lodash';
|
|
import coreModule from '../core_module';
|
|
|
|
export function arrayJoin() {
|
|
'use strict';
|
|
|
|
return {
|
|
restrict: 'A',
|
|
require: 'ngModel',
|
|
link: (scope: any, element: any, attr: any, ngModel: any) => {
|
|
function split_array(text: string) {
|
|
return (text || '').split(',');
|
|
}
|
|
|
|
function join_array(text: string) {
|
|
if (isArray(text)) {
|
|
return ((text || '') as any).join(',');
|
|
} else {
|
|
return text;
|
|
}
|
|
}
|
|
|
|
ngModel.$parsers.push(split_array);
|
|
ngModel.$formatters.push(join_array);
|
|
},
|
|
};
|
|
}
|
|
|
|
coreModule.directive('arrayJoin', arrayJoin);
|