refactor: moved array join directive to typecrtipt

This commit is contained in:
Torkel Ödegaard
2015-09-11 10:54:56 +02:00
parent 85baae1ebd
commit 812e4c7cd4
5 changed files with 33 additions and 44 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
export * from './directives/cool_dir'
export * from './directives/array_join'
export * from './routes/module_loader'
export * from './filters/filters'
+32
View File
@@ -0,0 +1,32 @@
///<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);
-7
View File
@@ -1,7 +0,0 @@
export class CoolDir {
getName() : string {
return "CoolDir";
}
}
-1
View File
@@ -1,5 +1,4 @@
define([
'./arrayJoin',
'./dashUpload',
'./grafanaSimplePanel',
'./dashEditLink',
-35
View File
@@ -1,35 +0,0 @@
define([
'angular',
'app',
'lodash'
],
function (angular, app, _) {
'use strict';
angular
.module('grafana.directives')
.directive('arrayJoin', function() {
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);
}
};
});
});