From 812e4c7cd4c312404dc676212c7023102accbab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 11 Sep 2015 10:54:56 +0200 Subject: [PATCH] refactor: moved array join directive to typecrtipt --- public/app/core/core.ts | 2 +- public/app/core/directives/array_join.ts | 32 ++++++++++++++++++++++ public/app/core/directives/cool_dir.ts | 7 ----- public/app/directives/all.js | 1 - public/app/directives/arrayJoin.js | 35 ------------------------ 5 files changed, 33 insertions(+), 44 deletions(-) create mode 100644 public/app/core/directives/array_join.ts delete mode 100644 public/app/core/directives/cool_dir.ts delete mode 100644 public/app/directives/arrayJoin.js diff --git a/public/app/core/core.ts b/public/app/core/core.ts index 1dbd6511e53..a8c74c756a8 100644 --- a/public/app/core/core.ts +++ b/public/app/core/core.ts @@ -1,5 +1,5 @@ -export * from './directives/cool_dir' +export * from './directives/array_join' export * from './routes/module_loader' export * from './filters/filters' diff --git a/public/app/core/directives/array_join.ts b/public/app/core/directives/array_join.ts new file mode 100644 index 00000000000..b91682b48c0 --- /dev/null +++ b/public/app/core/directives/array_join.ts @@ -0,0 +1,32 @@ +/// + +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); + diff --git a/public/app/core/directives/cool_dir.ts b/public/app/core/directives/cool_dir.ts deleted file mode 100644 index 78caa78bed8..00000000000 --- a/public/app/core/directives/cool_dir.ts +++ /dev/null @@ -1,7 +0,0 @@ - -export class CoolDir { - getName() : string { - return "CoolDir"; - } -} - diff --git a/public/app/directives/all.js b/public/app/directives/all.js index 0902410b089..bcf5bd5fa27 100644 --- a/public/app/directives/all.js +++ b/public/app/directives/all.js @@ -1,5 +1,4 @@ define([ - './arrayJoin', './dashUpload', './grafanaSimplePanel', './dashEditLink', diff --git a/public/app/directives/arrayJoin.js b/public/app/directives/arrayJoin.js deleted file mode 100644 index a2b5fbe59dd..00000000000 --- a/public/app/directives/arrayJoin.js +++ /dev/null @@ -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); - } - }; - }); - -});