cluedin-widget
Version:
This project contains all the pages needed for browsing entities and searching them. The aim is to replace the CluedIn.Webapp project with this one when all the pages ( including the Admin page ) will be ported to REACT.
56 lines (46 loc) • 1.41 kB
JavaScript
var template = require('lodash/template');
var templateSettings = require('lodash/templateSettings');
templateSettings.interpolate = /{{([\s\S]+?)}}/g;
var capitalizeFirstLetter = function (str) {
return str.charAt(0).toUpperCase() + str.slice(1);
};
var addZeroIfLessThenTenAndReturnStr = function (str) {
if (str < 10) {
str = '0' + str;
} else {
str += '';
}
return str;
};
module.exports = {
template: template,
hasStartAsLastCharacter: function (str) {
return str.slice(-1) === '*';
},
removeLastCharacter: function (str) {
return str.substring(0, str.length - 1);
},
capitalizeFirstLetter: capitalizeFirstLetter,
formatDisplayName: function (name) {
return capitalizeFirstLetter(name.replace(/[-_]/g, ' ').replace(/([a-z])([A-Z])/g, '$1 $2'));
},
createPropertyDisplayName: function (p) {
var nameParts = p.split('.');
var name = nameParts[( nameParts.length - 1 )];
if (name && name.indexOf(':') > -1) {
name = name.split(':')[1];
}
if (!name) {
return p;
}
if (name.indexOf('property-') > -1 || name.indexOf('Property-') > -1) {
return name.replace(/property-/i, '');
}
return name;
},
getWordWithCount: function (word, count) {
var result = word.replace('/', '');
return result + ' (' + count + ')';
},
addZeroIfLessThenTenAndReturnStr: addZeroIfLessThenTenAndReturnStr
};