Skip to content

Commit

Permalink
Merge pull request #2011 from zacpwhite/bugifx/2000
Browse files Browse the repository at this point in the history
#2000 - Recursive page search
  • Loading branch information
tidyui authored Sep 20, 2023
2 parents 62d0670 + e9554df commit 3a456b3
Show file tree
Hide file tree
Showing 8 changed files with 2,170 additions and 2,475 deletions.
2,222 changes: 1,027 additions & 1,195 deletions core/Piranha.Manager/assets/dist/js/piranha-deps-dev.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2,222 changes: 1,027 additions & 1,195 deletions core/Piranha.Manager/assets/dist/js/piranha-deps.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/Piranha.Manager/assets/dist/js/piranha-deps.min.js

Large diffs are not rendered by default.

125 changes: 59 additions & 66 deletions core/Piranha.Manager/assets/dist/js/piranha.components.js

Large diffs are not rendered by default.

35 changes: 27 additions & 8 deletions core/Piranha.Manager/assets/dist/js/piranha.js
Original file line number Diff line number Diff line change
Expand Up @@ -932,14 +932,33 @@ piranha.pagepicker = new Vue({
},
computed: {
filteredItems: function () {
var self = this;

return this.items.filter(function (item) {
if (self.search.length > 0) {
return item.title.toLowerCase().indexOf(self.search.toLowerCase()) > -1
}
return true;
});
let self = this;

if (self.search && self.search.length < 1) {
return this.items;
}

let items = Object.assign([], this.items);
let searchTerm = self.search ? self.search.toLowerCase() : "";

let filterRecursive = function(arr) {
return arr.reduce(function(acc, item){
let newItem = Object.assign({}, item);

if (newItem.items) {
newItem.items = filterRecursive(item.items);
newItem.isExpanded = newItem.items.length > 0;
}

if (newItem.title && (newItem.title.toLowerCase().indexOf(searchTerm) > -1 || newItem.isExpanded)) {
acc.push(newItem);
}

return acc;
}, []);
};

return filterRecursive(items);
}
},
methods: {
Expand Down
2 changes: 1 addition & 1 deletion core/Piranha.Manager/assets/dist/js/piranha.min.js

Large diffs are not rendered by default.

35 changes: 27 additions & 8 deletions core/Piranha.Manager/assets/src/js/piranha.pagepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,33 @@ piranha.pagepicker = new Vue({
},
computed: {
filteredItems: function () {
var self = this;

return this.items.filter(function (item) {
if (self.search.length > 0) {
return item.title.toLowerCase().indexOf(self.search.toLowerCase()) > -1
}
return true;
});
let self = this;

if (self.search && self.search.length < 1) {
return this.items;
}

let items = Object.assign([], this.items);
let searchTerm = self.search ? self.search.toLowerCase() : "";

let filterRecursive = function(arr) {
return arr.reduce(function(acc, item){
let newItem = Object.assign({}, item);

if (newItem.items) {
newItem.items = filterRecursive(item.items);
newItem.isExpanded = newItem.items.length > 0;
}

if (newItem.title && (newItem.title.toLowerCase().indexOf(searchTerm) > -1 || newItem.isExpanded)) {
acc.push(newItem);
}

return acc;
}, []);
};

return filterRecursive(items);
}
},
methods: {
Expand Down

0 comments on commit 3a456b3

Please sign in to comment.