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 2a0232e8aab6f8d7256faddc1ff2b44212770161 Author: Benjamin <poussin@codelutin.com> Date: Sun May 31 01:08:09 2020 +0200 ajout delai avant enregistrement maxResult et MaxTagInCloud --- pkg/repository/bookmarkRepository.go | 2 +- pkg/repository/database.go | 6 +-- web/src/components/preferences/MaxResultEditor.vue | 41 +++++++++++++------- .../components/preferences/MaxTagInCloudEditor.vue | 44 ++++++++++++++-------- 4 files changed, 60 insertions(+), 33 deletions(-) diff --git a/pkg/repository/bookmarkRepository.go b/pkg/repository/bookmarkRepository.go index 1e01756..1993a24 100644 --- a/pkg/repository/bookmarkRepository.go +++ b/pkg/repository/bookmarkRepository.go @@ -29,7 +29,7 @@ func BookmarkJSON(currentUser model.BowUser, id string, uri string, tags []strin } // normalize orderBy to prevent SQL injection - orderBy = bookmakFields[orderBy] + orderBy = bookmarkFields[orderBy] if orderBy == "" { orderBy = "creationdate" } diff --git a/pkg/repository/database.go b/pkg/repository/database.go index a8bb644..bd92d43 100644 --- a/pkg/repository/database.go +++ b/pkg/repository/database.go @@ -29,7 +29,7 @@ type errorLineExtract struct { // Use to normalize orderBy to prevent SQL injection // key: struct field name or database field name in lower case // value: database field name (to use in query) -var bookmakFields = make(map[string]string) +var bookmarkFields = make(map[string]string) /* Init initialise la connexion a la base en utilisant @@ -65,8 +65,8 @@ func computeFieldAvailable() { field := val.Type().Field(i) fieldName := strings.ToLower(field.Name) jsonName := strings.ToLower(strings.Split(field.Tag.Get("json"), ",")[0]) - bookmakFields[fieldName] = jsonName - bookmakFields[jsonName] = jsonName + bookmarkFields[fieldName] = jsonName + bookmarkFields[jsonName] = jsonName } } diff --git a/web/src/components/preferences/MaxResultEditor.vue b/web/src/components/preferences/MaxResultEditor.vue index e67869a..6990045 100644 --- a/web/src/components/preferences/MaxResultEditor.vue +++ b/web/src/components/preferences/MaxResultEditor.vue @@ -15,27 +15,40 @@ import { Component, Vue } from 'vue-property-decorator' class MaxResultEditor extends Vue { errorMsg = '' + timeoutSave = 0 + + cancelTimeoutSave() { + this.timeoutSave && clearTimeout(this.timeoutSave) + this.timeoutSave = 0 + } + get maxresult() { return this.user.maxresult } set maxresult(value) { - let newMaxresult = parseInt(value) - this.$fetch.put('/users/current/maxresult', {maxresult: newMaxresult}).then( - () => { - let newUser = {...this.user} - newUser.maxresult = newMaxresult - this.saveUser(newUser) - - this.errorMsg = 'saved' - }, - (err) => { - console.log('ko', err) - this.errorMsg = err.cause - } + this.cancelTimeoutSave() + this.timeoutSave = setTimeout( + function(v) { + let newMaxresult = parseInt(v) + this.$fetch.put('/users/current/maxresult', { maxresult: newMaxresult }).then( + () => { + let newUser = { ...this.user } + newUser.maxresult = newMaxresult + this.saveUser(newUser) + + this.errorMsg = 'saved' + }, + (err) => { + console.log('ko', err) + this.errorMsg = err.cause + } + ) + }.bind(this), + 800, + value ) } - } export default MaxResultEditor diff --git a/web/src/components/preferences/MaxTagInCloudEditor.vue b/web/src/components/preferences/MaxTagInCloudEditor.vue index da43fc1..d402e5e 100644 --- a/web/src/components/preferences/MaxTagInCloudEditor.vue +++ b/web/src/components/preferences/MaxTagInCloudEditor.vue @@ -1,6 +1,7 @@ <template> <div class="maxtagincloud-editor"> - <label for="maxtagincloud">Cloud's tag</label><input id="maxtagincloud" class="maxtagincloud" v-model="maxtagincloud" /> + <label for="maxtagincloud">Cloud's tag</label + ><input id="maxtagincloud" class="maxtagincloud" v-model="maxtagincloud" /> <span class="errorMsg">{{ errorMsg }}</span> </div> </template> @@ -15,27 +16,40 @@ import { Component, Vue } from 'vue-property-decorator' class MaxTagInCloudEditor extends Vue { errorMsg = '' + timeoutSave = 0 + + cancelTimeoutSave() { + this.timeoutSave && clearTimeout(this.timeoutSave) + this.timeoutSave = 0 + } + get maxtagincloud() { return this.user.maxtagincloud } set maxtagincloud(value) { - let newMaxTagInCloud = parseInt(value) - this.$fetch.put('/users/current/maxtagincloud', {maxtagincloud: newMaxTagInCloud}).then( - () => { - let newUser = {...this.user} - newUser.maxtagincloud = newMaxTagInCloud - this.saveUser(newUser) - - this.errorMsg = 'saved' - }, - (err) => { - console.log('ko', err) - this.errorMsg = err.cause - } + this.cancelTimeoutSave() + this.timeoutSave = setTimeout( + function(v) { + let newMaxTagInCloud = parseInt(v) + this.$fetch.put('/users/current/maxtagincloud', { maxtagincloud: newMaxTagInCloud }).then( + () => { + let newUser = { ...this.user } + newUser.maxtagincloud = newMaxTagInCloud + this.saveUser(newUser) + + this.errorMsg = 'saved' + }, + (err) => { + console.log('ko', err) + this.errorMsg = err.cause + } + ) + }.bind(this), + 800, + value ) } - } export default MaxTagInCloudEditor -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.