@@ -115,6 +146,9 @@
isTaskEdit: false,
taskEditTask: TaskModel,
newTaskText: '',
+
+ showTaskSearch: false,
+ searchTerm: '',
}
},
components: {
@@ -159,8 +193,11 @@
this.error(e, this)
})
},
- loadTasks(page) {
+ loadTasks(page, search = '') {
const params = {sort_by: ['done', 'id'], order_by: ['asc', 'desc']}
+ if (search !== '') {
+ params.s = search
+ }
this.taskCollectionService.getAll({listID: this.$route.params.id}, params, page)
.then(r => {
this.$set(this, 'tasks', r)
@@ -262,6 +299,22 @@
return 0
})
},
+ searchTasks() {
+ if (this.searchTerm === '') {
+ return
+ }
+ this.loadTasks(1, this.searchTerm)
+ },
+ hideSearchBar() {
+ // This is a workaround.
+ // When clicking on the search button, @blur from the input is fired. If we
+ // would then directly hide the whole search bar directly, no click event
+ // from the button gets fired. To prevent this, we wait 200ms until we hide
+ // everything so the button has a chance of firering the search event.
+ setTimeout(() => {
+ this.showTaskSearch = false
+ }, 200)
+ },
}
}
\ No newline at end of file
diff --git a/src/main.js b/src/main.js
index 6db87580..1c84898f 100644
--- a/src/main.js
+++ b/src/main.js
@@ -62,6 +62,7 @@ import { faAlignLeft } from '@fortawesome/free-solid-svg-icons'
import { faPaperclip } from '@fortawesome/free-solid-svg-icons'
import { faClock } from '@fortawesome/free-regular-svg-icons'
import { faHistory } from '@fortawesome/free-solid-svg-icons'
+import { faSearch } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
library.add(faSignOutAlt)
@@ -98,6 +99,7 @@ library.add(faAlignLeft)
library.add(faPaperclip)
library.add(faClock)
library.add(faHistory)
+library.add(faSearch)
Vue.component('icon', FontAwesomeIcon)
diff --git a/src/styles/components/list.scss b/src/styles/components/list.scss
index 362e13db..c5bf6d29 100644
--- a/src/styles/components/list.scss
+++ b/src/styles/components/list.scss
@@ -34,3 +34,28 @@
padding: 10px 1em;
height: 40px;
}
+
+.search {
+ max-width: 300px;
+ margin-top: -78px;
+ float: right;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+
+ .field {
+ transition: width $transition;
+ width: 100%;
+
+ &.hidden {
+ width: 0;
+ height: 0;
+ margin: 0;
+ overflow: hidden;
+ }
+
+ .button {
+ height: 100%;
+ }
+ }
+}
diff --git a/src/styles/theme/form.scss b/src/styles/theme/form.scss
index 56019c04..d432d3bb 100644
--- a/src/styles/theme/form.scss
+++ b/src/styles/theme/form.scss
@@ -152,3 +152,6 @@
float: right;
}
+.control.has-icons-left .icon, .control.has-icons-right .icon {
+ z-index: 4;
+}