From c6514280637b9e842aead04669d2ad05819c7276 Mon Sep 17 00:00:00 2001 From: Gerard Date: Thu, 19 Apr 2018 15:00:44 +0200 Subject: [PATCH] Bug #243 Creacion del filtro dash-if-empty para ticket Index --- client/core/src/filters/dash-if-empty.js | 15 +++++++++++++++ client/core/src/filters/index.js | 1 + 2 files changed, 16 insertions(+) create mode 100644 client/core/src/filters/dash-if-empty.js diff --git a/client/core/src/filters/dash-if-empty.js b/client/core/src/filters/dash-if-empty.js new file mode 100644 index 000000000..704ec2847 --- /dev/null +++ b/client/core/src/filters/dash-if-empty.js @@ -0,0 +1,15 @@ +import ngModule from '../module'; + +/** + * Returns dash when value is empty, otherwise returns the same string. + * + * @return {String} The string result + */ +export default function dashIfEmpty() { + return function(input) { + if (input == null || input == '') + return '-'; + return input; + }; +} +ngModule.filter('dashIfEmpty', dashIfEmpty); diff --git a/client/core/src/filters/index.js b/client/core/src/filters/index.js index 885f3cd66..65d3a996b 100644 --- a/client/core/src/filters/index.js +++ b/client/core/src/filters/index.js @@ -1,2 +1,3 @@ import './phone'; import './ucwords'; +import './dash-if-empty';