Merge "Translate angular html with '-'."
This commit is contained in:
commit
908a2a3bc1
@ -23,6 +23,7 @@
|
|||||||
.filter('mb', mbFilter)
|
.filter('mb', mbFilter)
|
||||||
.filter('title', titleFilter)
|
.filter('title', titleFilter)
|
||||||
.filter('noUnderscore', noUnderscoreFilter)
|
.filter('noUnderscore', noUnderscoreFilter)
|
||||||
|
.filter('noValue', noValueFilter)
|
||||||
.filter('decode', decodeFilter)
|
.filter('decode', decodeFilter)
|
||||||
.filter('bytes', bytesFilter)
|
.filter('bytes', bytesFilter)
|
||||||
.filter('itemCount', itemCountFilter);
|
.filter('itemCount', itemCountFilter);
|
||||||
@ -107,6 +108,23 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc filter
|
||||||
|
* @name noValue
|
||||||
|
* @description
|
||||||
|
* Replaces null / undefined / empty string with translated '-'.
|
||||||
|
*/
|
||||||
|
function noValueFilter() {
|
||||||
|
return function (input) {
|
||||||
|
if (input === null || angular.isUndefined(input) ||
|
||||||
|
(angular.isString(input) && '' == input.trim())) {
|
||||||
|
return gettext('-');
|
||||||
|
} else {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ngdoc filter
|
* @ngdoc filter
|
||||||
* @name decode
|
* @name decode
|
||||||
@ -161,7 +179,7 @@
|
|||||||
*/
|
*/
|
||||||
function itemCountFilter() {
|
function itemCountFilter() {
|
||||||
|
|
||||||
function ensureNonNegative (input) {
|
function ensureNonNegative(input) {
|
||||||
var isNumeric = (input !== null && isFinite(input));
|
var isNumeric = (input !== null && isFinite(input));
|
||||||
var number = isNumeric ? Math.round(input) : 0;
|
var number = isNumeric ? Math.round(input) : 0;
|
||||||
return (number > 0) ? number : 0;
|
return (number > 0) ? number : 0;
|
||||||
|
@ -127,6 +127,31 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('noValue', function () {
|
||||||
|
var noValueFilter;
|
||||||
|
beforeEach(inject(function (_noValueFilter_) {
|
||||||
|
noValueFilter = _noValueFilter_;
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('returns value if there is a value', function () {
|
||||||
|
expect(noValueFilter('foo')).toBe('foo');
|
||||||
|
expect(noValueFilter(' foo ')).toBe(' foo ');
|
||||||
|
expect(noValueFilter(true)).toBe(true);
|
||||||
|
expect(noValueFilter(false)).toBe(false);
|
||||||
|
var object = {};
|
||||||
|
expect(noValueFilter(object)).toBe(object);
|
||||||
|
var array = [];
|
||||||
|
expect(noValueFilter(array)).toBe(array);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('replaces undefined, null, blank with -', function () {
|
||||||
|
expect(noValueFilter(null)).toBe('-');
|
||||||
|
expect(noValueFilter()).toBe('-');
|
||||||
|
expect(noValueFilter('')).toBe('-');
|
||||||
|
expect(noValueFilter(' ')).toBe('-');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("decode", function () {
|
describe("decode", function () {
|
||||||
var decodeFilter;
|
var decodeFilter;
|
||||||
beforeEach(inject(function (_decodeFilter_) {
|
beforeEach(inject(function (_decodeFilter_) {
|
||||||
|
@ -82,13 +82,13 @@
|
|||||||
</dl>
|
</dl>
|
||||||
<dl class="col-sm-2">
|
<dl class="col-sm-2">
|
||||||
<dt translate>Project ID</dt>
|
<dt translate>Project ID</dt>
|
||||||
<dd>{$ user.tenantId || user.default_project_id || '-'$}</dd>
|
<dd>{$ user.tenantId || user.default_project_id | noValue $}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<span class="rsp-alt-p2">
|
<span class="rsp-alt-p2">
|
||||||
<dl class="col-sm-2">
|
<dl class="col-sm-2">
|
||||||
<dt translate>Email</dt>
|
<dt translate>Email</dt>
|
||||||
<dd>{$ user.email || '-' $}</dd>
|
<dd>{$ user.email | noValue $}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<dl class="col-sm-2">
|
<dl class="col-sm-2">
|
||||||
<dt translate>Enabled</dt>
|
<dt translate>Enabled</dt>
|
||||||
|
@ -10,11 +10,11 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tr ng-repeat="d in row.security_group_rules">
|
<tr ng-repeat="d in row.security_group_rules">
|
||||||
<td>{$ d.direction || '-' $}</td>
|
<td>{$ d.direction | noValue $}</td>
|
||||||
<td>{$ d.ethertype || '-' $}</td>
|
<td>{$ d.ethertype | noValue $}</td>
|
||||||
<td>{$ d.protocol || '-' $}</td>
|
<td>{$ d.protocol | noValue $}</td>
|
||||||
<td>{$ d.port_range_min || '-' $}</td>
|
<td>{$ d.port_range_min | noValue $}</td>
|
||||||
<td>{$ d.port_range_max || '-' $}</td>
|
<td>{$ d.port_range_max | noValue $}</td>
|
||||||
<td>{$ d.remote_ip_prefix || '-' $}</td>
|
<td>{$ d.remote_ip_prefix | noValue $}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
<td class="rsp-p1">{$ image.status | imageStatus $}</td>
|
<td class="rsp-p1">{$ image.status | imageStatus $}</td>
|
||||||
<td class="rsp-p2">{$ image.is_public | yesno $}</td>
|
<td class="rsp-p2">{$ image.is_public | yesno $}</td>
|
||||||
<td class="rsp-p2">{$ image.protected | yesno $}</td>
|
<td class="rsp-p2">{$ image.protected | yesno $}</td>
|
||||||
<td class="rsp-p2">{$ image.disk_format || '-' $}</td>
|
<td class="rsp-p2">{$ image.disk_format | noValue | uppercase $}</td>
|
||||||
<td class="rsp-p2">{$ image.size | bytes $}</td>
|
<td class="rsp-p2">{$ image.size | bytes $}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@ -99,7 +99,7 @@
|
|||||||
</dl>
|
</dl>
|
||||||
<dl class="col-sm-2">
|
<dl class="col-sm-2">
|
||||||
<dt translate>Format</dt>
|
<dt translate>Format</dt>
|
||||||
<dd>{$ image.disk_format || '-' $}</dd>
|
<dd>{$ image.disk_format | noValue $}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<dl class="col-sm-2">
|
<dl class="col-sm-2">
|
||||||
<dt translate>Size</dt>
|
<dt translate>Size</dt>
|
||||||
@ -111,11 +111,11 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<dl class="col-sm-2">
|
<dl class="col-sm-2">
|
||||||
<dt translate>Min Disk (GB)</dt>
|
<dt translate>Min Disk (GB)</dt>
|
||||||
<dd>{$ image.min_disk || '-' $}</dd>
|
<dd>{$ image.min_disk | noValue $}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<dl class="col-sm-2">
|
<dl class="col-sm-2">
|
||||||
<dt translate>Min RAM (MB)</dt>
|
<dt translate>Min RAM (MB)</dt>
|
||||||
<dd>{$ image.min_ram || '-' $}</dd>
|
<dd>{$ image.min_ram | noValue $}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user