This is an automated email from the git hooks/post-receive script. New commit to branch bow-v2-go in repository bow. See https://gitlab.nuiton.org/chorem/bow.git commit 5e6b4480043cc66cc610c7e9e161771bbc7a2248 Author: Benjamin <poussin@codelutin.com> Date: Fri May 22 04:21:25 2020 +0200 amelioration navigation (borne) et refaco du inputSearch --- web/src/components/SearchInput.vue | 70 +++++++++----------------------------- web/src/main.js | 12 ++++--- web/src/views/Home.vue | 13 ++++--- 3 files changed, 33 insertions(+), 62 deletions(-) diff --git a/web/src/components/SearchInput.vue b/web/src/components/SearchInput.vue index a1c559b..dede299 100644 --- a/web/src/components/SearchInput.vue +++ b/web/src/components/SearchInput.vue @@ -31,39 +31,10 @@ class SearchInput extends Vue { mTags = '' mFulltext = '' mQuery = '' - mOrderby = 'creationdate' - mOrderdesc = false - mFirst = 0 - - sameValue(a, b) { - let result = a === b - if (!result) { - // permet de dire que undefined === "" - result = !a && !b - } - return result - } search() { console.log('search', this.mTags, this.mFulltext) - if ( - !this.sameValue(this.mTags, this.tags) || - !this.sameValue(this.mFulltext, this.fulltext) || - !this.sameValue(this.mQuery, this.query) || - !this.sameValue(this.mOrderby, this.orderby) || - !this.sameValue(this.mOrderdesc, this.orderdesc) || - !this.sameValue(this.mFulltext, this.first) - ) { - let query = {} - this.mTags && (query.tags = this.mTags) - this.mFulltext && (query.fulltext = this.mFulltext) - this.mQuery && (query.query = this.mQuery) - this.mOrderby && (query.orderBy = this.mOrderby) - this.mOrderdesc && (query.orderDesc = this.mOrderdesc) - this.mFulltext && (query.first = this.mFirst) - console.log("XXXX Query", query) - this.$router.push({ name: 'Home', query }) - } + this.changeTagsAndFulltextAndGo(this.mTags, this.mFulltext) } action() { @@ -71,7 +42,7 @@ class SearchInput extends Vue { } get tags() { - const tags = this.$route.query.tags + const tags = this.queryInfo.tags if (!tags) { return [] } @@ -80,38 +51,29 @@ class SearchInput extends Vue { } get fulltext() { - return this.$route.query.fulltext + return this.queryInfo.fulltext } get query() { - return this.$route.query.query - } - - get orderby() { - return this.$route.query.orderby || 'creationdate' - } - - get orderdesc() { - return this.$route.query.orderdesc || false + return this.queryInfo.query } - get first() { - return this.$route.query.first || 0 + @Watch('tags', { immediate: true, deep: true }) + onTagsChange(tags) { + console.log('onTagsChange SearchInput', tags) + this.mTags = this.tags } - update(route) { - this.mTags = this.tags - this.mFulltext = this.fulltext || '' - this.mQuery = this.query || '' - this.mOrderby = this.orderby || '' - this.mOrderdesc = this.orderdesc || false - this.mFirst = this.first || 0 + @Watch('fulltext', { immediate: true, deep: true }) + onFulltextChange(fulltext) { + console.log('onFulltextChange SearchInput', fulltext) + this.mFulltext = this.fulltext } - @Watch('$route', { immediate: true, deep: true }) - onRouteChange(to, from) { - console.log('onRouteChange SearchInput', to, from) - this.update(to) + @Watch('query', { immediate: true, deep: true }) + onQueryChange(query) { + console.log('onQueryChange SearchInput', query) + this.mQuery = this.query } } diff --git a/web/src/main.js b/web/src/main.js index 0111df3..35dc0bd 100644 --- a/web/src/main.js +++ b/web/src/main.js @@ -40,6 +40,13 @@ Vue.mixin({ console.log('go', query) this.$router.push({ name: 'Home', query }) }, + changeTagsAndFulltextAndGo: function(tags, fulltext) { + let query = { ...this.currentQuery } + query.first = 0 + query.tags = tags + query.fulltext = fulltext + this.go(query) + }, goFirst: function() { let query = { ...this.currentQuery } query.first = 0 @@ -50,10 +57,7 @@ Vue.mixin({ goNext: function() { let query = { ...this.currentQuery } query.first = query.first + this.user.maxresult - if (query.first > this.queryInfo.total - this.user.maxresult) { - query.first = this.queryInfo.total - this.user.maxresult - } - if (query.first != this.currentQuery.first) { + if (query.first < this.queryInfo.total) { this.go(query) } }, diff --git a/web/src/views/Home.vue b/web/src/views/Home.vue index 5fb0141..8650ff5 100644 --- a/web/src/views/Home.vue +++ b/web/src/views/Home.vue @@ -5,10 +5,10 @@ <div class="navigation"> <button @click="goFirst()"><<</button> <button @click="goPrev()"><</button> - {{ 1 + queryInfo.first }}-{{ queryInfo.first + queryInfo.limit }} + {{ 1 + queryInfo.first }}-{{ last }} <button @click="goNext()">></button> <button @click="goLast()">>></button> - / {{ queryResponse.info.total }} + / {{ queryInfo.total }} </div> <div class="bookmarks-list"> <Bookmark v-for="bookmark in bookmarks" :key="bookmark.id" :bookmark="bookmark"></Bookmark> @@ -44,7 +44,13 @@ class Home extends Vue { mFirst = this.first || 0 errorMsg = '' - queryResponse = {info:{}, tags:{}, result: {}} + + get last() { + if (this.queryInfo.first + this.queryInfo.limit <= this.queryInfo.total) { + return this.queryInfo.first + this.queryInfo.limit + } + return this.queryInfo.total + } get bookmarks() { return this.queryResult @@ -70,7 +76,6 @@ class Home extends Vue { this.$fetch.get(`/bookmarks?${searchParams.toString()}`).then( (data) => { - this.queryResponse = data this.$store.commit('query', data) }, (err) => { -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.