feat(template): display hide/show hidden button only if hidden templates exists

This commit is contained in:
Denis Gukov 2017-10-24 15:13:30 +05:00
parent 345ff4d182
commit eaf05e9c9e
2 changed files with 8 additions and 4 deletions

View File

@ -1,7 +1,7 @@
h3 Task Templates
button.btn.btn-success.btn-xs.pull-right(ng-click="add()" style="margin-left: 5px;") New Template
button.btn.btn-default.btn-xs.pull-right(ng-if="allShown" ng-click="hideHidden()") Hide Hidden
button.btn.btn-default.btn-xs.pull-right(ng-if="!allShown" ng-click="showAll()") Show Hidden
button.btn.btn-default.btn-xs.pull-right(ng-if="allShown && hasHiddenTemplates()" ng-click="hideHidden()") Hide Hidden
button.btn.btn-default.btn-xs.pull-right(ng-if="!allShown && hasHiddenTemplates()" ng-click="showAll()") Show Hidden
table.table.table-hover
thead: tr

View File

@ -41,7 +41,7 @@ define(['controllers/projects/taskRunner'], function () {
function getHiddenTemplates() {
try {
return JSON.parse($window.localStorage.getItem('hidden-templates') || '[]')
return JSON.parse($window.localStorage.getItem('hidden-templates') || '[]');
} catch(e) {
return [];
}
@ -51,10 +51,14 @@ define(['controllers/projects/taskRunner'], function () {
$window.localStorage.setItem('hidden-templates', JSON.stringify(hiddenTemplates));
}
function hasHiddenTemplates() {
return getHiddenTemplates().length > 0;
}
$scope.reload = function () {
$http.get(Project.getURL() + '/templates?sort=alias&order=asc').success(function (templates) {
var hiddenTemplates = getHiddenTemplates();
for (var i in templates) {
for (var i = 0; i < templates.length; i++) {
var template = templates[i];
if (hiddenTemplates.indexOf(template.id) !== -1) {
template.hidden = true;