mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
33 lines
677 B
TypeScript
33 lines
677 B
TypeScript
///<reference path="../../headers/common.d.ts" />
|
|
|
|
import angular = require('angular');
|
|
import _ = require('lodash');
|
|
|
|
export function ArrayJoin()
|
|
{
|
|
return {
|
|
restrict: 'A',
|
|
require: 'ngModel',
|
|
link: function(scope, element, attr, ngModel) {
|
|
|
|
function split_array(text) {
|
|
return (text || '').split(',');
|
|
}
|
|
|
|
function join_array(text) {
|
|
if(_.isArray(text)) {
|
|
return (text || '').join(',');
|
|
} else {
|
|
return text;
|
|
}
|
|
}
|
|
|
|
ngModel.$parsers.push(split_array);
|
|
ngModel.$formatters.push(join_array);
|
|
}
|
|
};
|
|
}
|
|
|
|
angular.module('grafana.directives').directive('arrayJoin', ArrayJoin);
|
|
|