branch bow-v2-go updated (5e6b448 -> fff8634)
This is an automated email from the git hooks/post-receive script. New change to branch bow-v2-go in repository bow. See https://gitlab.nuiton.org/chorem/bow.git from 5e6b448 amelioration navigation (borne) et refaco du inputSearch new fedbb6a ordre par defaut desc (les plus recent d'abord) new fff8634 on ne met plus d'en l'url les params qui ont la valeur par defaut The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit fff863477f5f69b59941319c95729eafb89e00a3 Author: Benjamin <poussin@codelutin.com> Date: Mon May 25 00:08:19 2020 +0200 on ne met plus d'en l'url les params qui ont la valeur par defaut commit fedbb6aec4f9ea99c8dba443438bdc2ccb2a2b91 Author: Benjamin <poussin@codelutin.com> Date: Sun May 24 23:09:18 2020 +0200 ordre par defaut desc (les plus recent d'abord) Summary of changes: doc/front-concept.md | 22 ++++++++++++++++++ pkg/constant/const.go | 4 ++-- pkg/http/bookmarkResource.go | 6 ++--- pkg/repository/bookmarkRepository.go | 8 +++---- web/src/main.js | 44 ++++++++++++++++++++---------------- web/src/router/index.js | 2 +- web/src/views/Home.vue | 8 +++---- 7 files changed, 60 insertions(+), 34 deletions(-) create mode 100644 doc/front-concept.md -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
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 fedbb6aec4f9ea99c8dba443438bdc2ccb2a2b91 Author: Benjamin <poussin@codelutin.com> Date: Sun May 24 23:09:18 2020 +0200 ordre par defaut desc (les plus recent d'abord) --- pkg/constant/const.go | 4 ++-- pkg/http/bookmarkResource.go | 6 +++--- pkg/repository/bookmarkRepository.go | 8 ++++---- web/src/main.js | 4 ++-- web/src/router/index.js | 2 +- web/src/views/Home.vue | 8 ++++---- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pkg/constant/const.go b/pkg/constant/const.go index 2f870f9..28ed36d 100644 --- a/pkg/constant/const.go +++ b/pkg/constant/const.go @@ -82,9 +82,9 @@ OrderBy query parameter name for select order sorting const OrderBy = "orderby" /* -OrderDesc query parameter name for select order sorting direction descending +OrderAsc query parameter name for select order sorting direction descending */ -const OrderDesc = "orderdesc" +const OrderAsc = "orderasc" /* First query parameter name first result diff --git a/pkg/http/bookmarkResource.go b/pkg/http/bookmarkResource.go index 3ce52a8..da2c34b 100644 --- a/pkg/http/bookmarkResource.go +++ b/pkg/http/bookmarkResource.go @@ -25,16 +25,16 @@ func getBookmarks(w http.ResponseWriter, r *http.Request) { log.Println("query: ", queryParams) orderBy := queryParams.Get(constant.OrderBy) - orderDesc, err := strconv.ParseBool(queryParams.Get(constant.OrderDesc)) + orderAsc, err := strconv.ParseBool(queryParams.Get(constant.OrderAsc)) if err != nil { - orderDesc = false + orderAsc = false } first, err := strconv.ParseInt(queryParams.Get(constant.First), 10, 16) if err != nil { first = 0 } - json, err := repository.BookmarkJSON(currentUser, id, uri, tags, fulltext, orderBy, orderDesc, int(first)) + json, err := repository.BookmarkJSON(currentUser, id, uri, tags, fulltext, orderBy, orderAsc, int(first)) if err != nil { if utils.Is404(err) { // on a rien retrouve, on renvoie une collection vide diff --git a/pkg/repository/bookmarkRepository.go b/pkg/repository/bookmarkRepository.go index 0782cfc..5c16873 100644 --- a/pkg/repository/bookmarkRepository.go +++ b/pkg/repository/bookmarkRepository.go @@ -19,7 +19,7 @@ si id est non vide alors fait une recherche exact sur l'id si uri est non vide alors fait une recherche exact sur l'uri sinon fait une recherche sur les critères: tags, fulltext */ -func BookmarkJSON(currentUser model.BowUser, id string, uri string, tags []string, fulltext string, orderBy string, orderDesc bool, first int) (string, error) { +func BookmarkJSON(currentUser model.BowUser, id string, uri string, tags []string, fulltext string, orderBy string, orderAsc bool, first int) (string, error) { var result string var err error @@ -35,11 +35,11 @@ func BookmarkJSON(currentUser model.BowUser, id string, uri string, tags []strin } orderDirection := "" - if orderDesc { + if !orderAsc { orderDirection = "desc" } - log.Printf("search bookmark id: %v, uri: %v, tags: '%v', fulltext: '%v', orderBy: %v, orderDesc: %v, first:%v", id, uri, tags, fulltext, orderBy, orderDesc, first) + log.Printf("search bookmark id: %v, uri: %v, tags: '%v', fulltext: '%v', orderBy: %v, orderAsc: %v, first:%v", id, uri, tags, fulltext, orderBy, orderAsc, first) if id != "" { q := &query{sql: `WITH __all AS (select * from bookmark where id=$1) SELECT json_agg(__all.*) as j FROM __all`} result, err = q.QueryString(currentUser, id) @@ -50,7 +50,7 @@ func BookmarkJSON(currentUser model.BowUser, id string, uri string, tags []strin tagsJoined := strings.Join(tags, ",") q := &query{sql: fmt.Sprintf(`WITH __query AS (select * from bookmark where tags @> string_to_array($1, ',')), - __info AS (select %[3]d as first, %[4]d as limit, count(id) as total, '%[1]s' as orderby, to_json('%[2]s' = 'desc') as orderdesc, string_to_array($1, ',') as tags, $2::TEXT as fulltext from __query), + __info AS (select %[3]d as first, %[4]d as limit, count(id) as total, '%[1]s' as orderby, to_json('%[2]s' = 'asc') as orderasc, string_to_array($1, ',') as tags, $2::TEXT as fulltext from __query), __infoJson AS (select row_to_json(i.*) as info from __info i), __allTags AS (select unnest(tags) as tag from __query), __tags AS (select tag, count(tag) from __allTags group by tag order by 2 desc), diff --git a/web/src/main.js b/web/src/main.js index 35dc0bd..cb2bc37 100644 --- a/web/src/main.js +++ b/web/src/main.js @@ -32,7 +32,7 @@ Vue.mixin({ query.fulltext = this.queryInfo.fulltext query.query = this.queryInfo.query query.orderby = this.queryInfo.orderby - query.orderdesc = this.queryInfo.orderdesc + query.orderasc = this.queryInfo.orderasc query.first = this.queryInfo.first return query }, @@ -112,7 +112,7 @@ Vue.mixin({ fulltext: i.fulltext, query: i.query, orderby: i.orderby, - orderdesc: i.orderdesc + orderasc: i.orderasc } }, queryInfo: function() { diff --git a/web/src/router/index.js b/web/src/router/index.js index 29185ad..ad2c665 100644 --- a/web/src/router/index.js +++ b/web/src/router/index.js @@ -34,7 +34,7 @@ const routes = [ fulltext: route.query.fulltext, query: route.query.query, orderby: route.query.orderby, - orderdesc: route.query.orderdesc, + orderasc: route.query.orderasc, first: route.query.first }) }, diff --git a/web/src/views/Home.vue b/web/src/views/Home.vue index 8650ff5..fdcaf72 100644 --- a/web/src/views/Home.vue +++ b/web/src/views/Home.vue @@ -24,7 +24,7 @@ import CloudTags from '@/components/CloudTags' @Component({ name: 'Home', - props: ['id', 'tags', 'fulltext', 'query', 'orderby', 'orderdesc', 'first'], + props: ['id', 'tags', 'fulltext', 'query', 'orderby', 'orderasc', 'first'], components: { CloudTags, Bookmark } }) class Home extends Vue { @@ -33,14 +33,14 @@ class Home extends Vue { @Prop fulltext @Prop query @Prop orderby - @Prop orderdesc + @Prop orderasc @Prop first mTags = this.forceArrayTags(this.tags) mFulltext = this.fulltext || '' mQuery = this.query || '' mOrderby = this.orderby || '' - mOrderdesc = this.orderdesc || false + mOrderasc = this.orderasc || false mFirst = this.first || 0 errorMsg = '' @@ -71,7 +71,7 @@ class Home extends Vue { this.mFulltext && searchParams.append('fulltext', this.mFulltext) this.mQuery && searchParams.append('query', this.mQuery) this.mOrderby && searchParams.append('orderby', this.mOrderby) - this.mOrderdesc && searchParams.append('orderdesc', this.mOrderdesc) + this.mOrderasc && searchParams.append('orderasc', this.mOrderasc) this.mFirst && searchParams.append('first', this.mFirst) this.$fetch.get(`/bookmarks?${searchParams.toString()}`).then( -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
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 fff863477f5f69b59941319c95729eafb89e00a3 Author: Benjamin <poussin@codelutin.com> Date: Mon May 25 00:08:19 2020 +0200 on ne met plus d'en l'url les params qui ont la valeur par defaut --- doc/front-concept.md | 22 ++++++++++++++++++++++ web/src/main.js | 42 +++++++++++++++++++++++------------------- 2 files changed, 45 insertions(+), 19 deletions(-) diff --git a/doc/front-concept.md b/doc/front-concept.md new file mode 100644 index 0000000..0c9a625 --- /dev/null +++ b/doc/front-concept.md @@ -0,0 +1,22 @@ +### Front + +Le front est en vuejs + vuerouter + vuex + +L'intégration de vuex n'est là que pour ce qui est vraiment comment à tous les composants: +- user pour les infos de l'utilisateur courant +- authenticated (boolean) pour savoir si l'utilisateur a un jeton jwt +- query qui contient les infos et le resultat de la requête courante (info: {}, tags:[[tags...],[occurence...]], result:) + +Il faut sinon privilégier le dialogue parent/enfant dans les composants + +Il exist un mixin déclarer dans main.js qui permet l'accès à toutes les +informations du store vuex sous forme de properties. Ce mixin apporte aussi un +ensemble de methodes pour faire évoluer la query courante. + +Lorsque l'utilisateur se connecte ou se déconnecte, le user modifier est celui +du localStorage, qui envoie ensuite un event qui est intercepté dans App.js +pour mettre à jour le store vuex (user et authenticated) + +La query elle, est mise à jour dans le store lorsqu'on recoie le nouveau +résultat, le composant qui fait cette requête lors du changement d'url est +Home.vue \ No newline at end of file diff --git a/web/src/main.js b/web/src/main.js index cb2bc37..fed1c74 100644 --- a/web/src/main.js +++ b/web/src/main.js @@ -26,18 +26,19 @@ Vue.prototype.$storage = StoreHelper Vue.mixin({ methods: { - getCurrentQuery() { + go: function(fullQuery) { + console.log('go query', fullQuery) + + // keep only non default params, to not pollute url let query = {} - query.tags = this.queryInfo.tags - query.fulltext = this.queryInfo.fulltext - query.query = this.queryInfo.query - query.orderby = this.queryInfo.orderby - query.orderasc = this.queryInfo.orderasc - query.first = this.queryInfo.first - return query - }, - go: function(query) { - console.log('go', query) + fullQuery.first && (query.first = fullQuery.first) + fullQuery.tags && (query.tags = fullQuery.tags) + fullQuery.fulltext && (query.fulltext = fullQuery.fulltext) + fullQuery.query && (query.query = fullQuery.query) + fullQuery.orderby != 'creationdate' && (query.orderby = fullQuery.orderby) + fullQuery.orderasc && (query.orderas = fullQuery.orderasc) + + console.log('go params', query) this.$router.push({ name: 'Home', query }) }, changeTagsAndFulltextAndGo: function(tags, fulltext) { @@ -48,9 +49,10 @@ Vue.mixin({ this.go(query) }, goFirst: function() { - let query = { ...this.currentQuery } + let c = this.currentQuery + let query = { ...c } query.first = 0 - if (query.first != this.currentQuery.first) { + if (query.first != c.first) { this.go(query) } }, @@ -62,22 +64,24 @@ Vue.mixin({ } }, goPrev: function() { - let query = { ...this.currentQuery } + let c = this.currentQuery + let query = { ...c } query.first = query.first - this.user.maxresult if (query.first < 0) { query.first = 0 } - if (query.first != this.currentQuery.first) { + if (query.first != c.first) { this.go(query) } }, goLast: function() { - let query = { ...this.currentQuery } + let c = this.currentQuery + let query = { ...c } query.first = this.queryInfo.total - this.user.maxresult if (query.first < 0) { query.first = 0 } - if (query.first != this.currentQuery.first) { + if (query.first != c.first) { this.go(query) } }, @@ -85,7 +89,7 @@ Vue.mixin({ let query = { ...this.currentQuery } let added = false query.tags = query.tags ? [...query.tags] : [] - tags.forEach(t => { + tags.forEach((t) => { if (query.tags.indexOf(t) === -1) { query.tags.push(t) added = true @@ -104,8 +108,8 @@ Vue.mixin({ return this.$store.state.user }, currentQuery: function() { + // faut-il mettre aussi: id ? uri ? let i = this.queryInfo - // id ? uri ? return { first: i.first, tags: i.tags, -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm